Shop OBEX P1 Docs P2 Docs Learn Events
Servo control witht he Parllax Servo controller — Parallax Forums

Servo control witht he Parllax Servo controller

Rob311Rob311 Posts: 83
edited 2008-05-18 16:35 in BASIC Stamp
I'm trying to get all of my servos to move at the same time. Here is my current code:

go:

DEBUG "Hip (A1) to ", DEC A1pw, ". Thigh (A2) to ",DEC A2pw,". Knee (A3) to ",DEC A3pw,CR
'A1
SEROUT Sdat, Baud+$8000,[noparse][[/noparse]"!SC", A1ch, ra, A1pw.LOWBYTE, A1pw.HIGHBYTE, CR]
'A2
SEROUT Sdat, Baud+$8000,[noparse][[/noparse]"!SC", A2ch, ra, A2pw.LOWBYTE, A2pw.HIGHBYTE, CR]
'A3
SEROUT Sdat, Baud+$8000,[noparse][[/noparse]"!SC", A3ch, ra, A3pw.LOWBYTE, A3pw.HIGHBYTE, CR]


DEBUG "Hip (C1) to ", DEC C1pw, ". Thigh (C2) to ",DEC C2pw,". Knee (C3) to ",DEC C3pw,CR
'C1
SEROUT Sdat, Baud+$8000,[noparse][[/noparse]"!SC", C1ch, ra, C1pw.LOWBYTE, C1pw.HIGHBYTE, CR]
'C2
SEROUT Sdat, Baud+$8000,[noparse][[/noparse]"!SC", C2ch, ra, C2pw.LOWBYTE, C2pw.HIGHBYTE, CR]
'C3
SEROUT Sdat, Baud+$8000,[noparse][[/noparse]"!SC", C3ch, ra, C3pw.LOWBYTE, C3pw.HIGHBYTE, CR]


DEBUG "Hip (B1) to ", DEC B1pw, ". Thigh (B2) to ",DEC B2pw,". Knee (B3) to ",DEC B3pw,CR
'B1
SEROUT Sdat, Baud+$8000,[noparse][[/noparse]"!SC", B1ch, ra, B1pw.LOWBYTE, B1pw.HIGHBYTE, CR]
'B2
SEROUT Sdat, Baud+$8000,[noparse][[/noparse]"!SC", B2ch, ra, B2pw.LOWBYTE, B2pw.HIGHBYTE, CR]
'B3
SEROUT Sdat, Baud+$8000,[noparse][[/noparse]"!SC", B3ch, ra, B3pw.LOWBYTE, B3pw.HIGHBYTE, CR]


DEBUG "Hip (D1) to ", DEC D1pw, ". Thigh (D2) to ",DEC D2pw,". Knee (D3) to ",DEC D3pw,CR
'D1
SEROUT Sdat, Baud+$8000,[noparse][[/noparse]"!SC", D1ch, ra, D1pw.LOWBYTE, D1pw.HIGHBYTE, CR]
'D2
SEROUT Sdat, Baud+$8000,[noparse][[/noparse]"!SC", D2ch, ra, D2pw.LOWBYTE, D2pw.HIGHBYTE, CR]
'D3
SEROUT Sdat, Baud+$8000,[noparse][[/noparse]"!SC", D3ch, ra, D3pw.LOWBYTE, D3pw.HIGHBYTE, CR]


DEBUG "Done",CR

PAUSE pausetime

RETURN

What happens right now is that one leg moves after the other. Its a small delay, but enough to topple my 4 legged bot. Looking at the code right now, removing the debug statements might hurry it up, but is that the only thing i can do?

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-05-18 16:35
    With the Parallax Servo Controller and the Stamp, maybe 40-50ms between servos is the best you can do. That's the time it takes just to send the control strings and for the Servo Controller to update its information. The DEBUG statements take 50-75ms each as well.

    If you need closer control of the servos, you may need to use something like a Propeller to directly control the servos and is fast enough to give you finer control. Do keep in mind that servos are imprecise devices with a lot of "slop" internally, both mechanical and electronic, and you may need to work out movement that's more balanced and less subject to toppling with rough control.
Sign In or Register to comment.