Hey All,
Okay, so I'm wanting to drive some steppers with Arduino, and I've looked at the Stepper library. The steppers I'm trying to drive are 200 step motors, and I'm pretty sure I can drive them at 30-40 RPM.
Here's the dilemma: the delay time between steps is calculated like so: 60 seconds * 1000 / 40rpm / 200 steps = 7.5 milliseconds between steps. Since this value is an integer (or technically, unsigned long??) It gets rounded to either 7 or 8 (i havent checked the real value) Also, eventually I'm going to want to do half-stepping. That doubles the number of steps, and gives me a value of 3.75. at that point the timing becomes crucial.
What I really need is to store this value as microseconds and then do the calculations based on that: then it would be 7500 microseconds between steps. Figuring out how many microseconds between steps to use is the easy part.
The hard part is figuring out how many microseconds have passed. Arduino only provides the millis() function, and I'm wondering if its possible to get something like micros(). All I really need is just a counter of how many microseconds have elapsed. Even if it rolls over every few minutes, thats okay with me. I just need to be able to use it for precise timings.
Is there anything l could do to get that? Is there a better approach to this? I've read a tiny bit about interrupt timers, but I don't know much about them. Any help or suggestions would be appreciated.