Controlling A Servo
Stampy
Posts: 26
So, Im trying to learn how to run a servo using the PWM. I am using a BS2, and have tried a regular servo that a Continues servo but get either servo to run for a period or change
direction, note I am using the Sample Parallax code...
The code:
' RotateParallaxCrServo.bs2
' {$STAMP BS2}
' {$PBASIC 2.5}
counter VAR Word
servoPin PIN 12 ' change I/O pin for servo signal here
FOR counter = 1 TO 100 ' Rotate counterclockwise for ~3 seconds
PULSOUT servoPin, 850
PAUSE 20
NEXT
FOR counter = 1 TO 100 ' Hold still for ~3 seconds
PULSOUT servoPin, 750
PAUSE 20
NEXT
FOR counter = 1 TO 100 ' Rotate clockwise for ~3 seconds
PULSOUT servoPin, 650
PAUSE 20
NEXT
END
This is the sample Parallax code. When I use a continues rotate servo, it spins only one direction never stopping. When I use a regular servo it barely moves. Note the BS2 is plugged into a Board of ED platform, Please, any ideas whats going on???
direction, note I am using the Sample Parallax code...
The code:
' RotateParallaxCrServo.bs2
' {$STAMP BS2}
' {$PBASIC 2.5}
counter VAR Word
servoPin PIN 12 ' change I/O pin for servo signal here
FOR counter = 1 TO 100 ' Rotate counterclockwise for ~3 seconds
PULSOUT servoPin, 850
PAUSE 20
NEXT
FOR counter = 1 TO 100 ' Hold still for ~3 seconds
PULSOUT servoPin, 750
PAUSE 20
NEXT
FOR counter = 1 TO 100 ' Rotate clockwise for ~3 seconds
PULSOUT servoPin, 650
PAUSE 20
NEXT
END
This is the sample Parallax code. When I use a continues rotate servo, it spins only one direction never stopping. When I use a regular servo it barely moves. Note the BS2 is plugged into a Board of ED platform, Please, any ideas whats going on???
Comments
A standard servo moves through a range of 180 degrees typically over a pulse width of 1.0ms to 2.0ms (500 to 1000). Midpoint is at 1.5ms (750). There's not a lot of position difference between 850 and 750 or between 750 and 650. Try PULSOUT values more toward the ends of the range like 550 and 950.
Is it a Parallax CR Servo?
It's more likely your power supply can't provide enough current. I'm going to bet you're using a 9V battery? If so, don't!
Servo draw a lot of current when they first start to move and this causes the voltage to drop which resets the microcontroller. This is a very very common problem.
You either need a better battery pack or a good wall transformer which can supply at least 1 amp of current.
Sometimes a big capacitor across the servo power lines will keep a microcontroller from resetting when using weak batteries/power supply. You might want to try adding a capacitor across the power lines of your servo.
As Duane mentioned weak batteries can cause all kinds of servos issues and Continuous Rotation servos must first be centered.
Chapter 4 of What's a Microcontroller is on Standard servos
http://www.parallax.com/sites/default/files/downloads/28123-Whats-a-Micro-v3.0.pdf
Chapter 2 of Robotics with the Boe-Bot is on Continuous Rotation servos
http://www.parallax.com/sites/default/files/downloads/28125-Robotics-With-The-Boe-Bot-v3.0.pdf
a thought. Any other value to suggest if other that the 3300uf to use? I am still thinking of trying another BS2 or SX which also have.
That's what I'd use.
If you add a line to your code to send a debug message when the program starts (or blink a LED) you can see if the BS2 is resetting or not (I bet it is). Wall warts can have trouble keeping up with the demands of a servo. There's a good chance the cap will help.
able to verify with both a regular servo and the continues one. S I have very happy to have get this far. Thank you all.
http://www.parallax.com/sites/default/files/downloads/900-00005-Standard-Servo-Product-Documentation-v2.2.pdf
http://www.parallax.com/sites/default/files/downloads/900-00008-Continuous-Rotation-Servo-Documentation-v2.2.pdf
Also, what is the jumper between the servo ports set to? Vdd or Vin?
this regulator. All this was to see if maybe I had a bad stamp issue. The next robot, I plan on providing separate power to the stamp and servos ( I have an old bot design from several years ago that I want to recreate, and make it into a much larger design eventually.
http://www.parallax.com/product/28124