3 ms·
Id have to imagine that Stepper Motor control is a job for RP2040 PIO? I can't say that I'm too familiar with PIO but a tiny bit of state (literally a few bits
by dragontamer 2y ago
Id have to imagine that Stepper Motor control is a job for RP2040 PIO?
I can't say that I'm too familiar with PIO but a tiny bit of state (literally a few bits) and a few bytes of code should be enough to make a good driver and offload the whole task from the CPUs.
I know RP2040 has dual CPU but motor control is often the job of a timer on other uCs.
- dekhn 2y agoHmm. Looking at https://github.com/redoxcode/micropython-stepper/blob/main/src/stepper/__init__.py#L101 https://github.com/redoxcode/micropython-stepper/blob/main/s... it looks like they basically run a fairly tight loop in Python using a Timer (which uses the hardware timer on ESP32 and RP2040, likely), poking the step pin in Python in the Timer callback. There is no specific timing for the step pulse, they just turn it on and then immediately off. I guess this works because the micropython implementation does fast attribute access and function calls. On a microcontroller, you could use PIO or I think the RMT peripheral or even just interrupt-driven pin poking. That's good for many use cases, although I strongly suspect it would fall over once you tried a very high step rate with microstepping (I run at 800-6400 step/sec) but I will try this out both for my lightweight test steppers (which use AccelStepper) as well as my microscope (which uses FluidNC). The scope will make it quite clear if we lose steps as I have a visual reference (the microscope slide has a calibrated fiducial marker).