gavinray
Member level 1
CANopen provides two communication modes: SDO (Service Data Object) and PDO (Process Data Object). SDO is typically used by the master station to read data from the slave or configure the PDO communication mode of the slave. After receiving the message, the slave station must acknowledge, as shown in the diagram below.
PDO operates in a producer-consumer model, where messages are sent without requiring a reply. One message can have multiple consumers. After the slave enters the operational mode, it sends PDO messages cyclically or upon event triggers based on the configured communication parameters. If the SYNC function is enabled, the PDO is sent after receiving a specified number of synchronization frames. The master station can also send PDO messages, as illustrated in the diagram below.
When powered on, the device will send two messages to the master station: one with frame ID 0x700 + Node_ID, data 00 (indicating the device is in initialization mode) and another with data 7F (indicating the device is in pre-operational mode), as shown in the diagram below.
At this point, the device is in pre-operational mode. In ECanTools, select the CANopen option, click to add slave with Node ID 2, choose the NMT (Network Management) Function option, and select "Start Remote Node", then click NMT, as shown in the diagram below.
At this point, the master station will send a message with frame ID 000, data 01 (for operational state) and 02 (for Node 2; 00 for broadcast), as shown below. The Node 2 IO device will start sending PDO frames with ID 182 and a data length of 2 bytes. These 2 bytes correspond to the 16 DI (Digital Input) channels, with each bit representing the input status (1 for active). Note that this feature is custom to Guangcheng and not part of the standard CIA301 protocol. The result is shown below.
Manually sending data with the CAN tool also produces the same effect, as shown below.
When sending manually, set the frame ID to 602 (where 600 indicates SDO functionality + Node ID 2). The first byte of data (2B) represents writing two bytes. Note that the data is little-endian, so 2000h index is written as 0020h, and the data 1FF is written as 01FF. After sending, the slave will respond with a frame ID of 582 and a data header of 60, indicating that the write operation was successful. Once the slave enters operational mode again, the PDO data timestamp will change to 511μs, corresponding to 1FF.
Note: In the standard CIA301 protocol, the inhibit time unit is 100μs. For more details on how to read and write data longer than 4 bytes using SDO, refer to the detailed documentation.
The COB-ID for RPDO1 is used to read the data and control the DO output. Similarly, RPDO2 is used to read the PDO data from the master (frame ID 302) and control the rate of DI data returns from the slave’s TPDO1.
The mappable parameters for the communication objects and mapping objects are shown below. It is important to note that the COB-ID, communication, and mapping parameters have different ranges and meanings for RPDO and TPDO. For detailed information, refer to the CIA301 standard and detailed documentation.
In this simple example, we modify index 1401, sub-index 01 to set the COB-ID to 302. The mapping object at index 1601 contains the mapped parameters. To map the TPDO1 or RPDO to the corresponding data, we perform the following steps:
The Heartbeat service can be activated by setting a non-zero value for the heartbeat time in object 1017h:00h. Once activated, the slave will periodically send its NMT status to the CAN bus, as shown in the diagram below.
PDO operates in a producer-consumer model, where messages are sent without requiring a reply. One message can have multiple consumers. After the slave enters the operational mode, it sends PDO messages cyclically or upon event triggers based on the configured communication parameters. If the SYNC function is enabled, the PDO is sent after receiving a specified number of synchronization frames. The master station can also send PDO messages, as illustrated in the diagram below.
Setting CANopen Device Parameters
For the Guangcheng CANopen IO device, set the node ID to 2 and the baud rate to 10k by adjusting the DIP switches on the device, as shown in the diagram below.When powered on, the device will send two messages to the master station: one with frame ID 0x700 + Node_ID, data 00 (indicating the device is in initialization mode) and another with data 7F (indicating the device is in pre-operational mode), as shown in the diagram below.
At this point, the device is in pre-operational mode. In ECanTools, select the CANopen option, click to add slave with Node ID 2, choose the NMT (Network Management) Function option, and select "Start Remote Node", then click NMT, as shown in the diagram below.
At this point, the master station will send a message with frame ID 000, data 01 (for operational state) and 02 (for Node 2; 00 for broadcast), as shown below. The Node 2 IO device will start sending PDO frames with ID 182 and a data length of 2 bytes. These 2 bytes correspond to the 16 DI (Digital Input) channels, with each bit representing the input status (1 for active). Note that this feature is custom to Guangcheng and not part of the standard CIA301 protocol. The result is shown below.
Manually sending data with the CAN tool also produces the same effect, as shown below.
Modifying PDO Parameters Using SDO
By examining the EDS file, it can be seen that index 2000h, sub-index 01h allows modification of the inhibit time for TPDO1. The inhibit time controls the minimum interval between consecutive PDO messages. To demonstrate this, an SDO request (request-response mode) can be used.When sending manually, set the frame ID to 602 (where 600 indicates SDO functionality + Node ID 2). The first byte of data (2B) represents writing two bytes. Note that the data is little-endian, so 2000h index is written as 0020h, and the data 1FF is written as 01FF. After sending, the slave will respond with a frame ID of 582 and a data header of 60, indicating that the write operation was successful. Once the slave enters operational mode again, the PDO data timestamp will change to 511μs, corresponding to 1FF.
Note: In the standard CIA301 protocol, the inhibit time unit is 100μs. For more details on how to read and write data longer than 4 bytes using SDO, refer to the detailed documentation.
Configuring DO Output State via PDO
To configure the output state of DO (Digital Output) channels, the master station sends a PDO message with frame ID 0x200 + Node_ID and a length of 2 bytes to the slave. The data 0F 00 will turn on all DO channels (bits 0-3, with little-endian ordering), as shown in the diagram below.Configuring PDO Mapping
Since the Guangcheng device's PDO functionality is incomplete, let’s explain how to configure PDO using SDO. As mentioned earlier, modifying the data in index 2000, sub-index 01 can change the PDO send interval for DI data. Assuming the data is mappable, here’s an example:The COB-ID for RPDO1 is used to read the data and control the DO output. Similarly, RPDO2 is used to read the PDO data from the master (frame ID 302) and control the rate of DI data returns from the slave’s TPDO1.
The mappable parameters for the communication objects and mapping objects are shown below. It is important to note that the COB-ID, communication, and mapping parameters have different ranges and meanings for RPDO and TPDO. For detailed information, refer to the CIA301 standard and detailed documentation.
In this simple example, we modify index 1401, sub-index 01 to set the COB-ID to 302. The mapping object at index 1601 contains the mapped parameters. To map the TPDO1 or RPDO to the corresponding data, we perform the following steps:
- Disable the PDO:
- 602 22 01 14 01 02 03 00 80 (Set COB-ID to 302 and disable PDO)
- Clear the Mapping Object:
- 602 22 01 16 00 00 00 00 00
- Write the Mapping Object:
- 602 22 01 16 01 10 01 00 20 (16-bit format for index 2000)
- 602 22 01 16 00 01 00 00 00 (One parameter)
- Enable PDO:
- 602 22 01 14 01 02 03 00 00 (Enable PDO)
SYNC Function
If the SYNC function is enabled, the master will periodically send a frame ID 80 without any data. This signal triggers the slave to send its PDO data. Due to the incomplete PDO functionality on this device, the exact effect of the SYNC function is not demonstrated here, but the configuration method is described in the detailed documentation and CIA301 specification.Error Control (EMCY)
The EMCY (Error Control) function sends error messages from the slave to the master. This functionality cannot be demonstrated here.Node Guarding and Heartbeat Services
The Node Guarding service works by sending an RTR message with CAN-ID 700h + Node ID from the master to the slave. The slave must respond to confirm that it is active. The slave’s response includes a NMT (Network Management) status, where bit 7 alternates to indicate message loss. The slave waits for the RTR message from the master for a period set by 100Ch:00 (guard time) and 100D:00 (life time factor).The Heartbeat service can be activated by setting a non-zero value for the heartbeat time in object 1017h:00h. Once activated, the slave will periodically send its NMT status to the CAN bus, as shown in the diagram below.