Attention

You are viewing an older version of the documentation. The latest version is v3.3.

CANopen Overview

CANopen is a CAN-based communication system, which comprises higher-layer protocols and profile specifications. CANopen has been developed as an international standard (EN 50325-4)(CiA301) with highly flexible configuration capabilities. It is used in various applications, such as medical equipment, AMR, and Robotic or motion-oriented machine control systems.

A general CANopen device has three logical parts:

  • CANopen protocol stack handles communication via the CAN network.

  • Application software provides the internal control functionality and the interface to process hardware.

  • Object dictionary interfaces the protocol and the application software. It contains references of all data types used, and stores all communication and application parameters.

This section describes the procedure to run CANopen stack on Intel® Edge Controls for Industrial (Intel® ECI or ECI).

Prepare CANopen

Install CANopen

You can install this component from the ECI APT repository. Setup the ECI APT repository, then perform either of the following commands to install this component:

Install from meta-package
$ sudo apt install eci-softplc-fieldbus
Install from individual Deb package
$ sudo apt install canopen canopen-tests canopenservo canopenservo-tests

Load Driver

Click the corresponding tab to learn more.

Check the CAN driver status, and confirm whether the peak_pci kernel driver is in use:

01:00.0 Network controller: PEAK-System Technik GmbH Device 0008 (rev 02)
       Subsystem: PEAK-System Technik GmbH Device 0002
       Flags: bus master, fast devsel, latency 0, IRQ 16
       Memory at 90810000 (32-bit, non-prefetchable) [size=64K]
       Memory at 90800000 (32-bit, non-prefetchable) [size=64K]
       Capabilities: <access denied>
       Kernel driver in use: peak_pci
       Kernel modules: peak_pci

If the peak_pci kernel driver is not in use, set up udev rules or type the following command manually:

$ modprobe peak_pci

Set up CAN/VCAN Interface

Click the corresponding tab to learn more.

  1. Configure CAN bitrate (for example, 1Mbps):

    $ ip link set can0 type can bitrate 1000000
    
  2. Bring up the CAN interface:

    $ ip link set up can0
    
  3. Check the CAN interface link status:

    $ ip addr ls dev can0
    

CANopen - Sanity Checks

The following section is applicable to:

../_images/target.png

Sanity Check #2: SocketCAN Dump Test

  1. Set up the CAN/VCAN interface.

  2. Capture the incoming CAN frames on can0:

    $ candump can0
    
  3. Send a standard CAN frame with 0x1FF as the ID and 0x01, 0x02, 0x03, 0x04 as 4-byte payloads:

    $ cansend can0 1FF#01020304
    

Sanity Check #3: CANopen Tests Automatically

  1. Set up the CAN/VCAN interface.

  2. Navigate to the /opt/opencan/test directory:

    $ cd /opt/opencan/test
    
  3. Start the devices:

    $ canopend can0 -i 1 -c "local-/tmp/CO_command_socket" &
    $ ./demoLinuxDevice can0 &
    
  4. Navigate to the /opt/opencan/test/running_canopen directory:

    $ cd /opt/opencan/test/running_canopen
    
  5. Run the tests:

    $ ./SDO_transfer.bats
    
  6. View the test results on the console:

    root@ECI:/opt/opencan/test/running_canopen# ./SDO_transfer.bats
    \u2713 Segmented write
    \u2713 Segmented read
    \u2713 Segmented transfer, files equal
    \u2713 Block write
    \u2713 Block read - 2x
    \u2713 Block transfer, files equal
    
      10240 bytes, segmented written/read: / milliseconds.
      10240 bytes, block written/read: / milliseconds.
    
    6 tests, 0 failures
    

    Tip

    If canopend or demoLinuxDevice program exits abnormally, make sure that local socket interface local-/tmp/CO_command_socket and several *.persist files has been deleted before next time launch the program.

Sanity Check #4: CANopen Servo SDO Enable Test

  1. Set up the CAN/VCAN interface and connect servo drive.

  2. Navigate to the /opt/opencan/test directory:

    $ cd /opt/opencan/test
    
  3. Start the devices, default servo nodeId 1:

    $ ./demoLinuxDevice can0 -i 1 -c local-/tmp/CO_command_socket &
    $ cocomm "1 preop"
    $ cocomm "1 start"
    $ cocomm "1 w 0x6040 0x00 u16 0x86"
    $ cocomm "1 w 0x6040 0x00 u16 0x07"
    $ cocomm "1 w 0x6040 0x00 u16 0x0F"
    $ cocomm "1 w 0x6060 0x00 u8 0x03"
    $ cocomm "1 w 0x60FF 0x00 u32 100"
    

Expected result: CANopen servo motor will rotate.