Configuring RevPi Con CAN

Configuring CANopen Master

Prerequisites

A project is created using a RevPi Connect base module and a RevPi Con CAN expansion module at the piBridgeRight interface.

  • Right-click on the root device.
  • Click on Add Device.
  • Select CANbus from the Fieldbuses.
  • Click on Add.
  • Right-click on the CANbus device.
  • Click on Add Device.
  • Select CANopen_Manager from the Fieldbuses.

    • Click on Add Device.
    • Right-click on your project in the project tree.
    • Click on Add Object.
    • Insert the following objects: Task Configuration and POU.

  • Add the call POU to the task configuration.

  • Download the project to the RevPi device.
  • Log in via the Login icon in the menu bar.

The CANopen master is in operation.

Insert KUNBUS CANopen mGate

  • Right-click on the CANopen_Manager in the device tree.
  • Click on Add Device.
  • Select KUNBUS-mGate CANopen.
  • Click on Add Device.

  • Set the node ID and the bit rate of the gateway on the rotary coding switches of the device.
  • Download the project to the RevPi device.
  • Log in via the Login icon in the menu bar.
    The gateway is recognized by the master.

  • Configure the script to set the baud rate.
    sudo nano /var/opt/codesys/rts_set_baud.sh
    #!/bin/sh
    BITRATE=expr $2 \\* 1000
    ifconfig $1 down
    echo ip link set $1 type can bitrate $BITRATE
    ip link set $1 type can bitrate $BITRATE
    ifconfig $1 up
  • Make the script executable using the following command:
    sudo chmod +x /var/opt/codesys/rts_set_baud.sh
  • Activate RevPi Con CAN either on the Config tab in PiCtory by activating Support RevPi Con Can device or using the following command:
    sudo revpi-config enable revpi-con-can
  • Download the CODESYS project.
  • Important: Reboot the system or do a hard reset.

The RevPi Con CAN module can now be used with CODESYS.

Configuring CANopen Slave

The CANopen slave is configured in the same way as the CANopen master.
The CANopen slave only needs to be configured for the slave function when setting the baud rate and activating the Con CAN module.

You can also take a look at the RevPi Con CAN example on this topic.