Instruction/Status Packet

1.       Basic Structure of Instruction Packet

Header

Reserved

Packet ID

Packet Length

Instruction

Parameter

16bit CRC

0xFF

0xFF

0xFD

0x00

ID

LEN_L

LEN_H

Instruction

Parameter1

ParameterN

CRC_L

CRC_H

 

1) Instruction Packet is the command data that the Main Controller sends to the Device.

2) Header : This is the field that indicates the start of the Packet

3) Reserved : 0x00 (0xFD cannot be used)

4) Packet ID : This is the field that indicates the ID of the Device that should receive the Instruction Packet and process it

① Range : 0 ~ 252 (0x00 ~ 0xFC), which is a total of 253 numbers that can be used

② Broadcast ID : 254 (0xFE), which makes all connected devices execute the Instruction Packet

③ 253(0xFD), 255(0xFF) : These are not used in order to avoid duplicate use with Header

5) Packet Length : The length after the Packet Length field (Instruction, Parameter, CRC fields), hence number of Parameters + 3

6) Instruction : This is the field that defines the purpose of Packet

Value

Instruction

Description

0x01

Ping

Instruction that checks whether the Packet has arrived to a device with the same ID as Packet ID

0x02

Read

Instruction to read data from the Device

0x03

Write

Instruction to write data on the Device

0x04

Reg Write

Instruction that registers the Instruction Packet to a standby status; Packet is later executed through the Action command

0x05

Action

Instruction that executes the Packet that was registered beforehand using Reg Write

0x06

Factory Reset

Instruction that resets the Control Table to its initial factory default settings

0x08

Reboot

Instruction to reboot the Device

0x55

Status(Return)

Return Instruction for the Instruction Packet

0x82

Sync Read

For multiple devices, Instruction to read data from the same Address with the same length at once

0x83

Sync Write

For multiple devices, Instruction to write data on the same Address with the same length at once

0x92

Bulk Read

For multiple devices, Instruction to read data from different Addresses with different lengths at once

0x93

Bulk Write

For multiple devices, Instruction to write data on different Addresses with different lengths at once

 

7) Parameter

① As the auxiliary data field for Instruction, its purpose is different for each Instruction.

② Method of expressing negative number data : This is different for each product, so please refer to the e-manual of the corresponding product

8) 16bit CRC : This is the field that checks if the Packet has been damaged during communication

① Refer to the link before for the function to calculate CRC

http://support.robotis.com/en/product/actuator/dynamixel_pro/communication/crc.htm

② Example of calculating CRC

  • unsigned short update_crc(unsigned short crc_accum, unsigned char *data_blk_ptr, unsigned short data_blk_size);
  • Return Value : 16bit CRC Value
  • Argument

- crc_accum : set as ‘0’

- data_blk_ptr : Packet array pointer

- data_blk_size : number of bytes in the Packet excluding the CRC

  data_blk_size = Header(3) + Reserved(1) + Packet ID(1) + Packet Length(2) + Packet Length – CRC(2)

                            = 3+1+1+2+Pakcet Length-2 = 5 + Packet Length;

  Packet Length = (LEN_H << 8 ) + LEN_L;  //Little-endian

  • Packet Analysis and CRC Calculation

- Example for sent Packet : unsigned char TxPacket[] = { 0xFF, 0xFF, 0xFD, 0x00, 0x01, 0x07, 0x00, 0x02, 0x00, 0x00, 0x02, 0x00, CRC_L, CRC_H }

Header

Reserved

Packet ID

Packet Length

Instruction

Param1

Param2

Param3

Param4

16bit CRC

Read

Start Address

Data Length

0xFF

0xFF

0xFD

0x00

0x01

0x07

0x00

0x02

0x00

0x00

0x02

0x00

CRC_L

CRC_H

- Read Instruction Packet to Read the Data Length(2byte) from the Start Address(0x0000) of the Device

- CRC calculation :

  CRC = update_crc ( 0, TxPacket , 12 ) ;               // 12 = 5 + Packet Length(7)

  CRC_L = (CRC & 0x00FF);                //Little-endian

  CRC_H = (CRC>>8) & 0x00FF;

 

 

2. Basic Structure of Status Packet (Return Packet)

Header

Reserved

Packet ID

Packet Length

Instruction

Error

Parameter

16bit CRC

0xFF

0xFF

0xFD

0x00

ID

LEN_L

LEN_H

0x55

ERROR

Param1

ParamN

CRC_L

CRC_H

1) Basic composition (Header, Reserved, Packet ID, Packet Length, 16bit CRC) : Same as Instruction Packet

2) Instruction : Instruction of the Status Packet is fixed as 0x55 (Status)

3) Error : This is the field that indicates the processing result of Instruction Packet

Bit 7

Bit 6

Bit 5

Bit 4

Bit 3

Bit 2

Bit 1

Bit 0

Alert

Error Number

 ① Alert : When there has been a problem in the Device, this field is set as 1. Checking the Hardware error status value of the Control Table can indicate the cause of the problem.

 ② Error Number : When there has been an Error in the processing of the Instruction Packet

Value

Error

Description

0x01

Result Fail

- When it has failed to process the sent Instruction Packet

0x02

Instruction Error

- When an undefined Instruction has been used
- When Action has been used without Reg Write

0x03

CRC Error

- When the CRC of the sent Packet does not match

0x04

Data Range Error

- When the Data to be written in the corresponding Address is outside the range of the minimum/maximum value

0x05

Data Length Error

- When you attempt to write Data that is shorter than the data length of the corresponding Address

(ex: when you attempt to only use 2 bytes of a item that has been defined as 4 bytes)

0x06

Data Limit Error

- When the Data to be written in the corresponding Address is outside of the Limit value

0x07

Access Error

- When you attempt to write a value in an Address that is Read Only or has not been defined

- When you attempt to read a value in an Address that is Write Only or has not been defined

- When you attempt to write a value in the ROM domain while in a state of Torque Enable(ROM Lock)

 

4) Parameter

① As the auxiliary data field for Instruction, its purpose is different for each Instruction.

② Method of expressing negative number data : This is different for each product, so please refer to the e-manual of the corresponding product

3. Processing of Packet Before / After Transmission (Addition of byte stuffing in order to prevent appearance of Header patterns)

1) Processing Order of Transmission

① Generate basic form of Packet and afterwards Byte Stuffing(0xFD)

- Inspection range : Everything within the Instruction field to the Parameter field (not the CRC)

- Processing method : When the pattern “0xFF 0xFF 0xFD” appears, add Byte Stuffing (0xFD)

(If “0xFF 0xFF 0xFD” already exists, add a 0xFD to change it to “0xFF 0xFF 0xFD 0xFD”)

② Packet Length : Modify to Packet Length with Byte Stuffing applied

③ CRC : Calculate CRC with Byte Stuffing applied

2) Processing Order of Reception

① Search for Header(0xFF 0xFF 0xFD) : Ignore the Byte Stuffing(“0xFF 0xFF 0xFD 0xFD”).

② Packet ID : If Packet ID is valid, receive additional transmission the size of Packet Length

③ CRC : Calculate with the received Packet with Byte Stuffing included, and once CRC is matched then remove Byte Stuffing

 

Types of Instructions

1. Ping Instruction (0x01)

1) Description

① Instruction to check the existence of a Device and basic information

② Regardless of the Status Return Level of the Device, the Status Packet is always sent to Ping Instruction.

③ When the Packet ID field is 0xFE(Broadcast ID) : All devices send their Status Packet according to their arranged order.

2) Instruction Packet Parameter : None

3) Status Packet Parameter

Section

Description

Parameter 1

 Model Number LSB

Parameter 2

Model Number MSB

Parameter 3

Version of Firmware

 

4) Example

① Conditions

    - ID1(XM430-W210) : For Model Number 1030(0x0406), Version of Firmware 38(0x26)

    - ID2(XM430-W210) : For Model Number 1030(0x0406), Version of Firmware 38(0x26)

② Packet Example Case 1 : Packet ID 1

Ping Instruction Packet

Header

Reserved

Packet ID

Packet Length

Instruction

16bit CRC

0xFF

0xFF

0xFD

0x00

0x01

0x03

0x00

0x01

0x19

0x4E

 

ID1 Status Packet

Header

Reserved

Packet ID

Packet Length

Instruction

Error

Param1

Param2

Param3

16bit CRC

Model Number

FW Ver.

0xFF

0xFF

0xFD

0x00

0x01

0x07

0x00

0x55

0x00

0x06

0x04

0x26

0x65

0x5D

 

 

③ Packet Example Case 2 : Packet ID 254(Broadcast ID)

Ping Instruction Packet

Header

Reserved

Packet ID

Packet Length

Instruction

16bit CRC

0xFF

0xFF

0xFD

0x00

0xFE

0x03

0x00

0xFE

0x31

0x42

 

ID1 Status Packet

Header

Reserved

Packet ID

Packet Length

Instruction

Error

Param1

Param2

Param3

16bit CRC

Model Number

FW Ver.

0xFF

0xFF

0xFD

0x00

0x01

0x07

0x00

0x55

0x00

0x06

0x04

0x26

0x65

0x5D

 

ID2 Status Packet

Header

Reserved

Packet ID

Packet Length

Instruction

Error

Param1

Param2

Param3

16bit CRC

Model Number

FW Ver.

0xFF

0xFF

0xFD

0x00

0x02

0x07

0x00

0x55

0x00

0x06

0x04

0x26

0x6F

0x6D

 

2. Read Instruction (0x02)

1) Description

① Instruction to read a value from Control Table

② Method of expressing negative number data : This is different for each product, so please refer to the e-manual of the corresponding product

2) Instruction Packet Parameter

Section

Description

Parameter 1

 Low-order byte from the starting address

Parameter 2

High-order byte from the starting address

Parameter 3

Low-order byte from the data length (X)

Parameter 4

High-order byte from the data length (X)

 

3) Status Packet Parameter

Section

Description

Parameter 1

First byte

Parameter 2

Second byte

Parameter X

Byte number X

 

4) Example

① Condition : When the Present Position(132, 0x0084, 4[byte]) of ID1(XM430-W210) is 166(0x000000A6)

② Packet Example

Read Instruction Packet

Header

Reserved

Packet ID

Packet Length

Instruction

Param1

Param2

Param3

Param4

16bit CRC

Address

Data Length

0xFF

0xFF

0xFD

0x00

0x01

0x07

0x00

0x02

0x84

0x00

0x04

0x00

0x1D

0x15

 

ID1 Status Packet

Header

Reserved

Packet ID

Packet Length

Instruction

Error

Param1

Param2

Param3 Param4

16bit CRC

Data

0xFF

0xFF

0xFD

0x00

0x01

0x08

0x00

0x55

0x00

0xA6

0x00

0x00

0x00

0x8C

0xC0

 

3. Write Instruction (0x03)

1) Description

① Instruction to write a value on the Control Table

② Method of expressing negative number data : This is different for each product, so please refer to the e-manual of the corresponding product

2) Instruction Packet Parameter

Section

Description

Parameter 1

Low-order byte from the starting address

Parameter 2

High-order byte from the starting address

Parameter 2 +1

First byte

Parameter 2 +2

Second byte

Parameter 2 +X

Byte number X

3) Status Packet Parameter : None

 

4) Example

① Condition : When trying to change the Goal Position(116, 0x0074, 4[byte]) of ID1(XM430-W210) to 512(0x00000200)

② Packet Example

Write Instruction Packet

Header

Reserved

Packet ID

Packet Length

Instruction

Param1

Param2

Param3

Param4

Param5

Param6

16bit CRC

Address

Data

0xFF

0xFF

0xFD

0x00

0x01

0x09

0x00

0x03

0x74

0x00

0x00

0x02

0x00

0x00

0xCA

0x89

 

ID1 Status Packet

Header

Reserved

Packet ID

Packet Length

Instruction

Error

16bit CRC

0xFF

0xFF

0xFD

0x00

0x01

0x04

0x00

0x55

0x00

0xA1

0x0C

 

4. Reg Write Instruction (0x04)

1) Description

① Instruction that is similar to Write Instruction, but has an improved synchronization characteristic

② Write Instruction is executed immediately when an Instruction Packet is received.

③ Reg Write Instruction registers the Instruction Packet to a standby status, and sets Control table Registered Instruction to ‘1’.

④ When an Action Instruction is received, the registered Packet is executed, and sets Control Table Registered Instruction to ‘0’.

2) Instruction Packet Parameter(Same as Write Instruction)

Section

Description

Parameter 1

Low-order byte from the starting address

Parameter 2

High-order byte from the starting address

Parameter 2 +1

First byte

Parameter 2 +2

Byte number X

Second byte

Parameter 2+X

Byte number X

 

3) Status Packet Parameter : None

4) Example

① Condition : When trying to change the Goal Velocity(104, 0x0068, 4[byte]) of ID1(XM430-W210) to 200(0x000000C8)

② Packet Example

Reg Write  Instruction Packet

Header

Reserved

Packet ID

Packet Length

Instruction

Param1

Param2

Param3

Param4

Param5

Param6

16bit CRC

Address

Data

0xFF

0xFF

0xFD

0x00

0x01

0x09

0x00

0x04

0x68

0x00

0xC8

0x00

0x00

0x00

0xAE

0x8E

 

ID1 Status Packet

Header

Reserved

Packet ID

Packet Length

Instruction

Error

16bit CRC

0xFF

0xFF

0xFD

0x00

0x01

0x04

0x00

0x55

0x00

0xA1

0x0C

 

5. Action Instruction (0x05)

1) Description

① Instruction that executes the Packet that has been registered using Reg Write Instruction

② When controlling multiple devices using Write Instruction, there will be a difference in the time of execution between the first device that receives the Packet and the last device that receives the Packet.

③ By using Reg Write and Action Instruction, one can operate multiple devices simultaneously.

2) Instruction Packet Parameter : None

3) Status Packet Parameter :

4) Example

① Condition : ID1(XM430-W210), When an Instruction has been registered using Reg Write Instruction

② Packet Example

Action Instruction Packet

Header

Reserved

Packet ID

Packet Length

Instruction

16bit CRC

0xFF

0xFF

0xFD

0x00

0x01

0x03

0x00

0x05

0x02

0xCE

 

ID1 Status Packet

Header

Reserved

Packet ID

Packet Length

Instruction

Error

16bit CRC

0xFF

0xFF

0xFD

0x00

0x01

0x04

0x00

0x55

0x00

0xA1

0xC0

 

6. Factory Reset Instruction (0x06)

1) Description

① Instruction that resets the Control Table to its initial factory default settings

2) Instruction Packet Parameter

Section

Description

Parameter 1

0xFF : Reset all values

             -  0x01 : Reset all values except ID

             - 0x02 : Reset all values except ID and Baudrate

3) Status Packet Parameter None

4) Example

① Condition : ID1(XM430-W210), Option 0x01(Reset all values except ID)

② Packet Example

Factory Reset Instruction Packet

Header

Reserved

Packet ID

Packet Length

Instruction

Param1

16bit CRC

0xFF

0xFF

0xFD

0x00

0x01

0x04

0x00

0x06

0x01

0xA1

0xE6

 

ID1 Status Packet

Header

Reserved

Packet ID

Packet Length

Instruction

Error

16bit CRC

0xFF

0xFF

0xFD

0x00

0x01

0x04

0x00

0x55

0x00

0xA1

0x0C

 

7. Reboot Instruction (0x08)

1) Description

Instruction to reboot the device2) Instruction Packet Parameter : None

3) Status Packet Parameter : None

4) Example

① Condition : When rebooting ID1(XM430-W210)

② Packet Example

Reboot Instruction Packet

Header

Reserved

Packet ID

Packet Length

Instruction

16bit CRC

0xFF

0xFF

0xFD

0x00

0x01

0x03

0x00

0x08

0x2F

0x4E

 

ID1 Status Packet

Header

Reserved

Packet ID

Packet Length

Instruction

Error

16bit CRC

0xFF

0xFF

0xFD

0x00

0x01

0x04

0x00

0x55

0x00

0xA1

0x0C

 

8. Sync Read Instruction (0x82)

1) Description

① Instruction to read data from multiple devices simultaneously using one Instruction Packet

② The Address and Data Length of the data must all be the same.

③ If the Address of the data is not continual, an Indirect Address can be used.

④ Packet ID field : 0xFE (Broadcast ID)

2) Instruction Packet Parameter

Section

Description

Parameter 1

Low-order byte from the starting address

Parameter 2

High-order byte from the starting address

Parameter 3

Low-order byte from the data length (X)

Parameter 4

High-order byte from the data length (X)

Parameter 4+1

ID of first Device

Parameter 4+2

ID of second Device

Parameter 4+M

ID of Device number M

 

3) Status Packet Parameter(Parameter for each Device)

Section

Description

Parameter 1

First byte

Parameter 2

Second byte

Parameter X

Byte number X

 

4) Example

① Condition

- ID1(XM430-W210) : When Present Position(132, 0x0084, 4[byte]) is 166(0x000000A6)

- ID2(XM430-W210) : When Present Position(132, 0x0084, 4[byte]) is 2,079(0x0000081F)

② Packet Example

Sync Read Instruction Packet

Header

Reserved

Packet ID

Packet Length

Instruction

Param1

Param2

Param3

Param4

Param5

Param6

16bit CRC

Address

Data Length

IDS

0xFF

0xFF

0xFD

0x00

0xFE

0x09

0x00

0x82

0x84

0x00

0x04

0x00

0x01

0x02

0xCE

0xFA

 

ID1 Status Packet

Header

Reserved

ID

Packet Length

Instruction

Error

Param1

Param2

Param3

Param4

16bit CRC

Data

0xFF

0xFF

0xFD

0x00

0x01

0x08

0x00

0x55

0x00

0xA6

0x00

0x00

0x00

0x8C

0xC0

 

ID2 Status Packet

Header

Reserved

Packet ID

Packet Length

Instruction

Error

Param1

Param2

Param3

Param4

16bit CRC

Data

0xFF

0xFF

0xFD

0x00

0x02

0x08

0x00

0x55

0x00

0x1F

0x08

0x00

0x00

0xBA

0xBE

 

9. Sync Write Instruction (0x83)

1) Description

① Instruction to control multiple devices simultaneously using one Instruction Packet

② The Address and Data Length of the data must all be the same.

③ If the Address of the data is not continual, an Indirect Address can be used.

④ Packet ID field : 0xFE (Broadcast ID)

2) Instruction Packet Parameter

Section

Description

Parameter 1

Low-order byte from the starting address

Parameter 2

High-order byte from the starting address

Parameter 3

Low-order byte from the data length (X)

Parameter 4

High-order byte from the data length (X)

Parameter 5

First Device

ID

Parameter 5+1

First byte

Parameter 5+2

Second byte

Parameter 5+X

Byte number X

Parameter 6+X

Second Device

ID

Parameter 6+X+1

First byte

Parameter 6+X+2

Second byte

Parameter 6+2X

Byte number X

 

3) Status Packet Parameter : Does not send Status Packet

4) Example

① Condition

- ID1(XM430-W210) : When trying to change Goal Position(116, 0x0074, 4[byte]) to 150(0x00000096)

- ID2(XM430-W210) : When trying to change Goal Position(116, 0x0074, 4[byte]) to 170(0x000000AA)

② Packet Example

Sync Write Instruction Packet

Header

Reserved

Packet ID

Packet Length

Instruction

Param1

Param2

Param3

Param4

Address

Data Length

0xFF

0xFF

0xFD

0x00

0xFE

0x11

0x00

0x83

0x74

0x00

0x04

0x00

 

Sync Write Instruction Packet

Param5

Param6

Param7

Param8

Param9

1st ID

1st ID Data

0x01

0x96

0x00

0x00

0x00

 

Sync Write Instruction Packet

Param10

Param11

Param12

Param13

Param14

16bit CRC

2nd ID

2nd ID Data

0x02

0xAA

0x00

0x00

0x82

0x87

 

10. Bulk Read Instruction (0x92)

1) Description

① Similar to Sync Read, this is an Instruction to read data from multiple devices simultaneously using one Instruction Packet

② This Instruction can be used even if the Address and Data Length of the data for each device are not all the same.

③ The same ID cannot be used multiple times in the Parameter. In other words, it can only read once from each individual device.

④ If the Address of the data is not continual, an Indirect Address can be used.

⑤ Packet ID field : 0xFE (Broadcast ID)

2) Instruction Packet Parameter

Section

Description

Parameter 1

First Device

ID

Parameter 2

Low-order byte from the starting address

Parameter 3

High-order byte from the starting address

Parameter 4

Low-order byte from the data length (X)

Parameter 5

High-order byte from the data length (X)

Parameter 6

Second Device

ID

Parameter 7

Low-order byte from the starting address

Parameter 8

High-order byte from the starting address

Parameter 9

Low-order byte from the data length (Y)

Parameter 10

High-order byte from the data length (Y)

 

3) Status Packet Parameter(Parameter for each Device)

Section

Description

Parameter 1

First byte

Parameter 2

Second byte

Parameter X

Byte number X

4) Example

① Condition

- ID1(XM430-W210) : When Present Voltage(144, 0x0090, 2[byte]) is 119(0x0077)

- ID2(XM430-W210) : When Present Temperature(146, 0x0092, 1[byte]) is 36(0x24)

② Packet Example

Bulk Read Instruction Packet

Header

Reserved

Packet ID

Packet Length

Instruction

Param1

Param2

Param3

Param4

Param5

1st ID

1st ID Address

1st ID Data Length

0xFF

0xFF

0xFD

0x00

0xFE

0x0D

0x00

0x92

0x01

0x90

0x00

0x02

0x00

 

Bulk Read Instruction Packet

Param6

Param7

Param8

Param9

Param10

16bit CRC

2nd ID

2nd ID Address

2nd ID Data Lenth

0x02

0x92

0x00

0x01

0x00

0x1A

0x05

 

ID1 Status Packet

Header

Reserved

Packet ID

Packet Length

Instruction

Error

Param1

Param2

16bit CRC

Data

0xFF

0xFF

0xFD

0x00

0x01

0x06

0x00

0x55

0x00

0x77

0x00

0xC3

0x69

 

ID2 Status Packet

Header

Reserved

Packet ID

Packet Length

Instruction

Error

Param1

16bit CRC

Data

0xFF

0xFF

0xFD

0x00

0x02

0x05

0x00

0x55

0x00

0x24

0x8B

0xA9

 

11. Bulk Write Instruction (0x93)

1) Description

① Similar to Sync Write, this is an Instruction to control multiple devices simultaneously using one Instruction Packet

② This Instruction can be used even if the Address and Data Length of the data for each device are not all the same.

③ The same ID cannot be used multiple times in the Parameter. In other words, it can only write once for each individual device.

④ If the Address of the data is not continual, an Indirect Address can be used.

⑤ Packet ID field : 0xFE (Broadcast ID)

2) Instruction Packet Parameter

Section

Description

Parameter 1

First Device

ID

Parameter 2

Low-order byte from the starting address

Parameter 3

High-order byte from the starting address

Parameter 4

Low-order byte from the data length (X)

Parameter 5

High-order byte from the data length (X)

Parameter 5+1

First byte

Parameter 5+2

Second byte

Parameter 5+X

Byte number X

Parameter 6+X

Second Device

ID

Parameter 7+X

Low-order byte from the starting address

Parameter 8+1

High-order byte from the starting address

Parameter 9+2

Low-order byte from the data length (Y)

Parameter 10+X

High-order byte from the data length (Y)

Parameter 10+X+1

First byte

Parameter 10+Y+1

Byte number Y

 

3) Status Packet Parameter : Does not send Status Packet

4) Example

① Condition

- ID1(XM430-W210) : When trying to change Max Voltage Limit(32, 0x0020, 2[byte]) to 160(0x00A0)

- ID2(XM430-W210) : When using Temperature Limit(31, 0x001F, 1[byte]) as 80(0x50)

② Packet Example

 

Bulk Write Instruction Packet

Header

Reserved

Packet ID

Packet Length

Instruction

0xFF

0xFF

0xFD

0x00

0xFE

0x12

0x00

0x93

 

Bulk Write Instruction Packet

Param1

Param2

Param3

Param4

Param5

Param6

Param7

1st ID

1st ID Address

1st ID Data Lenth

1st ID Data

0x01

0x20

0x00

0x02

0x00

0xA0

0x00

 

Bulk Write Instruction Packet

Param8

Param9

Param10

Param11

Param12

Param13

16bit CRC

2nd ID

2nd ID Address

2nd ID Data Lenth

2nd ID Data

0x02

0x1F

0x00

0x01

0x00

0x50

0xB7

0x68