PDA

View Full Version : Futaba servos out of control after modification!



Miltos
12-22-2011, 08:41 PM
After reading a lot of articles "how to modify a standard servo for continous rotation", I succesfully alter my futaba s3003 for continous rotation. Nevertheless the servos run with non stop for a counter loop from 1 to 256 (and above), see code below:


' {$STAMP BS2}' {$PBASIC 2.5}




'------------- Variables --------------


counter VAR Byte 'variable for PULSOUT loop
PBin VAR IN2 'PushButton for PIN2


'------------- Constants ---------------


SERVO_Right CON 12 ' Right Servo
SERVO_Left CON 13 ' Left Servo


start:
FOR counter = 1 TO 259
PULSOUT SERVO_Left, 850
PULSOUT SERVO_Right, 650
PAUSE 20
NEXT






standby:
DEBUG "Stanby mode",CR
IF PBin = 0 THEN start
GOTO standby:

How can I make the servos run for let's say 2 min...as any end value above 250 will make them run for ever???
Any help will be much appreciated.

Mike Green
12-22-2011, 08:50 PM
The servos are doing exactly what your program is telling them to do ... run. They will run as long as the program is producing the servo pulses. There should be a pulse width that causes the servos to stop moving, usually it's around a value of 750 (a pulse width of 1.5ms). If you look in the "Robotics with the BoeBot Robot" tutorial, you'll see a section where they talk about calibrating the servo. There should be an adjustment that you can use to make this "stop point" be a pulse width of 1.5ms. Pulses shorter than that move the servo in one direction at increasing speeds (as the pulse width gets shorter). Pulses longer than that move the servo in the other direction at increasing speeds.

There is no direct way to make the servos move for a period of time. Normally this is done by putting out a control pulse every 20ms for a total of say 2 minutes. That's 120 seconds or 6000 pulses. You'd make your FOR loop run for 6000 pulses so the servos would run for 2 minutes. You'd have to make your counter be a word variable instead of a byte variable.

erco
12-30-2011, 11:59 PM
BTW, your byte variable COUNTER and your for/next range of 1-259 don't jibe. Either change the range to 0-255 (max range of a byte) or make COUNTER a word variable.

And while you're for/nexting, try this fun speed-changing code on your CR servos:

counter var word
xcounter var word
FOR counter = 500 TO 1000
xcounter=1500-counter
PULSOUT SERVO_Left, counter
PULSOUT SERVO_Right, xcounter
PAUSE 20
NEXT