Shop OBEX P1 Docs P2 Docs Learn Events
Help with servo controller — Parallax Forums

Help with servo controller

jpric18jpric18 Posts: 2
edited 2006-01-14 18:16 in Robotics
I'm using the 16 servo Parallax servo controller on a 18f4520 using UART (software). I'm having trouble trying to figure out how to do this in C since the examples in the documentation for the servo controller are in PBASIC? any examples of controlling the servo in C? Thanks in advance.

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-01-14 04:17
    Not from us -- but others have done it so you can too.· What you need to know is the the communication is standard 8 bits, N81 serial, true mode (that means the idle state of the serial line is high and a "1" bit pulls the line low).· On your processor you may not be able to use the same pin for output and input so what you'll need to do is put a 1K resistor between your TX and RX and connect the PSC serial line to the RX pin.· The 1K resistor will give the PSC something to drive against regardless of the state TX gets left in.

    Good luck.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • jpric18jpric18 Posts: 2
    edited 2006-01-14 16:32
    ah ok. That makes sense. But the syntax for the servo controller to move a servo is "!SC" ch ra pw.LOWBYTE, pw.HIGHBYTE, $0D. We are trying to send each character at a time, '!', 'S', 'C', then for ch, ra and the pw's, we are sending as hex values.
    ch = 0x00
    ra = 0x20
    pw.LOWBYTE = 0x03
    pw.HIGHBYTE = 0xF4


    we are putting each character into one array. Using a for loop to run through the array, we are writeing each character to the serial out followed by a delay. Is this the wrong way to send the command to the servo controller?
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-01-14 18:16
    What do you mean sending the other values as hex values?· They should be sent as their raw binary value with no format conversion being done to them.· If you're just sending a value, such as 7 that's fine.· But if you're converting the 7 into a hex $07 and sending that it won't work.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
Sign In or Register to comment.