ESP32 Board for High-Speed Stepper Motor Control

Hello Community,

I'm currently working on a project that involves controlling stepper motors at high speeds using an ESP32 board with built-in WiFi. However, I'm facing issues with the ESP32 WROOM 32 Dev Module, as it is unable to run the motors properly alongside WiFi communication.

I'm now looking for recommendations on the most powerful ESP32 board that can handle high-speed stepper motor control while maintaining reliable WiFi communication. Any suggestions or insights into boards that have been successfully used for similar applications would be greatly appreciated.

Thank you in advance for your help and advice!

Post the code and hardware that you are using now.

I am building a differential drive rc robot. Stepper motor runs upto 7000steps/s and both motors at different speeds.

Hardware: esp32 Wroom 32, li-ion cells, drv8825 stepper driver, nema 17 stepper motor
Here is the code: davinci_robot/drv_stepper_test.ino at main · robofuntastic/davinci_robot · GitHub
I am using Accelstepper library for motors

The problem is that both motors does not move at different speeds, and also they move slower then the input speed

If we remove WiFi code and remove FreeRTOS part then it works great

Maybe easier to use MobaTools instead. MobaTools creates the steps by timer interrupts in the background. So you don't have to bother with step creation in your sketch, which makes it a lot easier. In the sketch you only tell the motor what to do ( speed, target, ramping ... ). The moving itself is done by the ISR ( without blocking the sketch!). I think you will not need any FreeRTOS task to do this job.
MobaTools is able to create up to 30000 steps/sec on esp32 Wroom 32.

There is also an example controlling a stepper via WiFi on ESP32 ( unfortunately it is commented in german :roll_eyes: )

1 Like

I will try that library and inform you about the results.
If I use that library with FreeRTOS, will that be an issue?

I never tried it, but I don't think so.

That library did not work
i tried it with FreeRTOS
it just jams the motor and does not move

Can you show your attempt?

I edited the ESP32Web example and added a simple RTOS task running in parallel ( printing to the Serial line every second ) and it worked.
What may be a problem is running MobaTools from different tasks in parallel. MobaTools methods are not written to be re-entrant. I tried that and it worked, but that was more of a coincidence and will not be reliable.

There must be another problem with your code.

Have you considered using other drivers? I mean from the TMC series with UART control.

Alright may be there could be problem with my code
I have discussed it with a professional
He said that its not a good idea to use the interrupts with FreeRTOS. Our application cannot compromise over slow speed and also other task should also work smoothly.
So we have decided to use 2 esp32 boards and connect via UART. One esp32 will handle the stepper motors and the other will be handling the wifi and LEDs strip tasks.

Its not the driver issue. The motors work fine when we just run the function in void loop. When we include freeRTOS then we get issues.

I didn't say your driver doesn't work. In order for the stepper motor to move, the microcontroller must generate a pulse for each step. Since you are doing a lot of other things as well, I assumed that might be the problem. If you control a TMC driver by UART, you can tell it how many steps to take, and the rest is taken care of by the driver, and the microcontroller does not need to generate a pulse for each step.

I got your point. I did not know that TMC can be connected via UART.
I baught some TMC2208. I will try the UART connection and will inform you soon.

Interesting never heard of driver controlled with UART, thanks!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.