SDO (Service Data Object) is a type of message in the CANopen protocol used for reading and writing data over a CAN network.
SDO is used to transmit data that is not time-sensitive, such as configuration information that only needs to be set once during initialization.
There are several types of SDO transmissions:
-
SDO Download
-
Normal SDO Download
-
Expedited SDO Download
-
SDO Upload
-
Normal SDO Upload
-
Expedited SDO Upload
The difference between normal transmission (segment transmission) and expedited transmission is that expedited transmission can handle a maximum of 4 bytes. If the data exceeds 4 bytes, normal transmission must be used.
Normal transmission is less common and is mainly used for program upgrades, string transmissions, etc. Expedited transmission is used more frequently, and this section will focus on expedited transmission.
Expedited transmission is achieved by sending data in a single CAN message. SDO messages are data frames, and the data size is always 8 bytes. The message format is as follows:
All SDO messages mentioned below belong to expedited transmission.
Sent SDO messages: Client sends to server.
Response SDO messages: Server sends to client.
COB-ID:
The sender’s ID is 0x600 + Node-ID, and the destination’s response ID is 0x580 + Node-ID.
For example, if device 1 sends a message to device 5:
The request message sent by device 1 has an ID of 0x605;
When device 5 responds, its ID is 0x581.
When reading data (SDO Upload), the command byte:
-
The command byte of the sent SDO message is 0x40, and the data area is defaulted to 0;
-
The command byte of the response SDO message depends on the number of data bytes:
-
If it is 1 byte, the command byte is 0x4F.
-
If it is 2 bytes, the command byte is 0x4B.
-
If it is 3 bytes, the command byte is 0x47.
-
If it is 4 bytes, the command byte is 0x43.
-
If the responder cannot correctly reply to the message, the command byte is 0x80, and the data area contains the error code.
For example, if station 2 wants to read data from station 6 (Object Index: 0x2010, Sub-index: 0x2, Data Value: 0x12345678):
Message sent by station 2:
Response message from station 6:
Command byte for writing data (SDO Download):
-
The command byte of the sent SDO message depends on the number of data bytes:
-
If it is 1 byte, the command byte is 0x2F.
-
If it is 2 bytes, the command byte is 0x2B.
-
If it is 3 bytes, the command byte is 0x27.
-
If it is 4 bytes, the command byte is 0x23.
-
If the responder correctly receives the data, the command byte of the response message is 0x60; if there is an error, the command byte is 0x80, and the data area contains the error code.
For example, if station 2 wants to write data to station 6 (Object Index: 0x2030, Sub-index: 0x12, Data to be written: 0x11223344):
Message sent by station 2:
Response message from station 6: