Custom AX12 Servo Firmware


As we need to improve not just the communication speed by changing the communication protocol, but also to adapt the servo data format and the servo data inputs to our control type. We are developing our own AX12 servo firmware so that we can drive the closed loop control from the embedded linux at high speed. Here are a list of objectives:

1) maximize the control loop by having the servos send their position/speed/voltage continously without requiring the Master to request their data.
2) Servos deploy 2 control algorithms. Speed Control when moving between target position ; Position Control once reaching target position

Communication speed and protocol

The first version will have mapping of servos on bus per each servo, with this we can make the servos send the position and speed one after the other without needing to send a data request first.

This mapping is started by the Master ( CM5 or ROBOARD ) which sends an initial “stand up and be counted” packet. Every servo waits until he thinks it is his turn to communicate based on his own servo ID number.

Once they are counted, the master has a map of the servos on the bus and then servos send their data (position, speed, voltage) continuously. Each servo listens to the bus and knows after which servo they must send the data. This is the most efficient way of doing things and should result in the highest theoretical control loop speed at 1mbps baud (depending on number of servos and packet size per servo). The Master has the right to send command packets at the end of a servo-sending-loop.

All the servos do is wait for the previous lower ID servo to send something and he knows it is his turn. Once the last servo sends his packet, it is up to the Master to send a OK packet or to send DATA to one of the servos.

Data format and the servo data inputs

The data packet is similar to robotis packets because we do need a checksum since we have encountered odd noise on the bus. Data to be sent to a servo from the Master:

Postion –  Position from 1 to 0x3FE that represents zero to 300 degrees

Speed   –   The speed is set on 10% steps, meaning from 0 to 100% of the maximum speed we have 10 steps as it is not really possible to control the AX12 speed at higher resolution.

Spring  –  A spring effect is emulated at the target position when external torque is applied to the shaft of the servo. Once the servo reaches target position, it switches from speed control to position control. In position control mode, the further the angle is from the target position, the more power the servo applies to correct the offset. This is a linear increase from 0 to FF representing the deviation angle at which point the Maximum power will be applied. At target position, zero power is applied.

Maximum Power – This maximum power limit goes from 0 to 100% of the total power available from the battery. this value applies for both Speed Control and Position Control modes.

Control example

On this demo we have a cycle that set a goal position of 1022 at a speed of 100% and when reach the position set the next Goal point as 1 at a speed of 10%. Always 100%  maximum power. (Servo has a demo code inside no external control being made)

Source Code


7 Responses to “Custom AX12 Servo Firmware”

  1. Mohit Jindal Says:

    Any tried to control Bioloid from Pc using Usb2Dynamixel ?
    Please share the Visual C++ code with me.

    • robomarinheiro Says:

      Hi Mohit

      I’m very near to release our custom made AX12 Firmware code and respective project as well, and in addition I’ve made a very simple GUI in C# to interface it and also the project.
      So if you want to interface Bioloid AX12 with the GUI, just open the project and change the servos memory addresses, the packets contents and the CRC calculation, and i think you will do it easily, but i’ve never tried. With this new firmware you will be able to control position with PID, 10 different speeds with PID, Limits, direct PWM broadcast access and broadcast position request with chain reply etc.

  2. Jindong Says:

    hi, it looks very great. How did you manage to download your firmware to the motor? Do you have the code for MX-106 firmware?

  3. Mohit Says:

    I want to attach a new motor controller board with the AX12+ Atmega 8A. But with same firmware.
    Can you tell me which pins go where ?
    Below are the 7 pins of new motor driver board:-

    1 GND Ground
    2 IN-1 Logic input for the motor direction.
    3 Diagnostic 1
    Output pin with logic 1 output in normal operation. Represents side of the internal
    H bridge corresponding to IN-1. Pin is pulled to logic low by the motor driver in
    case of over temperature or overload due to short circuit.
    4 PWM Used to apply Pulse Width Modulation to control motor velocity
    5 Diagnostic 2
    Output pin with logic 1 output in normal operation. Represents side of the internal
    H bridge corresponding to IN-2. Pin is pulled to logic low by the motor driver in
    case of over temperature or overload due to short circuit.
    6 IN-2 Logic input for the motor direction.
    7 CS* Current Sense output to measure the current flowing through the driver

  4. Latoya Says:

    Greetings! I was curious to know if setting up a blogging site such your own: is hard
    to do for unskilled people? I’ve been wanting to set up my own website for a while now but have been turned off because I’ve always assumed it required
    tons of work. What do you think? Thanks alot 🙂

    • robomarinheiro Says:

      Hi there,
      All depends on what you wanna do.
      For publishing, its quite easy, either you use wordpress or a similar to publish info like magazine style or newspaper (what we have done here), or mount a publish type template one your own server.
      For sharing more stuff, links to a different variety of other things, you might need to have your own thing. Get a pre-built template pack or so, modify it (there are some user friendly tools) and get it running on an Apache server or so. My guess is, free DDNS and a small computer at home will do the trick. 🙂 Either that or rent a domain and space for a cheap fee.

      Hope it helped

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: