Legacy Forum: Preserving Nearly 20 Years of Community History - A Time Capsule of Discussions, Memories, and Shared Experiences.

AVR USART-Tristate turnaround time

Bioloid robot kit from Korean company Robotis; CM5 controller block, AX12 servos..
4 postsPage 1 of 1
4 postsPage 1 of 1

AVR USART-Tristate turnaround time

Post by Miamicanes » Tue Jun 17, 2008 3:44 pm

Post by Miamicanes
Tue Jun 17, 2008 3:44 pm

Has anybody ever tried to get half-duplex serial communication with an AVR to work by connecting BOTH RxD and TxD to the serial bus, and tristating one or the other by setting and clearing the RX/TX enable bits in UCSR0A? I tried it last night, and it kind of seemed like it might not be turning around fast enough, but it's also possible that the AVR might take longer to tristate a USART pin than it takes to activate one, and the final dying gasps of the transmit pin before it tristates might be triggering the receive pin, then taking longer to timeout than it takes for the AX-12 to begin sending its response datagram.

I'm getting ready to try and hook up the parallel-port analyzer I built a few months ago, but I'd love to know whether anyone has already tried going down this path and conclusively determined that it ultimately will or won't work :-)
Has anybody ever tried to get half-duplex serial communication with an AVR to work by connecting BOTH RxD and TxD to the serial bus, and tristating one or the other by setting and clearing the RX/TX enable bits in UCSR0A? I tried it last night, and it kind of seemed like it might not be turning around fast enough, but it's also possible that the AVR might take longer to tristate a USART pin than it takes to activate one, and the final dying gasps of the transmit pin before it tristates might be triggering the receive pin, then taking longer to timeout than it takes for the AX-12 to begin sending its response datagram.

I'm getting ready to try and hook up the parallel-port analyzer I built a few months ago, but I'd love to know whether anyone has already tried going down this path and conclusively determined that it ultimately will or won't work :-)
Miamicanes
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 28
Joined: Thu Dec 28, 2006 1:00 am

Post by i-Bot » Tue Jun 17, 2008 4:43 pm

Post by i-Bot
Tue Jun 17, 2008 4:43 pm

You may need to set the pullup on the I/O pin to ensure it floats high quickly.
You may need to set the pullup on the I/O pin to ensure it floats high quickly.
i-Bot
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 1142
Joined: Wed May 17, 2006 1:00 am

Post by Nathan Monson » Tue Jun 17, 2008 7:02 pm

Post by Nathan Monson
Tue Jun 17, 2008 7:02 pm

I haven't used this on an AVR, but I did exactly that with a Cypress uC and it worked fine. A pull-up is important because the AX-12 can't transmit unless the host is pulling the line to at least +3V. The default turnaround time for the AX-12 is 500us which should be plenty of time to float the pin!

If you still suspect you are not floating the pin soon enough, you could try dropping the baud rate, to increase your chances of receiving the tail-end of something. I did a lot of development at 9600 baud, where a simple status packet takes a good 6250us on the wire.

I happened to use 3V signalling, and I found that at 1mbps, I could not reliably send and receive with more than 2-3 servos on the bus. At 200kbps, I have had no problems with 10+.
I haven't used this on an AVR, but I did exactly that with a Cypress uC and it worked fine. A pull-up is important because the AX-12 can't transmit unless the host is pulling the line to at least +3V. The default turnaround time for the AX-12 is 500us which should be plenty of time to float the pin!

If you still suspect you are not floating the pin soon enough, you could try dropping the baud rate, to increase your chances of receiving the tail-end of something. I did a lot of development at 9600 baud, where a simple status packet takes a good 6250us on the wire.

I happened to use 3V signalling, and I found that at 1mbps, I could not reliably send and receive with more than 2-3 servos on the bus. At 200kbps, I have had no problems with 10+.
Nathan Monson
Robot Builder
Robot Builder
Posts: 10
Joined: Thu Apr 24, 2008 8:32 pm

Post by JonHylands » Tue Jun 17, 2008 9:10 pm

Post by JonHylands
Tue Jun 17, 2008 9:10 pm

Yes, I do this with all my Bioloid bus devices. My brother wrote the serial port handler code, and you can find it here:

http://svn.hylands.org/common/avr/bioloid-uart.c
http://svn.hylands.org/common/avr/bioloid-uart.h

- Jon
Yes, I do this with all my Bioloid bus devices. My brother wrote the serial port handler code, and you can find it here:

http://svn.hylands.org/common/avr/bioloid-uart.c
http://svn.hylands.org/common/avr/bioloid-uart.h

- Jon
JonHylands
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 512
Joined: Thu Nov 09, 2006 1:00 am
Location: Ontario, Canada


4 postsPage 1 of 1
4 postsPage 1 of 1