Stepper controller using PIO and DMA #12541
Replies: 3 comments 2 replies
-
The link doesn't work any more. Did you work on this further? I was thinking of implementing one without a speed-update interrupt to allow for 8 axes. |
Beta Was this translation helpful? Give feedback.
-
Hi! I will put the code in a better place so you can download it... But no, I didn't make improvements. I'm pretty sure it is possible to drive 8 axes, but this would require some work, as I'm using 2 State Machines per axis: 1 to generate pulses, 1 to precisely count pulses. |
Beta Was this translation helpful? Give feedback.
-
FYI, I put my code here: https://framagit.org/fma38/micropython-lib |
Beta Was this translation helpful? Give feedback.
-
Hi!
After a few weeks, here is a working version of a (smart) stepper controller (not yet on a git repo):
https://cloud.gbiloba.org/s/tjfaATSpcdGRrFY
(the module is called
smartStepper
; other modules are dependencies).This implementation uses PIOs and DMA, letting (most of) CPU free for other tasks. It handles non-linear acceleration/deceleration (you can easily add any curve you want), even in jog mode and asynchronous stop (an emergency stop without deceleration is also available).
I wrote it so it is possible to have 4 steppers working in parallel, but I didn't check that feature yet. Each instance uses 1 State Machine from PIO0, 1 State Machine from PIO1, and 1 DMA channel.
The CPU is still a little bit involved, because of the PIO interrupt in PulseGenerator, keeping the current speed up to date. And the controller sometime does not work well if the CPU is used too much; don't know why yet.
Anyway, I'll use this code in a machine to automatically cut and strip small wires to make jumpers (still need to tune the bending part).
I would like to thank you, guys, for all the help you provided me; I'm now a little bit more comfortable with PIO programming and DMA usage :o)
Best,
Frédéric
Beta Was this translation helpful? Give feedback.
All reactions