by dhylands » Tue Dec 19, 2006 10:56 pm
by dhylands
Tue Dec 19, 2006 10:56 pm
There are a bunch of issues trying to get a device to talk to an AX-12 servo.
The first is the fact that the AX-12 uses a half-duplex form of communication. The second is getting the baud rates to match.
Lets talk about baud rates first. Many devices, like the gumstix, use crystals which are based around frequencies which are multiples of 1200. The gumstix happens to use a 3.6864 MHz crystal for its serial communications. This makes getting baud rates like 115,200 or 921,600 bang on.
The AX-12 uses (I believe) an AVR based processor running at 16 MHz, which makes baud rates like 1000000 easy, but rates like 921600 not possible. With a 16 MHz crystal, you can get 117647 baud which is within about 2% or 115200, but the closest you can get to 921600 is 1Mbit which is 8.5% error, which is too big a difference to allow reliable communication (the datasheets recommends 2% as the max error for reliable communication)
So the next issues is using the half-duplex protocol. With the code I was doing for Jon, I was trying to use an ATMega128 (the robostix) to talk to the AX-12 by using no additional hardware. Even then it was a bit tricky. You need to be careful about when you stop driving the Tx line. You need to wait until all of the bits have actually been shifted out of the Tx shift register, and then within 160 usec, you need to configure the Tx line as a GPIO input (so it's not driving the line anymore).
I chose to receive my own input and when I start to send a character I put the Tx into output mode. After I've received the character being sent I turn the Tx back into an input (since I've received the character, by definition the last bit must have been shifted out).
So, given the above, it didn't seem practical to use the gumstix to talk directly to the AX-12. The baud rates don't work out and linux can't guarantee that I can turn my Tx off within 160 usec of sending the last character.
The initial version I did for Jon uses the gumstix talking at 115,200 to the robostix and the robostix talking at 1Mbit to the the AX-12. Eventually, I'd like to redo it so that the gumstix/robostix link is using SPI, which will allow going up to full 1Mbit transfer rates.
--
Dave Hylands
Vancouver, BC, Canada
http://www.DaveHylands.com/
There are a bunch of issues trying to get a device to talk to an AX-12 servo.
The first is the fact that the AX-12 uses a half-duplex form of communication. The second is getting the baud rates to match.
Lets talk about baud rates first. Many devices, like the gumstix, use crystals which are based around frequencies which are multiples of 1200. The gumstix happens to use a 3.6864 MHz crystal for its serial communications. This makes getting baud rates like 115,200 or 921,600 bang on.
The AX-12 uses (I believe) an AVR based processor running at 16 MHz, which makes baud rates like 1000000 easy, but rates like 921600 not possible. With a 16 MHz crystal, you can get 117647 baud which is within about 2% or 115200, but the closest you can get to 921600 is 1Mbit which is 8.5% error, which is too big a difference to allow reliable communication (the datasheets recommends 2% as the max error for reliable communication)
So the next issues is using the half-duplex protocol. With the code I was doing for Jon, I was trying to use an ATMega128 (the robostix) to talk to the AX-12 by using no additional hardware. Even then it was a bit tricky. You need to be careful about when you stop driving the Tx line. You need to wait until all of the bits have actually been shifted out of the Tx shift register, and then within 160 usec, you need to configure the Tx line as a GPIO input (so it's not driving the line anymore).
I chose to receive my own input and when I start to send a character I put the Tx into output mode. After I've received the character being sent I turn the Tx back into an input (since I've received the character, by definition the last bit must have been shifted out).
So, given the above, it didn't seem practical to use the gumstix to talk directly to the AX-12. The baud rates don't work out and linux can't guarantee that I can turn my Tx off within 160 usec of sending the last character.
The initial version I did for Jon uses the gumstix talking at 115,200 to the robostix and the robostix talking at 1Mbit to the the AX-12. Eventually, I'd like to redo it so that the gumstix/robostix link is using SPI, which will allow going up to full 1Mbit transfer rates.
--
Dave Hylands
Vancouver, BC, Canada
http://www.DaveHylands.com/