Shop OBEX P1 Docs P2 Docs Learn Events
Futaba servos out of control after modification! — Parallax Forums

Futaba servos out of control after modification!

MiltosMiltos Posts: 16
edited 2011-12-30 15:59 in Learn with BlocklyProp
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.

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2011-12-22 12:50
    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.
  • ercoerco Posts: 20,257
    edited 2011-12-30 15:59
    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
Sign In or Register to comment.