We decided to experiment with some Dynamixel AX-12A servos for this project. Despite being a little bit more expensive, this motor has a couple of advantages over the more commonly found TowerPro motors.
Mainly, the Dynamixel motors are stronger, daisy chainable, and have a robust control system that reports position, temperature, torque, etc…
We found two different manuals for the AX-12A motors online. This manual is from 2006, and is a little outdated: some of the spec values are outdated (operating voltage range, for example), and some of the initial values reported in the Control Table are not correct, but it goes into detail about how to send instructions to the motor and how to read its response.
This other manual has more accurate values for specs and initial conditions, but lacks some of the detailing of the communication protocol.
It’s useful to have both of them.
Unlike other servos, the Dynamixel doesn’t respond to PWM signals, but a slightly more complicated protocol of instructions for reading and writing onto its memory. This communication happens over a half-duplex UART port, using only one wire for both sending and receiving.
What this means is that we need to build a small circuit that converts full-duplex into half-duplex, if we want to use a Raspberry Pi or an Arduino (or another microcontroller with a full-duplex serial interface) to control these motors.
One of the AX-12 manuals recommends this circuit:
It’s basically a tri-state buffering scheme for arbitrating the bus; it makes sure that when the controller is transmitting, the bus isn’t connected to the Rx pin, and that when it’s expecting to receive, it’s not being driven by the Tx pin.
Instead of using a 74HC126 and a 74HC04, we used a 74LS241 (as recommended here), because it already has the built-in capability of enabling half of its buffers with a high signals, and the other half with a low signal.
Something like this:
We first tested the circuit using an Arduino and the library found here.
But, because we might eventually want to connect our robots to the internet, or keep track of their state between reboots, or do some heavier computation… we might want to use a Raspberry Pi as the controller. We started testing this library for controlling the motors using a Raspberry Pi, but then decide to re-write it to make it more object-oriented, and to have some of the same capabilities as the Arduino library.