I'm making a device that moves a camera along a linear slider controlled by a stepper.
The step speed is affected by the amount of stuff the code does in the main loop before returning to the beginning when it sends another step. This stuff includes checking to see if one of the end stops have been hit, and checking to see if one of the 3 buttons has been pushed. If I get around to utilizing the accelstepper library, that would also add more overhead in there.
I don't need the maximum speed, but do need consistent speed while the processor is doing other things.
I don't need to check the buttons every cycle, but do need the end stops to reverse direction immediately on contact.
I'm sure there are 10 better ways to do this- maybe interrupts? maybe some sort of multi-threaded state machine?
Ideas?
-Tom
The step speed is affected by the amount of stuff the code does in the main loop before returning to the beginning when it sends another step. This stuff includes checking to see if one of the end stops have been hit, and checking to see if one of the 3 buttons has been pushed. If I get around to utilizing the accelstepper library, that would also add more overhead in there.
I don't need the maximum speed, but do need consistent speed while the processor is doing other things.
I don't need to check the buttons every cycle, but do need the end stops to reverse direction immediately on contact.
I'm sure there are 10 better ways to do this- maybe interrupts? maybe some sort of multi-threaded state machine?
Ideas?
-Tom