Shop OBEX P1 Docs P2 Docs Learn Events
Controlling 2 or more servo's with the USB servo controller board on the PDB! — Parallax Forums

Controlling 2 or more servo's with the USB servo controller board on the PDB!

kingspudkingspud Posts: 128
edited 2005-05-25 17:38 in Robotics
NEED HELP!!!!

I have the PDB board and the USB servo controller board and I am trying to control two or more servo's but don't under stand the code!

Can someone PLEASE help with the code to move two servos with this type of configuration!

I have the connection correct "I think!" and when I try the code in the USB Servo controller doc nothing happens!·I see that the light is blinking on the Servo controller·due to the pulse but·No servo movement!· I also have the 24psx module on the PDB board!

What am I doing wrong?·This is very frustrating because·there is no docs on the new PDB board and only on the BOE. ·If someone could just write me code that would move even one servo I could modify it to move more!

Please help!

Joe

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-05-24 17:55
    Hello,

    ·· There's no BS2psx module.· Do you have the BS2px or the BS2sx?· Either way you will most likely have to change the baud rate parameters since they're for the BS2.



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • kingspudkingspud Posts: 128
    edited 2005-05-24 18:00
    Sorry... I meant to say the BASIC Stamp 2px 24-Pin Module
  • kingspudkingspud Posts: 128
    edited 2005-05-24 18:06
    Sub question: What would the buad rate be for the BASIC Stamp 2px 24-Pin Module be???
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-05-24 18:35
    I include this in my standard programming template so I never have to guess baud parameters -- it's easier to delete what I don't need than to look them up or calculate them:

    #SELECT $STAMP
    · #CASE BS2, BS2E, BS2PE
    ··· T1200······ CON···· 813
    ··· T2400······ CON···· 396
    ··· T4800······ CON···· 188
    ··· T9600······ CON···· 84
    ··· T19K2······ CON···· 32
    ··· TMidi······ CON···· 12
    ··· T38K4······ CON···· 6
    · #CASE BS2SX, BS2P
    ··· T1200······ CON···· 2063
    ··· T2400······ CON···· 1021
    ··· T4800······ CON···· 500
    ··· T9600······ CON···· 240
    ··· T19K2······ CON···· 110
    ··· TMidi······ CON···· 60
    ··· T38K4······ CON···· 45
    · #CASE BS2PX
    ··· T1200······ CON···· 3313
    ··· T2400······ CON···· 1646
    ··· T4800······ CON···· 813
    ··· T9600······ CON···· 396
    ··· T19K2······ CON···· 188
    ··· TMidi······ CON···· 108
    ··· T38K4······ CON···· 84
    #ENDSELECT

    SevenBit······· CON···· $2000
    Inverted······· CON···· $4000
    Open··········· CON···· $8000

    Baud··········· CON···· T2400 + Open


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • kingspudkingspud Posts: 128
    edited 2005-05-24 20:30
    Hi Jon,

    This is the code I am trying to use to test the servos and it will not work, any guesses?

    I think I am using the correct baud rate of 396 for the BS2px chip

    ' {$STAMP BS2px}
    ' {$PBASIC 2.5}

    ch VAR Byte
    pw VAR Word
    ra VAR Byte
    x VAR Byte
    Buff VAR Byte(3)
    Sdat CON 1
    Baud CON 396
    Init:
    ra = 15: ch = 0
    DO
    pw = 1240: GOSUB WRservo
    pw = 240: GOSUB WRservo
    LOOP
    WRservo:
    SEROUT Sdat, Baud+$8000, [noparse][[/noparse]"!SC", ch, ra, pw.LOWBYTE, pw.HIGHBYTE, CR]
    FOR x = 0 TO 4
    PAUSE 1000
    SEROUT Sdat, Baud+$8000, [noparse][[/noparse]"!SCRSP", ch, CR]
    SERIN Sdat, Baud, 1000, Init, [noparse][[/noparse]STR Buff\3]
    DEBUG "Servo ", DEC buff(0), " ", HEX2 buff(1), " :", HEX2 buff(2), CR
    NEXT
    RETURN
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-05-24 20:40
    If you're using the BS2px you need to change the Baud definition to 1646 for 2400 baud. The PSC communicates at two rates: 2400 or 38.4K. It starts up at 2400 and can then be switched to 38.4K through the serial link (with the "!SCSBR" command). This is covered in the documentation.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • kingspudkingspud Posts: 128
    edited 2005-05-25 17:38
    Thanks Jon,

    Worked like a charm, the only problem I had was my 7.2 V battery for the servo's kept dying and I need to get a new one.
    Thanks again,
    Joe
Sign In or Register to comment.