Shop OBEX P1 Docs P2 Docs Learn Events
servo problem — Parallax Forums

servo problem

CyrillCyrill Posts: 3
edited 2004-10-07 15:36 in BASIC Stamp
Hi

Who can explain with a little program ,how I can rotate two servo's at the same time
For now I can rotate them after each other.
But what should is ,for example

servo_1 rotate for ever between
For pulse =·1200 to 1800 step 8 and then from pulse 1800 to 1200

and at the same time
servo_2 rotate for ever between 1400 to 1600 step 10 and then from
pulse 1600 to 1400



thanks for any information

Cyrill

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-10-07 15:03
    The values you specify are probably what you meant·the PULSOUT value to be, so you'll have to adjust the numbers below to get the right pulse widths·(cut in half if using a BS2/BS2e/BS2pe).·

    Start:
    · servo1 = 1200
    · s1dir = 0
    · servo2 = 1400
    · s2dir = 0


    Main:
    · DO
    ··· PULSOUT S1, servo1
    ··· PULSOUT S2, servo2
    ··· PAUSE 20


    ··· IF (s1dir = 0) THEN
    ····· servo1 = servo1 + 8
    ····· IF (servo1 >= 1800) THEN
    ······· s1dir = 1
    ····· ENDIF
    ··· ELSE
    ····· servo1 = servo 1 - 8
    ····· IF (servo1 <= 1200) THEN
    ······· s1dir = 0
    ····· ENDIF
    ··· ENDIF


    ··· IF (s2dir = 0) THEN
    ····· servo2 = servo2 + 10
    ····· IF (servo2 >= 1600) THEN
    ······· s2dir = 1
    ····· ENDIF
    ··· ELSE
    ····· servo2 = servo2 - 10
    ····· IF (servo1 >= 1600) THEN
    ······· s2dir = 0
    ····· ENDIF
    ··· ENDIF


    · LOOP



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office
  • allanlane5allanlane5 Posts: 3,815
    edited 2004-10-07 15:36
    Servo's need a 1 to 2 mSec pulse, repeated every 20 to 50 mSec. So, you can pulse one, then pulse the other, very close together, and get the same effect as pulsing both at the same time. The Servo has an internal circuit that actually drives the little motor inside.

    If you REALLY need both to move at exactly the same time (like it's driving a pen for writing) -- well, I don't know that you can do this.
Sign In or Register to comment.