CANFD:
Introduction of CANFD Protocol Overview of communication protocol
Joint products employ the CANFD communication protocol, which is an ask-and-answer communication mode between the controller and module. The controller sends out a command package and the module returns a response package. A CAN bus network can connect multiple modules, and each module is assigned with an ID number. The control command sent from the controller contain ID information, and only the module matching the ID number will receive this command completely and return the response information.
All query, control, and parameter modification commands will be completed through read-write operations on a memory control table stored inside the module's main control chip. The basic storage unit of the memory control table is 2-byte signed integer.
All data longer than 1 byte will be transmitted and stored with the lower byte first. In protocol analysis, the memcpy function in c programming language can be used in combination to realize the conversion from byte data to integer data or from integer data to byte data.
The command types include the following:
Command | Function | Value | Data segment length |
---|---|---|---|
CMD_RD (read) | Query the data in the control table | 0x01 | 1 |
CMD_RD (write) | Write data into the control table | 0x02 | 2 |
Protocol format convention
Joints use the standard frame format of CANFD, where only data frames are used, and there is no response for remote frames. The data frame of the CANFD protocol is up to 64 bytes long, and the communication rate can reach 5M. The data length codes of the CANFD protocol are shown below.
CANFD data field | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
DLC | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
Data Bytes | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 16 | 20 | 24 | 32 | 48 | 64 |
Command package
The format of command package is as follows:
Arbitration field | Control field | Data field | CRC and other fields | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
STID/11 | R1 | IDE | FDF | R0 | BRS | ESI | DLC/4 | Data(64Byte) | CRC | ACK | EOF | IFS | ||||
ID | 0 | 0 | 1 | 0 | 1 | 0 | Length | CMD | INDEX | DATA | DATA | ...... |
Arbitration field: Only the target ID segment needs arbitration. The arbitration field ID is the module ID. The module ID is 0x00 - 0x1E (0 - 30), and the broadcasting ID is 0x00 (0). Typically, ID0 is for the interface board.
Control field: DLC length, i.e., the length of data field bytes, is up to 64 bytes. The data length table is as shown above; BRS stands for the variable rate, where 1 means variable, and 0 means not variable; ESI is temporarily set to 0, and the bus does not actively report errors.
Data field: The first byte of the data field represents the command type, the second byte represents the control table index, and the third to fourth bytes represent the data sent together with the command. The read command has one byte of data representing the number of memory table registers to be read; and the write command consists of two bytes of data, which are the contents to be written to the memory table, with the lower bits coming first.
Response package
The format of response package is as follows:
Arbitration field | Control field | Data field | CRC and other fields | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
STID/11 | R1 | IDE | FDF | R0 | BRS | ESI | DLC/4 | Data | CRC | ACK | EOF | IFS | ||||
ID+0x100 | 0 | 0 | 1 | 0 | 1 | 0 | Length | CMD | INDEX | DATA | DATA | ...... |
The format of response package is substantially the same as that of the command package, except the following differences:
- If the module receives a read command, the returned data segment is the data of the specified length.
- If the module receives a write command, the returned data segment is whether the operation was successful, with 0x01- standing for success, and 0x00- standing for failure.
- The ID of the response package is ID+0x100.
Remarks: When the issued CANFD control frame does not meet the protocol requirements, the actuator returns a CMD_ERR response package in the following format.
Arbitration field | Control field | Data field | CRC and other fields | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
STID/11 | R1 | IDE | FDF | R0 | BRS | ESI | DLC/4 | Data(2Byte) | CRC | ACK | EOF | IFS | |
ID+0x100 | 0 | 0 | 1 | 0 | 1 | 0 | 2 | CMD_ERR | ERR |
ERR represents the error type, with the error codes shown as follows:
Error bit | Definition | Description |
---|---|---|
0x01 | Format error | The control frame data does not meet the protocol format. |
0x02 | Authority error | The control frame has no operation authority. |