View Full Version : Controlling Servo Direction

01-30-2007, 02:57 PM
Hello everyone...

I've just bought a BS2 and two continuous servo motors.

I would like to control the direction of rotation of the servo... (clockwise/anticlockwise)

How can I do that? Thanks!

ServoL_pin CON 12
ServoR_pin CON 13

PULSOUT ServoL_pin, 750
PULSOUT ServoR_pin, 750
GOTO Start

I can only make the motors turn in clockwise direction with this code...

How can I make one turns clockwise while another one turns anticlockwise??

Post Edited (koolitude) : 1/30/2007 8:01:52 AM GMT

01-30-2007, 03:11 PM
Please Help~~~~~~~~ Thanks~~~~~~~~~~

01-30-2007, 03:16 PM
You can try these ...

FOR i = 1 TO 20
PULSOUT 12, 650
PULSOUT 13, 850

Don't forget to adjust the servo, so it will be stop when giving a 750 width pulse.

01-30-2007, 03:18 PM
Thanks a lot...

just some follow up questions....

Would the speeds of the motors be the same?

How did you decide the value of 650 and 850?

Thanks once again~~~~~~~~~~~~~~~~~~

Bill Chennault
01-30-2007, 08:53 PM
koolitude (http://forums.parallax.com/member.php?u=48474)--

Just download the book "What's a Microcontroller?" Parallax makes it available for free download. You can either download it or read it online at . . .


In any case, I believe exactly what you want is in chapter 4, which begins on page 103.

Have fun!


You are what you write.

01-30-2007, 09:13 PM
Servos are commanded to position by signals between 1000 and 2000 ms; 1500 is center. The pulsout command outputs in 2ms steps so... pulsout 500 moves an UNMODIFIED servo to full anticlockwise, pulsout 1000 move the unmdified servo to full clockwise position and pulsout 750 is center. The servo 'knows' these positions, because it turns a potentiometer as the motor turns and, when the two signals agree, the servo is in position. This is useful in a variety of ways (but doesn't answer your question). If the servo is 'modified' in that the feedback potentiometer is disconncted, the servo will continue to spin 'continuously' as it tries to find the motor position where the pot signal and the motor position agree. Pulseouts > 750 turn the motor clockwise to search, pulseouts < 750 turn the motor anticlockwise to search. "Centering" the servo is the act or process of adjusting the disconnected pot so that at a pulsout of 750, the pot and the motor position agree... therefore the motor remains still.
In practice, one sends pulsout 750 to the modified servo and adjusts the pot until the motor stops turning, then sends pulsouts of > 750 to move the 'bot forward and <750 to move it opposite. Since the servos are likely mounted on opposite sides of the robot, one servo must go clockwise and one must go anticlockwise to move both wheels 'forward', hence Christj's code commands one servo to 650 (<750) and one to 850 (>750).

01-31-2007, 04:22 AM
Servos are commanded to position by signals between 1000 and 2000 ms; 1500 is center. ...
Actually, between 1 and 2 milliseconds (ms), or 1000 and 2000 microseconds (us).


01-31-2007, 06:53 AM
Right, right. Thank you for the correction.

01-31-2007, 03:53 PM
Thank you very much for all your help!
Y'all are very helpful! =)