Shop OBEX P1 Docs P2 Docs Learn Events
Controlling Servo Direction — Parallax Forums

Controlling Servo Direction

koolitudekoolitude Posts: 37
edited 2007-01-31 08:53 in BASIC Stamp
Hello everyone...

I've just bought a BS2 and two continuous servo motors.

I would like to control the direction of rotation of the servo... (clockwise/anticlockwise)

How can I do that? Thanks!


ServoL_pin CON 12
ServoR_pin CON 13

Start:
PULSOUT ServoL_pin, 750
PULSOUT ServoR_pin, 750
PAUSE 20
GOTO Start


I can only make the motors turn in clockwise direction with this code...

How can I make one turns clockwise while another one turns anticlockwise??

Post Edited (koolitude) : 1/30/2007 8:01:52 AM GMT

Comments

  • koolitudekoolitude Posts: 37
    edited 2007-01-30 08:11
    Please Help~~~~~~~~ Thanks~~~~~~~~~~
  • ChristjChristj Posts: 13
    edited 2007-01-30 08:16
    You can try these ...

    FOR i = 1 TO 20
    PULSOUT 12, 650
    PULSOUT 13, 850
    PAUSE 20
    NEXT

    Don't forget to adjust the servo, so it will be stop when giving a 750 width pulse.
  • koolitudekoolitude Posts: 37
    edited 2007-01-30 08:18
    Thanks a lot...

    just some follow up questions....

    Would the speeds of the motors be the same?

    How did you decide the value of 650 and 850?

    Thanks once again~~~~~~~~~~~~~~~~~~
  • Bill ChennaultBill Chennault Posts: 1,198
    edited 2007-01-30 13:53
    koolitude--

    Just download the book "What's a Microcontroller?" Parallax makes it available for free download. You can either download it or read it online at . . .

    http://www.parallax.com/dl/docs/books/edu/Wamv2_2.pdf

    In any case, I believe exactly what you want is in chapter 4, which begins on page 103.

    Have fun!

    --Bill


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    You are what you write.
  • LSBLSB Posts: 175
    edited 2007-01-30 14:13
    Servos are commanded to position by signals between 1000 and 2000 ms; 1500 is center. The pulsout command outputs in 2ms steps so... pulsout 500 moves an UNMODIFIED servo to full anticlockwise, pulsout 1000 move the unmdified servo to full clockwise position and pulsout 750 is center. The servo 'knows' these positions, because it turns a potentiometer as the motor turns and, when the two signals agree, the servo is in position. This is useful in a variety of ways (but doesn't answer your question). If the servo is 'modified' in that the feedback potentiometer is disconncted, the servo will continue to spin 'continuously' as it tries to find the motor position where the pot signal and the motor position agree. Pulseouts > 750 turn the motor clockwise to search, pulseouts < 750 turn the motor anticlockwise to search. "Centering" the servo is the act or process of adjusting the disconnected pot so that at a pulsout of 750, the pot and the motor position agree... therefore the motor remains still.
    In practice, one sends pulsout 750 to the modified servo and adjusts the pot until the motor stops turning, then sends pulsouts of > 750 to move the 'bot forward and <750 to move it opposite. Since the servos are likely mounted on opposite sides of the robot, one servo must go clockwise and one must go anticlockwise to move both wheels 'forward', hence Christj's code commands one servo to 650 (<750) and one to 850 (>750).
  • PARPAR Posts: 285
    edited 2007-01-30 21:22
    Servos are commanded to position by signals between 1000 and 2000 ms; 1500 is center. ...
    Actually, between 1 and 2 milliseconds (ms), or 1000 and 2000 microseconds (us).

    PAR
  • LSBLSB Posts: 175
    edited 2007-01-30 23:53
    Right, right. Thank you for the correction.
  • koolitudekoolitude Posts: 37
    edited 2007-01-31 08:53
    Thank you very much for all your help!
    Y'all are very helpful! =)
Sign In or Register to comment.