yellow-beak
New member
I want to control multiple stepper motors with STEP/DIR pulsemode drivers using a Teensy 4.1. To better understand the problem, I've been studying the source code of projects such as https://github.com/luni64/TeensyStep4, which gave me a rough idea of how this can be implemented. However, the library hasn't been actively updated in the last two years and is marked as experimental, so I'm unsure if it's a good reference.
At a high level, I set the STEP pin
I'm wondering whether I should use a separate timer just to pull the pin
I haven't been able to figure this out from other people's source code. From what I can tell, they often take a different approach, using a fixed pulse width where the pin stays
At a high level, I set the STEP pin
HIGH, wait briefly, and then set it LOW again. However, I'm unsure how to schedule this cycle properly. It's easy to implement using delay(), but that obviously blocks execution.I'm wondering whether I should use a separate timer just to pull the pin
LOW after n cycles, or instead introduce some state logic. For example, if I need 800 pulses per second, I could effectively double that rate and toggle the pin on every interrupt: setting it HIGH on one call and LOW on the next.I haven't been able to figure this out from other people's source code. From what I can tell, they often take a different approach, using a fixed pulse width where the pin stays
HIGH for a defined time before being pulled LOW again. That's different from my idea, where the HIGH and LOW phases would be symmetric in duration. But I can't figure out how they achieve this!