Dynamixel AX-12 Driver
Adds support for the Dynamixel AX-12 servo.
See http://www.trossenrobotics.com/dynamixel-ax-12-robot-actuator.aspx for more info and a data sheet.
These servos are controlled over a UART in half-duplex mode and allows multiple servos to be controlled via the same UART. You MUST make sure that each servo has been changed to have a unique ID number as described in the manual. Try to make sure that you label each servo with its current ID number as this will save heartaches in the future!
By default these servos communicate at 1 million baud. Yep 1 million. This works fine and you shouldn't need to change it. Note that if you feel you need to change it then you will need to make sure that all of the AX12 servos are using the same baud rate (coz they are on the same bus) and that your micro controller is using the same baud rate. Note: this is not for the faint hearted as its easy to mess up a servo - ie if you don't know what baud rate it has been set to then how can you send it messages to re-program it !
These devices are very impressive but they aren't cheap!! You can use them as a servo (you can even decide what the min/max swing is) or you can put them into continuous rotation mode so that they work like motors. You can even get information, per servo, regarding its current temperature, loading. voltage etc. No wonder they are the servo of choice to the biped market. All very cool!
The half duplex mode means that the transmit wire from your UART is connected to all of the AX-12 servos. Hence: when you send a command over the wire then all of the servos will hear it - but because the message contains the destination servo ID then only one servo, matching that ID number, will process it. If the message requires a response then it is sent back down the same wire from the servo back to your UART.
If there is more than one servo with the same ID then they will both try to send their response down the same wire and that is bad - very bad. At best the reply will be garbaged - at worst something may go bang.
The half-duplex mode means that a single wire is used to transmit data to the servo and is also used to listen for any response. In order to connect this to the UART on your board you will need some additional circuitry like this:
Note that you only need to make one of these circuits regardless of the number of servos you are controlling. The effect of the circuit is to use the 'Direction' I/O line to connect the 'Data' line to the 'Tx' pin of your UART, or to the the 'Rx' pin of your UART - but never to both.
The WebbotLib driver takes care of this for you by setting the direction pin correctly at all times.
Here is a bigger schematic of the circuit. Note that the unused gates in the chips are shown in the bottom right and their inputs are connected to something to stop them noisily flapping around.
I think its possible to replace the hex inverter (of which we only use one gate) with one of the unused gates from the other chip + one resistor. Need to play with that !
Here is a schematic of the back of each servo so you can see how they are attached to the bus,
One group of 3 pins is used to feed the signal from the UART into the servo and the other group of 3 pins is used to output the signals to the next servo. The groups seem to be interchangeable - ie both groups are inputs and outputs.
- dump - Dump the current status of a given servo.
- getActualIsMoving - Following a successful read() this will return TRUE if the servo is actually moving or FALSE if not.
- getActualLoad - Following a successful read() this will return the current load in the range -1023 to +1023.
- getActualRPM - Following a successful read() this will return the current rotational speed in RPM (revolutions per minute).
- getActualSpeed - Following a successful read() this will return the current position or speed of the servo.
- getActualTemperature - Following a successful read() this will return the temperature of the servo in celsius.
- getActualVolts - Following a successful read() this will return the voltage being supplied to the servo in 10ths of a volt.
- getID - Returns the servo ID number.
- ledOff - Turns off the LED on the servo.
- ledOn - Turns on the LED on the servo.
- read - Read the current settings from a servo.
- connect - Connect the actuator to the drive system.
- disconnect - Disconnect the actuator from the drive system. Once an actuator is disconnected it will stop responding to other commands until it is connected once again.
- getSpeed - Returns the value you specified in your previous call to setSpeed.
- isConnected - Test if an actuator is connected
- isInverted - Test if an actuator is inverted
- setConnected - Connect or disconnect the actuator from the drive system.
- setSpeed - Set the required speed to a value between DRIVE_SPEED_MIN and DRIVE_SPEED_MAX.