Hi i am controlling a stepper motor with a driver... how can i stop a stepper motor from spinning when it reach my desired position.. e.g when i say go to 180 degrees it will turn to 180 degrees and stop der.. stepper is controlled with clock and direction pin. my stepper is a 1.8 degree bipolar stepper motor so 200 steps for 1 rev.
wow thanks didn't know that :).. it's working now.. now i want to move the stepper in 5 different position using 5 buttons.. 1 - 90 degrees, 2 - 180 degrees, 3 - 270 degrees, 4 - 360 degrees, 5 - random angle from the ff. angle.. 90,180,270,360..
And how will i know the absolute position of my motor so every press of a button it will return to it's initial position and go to the position of the pressed button?.
Let's say i want the initial position to be on top always.. so it's 0 degrees.
sample code.
if(button1=HIGH){
go to 0 degrees then turn 90 degrees
}
if(button2=HIGH){
go to 0 degrees then turn 180 degrees
}
Unless you have some sort of homing switch you have no way of knowing where the motor is other than looking at it. As far as keeping track of position, you will have to have a counter that you can use to monitor the current position. For a 200 step motor - 50 full steps = 90 degrees.
Sounds like button 1 - go to 0 degrees, then move to 90 degrees?
button 2 go to 0 degrees then move to 180 degrees
and such?
You can use the step routines, or create your own. Not very hard to do.