Shop OBEX P1 Docs P2 Docs Learn Events
Controlling the PSC from a microcontroller programmed in C — Parallax Forums

Controlling the PSC from a microcontroller programmed in C

PengatomPengatom Posts: 21
edited 2005-12-13 00:53 in General Discussion
Hi!

I've just started a project including a microcontroller and the Parallax Servo Controller. This mC is programmed in C, and my programming skills are not entirely steady [noparse];)[/noparse]

Earlier I've programmed BS and JS using PBASIC and java...

The first thing I want to do is testing that everything works, that is, a program in C that works like this one in java :
http://forums.parallax.com/attachment.php?attachmentid=37719

regards

Pengatom

Comments

  • PengatomPengatom Posts: 21
    edited 2005-11-30 17:50
    Hmmm, I guess my post might be a bit bad written tongue.gif

    My intention isn't to have someone else write my entire project.

    It is more of how to set up the communication bit, the format of the message to the PSC I hoped to get som help to...

    regards

    Pengatom

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    1 + 1 = 10· |· 4 + 4 = 10· |· 5 + 5 = 10· |· 8 + 8 = 10
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-11-30 17:56
    It's really quite straightforward: communication between the host happens (bi-directionally) over a single wire at 2400 (default) or 38.4 kBaud (standard N81 format). The mode is open-true; this means two things: 1) the host lets the serial line float at the end of a transmission, and 2) a start and "1" bit is 0v, the idle state of the line is 5v. Now, if you uC has separate TX and RX lines then you should connect them together with a 1K resistor and connect the RX line to the PSC. The 1K resistor will prevent the output state of the TX line from interfering with transmission back from the PSC.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • PengatomPengatom Posts: 21
    edited 2005-12-01 18:37
    The communication port is set up as an uart with
    8 databits
    not to use parity
    interrupt enable
    and baudrate 2400 (at startup anyway)

    The uart has "One transmit and one receive channel (full duplex)", so I guess I have to make a connection like this then? (see attachment)

    However the ports can have 3 states, In - Out - InOut
    Atm·they are Tx - Out and Rx - In.

    Do I need the interrupt, or should I just remove it?

    regards

    Pengatom

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    1 + 1 = 10· |· 4 + 4 = 10· |· 5 + 5 = 10· |· 8 + 8 = 10
    371 x 179 - 8K
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-12-01 20:26
    Hard to say.... If your UARTs are implemented in software and interrupt driven, you need it -- if not, then no and you should probably turn it off. You might consider something simple (like talking to a termina) before you move on to the PSC.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • PengatomPengatom Posts: 21
    edited 2005-12-05 20:02
    The UART is software implemented, actually the uC is an FPGA. (http://searchsmb.techtarget.com/sDefinition/0,290660,sid44_gci530571,00.html)

    I'm doing this babysteps, writing some code for talking to a terminal, and expanding it from there.

    Study to exam during the day, and then an hour (or so) with programming in the evening [noparse];)[/noparse]

    Thanks for the help anyway, hopefully I will get it to work soon [noparse]:)[/noparse]

    regards

    Pengatom

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    1 + 1 = 10· |· 4 + 4 = 10· |· 5 + 5 = 10· |· 8 + 8 = 10

    Post Edited (Pengatom) : 12/5/2005 8:06:34 PM GMT
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-12-06 13:07
    If it's being implemented on an FPGA then I'm sure timing is fine; just make sure that it uses the correct polarity (idle state is high, "1" bit is low), and that the packet is standard 8N1. Remember, too, that the PSC receives commands and sends its responses on the same pin, so you've got to be able to handle that on your end. What you probably need to do is put a 1K resistor between your TX and RX pin -- connect the PSC to the RX side of the connection.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2005-12-13 00:53
    I think the 1k may be too large, due to the 220 ohm pullup plus LED on
    the psc data line. I suggest 220 ohm between Tx and Rx line.

    You find a javelin psc class here. Javelin java is easily converted to C.
    http://groups.yahoo.com/group/JavelinCode/files/Javelin%20Stamp%20IDE/lib/stamp/peripheral/servo/psc/

    regards peter
Sign In or Register to comment.