- Why do we need this ContinuousStepper_Generic library
- Changelog
- Prerequisites
- Installation
- Examples
- 1. ATtiny_PWM_StepperControl
- 2. AVR_PWM_StepperControl
- 3. Dx_PWM_StepperControl
- 4. ESP32_PWM_StepperControl
- 5. MBED_RP2040_PWM_StepperControl
- 6. megaAVR_PWM_StepperControl
- 7. nRF52_MBED_PWM_StepperControl
- 8. nRF52_PWM_StepperControl
- 9. Portenta_H7_PWM_StepperControl
- 10. RP2040_PWM_StepperControl
- 11. SAMD_PWM_StepperControl
- 12. SAMDUE_PWM_StepperControl
- 13. STM32_PWM_StepperControl
- 14. Teensy_PWM_StepperControl
- Example RP2040_PWM_StepperControl
- Debug
- Troubleshooting
- Issues
- TO DO
- DONE
- Contributions and Thanks
- Contributing
- License
- Copyright
Why do we need this ContinuousStepper_Generic library
This PWM-wrapper library enables you to use Hardware-PWM use PWM to control continuous Stepper Motor.
This library is the wrapper of the following FastPWM libraries to enable you to port your PWM code easily between platforms
- RP2040_PWM
- AVR_PWM
- megaAVR_PWM
- ESP32_FastPWM
- SAMD_PWM
- SAMDUE_PWM
- nRF52_PWM
- Teensy_PWM
- ATtiny_PWM
- Dx_PWM
- Portenta_H7_PWM
- MBED_ContinuousStepper_Generic
- nRF52_MBED_PWM
- STM32_PWM
The most important feature is they're purely hardware-based PWM channels. Therefore, their operations are not blocked by bad-behaving software functions / tasks.
This important feature is absolutely necessary for mission-critical tasks. These hardware PWM-channels, still work even if other software functions are blocking. Moreover, they are much more precise (certainly depending on clock frequency accuracy) than other software timers using millis()
or micros()
. That's necessary if you need to control external systems (Servo, etc.) requiring better accuracy.
Being hardware-based PWM, their executions are not blocked by bad-behaving functions / tasks, such as connecting to WiFi, Internet or Blynk services. You can also have many (up to 16)
PWM output signals to use.
This non-being-blocked important feature is absolutely necessary for mission-critical tasks.
Imagine you have a system with a mission-critical function, controlling a robot or doing something much more important. You normally use a software timer to poll, or even place the function in loop(). But what if another function is blocking the loop() or setup().
So your function might not be executed, and the result would be disastrous.
You'd prefer to have your function called, no matter what happening with other functions (busy loop, bug, etc.).
The correct choice is to use a Hardware Timer with Interrupt to call your function.
These hardware-based PWM channels still work even if other software functions are blocking. Moreover, they are much more precise (certainly depending on clock frequency accuracy) than other software-based PWMs, using millis() or micros(). That's necessary if you need to measure some data requiring better accuracy.
Functions using normal software-based PWMs, relying on loop() and calling millis(), won't work if the loop() or setup() is blocked by certain operation. For example, certain function is blocking while it's connecting to WiFi or some services.
This ContinuousStepper_Generic library currently supports these following boards:
- nRF52 boards, such as AdaFruit Feather nRF52832, nRF52840 Express, BlueFruit Sense, Itsy-Bitsy nRF52840 Express, Metro nRF52840 Express, NINA_B302_ublox, NINA_B112_ublox, etc.
- SAM DUE
- SAMD21
- Arduino SAMD21: ZERO, MKRs, NANO_33_IOT, etc.
- Adafruit SAMD21 (M0): ItsyBitsy M0, Feather M0, Feather M0 Express, Metro M0 Express, Circuit Playground Express, Trinket M0, PIRkey, Hallowing M0, Crickit M0, etc.
- Seeeduino: LoRaWAN, Zero, Femto M0, XIAO M0, Wio GPS Board, etc.
- SAMD51
- Adafruit SAMD51 (M4): Metro M4, Grand Central M4, ItsyBitsy M4, Feather M4 Express, Trellis M4, Metro M4 AirLift Lite, MONSTER M4SK Express, Hallowing M4, etc.
- Seeeduino: Wio Terminal, Grove UI Wireless
-
Teensy (4.1, 4.0, 3.6, 3.5, 3,2, 3.1, 3.0, LC) with SPI, SPI1, SPI2
-
AVR Mega1280, 2560, ADK.
-
ESP32
-
ESP8266 To be added
-
RP2040-based boards, such as RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040, using Arduino-mbed RP2040 core or Earle Philhower's arduino-pico core with SPI, SPI1
-
Portenta_H7
-
Arduino UNO WiFi Rev2, AVR_NANO_EVERY, etc.
-
Arduino AVR_Dx boards using DxCore
-
AVRDA-based boards (AVR128DA, AVR64DA, AVR32DA, etc.)
-
AVRDB-based boards (AVR128DB, AVR64DB, AVR32DB, etc.)
- Seeeduino nRF52840-based boards such as XIAO_NRF52840 and XIAO_NRF52840_SENSE, etc. using Seeed
mbed
ornRF52
core
Arduino IDE 1.8.19+
for Arduino.Arduino AVR core 1.8.6+
for Arduino (Use Arduino Board Manager) AVR boards.Teensy core v1.57+
for Teensy (4.1, 4.0, 3.6, 3.5, 3,2, 3.1, 3.0) boards.Arduino SAM DUE core v1.6.12+
for SAM DUE ARM Cortex-M3 boards.Arduino SAMD core 1.8.13+
for SAMD ARM Cortex-M0+ boards.Adafruit SAMD core 1.7.11+
for SAMD ARM Cortex-M0+ and M4 boards (Nano 33 IoT, etc.).Seeeduino SAMD core 1.8.3+
for SAMD21/SAMD51 boards (XIAO M0, Wio Terminal, etc.).Adafruit nRF52 v1.3.0+
for nRF52 boards such as Adafruit NRF52840_FEATHER, NRF52832_FEATHER, NRF52840_FEATHER_SENSE, NRF52840_ITSYBITSY, NRF52840_CIRCUITPLAY, NRF52840_CLUE, NRF52840_METRO, NRF52840_PCA10056, PARTICLE_XENON, NINA_B302_ublox, etc.ESP32 Core 2.0.6+
for ESP32-based boards.ESP8266 Core 3.1.1+
for ESP8266-based boards. . To use ESP8266 core 2.7.1+ for LittleFS.ArduinoCore-mbed mbed_rp2040, mbed_nano, mbed_portenta core 3.5.4+
for Arduino (Use Arduino Board Manager) Portenta_H7, RP2040-based boards, such as Nano_RP2040_Connect, RASPBERRY_PI_PICO.Earle Philhower's arduino-pico core v2.7.1+
for RP2040-based boards such as RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040, etc.Arduino megaAVR core 1.8.7+
for Arduino megaAVR boards such as Arduino UNO WiFi Rev2, AVR_NANO_EVERY, etc..SpenceKonde DxCore core 1.5.3+
for Arduino AVRDx boards. . Follow DxCore Installation.Seeeduino nRF52 core 1.1.0+
for Seeed nRF52840-based boards such as Seeed_XIAO_NRF52840 and Seeed_XIAO_NRF52840_SENSE.Seeeduino mbed core 2.9.0+
for Seeed nRF52840-based boards such as SEEED_XIAO_NRF52840 and SEEED_XIAO_NRF52840_SENSE.
RP2040_PWM library v1.4.1+
. To install. checkAVR_PWM library v1.0.1+
. To install. checkmegaAVR_PWM library v1.0.1+
. To install. checkESP32_FastPWM library v1.0.1+
. To install. checkSAMD_PWM library v1.0.1+
. To install. checkSAMDUE_PWM library v1.0.1+
. To install. checknRF52_PWM library v1.0.1+
. To install. checkTeensy_PWM library v1.1.1+
. To install. checkATtiny_PWM library v1.0.1+
. To install. checkDx_PWM library v1.1.1+
. To install. checkPortenta_H7_PWM library v2.0.3+
. To install. checkMBED_RP2040_PWM library v1.0.1+
. To install. checknRF52_MBED_PWM library v1.0.3+
. To install. checkSTM32_PWM library v1.0.1+
. To install. check
The best and easiest way is to use Arduino Library Manager
. Search for ContinuousStepper_Generic, then select / install the latest version.
You can also use this link for more detailed instructions.
Another way to install is to:
- Navigate to ContinuousStepper_Generic page.
- Download the latest release
ContinuousStepper_Generic-main.zip
. - Extract the zip file to
ContinuousStepper_Generic-main
directory - Copy whole
ContinuousStepper_Generic-main
folder to Arduino libraries' directory such as~/Arduino/libraries/
.
- Install VS Code
- Install PlatformIO
- Install ContinuousStepper_Generic library by using Library Manager. Search for ContinuousStepper_Generic in Platform.io Author's Libraries
- Use included platformio.ini file from examples to ensure that all dependent libraries will installed automatically. Please visit documentation for the other options and examples at Project Configuration File
- ATtiny_PWM_StepperControl
- AVR_PWM_StepperControl
- Dx_PWM_StepperControl
- ESP32_PWM_StepperControl
- MBED_RP2040_PWM_StepperControl
- megaAVR_PWM_StepperControl
- nRF52_MBED_PWM_StepperControl
- nRF52_PWM_StepperControl
- Portenta_H7_PWM_StepperControl
- RP2040_PWM_StepperControl
- SAMD_PWM_StepperControl
- SAMDUE_PWM_StepperControl
- STM32_PWM_StepperControl
- Teensy_PWM_StepperControl
Example RP2040_PWM_StepperControl
Debug is enabled by default on Serial.
You can also change the debugging level _PWM_LOGLEVEL_
from 0 to 4
// Don't define _PWM_LOGLEVEL_ > 0. Only for special ISR debugging only. Can hang the system.
#define _PWM_LOGLEVEL_ 0
If you get compilation errors, more often than not, you may need to install a newer version of the core for Arduino boards.
Sometimes, the library will only work if you update the board core to the latest version because I am using newly added functions.
Submit issues to: ContinuousStepper_Generic issues
- Search for bug and improvement
- Similar features for remaining or new Arduino boards
- Initial coding to use PWM to control continuous Stepper Motor. Check Using PWM to step a stepper driver #16
- Use
allman astyle
and addutils
Many thanks for everyone for bug reporting, new feature suggesting, testing and contributing to the development of this library.
- Thanks to Paul van Dinther for proposing new way to use PWM to drive Stepper-Motor in Using PWM to step a stepper driver #16, leading to this library
Paul van Dinther |
If you want to contribute to this project:
- Report bugs and errors
- Ask for enhancements
- Create issues and pull requests
- Tell other people about this library
- The library is licensed under MIT
Copyright 2023- Khoi Hoang