12v stepper motor programm

i have the program for 12v stepper motor and TB6600 but if electricity is off inbetween it will not get back to the start point. and i must push it manually to the first point. how can i tell it at first you must come to the home point and then start do your job.

You need a switch at the home position that you can query with the Aurduino so that the Arduino knows when the motor has arrived at the home position. Then you write yourself a homing sequence that is called when the program starts, at the end of the void setup. This sequence causes the motor to search for the home position (drive back until the switch is activated). This means that when the program starts, the home position is automatically approached first, and then you have a defined initial state.

1 Like

call a homing procedure in setup().
If you are using a library like "speedStepper" the function is already written and return a feedback

1 Like

No, it is not. Upon power up, you have no way of knowing the position of the stepper without some sort of physical switch or feedback mechanism. Once established, you can define that position as '0' for the library and always go "HOME", but not before figuring out where you are at.

1 Like

I mean the home position routine.