Let’s look at the CANopen master simulator function of USB-CAN converter.
We can click on the left “Find slave station” to scan all CANopen slave nodes on the CAN bus. You can also add CANopen slave station manually. The station which is already been added will be shown as below. The user can double-click the specified node number to activate the interface to communicate with the slave station.
The CANopen master station function turns the USBCAN device into a CANopen master card and accesses the CANopen network. ECANTools has a variety of commonly used CANopen master station function. For example, NMT(Network Management), SYNC(synchronous protocol), EMERGENCY(urgent message), PDO(process data object), SDO(service data object), NODE GUARDING(node protection).
The following table lists the functional codes and frame ID ranges, which are correspond to the CANopen common frame types.
Message type | Function code | COB-ID range(Hex) |
NMT | 0000 | 000h |
SYNC | 0001 | 080h |
EMERGENCY | 0001 | 081h-0FFh |
TIME | 0010 | 100h |
PDO1(transmit) | 0011 | 181h-1FFh |
PDO1(receive) | 0100 | 201h-27Fh |
PDO2(transmit) | 0101 | 281h-2FFh |
PDO2(receive) | 0110 | 301h-37Fh |
PDO3(transmit) | 0111 | 381h-3FFh |
PDO3(receive) | 1000 | 401h-47Fh |
PDO4(transmit) | 1001 | 481h-4FFh |
PDO4(receive) | 1010 | 501h-57Fh |
SDO(transmit) | 1011 | 581h-5FFh |
SDO(receive) | 1100 | 601h-67Fh |
NMT Error Control | 1110 | 701h-77Fh |
1 NMT command
NMT command provides Network management(such as initialization, start and stop nodes, detection of failed nodes).
The user can use the NMT command to change the running state of the slave node.
Start remote node——Sets the node into the operation state
Stop remote node——Sets the node into the stop state
Enter pre-operational state——Sets the node into the pre-operation state
Reset node——Sets node reset
Reset communication——Sets node reset communication
2 SYNC message
SYNC is the synchronous message sent by the master station. All stations that have synchronized PDO communicate with the master station based on the SYNC message.
The user can cyclically send SYNC messages via the ECANTools.
3 EMERGENCY message
ECANTools can receive EMERGENCY messages from the slave station node. The message is sent by a slave node in a state of emergency. The CANopen master function of the ECANTools can receive and process this EMERGENCY message.
4 PDO (Process data object)
CANopen nodes use PDO to transfer data, which is mainly used to transmit real-time data.
PDO, full name is process data object, belongs to process data with one-way transmission. For receiving node, there is no need to respond the confirmed CAN message.
There are 4 pairs of transmitting and receiving PDO in ECANTools, which are TPDO/RPDO.
5 SDO (Service data object)
CANopen master module SDO function is divided into transmitting and receiving SDO. The SDO function in ECANTools allows users to communicate with the slave station by editing indexes and sub indexes.
6 NODE GUARDING
There are two ways to implement the node guarding function in ECANTools. The master station sends the command automatically to inquire about the status of the slave node (Node Guarding) and the slave node transmits its status periodically in the heartbeat (Heartbeat).
ECANTools can also manually simulate CANopen data by editing custom messages.
The user can send data directly to the CANopen slave station by writing function
codes, slave stations node ID and data.
The function code corresponding function is shown in the following table:
—-To configure PDO 0x1800+n
—-COB-ID is 0x387
—-PDO always triggers transmission
—-It must contain data: data X(2bytes), data Y(4bytes)
In the following order
–data X defined in index 0x6000, sub-index 03
–data Y defined in index 0x2010, sub-index 21
1– index 1800+n, sub-index 01: write COBID(4bytes)
2– index 1800+n, sub-index 02: write transport byte “t”(1byte)
t=1 to 0xF0: PDO will be transmitted if it receives “t” times SYNC.
t=FD : transfer after receiving the PDO request(rtr=1)
t=FF: the node transmits PDO automatically according to the event
3– index 1A00+n: a mapping that defines the first n data
sub-index 0: the number of data written to PDO (1byte). In this case, write “2”
sub-index 1: define where to look for the first data and size to write (8bytes)
The format is: index (2 bytes) – sub index (1 byte) – size in bits (1 byte)
In this case, write “60000310”
sub-index 2: define where to look for the second data and size to write (8bytes)
In this case, write”20102120″
Configuration node 5 PDO 1802 in each of the 3 SYNC transmission, the sending SDO (s) should be
605 23 02 18 01 00 00 8703
605 2F 02 18 02 03 00 00 00
605 2F 02 1A 00 02 00 00 00
605 23 02 1A 01 10 03 00 60
605 23 02 1A 02 20 21 10 20