Simple startup of Dynamixel AX12/18 - for Windows (from scratch)

Some words

There are several libraries and applications available for controlling Dynamixel servos. Since the Dynamixel RS232 based communication protocol is so simple, and one of the objectives in INF4500 is to go a little bit behind the "curtain" to see how things are working at a lower level, we will program everything from scratch based on simple code examples provided at the bottom of this page.

What you need

  • Servo(s)
  • Power 12V (be sure to use a power with a connector with minus as the shield)
  • The "USB to Dynamixel 3-wire bus communication dongle" (in the picture with an arrow at)
  • The "Dynamixel 3-wire bus power supply card" (in the picture)
  • Some Dynamixel 3-wire bus wires (in the picture)
  • Software on PC able to talk with the serial/COM port (Java based "Processing" is used in this tutorial)

Basic communication principle / operation

All behaviour of the servo is controlled by:

  • Writing values directly to the internal servo registers
    • Behaviour can be executed immediately
    • Behaviour can be saved and executed later with an "action" command
  • Sending a single instruction to the servo. This give you access to:
    • Reset, Ping and the "action" command

To get information back from the servo:

  • The servo may automatically send back some info as a response to a behaviour modification action sent by you
  • You may get all kind of information from the servo by directly reading the values in the corresponding registers
Details of communication

The RS232 protocol is only dealing with the physical layer, and to run the Dynamixel system a frame/packet based protocol is added to include addressing, control signals, error checking and so on.

  • Instruction packet: A behaviour modification action is generated by sending an ASCII byte packet (instruction packet) out on the Dynamixel bus. This can be addressed to a specific servo (ID) or broadcast to all servos. Content of the instruction packet byte for byte:
    • 0xFF (notifies the beginning of the packet)
    • 0xFF (notifies the beginning of the packet)
    • ID (the ID of the servo which will receive the instruction, ID = 254 means broadcast)
    • Length (the length of the packet. The length is calculated as "the number of parameters (N) + 2")
    • Instruction, types:
      • 0X03 Write-Data value to register in servo. Values in registers will cause action/behaviour in servo
      • 0X02 Read value from register in servo to get all kind of info from the servo
      • 0X01 Ping
      • 0X05 Action starts scheduled motion, if set up
      • 0X83 Synch_write to move all servos simultaneous
      • 0X06 Reset to factory / default values, if messed up
    • Parameter 0 (is used when Instruction requires ancillary data, byte no 0)
    • ...
    • Parameter N (is used when instruction requires ancillary data, byte no N)
    • Check sum = ~ ( ID + Length + Instruction + Parameter1 + ... Parameter N )
  • Status packet: If the instruction packet you sent generates a response back to you, you will get an ASCII byte packet (status packet) back. Format - byte for byte:
    • 0xFF (notifies the beginning of the packet)
    • 0xFF (notifies the beginning of the packet)
    • Length (the length of the packet. The length is calculated as "the number of Parameters (N) + 2")
    • Error code
    • Parameter 0 (returns data except ERROR, byte no 0)
    • ...
    • Parameter N (returns data except ERROR, byte no N)
    • Check sum = ~ ( ID + Length + Instruction + Parameter1 + ... Parameter N )
"Hello World"
  1. Connect the "USB to Dynamixel 3-wire bus communication dongle" to your USB PC port and hope for the drivers to succeed installing
  2. Go to PC "Device Manager" - Ports(COM LPT), make sure that you have got a new USB serial Port COM X here, remember the number X
  3. Make sure the mode switch on the "Dynamixel 3-wire bus communication dongle" (arrow/picture) is set to the position closest to the USB cable
  4. Connect the 12V power cable to the "bus power supply card" - it will light up
  5. ID configuration: Daisy Chain (serial connect) the "Dynamixel 3-wire bus communication dongle" with the "bus power supply card" and the first of your servos (only one), make sure that the other servos are not connected. Configure the ID number of the servo to a unique number 1-253 (see example code at the bottom of this page). In Processing open COM X, you remember X from point no.2
  6. Test the system by switching on/off the LED on the servo (see example code at the bottom of this page)
  7. Do the same for all of your servos (only one at the time, chose unique ID)
  8. Daisy Chain (serial connect) the "Dynamixel 3-wire bus communication dongle" with the "bus power supply card" and all your servos with the 3-wire cables (see picture)
  9. Test the system by switching on/off the LED on the each of the servos
  10. Make some simple moves on each of the servos to aling up the wheel angles. Have fun
Tips / features
  1. Servos may be in either "joint mode" or "wheel mode" (free running), to change it se below
  2. Angle position in joint mode : 0 - 300deg, corresponding digital code : 0 - 1023 (digital resolution is 0.29 degree)
  3. Speed in joint mode, digital specification 0 - 1023 (0 - 114rpm)
  4. Do not assemble the servos to the robot before you have performed a test move on them. (Easy to mix up the wheel angles - the robot may try to "kill" itself / you may have to reassemble the whole robot)
  5. Breaking a move into small steps and broadcasting / SYNC WRITE these steps to all servos in packets with a short (ms) pause in between, will give you access to smooth arbitrary motion. Recommended baud rate is then 1MBit.
Some short Java methods (templates) you may use

A general Processing sketch with serial communication and event based status packet handling + some bareBone "instruction packet" examples. No libraries to include, no paths to set up, no dlls or executable to point at, just install Processing, open it, paste this code in to it, start programming, save, and press the play arrow.