Standard Servo Pulse
I am having a hard time controlling a standard servo (first time, only done the continuous up until now). I have gotten it to go smoothly "forward" and skippy "backward".
The parallax sample code for BS2 is
That doesn't work, it just makes the servo go clockwise...then clockwise again. It is the servo that came with the PING)) by the way.
So I wrote
and it goes clockwise 180
and then
and it goes counter clockwise 180...but is jittery. What's up?
EDIT: I haven't checked, but I'm curious...the BoE-Bot book says to switch the jumper for the servos to VIN from VDD, but the PING)) book says to put it on VDD...does it make a difference? Could this be the problem...or just ANOTHER problem?
Post Edited (RICoder) : 1/10/2009 5:06:50 AM GMT
The parallax sample code for BS2 is
Servo_pin CON 0 'I/O pin that is connected to servo Temp VAR Word 'Work space for FOR NEXT start: FOR temp = 200 TO 1200 PULSOUT Servo_pin,temp PAUSE 50 NEXT FOR temp = 1200 TO 200 PULSOUT Servo_pin,temp PAUSE 50 NEXT GOTO start
That doesn't work, it just makes the servo go clockwise...then clockwise again. It is the servo that came with the PING)) by the way.
So I wrote
iLCV VAR Byte FOR iLCV = 1 TO 11 PULSOUT 14, 1 PAUSE 50 NEXT
and it goes clockwise 180
and then
iLCV VAR Byte FOR iLCV = 1 TO 11 PULSOUT 14, -1 PAUSE 50 NEXT
and it goes counter clockwise 180...but is jittery. What's up?
EDIT: I haven't checked, but I'm curious...the BoE-Bot book says to switch the jumper for the servos to VIN from VDD, but the PING)) book says to put it on VDD...does it make a difference? Could this be the problem...or just ANOTHER problem?
Post Edited (RICoder) : 1/10/2009 5:06:50 AM GMT
Comments
Your edit: Absolutely! do not run the servos off the battery, especially if you are using a high voltage. 5v is about ideal, and the higher the voltage is the faster your servo wear out. Also, do not power your ping off of VIN, you want it to have exactly 5 volts.
Edit: I'm not sure where you got your 'parallax' sample code. I'm pretty sure that they wouldn't make such critical mistakes such as pausing too long (50) or giving out of bounds values. And another note: you may have ruined your servo by giving it such an extreme pulse. When you give it an out of bounds, it tries to get there, but is stopped mechanically, possible resulting in stripped gears. You may want to try correct code on another servo, and then on the current servo to see if you get a duplicate action.
Post Edited (SRLM) : 1/10/2009 5:37:08 AM GMT
http://www.parallax.com/Portals/0/Downloads/docs/prod/motors/stdservo.pdf
I don't think the servos are wrecked, because they seem fine now. I am confused on meaning of pulse codes for this servo though. The continuous is easy >750 one way, <750 the other way. What is the 500-1000 values related to direction and speed?
EDIT: If it is absolute position, I mat be screwed because that isn't working....unless there is a way to initialize or calibrate it that I am missing.
Post Edited (RICoder) : 1/10/2009 6:33:51 AM GMT
Anyway, there are two basic types of servos (to concern us now):
Standard: this servo will travel to a particular position and hold that position until a change of command.
Continuous: this servo will travel at varying speeds in one direction or another based on commands received.
A continuous rotation servo cannot hold a certain position, and a standard servo can't complete a full rotation.
For a standard servo, the pulse range of 500 to 1000 corresponds to a series of 500 possible positions that you can tell your servo to turn to.
Based on this information, is your servo working correctly? Be sure to mention if you're testing a continuous rotation servo or a standard servo.
It is a standard servo. BS2. BoE.
This code swings it back and forth: (from the RoamingWithPING.bs found on this site)
I assumed that what you said was the case when I tried to use it, that 500 was an absolute position, but that just doesn't work. The servo itself (again, a standard NOT continuous) is the one that comes with the PING))) bracket kit.
Hello RICoder
Vdd goes through the voltage regulator, Vin does not. So if you use a 9v battery Vdd will be 5v and Vin will be 9v, if you use a 6v battery pack then Vdd will be 5v and Vin will be 6v, etc.
The duration parameter determines the position the servo turns to. For a standard servo you can think of 750 as the centre or 12 o'clock position, values lower will move the servo clockwise,a value of 500 will be about 2 o'clock. Higher values will move counterclockwise, 1000 will be about 10 o'clock. These instructions needs to be sent every 20 ms. The For...Next loop controls the time to get to and the time the servo stays at your chosen position. In the case of continuous rotation servos they have been modified so they can't find the position but they will keep trying. With these servos 750 will be stopped. Values lower will turn the servo clockwise and values higher will turn counterclockwise same as with a standard servo but in this case the farther you get from 750 the faster it will turn. About 650 and 850 are the maximums. The For...Next loop in this case controls how long the servo rotates. “What's a Microcontroller” and “ Robotics with the Boe-Bot” give far better explanations.
What exactly is your servo doing or not doing?
Brad
I expected to tell the servo to go to 750 once and have it do it without help. That's not the case at all.
It occurred to me after sleeping that perhaps it need to be told where to go repeatedly until it actually got there, so I changed my strategy and made it loop infinitely with different values (starting at the 9o'clock position). That works.
My servo seems to be range from about 250 - 1100 with a midpoint of about 700. I figure that is just tweaking to the particular drive.
Thank you all for your help...this one was definitely my fault but I appreciate the help finding my screw-up.