I have a stepper motor program that I have written to home a stepper to a switch. I now want to be able to move the stepper to three
different positons by using buttons to send the stepper moving. I do not want to go back home each time I push a button.
How do I use the home position to keep track of the current position and then sent it to the desired position from the original home setting?
Rmac
You can count the steps - but if there is a load on the motor to such an extent that steps are missed, this won't be accurate over the long run.
In that case, you will need to use some form of position sensor - depending on the accuracy required, this could be either a simple potentiometer or a multi-turn potentiometer (and possibly with a small error tolerance for either), or a digital encoder of some sort (rotational or linear, depending on the need - the greater the number of bits, the more accurate it will be - but also the more expensive); either or these would be attached to sense the final position of the load - not of the motor itself (thus, you may need additional gearing).
if the steppenmotor makes more than one rotation (360 degrees) a potmeter only indicates angle , not the amount of steps made.
If you need and the angle and the steps made, I advice the rotary encoder.
I would rather just count the steps if possible. I will only be turning the stepper about 120 degrees total. ( 40 degrees,80 degrees & 120 degrees )
Its for the gear selection on a automatic transmission. I am using push buttons to tell the stepper to select Park- 0 degrees ,Rev -40 degrees
,Ntrl- 80 degrees & Dr -120 Degrees.
The transmission has indents that help position the shift lever so it does not have to be super accurate. I just need to move the lever as you
would when using a gear shift. I plan on using one switch to establish the home position ( which will be Park ) and step from there for
the other gears. I don't want to go back to Park every time I select a gear so I need to keep up with the actual position.
I could use some help with the actual code to keep track of the counting. I am very new to C++. I have managed to get the code together
to sent the stepper home and read the home switch. I am not sure about how to keep up with the counter from the different positions.
Rmac