CODESYS: Configuring CANopen with RevPi Connect 5
This tutorial describes how to
- configure the CAN interfaces of a RevPi Connect 5 as CANopen Manager and CANopen Device in a CODESYS project.
- adapt the CANopen example project, which is provided by CODESYS, to the RevPi Connect 5.
Prerequisites
- CODESYS Development System incl. CODESYS Control for Linux ARM64 SL, installed on your PC
- Revolution Pi Library for CODESYS V2.1.0.0 or higher
- A CODESYS project is created using a RevPi Connect 5.
Details see CODESYS documentation.
Configuring CANopen
Configuring CANopen Manager
▷ In the device tree, right-click on Device (CODESYS Control for Linux ARM64 SL).
▷ Click on Add Device.
▷ Select CANbus within Fieldbuses.
▷ Click on Add Device.
▷ In the device tree, right-click on the added device CANbus.
▷ Click on Add Device.
▷ Select CANopen_Manager within Fieldbuses.
▷ Click on Add Device.
❯ The CANopen Manager is created in the device tree.
▷ Double-click on the CANbus device in the device tree to open the tabs.
▷ Select Network 0 in the General tab for the X3-CAN interface and Network 1 for the X2-CAN interface of the RevPi Connect 5.
Depending on the variant, the RevPi Connect 5 has one or two CAN interfaces.
❯❯ The CANopen Manager is configured.
Configuring CANopen Device
▷ In the device tree, right-click on Device (CODESYS Control for Linux ARM64 SL).
▷ Click on Add Device.
▷ Select CANbus within Fieldbuses.
▷ Click on Add Device.
▷ In the device tree, right-click on the added device CANbus.
▷ Click on Add Device.
▷ Select CANopen Device within Fieldbuses.
▷ Click on Add Device.
❯ The CANopen device is created in the device tree.
▷ Double-click on the CANbus device in the device tree to open the tabs.
▷ Select Network 0 in the General tab for the X3-CAN interface and Network 1 for the X2-CAN interface of the RevPi Connect 5.
Depending on the variant, the RevPi Connect 5 has one or two CAN interfaces.
❯❯ The CANopen device is configured.
CANopen Example Project
The example project provided by CODESYS contains different examples for using the programming interface of the CANopen master and CANopen slave stack. The project uses CODESYS Control Win V3 and one PEAK PCAN-USB Pro or two PEAK PCAN USB adapters.
Adapting the Project for RevPi Connect 5
▷ Select CODESYS Control for Linux ARM64 SL as runtime.
▷ Add RevPi Connect 5 to the device tree.
▷ Drag & drop the RevPi Connect 5 to the top of the device tree. CANbus interfaces or other network devices have to be added below the RevPi Connect 5 in the device tree, otherwise a configuration error will occur in the project after downloading.
▷ If the project is tested on a RevPi Connect 5 with two CAN interfaces set the baud rate to 250 kbit/s.
▷ Compile and download the project.
▷ Reboot the RevPi to get the CANopen Manager and the device into operating mode.