2 ms·
Hmm. Looking at https://github.com/redoxcode/micropython-stepper/blob/main/src/stepper/__init__.py#L101 https://github.com/redoxcode/micropython-stepper/blob/m
by dekhn 2y ago
Hmm. 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).