Shop OBEX P1 Docs P2 Docs Learn Events
Controlling 2 Servo's Simultaneously — Parallax Forums

Controlling 2 Servo's Simultaneously

MattyhMattyh Posts: 1
edited 2005-05-18 14:34 in BASIC Stamp
Does anyone know if you can run 2 sero's simultaneously with Basic Stamp 2? I've thought of using a background process or something, is this possible with Basic Stamp? I'm also trying to avoid using the "Parallax Servo Controller" . Right now I find that when I leave one·servo unpowered and go on (in the program) to the next servo, the unpowered servo losses its position(due to the·weight of the actuating arm). So is there any way to keep it powered whilst I move the other one?··Any help would be appreciated!!
-Matt

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-05-18 13:10
    You need to refresh the servo every 20 ms or so, otherwise you'll see this problem. If you're not able to do that because of your other processing then you may need a controller. That said, we frequently use two servos and do other things -- have a look at any of our BOE-Bot projects.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
  • allanlane5allanlane5 Posts: 3,815
    edited 2005-05-18 14:34
    Yes, you can use two servos
    ServoOne CON 0 ' ServoOne's control pin
    ServoTwo CON 1 ' ServoTwo's control pin

    ServoOnePulse VAR WORD
    ServoTwoPulse VAR WORD
    I VAR BYTE

    MAIN:
    · ServoOnePulse = 750 ' On BS2, 750 * 2 uSec is 1.5 mSec, or center position
    · ServoTwoPulse = 750
    · FOR I = 1 to 250
    ··· ServoOnePulse = ServoOnePulse + 1
    ··· ServoTwoPulse = ServoTwoPulse + 1
    ··· GOSUB ServoRefresh
    ··· PAUSE 20
    · NEXT
    · GOTO MAIN

    ' *** Subroutines ***

    ServoRefresh:
    · PULSOUT ServoOne, ServoOnePulse
    · PULSOUT ServoTwo, ServoTwoPulse
    · RETURN

    ' The point here is, you can do 'PULSOUT' for several servo's, then have a single delay
    ' before you refresh them all again.
    '
    '· The ServoRefresh routine makes sure they keep their position (if you haven't changed it)
    '· or move to a new position (if you have).


    Post Edited (allanlane5) : 5/18/2005 2:37:12 PM GMT
Sign In or Register to comment.