timer-interrupt driven operations

151 views
Skip to first unread message

david gauchard

unread,
Jul 27, 2022, 11:09:52 AM7/27/22
to accelstepper
Hi,

I added slight changes for interrupt-driven operations in a pull-request on github.
These changes are invisible and effect-less for other targets than esp8266/esp32.
An example is provided for esp8266.

This is needed because on heavy WiFi operations such as webservers, Arduino main loop is not looping often enough or may lose synchronicity with real time.

david

A. Craig West

unread,
Jul 27, 2022, 12:48:10 PM7/27/22
to accels...@googlegroups.com
I had a PR submitted for changes to allow interrupt based timers as well, I will see if I can find it

--
You received this message because you are subscribed to the Google Groups "accelstepper" group.
To unsubscribe from this group and stop receiving emails from it, send an email to accelstepper...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/accelstepper/4819abfa-0d8a-40d1-9e3e-c36711316cefn%40googlegroups.com.

gjgsm...@gmail.com

unread,
Jul 27, 2022, 11:27:15 PM7/27/22
to accelstepper
@david
With reference to ESP32 and your 'heavy WiFi operations' I would think that using Free-RTOS to assign tasks to manage WiFi operations on core1 and run Accelstepper tasks on core0 would give you maximum stepper speed, considering that Free-RTOS is already incorporated into ESP?

david gauchard

unread,
Jul 28, 2022, 4:16:22 AM7/28/22
to accelstepper
I'm not a user of esp32 but I believe they have the same constraints for ISR routines which must stay in RAM (= not handled by hardware cache) thanks to the IRAM_ATTR attribute.
I also heard that there are some ESP32 versions with a single core.
Unlike esp8266 (Arduino / nonos-sdk), it is true that esp32 has FreeRTOS and task priorities so this would be a true benefit for real time applications like AccelStepper.
But FreeRTOS is quite an advance use of uCs which is not necessarily accessible for the average Arduino users, and an example would benefit everybody.
The example I provide in the pull request is targetted only for esp8266 Arduino.
I believe examples are a mandatory way for users to handle Arduino libraries.
BTW and just in case, I didn't mention the PR link: https://github.com/waspinator/AccelStepper/pull/16/files

gjgsm...@gmail.com

unread,
Jul 28, 2022, 8:55:42 PM7/28/22
to accelstepper
This is just general info for those that might be interested...

In the Arduino sphere, the ESP32 is one of the most versatile, fast, powerful, cheap and well supported MCU's available.
For everthing ESP check out - Random Nerd Tutorials - Rui's tutorials and examples are well written and great! (No, I have no affiliation with RNT)

Here are some results after running a series of stepper 'steps/second' speed program:
                  RUN()      RUNSPEED()
UNO          4,191            14,865
MEGA       3,851            12,130
DUE        14,159            31,167
ESP32    44,280            75,953

Yes, multi-task applications like combining serial and wifi communications with accelstepper are more complex but it is not uncommon for communication tasks to be handled on one core while the main 'control' loop runs on the other.
See Shawn Hymel's tutorial #12 for multi-core tasking with example.

For anyone interested here are some links to help you learn about FreeRTOS.
Shawn Hymel's tutorials are excellent and include examples.
Reply all
Reply to author
Forward
0 new messages