Communication protocol between PC and CM5


The communication is based on the need of controlling the servos position, speed and torque according to the  mathematical algorithms, in this case we need servos position, speed and load as inputs to the algorithms and the outputs will be new servos positions and torque.

To do this communication between the servos and the PC efficient and fast, is used the CM5 as intermediate.

The CM5 has a firmware that keeps running in loop refreshing the servos data, checking PC new incoming data to servos and retrieving the new servo data to be sent to PC, each cycle.

To do this, CM5 have three stages since it boots up.

1st The Servos search;

2nd The PC Handshake;

3rd The loop of work.

The Servo Search

The CM5 search for devices, sending a ping to each ID from 1 to 253 and waiting for the replay until timeout, being this the maximum time that  a servo could take to reply.

For each successful reply, it adds the ID to the devices table and increment by one the number of devices present on the line.

The PC Handshake

After the search, the CM5 build a packet containing the number of servos and the list of IDs of each one of them, and send this packet once every second to the PC until get a reply.

As reply the PC has to send back the return delay of the servos that theoretically is always 1, and the limits of the servos positions, to the CM5.

The loop of work

After the handshake, the CM5 start the loop of interface between the PC and the servos, being like this:

1 Retrieve data from servos;

2 Look for data from PC to update the data to servos;

3 Send data to servos;

4 Send data retrieved on step 1, to PC

Go back to 1 again.

Retrieving data from servos

To retrieve data from servos, the CM5 send a packet to the servo and wait until timeout from the replay. This packet is a request to read 8 memory bytes from de servo ram, containing these, the servo current position, speed, load, voltage and temperature.

This is done for each found servo ID from the IDs table, filled on the servos search.

Look for data from PC to update the data to servos

If any data from PC is arrived on the incoming buffer, then the CM5 will update the data of each servo to be sent to the servo on the next cycle, with this new data.

This data is the new servo Torque Enable, Led, CW Compliance Margin, CCW Compliance Margin, CW Compliance Slope, CCW Compliance Slope, Goal Position, Moving Speed, Torque Limit, Lock and Punch values, for each servo.

Send data to servos

The values of Torque Enable, Led, CW Compliance Margin, CCW Compliance Margin, CW Compliance Slope, CCW Compliance Slope, Goal Position, Moving Speed, Torque Limit, Lock and Punch are sent using SYNC_WRITE to each servo, having these being updated or not.

Send data retrieved on step 1, to PC

CM5 build a packet to send to PC, containing Present Position, Present Speed, Present Load, Voltage and Temperature of each servo.

CM5 Firmware FLUX

Data Flux on Time between   CM5   PC and   Servos

The Packet format from PC to CM5 or CM5 to PC is

Len = number of Parameters

Checksum = Lower byte of ( LOGICAL_NOT(LenH + LenL + Param1 + Param2 + … + ParamN) )

All the information about the Servos can be found at AX-12(english).

3 Responses to “Communication protocol between PC and CM5”

  1. Roboard code examples to interface CM5 Firmware and IMU « Actuatedcharacter's Blog Says:

    […] A detailed explanation to the structure of the CM5 code and the data flux between the servos and the roboard, can be found on the previouse post  Communication protocol between PC and CM5. […]

  2. @hugobiwan Says:

    Hello from France !
    I am launching a real/virtual robot project and i simply need to speak to the CM5 with an arduino in the program mode, like the robot terminal.
    I have made a simple mini-jack from the arduino to CM5 trying to serial.print at 57600 the “\n” and “play n” strings in order to launch the animations.
    I know this is nothing compared to your work, but your help would be very much appreciated as i don’t understand why my arduino code does’nt work. The blog of the project is here (in french) :

    And my mail is here : hugobiwan.zolnir[at] – twitter @hugobiwan

  3. Brock Says:

    I am not sure where you’re getting your info, however great topic. I must spend a while studying much more or working out more. Thank you for wonderful info I used to be in search of this information for my mission.

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 )

Connecting to %s

%d bloggers like this: