Tuesday, August 7, 2007

How to control step motors

Controlling step motors is a little more difficult than that of DC motors. Moreover, the Handy Board can handle at most 2 step motors while it can handle 4 DC motors. Nevertheless, using the step motors for our project was better solution than using DC motors, because step motors gave us finer control than DC motors. I can move the step motor 1 step at a time and each step of the motor is 7.5 degrees of rotation. So if I command it to move 48 steps, then it will rotate 360 degrees.

The following set of commands moves the motor one step forward (clockwise).

float x = 0.001;
fd(0);
fd(1);
sleep(x);
bk(0);
fd(1);
sleep(x);
bk(0);
bk(1);
sleep(x);
fd(0);
bk(1);
sleep(x);

If you want to move it backward (counter-clockwise), you just need to reverse the above sequence.

I get this information from this web site:
http://www.cctc.demon.co.uk/stepper.htm

No comments: