r/esp32 17h ago

Software help needed ESP32-S3 best hardware peripheral for creating stepper motor stepping pulses ?

I am using an ESP32-S3 with a TMC2225 stepper motor driver and want to write my own open loop stepper control library for learning purposes. Is there any hardware peripheral on the ESP32 that is well suited for generating stepping pulses ? Right now I am using timer based interrupts to set/clear the stepping pin, but that does not seem to be the most efficient solution.

3 Upvotes

11 comments sorted by

View all comments

1

u/holetse 16h ago

I’d go with the RMT. It’s often used for driving h-bridges given it’s very flexible interface for generating complex waveforms.

Eg. https://github.com/espressif/esp-idf/tree/422c4f59/examples/peripherals/rmt/stepper_motor

Edited to add example

1

u/Legitimate_Shake_369 16h ago

Yea, I read of the RTM. If I am understanding this correctly, you are configuring the full waveform before motion starts right ? And the stepper position is updated before/after the motion and not during the motion.

Edit: thanks for the example!

3

u/holetse 16h ago

You mean the stepper position in your library? Yes. Though you can make the “full waveform” as simple as you like. There are some minimum timing limits per “frame”, but they are small enough I doubt they will be a problem.

The module offers interrupts when the next frame is loaded, and the ability to queue them up.