3.1. CANOPEN_MASTER

3.1.1. Overview

The canopen_master_demo provides the following features:

  • HeartBeat test

  • NMT test

  • SDO test

  • PDO test

3.1.2. Board Setting

Download master routines on one board, download slave routines on another board, connect two boards

3.1.3. Running Steps

After the program is successfully downloaded, master will enter a loop to wait for slave message. If the slave is in initial/pre optional/optional state, read the nodeid. Otherwise, continue the loop to wait

Read message from the slave through PDO based on the nodeid

Read/write message from/to the slave through SDO based on the nodeid

Note: This sample is intended to provide a simple presentation of the canopen communication process. Canopen supports one master and multiple slaves, but this sample only supports one master and one slave

3.1.4. Running the example

When the example runs successfully, the board shows the following:

----------------------------------------------------------------------
$$\   $$\ $$$$$$$\  $$\      $$\ $$\
$$ |  $$ |$$  __$$\ $$$\    $$$ |\__|
$$ |  $$ |$$ |  $$ |$$$$\  $$$$ |$$\  $$$$$$$\  $$$$$$\   $$$$$$\
$$$$$$$$ |$$$$$$$  |$$\$$\$$ $$ |$$ |$$  _____|$$  __$$\ $$  __$$\
$$  __$$ |$$  ____/ $$ \$$$  $$ |$$ |$$ /      $$ |  \__|$$ /  $$ |
$$ |  $$ |$$ |      $$ |\$  /$$ |$$ |$$ |      $$ |      $$ |  $$ |
$$ |  $$ |$$ |      $$ | \_/ $$ |$$ |\$$$$$$$\ $$ |      \$$$$$$  |
\__|  \__|\__|      \__|     \__|\__| \_______|\__|       \______/
----------------------------------------------------------------------
enter master mode and find slave device ~~
rxSize = 11, txSize = 8
excessive number of concurrent CAN RX filters enabled (needs 11, 16 available)

3.1.4.1. Test steps

The current routine is the master role of canopen. The board runs the current routine and connects to the board running the slave role.

If success, Master board show as:

Allocated 4712 bytes for CANopen objects
enter master mode and find slave device ~~
rxSize = 17, txSize = 9
find device, id:70a, status preoptional
slave enter to optional mode
PDO test successfully!
slave HBtime: 1000 ms
slave HBtime: 2000 ms
SDO test successfully!
canopen test done