Dynamixel XL-320

From Hackerspace Adelaide
Jump to: navigation, search

Pix bought a set of Dynamixel XL-320 servos and found that there wasn't a nice Arduino library for them.

The library can be found here: Dynamixel XL320 Arduino library

Wiring diagram: XL320-wiring.png

Image: XL320-arduino-library.jpg

Half Duplex[edit]

At first I thought that the serial line worked like the NeoPixel chips (input on one side, output on the other). But instead it is half-duplex, where all of the devices are connected to the serial line in a multi-drop arrangement, with non-transmitting devices in high-impedance mode. This normally requires extra hardware. I'm experimenting to see if this can be done purely done in software on an Arduino with a modified version of the SoftwareSerial library.


After some hints from Damien about the plausibility, I started looking in to doing half-duplex by toggling the TXEN0 and RXEN0 bits. The library as it stands is here: HalfDuplexHardwareSerial and I have used it to get some preliminary responses from a servo.

Early data[edit]

It turns out that HelloSpoon doesn't have packet reception implemented, so I'm working on that. But at the moment I have managed to read some "Status" messages, which are returned by default after any command.

Here is a packet returned after calling setJointSpeed(1,1024);

Data Description
F5,FD junk
FF,FF,FD,0 header
1, id
4,0 length (4 bytes remaining)
55 status return instruction
80 error (alert set but no error)
A2,8F checksum (which checks out with update_checksum(..) in dxl_pro.cpp!)

Three servo robotic laser tentacles[edit]

A work in progress Arduino example of three long carbon fibre tentacles with lasers in the tips for an exhibit at Ancient World. Each tentacle has three XL-320 servos, two in the shoulder joint, and one in the elbow joint.

Robotic laser tentacles Arduino sketch on github

On Raspberry Pi[edit]

Did some research and there is a UART on the Pi (not sure if it can handle 1Mbit serial though). But, it is only 3.3v. For sending only that would normally work fine (TTL high is about 2.7v), but since by default the servos try communicating back down the data line at 5v, it would be unwise to do without a level converter.

Can a 3.3v-5v level converter work with the half duplex setup? Definitely yes if you did it before the buffer circuit linked below. But that's quite a bit of extra gubbins.


The XL-320 uses Version 2.0 of the Dynamixel communication protocol (see also wayback archive).

The product page lists the valid addresses that can be written and read from the XL-320.

This other product page is not very useful apart from a wiring diagram and an example circuit showing how to turn full-duplex serial in to half-duplex using a tri-state buffer and an extra direction pin.