The “Robotics with the BOE-Bot” and the “What’s a Microcontroller?” manuals both cover this and have example code and both can be download free in PDF format from our website. Take care.
Basically, you use the "PULSOUT" command to send the 1.0 to 2.0 mSec control signal, and repeat that every 20 mSec. If you send a 1.0 mSec, it's full left (or clockwise full speed), 1.5 mSec is center (or stop), and 2.0 mSec is full right (or anti-clockwise full speed).
There's not a lot of speed control, actually. Servo's were designed to move to a commanded position as quickly as possible without overshooting it. When modified for "continuous" rotation, that doesn't leave a lot of leeway for speed control.
Hmmm. I had not realized that. Perhaps I should make a small co-processor that would interface PWM with a fet to control the speed and direction of these servos? I have a bunch of them.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Think Inside the box first and if that doesn't work..
Re-arrange what's inside the box then...
Think outside the BOX!
Conventional PWM won't work with servos unless you remove the internal controller and bring the motor leads out and connect them to an H-Bridge or equivalent for direction and speed control.
Temp VAR WORD
FOR temp = 0 TO 10 STEP 1
PULSOUT 14,750
PAUSE 2000
NEXT
FOR temp = 0 TO 10 STEP 1
PULSOUT 14,1000
PAUSE 2000
NEXT
FOR temp = 0 TO 10 STEP 1
PULSOUT 14,500
PAUSE 2000
NEXT
STOP
Is it correct that
For standard servos:
-the argument of the pulsout statement (750,1000,500) gives the POSITION of the servo but the 'pause' values must be small, 20 or so, or the rotation to that position is in small steps?
However
for continuous servos:
- these pulsout values give the DIRECTION of continuous rotation, and the rotation direction is opposite on opposite sides of 750, its 'center' where no rotation occurs? What difference does it matter how far the value is from 750?
Also the value of the pause affects the TOTAL amount of rotation that occurs for any pulsout value. What's going on?
Is there a detailed instruction of the workings and programming of these servos? I don't see it in the parallax manuals?
These servo's were designed for use in radio-controlled airplanes. So, the control signal is a 1.0 msec to 2.0 msed wide pulse, repeated every 20 mSec. It's repeated every 20 mSec, because the servo electronics contain a 'comparator' inside, that is trying to move the servo 'output shaft' (attached to a variable resistor, which turns with the output shaft). The 'comparator' compares your commanded pulse to the one generated by the servo electronics and the variable resistor. It then turns the output shaft to make the pulses match.
But it doesn't "remember" anything. So, if you refresh less often than 20 to 50 mSec (it does have that much slack) the internal electronics stop doing anything, and the shaft isn't "held" in the new position. Also, it tends to take a few repititions of the signal to get the shaft to the desired position in the first place.
Now, when the servo is "modified" for continuous rotation, the variable resistor is set to the mid-point, and disconnected from the output shaft. Thus commanding a 1.0 mSec will cause the servo to spin continuously, as it tries to get the disconnected variable resistor to go to a 1 mSec pulse width. Which it will never succeed, so the shaft continues to spin. Commanding a 1.5 mSec pulse is where the variable resistor is already set, so the shaft stops. Commanding 2.0 msec causes a spin the other way.
Thus, the canonical Servo control signal -- A PULSOUT of 1.0 to 1.5 to 2.0 msec, REPEATED by your code every 20 mSec. And the repetition DOES NOTHING except 'remind' the servo what your commanded position is. Doing it faster or slower has no effect on servo speed, except to make it harder for the servo to understand the signal.
Very good explanation allanlane5; I would only add that the servos have a rudimentary PID algorithm build in so that the motor moves slower as it approaches the pot value— 1.5 ms in a servo modified for continuous rotation. So… PULSOUT 750 (ideally) is stop, 760 may be slow, 1000 max speed.
Comments
Servos don’t have instruction sets because they’re not programmable. Perhaps you need information for a servo controller?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
http://www.parallax.com/html_pages/edu/curriculum/sic_curriculum.asp
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
There's not a lot of speed control, actually. Servo's were designed to move to a commanded position as quickly as possible without overshooting it. When modified for "continuous" rotation, that doesn't leave a lot of leeway for speed control.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Think Inside the box first and if that doesn't work..
Re-arrange what's inside the box then...
Think outside the BOX!
In the program below:
Temp VAR WORD
FOR temp = 0 TO 10 STEP 1
PULSOUT 14,750
PAUSE 2000
NEXT
FOR temp = 0 TO 10 STEP 1
PULSOUT 14,1000
PAUSE 2000
NEXT
FOR temp = 0 TO 10 STEP 1
PULSOUT 14,500
PAUSE 2000
NEXT
STOP
Is it correct that
For standard servos:
-the argument of the pulsout statement (750,1000,500) gives the POSITION of the servo but the 'pause' values must be small, 20 or so, or the rotation to that position is in small steps?
However
for continuous servos:
- these pulsout values give the DIRECTION of continuous rotation, and the rotation direction is opposite on opposite sides of 750, its 'center' where no rotation occurs? What difference does it matter how far the value is from 750?
Also the value of the pause affects the TOTAL amount of rotation that occurs for any pulsout value. What's going on?
Is there a detailed instruction of the workings and programming of these servos? I don't see it in the parallax manuals?
Thanks.
But it doesn't "remember" anything. So, if you refresh less often than 20 to 50 mSec (it does have that much slack) the internal electronics stop doing anything, and the shaft isn't "held" in the new position. Also, it tends to take a few repititions of the signal to get the shaft to the desired position in the first place.
Now, when the servo is "modified" for continuous rotation, the variable resistor is set to the mid-point, and disconnected from the output shaft. Thus commanding a 1.0 mSec will cause the servo to spin continuously, as it tries to get the disconnected variable resistor to go to a 1 mSec pulse width. Which it will never succeed, so the shaft continues to spin. Commanding a 1.5 mSec pulse is where the variable resistor is already set, so the shaft stops. Commanding 2.0 msec causes a spin the other way.
Thus, the canonical Servo control signal -- A PULSOUT of 1.0 to 1.5 to 2.0 msec, REPEATED by your code every 20 mSec. And the repetition DOES NOTHING except 'remind' the servo what your commanded position is. Doing it faster or slower has no effect on servo speed, except to make it harder for the servo to understand the signal.