PDA

View Full Version : Parallax Servo Controller with AVR



Mouse_Matrix
04-09-2007, 08:04 PM
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

Mike Green
04-09-2007, 10:53 PM
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_Matrix
04-09-2007, 11:32 PM
Atmega 128 serial communication has an idle bit (HIGH) and a start bit is low. Are the stop bits supposed to be HIGH?

Mike Green
04-10-2007, 01:19 AM
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_Matrix
04-10-2007, 05:53 PM
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_Matrix
04-10-2007, 06:55 PM
I looked up 1 is CTRL+A, and it displays ^A correctly, i wonder why the servo controller doesnt respond.

Mike Green
04-10-2007, 09:42 PM
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.

PAR
04-11-2007, 04:40 PM
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_Matrix
04-11-2007, 10:18 PM
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_Matrix
04-12-2007, 09:34 AM
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 Green
04-12-2007, 10:03 AM
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.