Shop OBEX P1 Docs P2 Docs Learn Events
Parallax Servo Controller with AVR — Parallax Forums

Parallax Servo Controller with AVR

Mouse_MatrixMouse_Matrix Posts: 6
edited 2007-04-12 02:03 in General Discussion
Hi,
I am trying to control the servo controller serially with atmega128 microcontroller.

I am sending the commands as mentioned in the documentation e.g "!SC"+ c+r+pwl+pwh+$0D at 2400 8 N 2.

I am sending the channel number, the ramping rate and the position ( high and low byte) as unsigned 8 bit integers.

I checked my output from the microcontroller with my pc at 2400 and the required configuration, and i can see the desired output.

the servo controller works fine with my stamp.

Is there anything that i am missing that needs to be addressed?

Thank you.
hussain

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-04-09 14:53
    The only thing you're not describing is how you have these items connected. The Stamp produces (and the servo controller expects) the serial line to idle at a logic high (usually +5V) and the start bit to be a logic low (0V). The atmega128 may be inverting the signal.
  • Mouse_MatrixMouse_Matrix Posts: 6
    edited 2007-04-09 15:32
    Atmega 128 serial communication has an idle bit (HIGH) and a start bit is low. Are the stop bits supposed to be HIGH?
  • Mike GreenMike Green Posts: 23,101
    edited 2007-04-09 17:19
    The stop bits are supposed to be HIGH, but many serial I/O routines ignore this.

    You might try monitoring the connection between the atmega128 and the servo controller using your PC. Most I/O pins can drive several inputs and the atmega128 should be able to drive both the servo controller and the input to a TTL to RS232 converter or TTL to USB serial adapter (don't connect the outputs together).
  • Mouse_MatrixMouse_Matrix Posts: 6
    edited 2007-04-10 09:53
    i tried ur advice, but i get a weird output, i wonder what it is.
    when i send int c= 1, r=1, pwl=1 pwh =1 i get this output. i wonder what it means.
    !SC^A^A^A^A

    apparently it is interpreting 1 as ^A (2 bytes).
  • Mouse_MatrixMouse_Matrix Posts: 6
    edited 2007-04-10 10:55
    I looked up 1 is CTRL+A, and it displays ^A correctly, i wonder why the servo controller doesnt respond.
  • Mike GreenMike Green Posts: 23,101
    edited 2007-04-10 13:42
    Yes. I looked again at the documentation and it sure looks like the right command sequence. You might try the same setup with a Stamp (so you can see what's actually sent) and make sure the servo controller responds. You could try calling Parallax's customer service line, reference this thread and see if they can help further.
  • PARPAR Posts: 285
    edited 2007-04-11 08:40
    Mouse_Matrix said...
    Hi,
    I am trying to control the servo controller serially with atmega128 microcontroller.

    I am sending the commands as mentioned in the documentation e.g "!SC"+ c+r+pwl+pwh+$0D at 2400 8 N 2.

    I am sending the channel number, the ramping rate and the position ( high and low byte) as unsigned 8 bit integers.


    ...
    Do the led's on the PSC light/blink when the atmega sends the data strings?

    If so, do they light/blink in the same pattern as when you connect the PSC to your Stamp?

    Also, what position value do you expect (want) the servo to get from·the combined pwl=1,pwh=1 when you send the two unsigned 8-bit integers?

    PAR
  • Mouse_MatrixMouse_Matrix Posts: 6
    edited 2007-04-11 14:18
    I am trying to go to position 257, which is in the range of 250-1250 allowed by the controller.
    After checking it with my computer and using the USB GUI, i observed that the led only blink while the transmission is in progress and it readily turns off. With my AVR the led is always ON and it blinks when i send the serial data and goes back to On.

    I am going to test it with the stamp today and observe how that behaves, and get the serial output to my computer and observe any changes.

    Post Edited (Mouse_Matrix) : 4/11/2007 2:34:51 PM GMT
  • Mouse_MatrixMouse_Matrix Posts: 6
    edited 2007-04-12 01:34
    i have another question. i observed that the serial l/o pin connection the stamp board and the controller is operating in half duplex. how will that have any implications in my code. because what i am doing is simply using the uart tx pin and connecting it to the controller serial.
    i make sure that i dont send any command that makes the controller write anythin on the line( enough for my purposes)

    is that fundamentally correct approach?
  • Mike GreenMike Green Posts: 23,101
    edited 2007-04-12 02:03
    The Stamps are strictly half duplex since serial reception is not buffered and the processor is single threaded. In other words, it can only do one thing at a time. Most of the peripherals designed for use with the Stamp are also half duplex to accomodate this. The main thing you have to do is not send a new command until you've received and interpreted any response from the previous command.
Sign In or Register to comment.