Attention

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

IgH EtherCAT Master Stack

The EtherCAT master stack by IgH is being used for open source projects for automation of systems such as ROS (Robot Operating System) and Linux CNC Applications of an open source–based EtherCAT master system not only reduces cost, but also makes application program development flexible. Based on the native, Intel made the following optimizations:

  • Support Linux Kernel 4.x

  • Support Xenomai 3 and Preempt RT

  • Migrate Operation thread to cobalt

  • Migrate latest igb driver to stack

This section describes how to run IgH EtherCAT Master Stack on Edge Controls for Industrial(ECI).

EtherCAT Master Setup

Dependencies

  • Native EtherCAT Device Driver – IGB (high performance)

    • Only support igb device(example: intel i210/i211 NICs)

    • One networking driver for EtherCAT and non-EtherCAT devices.

    • Driver gets more complicated, as it must handle EtherCAT and non-EtherCAT devices

  • Generic EtherCAT Device Driver – generic (low performance)
    • Any ethernet hardware, that is covered by a Linux Ethernet driver can be used for EtherCAT

    • Performance is a little worse than the native approach, because the frame data have to traverse the lower layers of the network stack

    • Note: If the target system does not support the IGB device driver, the generic EtherCAT device driver may be selected instead.

System Integration

The following section is applicable to:

../_images/target1.png

EtherCAT Init Script

The EtherCAT master init script is installed to /etc/init.d/ethercat.

EtherCAT Sysconfig File

The init script uses a sysconfig file installed to /etc/sysconfig/ethercat, that is mandatory for the init script. The sysconfig file contains all configuration variables need to operate one or more masters. The documentation is inside the file and included below:

../_images/ethercat_sysconfig.png
  • Set REBIND_NICS

    Use lspci to query net devices, one may be specified as an EtherCAT Network interface.

../_images/lspci.png
  • Fill MAC for MASTER0_DEVICE

    Get MAC address of the Network Interface Controllers selected for EtherCAT

../_images/ifconfig.png
  • Modify DEVICE_MODULES
    • Option 1: IGB device as EtherCAT driver(High performance)

      DEVICE_MODULES="igb"
      
    • Option 2: generic driver as EtherCAT driver(low performance)

      DEVICE_MODULES="generic"
      

Starting the Master as a service

After the init script and the sysconfig file are ready to configure and placed into the right location, the EtherCAT master can be inserted as a service. The init script can be used for manually starting and stopping the EtherCAT master. It has to be executed with one of the parameters start, stop, restart or status.

  • Start EtherCAT Master

# /etc/init.d/ethercat start
  • Stop EtherCAT Master

# /etc/init.d/ethercat stop
  • Restart EtherCAT Master

# /etc/init.d/ethercat restart
  • Status for EtherCAT Master

# /etc/init.d/ethercat status

Multi-Axis Synchronization System (MASS)

../_images/mass_hw_setup.png

This system setup includes motion controller, servo driver, motors and software. The Motion Controller is intel-based system with ECI enabled. The Motion Controller connects 8x Servo Drivers. The System runs a program to control 6 servos motor simultaneously through EtherCAT, which are paired every two to control pencil leads to rotate and move horizontally and vertically.

../_images/mass_arch.png

Another two servos are controlled to simultaneously through EtherCAT to draw a circle.

Test binary will be released in /opt/ighethercat/examples/ec_multi_axis_example

EtherCAT Control Loop and Time Measurement

../_images/rt_data_definition.png

EtherCAT Sanity-Check testing

The following section is applicable to:

../_images/target1.png

Sanity-Check #1: EtherCAT Master Start

Step 1: EtherCAT Master Start

# /etc/init.d/ethercat start
../_images/stack_start.png

Step 2: Check Master information

# ethercat master
  • Expected output

../_images/master_information.png

Sanity-Check #2: EtherCAT Master Scan

The following section is applicable to:

../_images/target1.png

Step 1: EtherCAT Master Start

# /etc/init.d/ethercat start

Step 2: Scan EtherCAT Slave

# ethercat rescan

Step 3: Check slaves on the bus

# ethercat slaves
  • Expected output

../_images/slave_device.png

Sanity-Check #3: MASS platform performance collection

Step 1: Use EtherCAT network cable to interconnect the MASS platform and Controller in specify EtherCAT network interface, power up the MASS platform.

Step 2: EtherCAT Master Start

#  /etc/init.d/ethercat start

Step 3: Check EtherCAT bus to confirm 8 ethercat slaves are scan and stay on PREOP status.

# ethercat slaves
  • Expected output

../_images/slaves.png

Step 4: Start /opt/ighethercat/examples/ec_multi_axis_example -r to collect real-time performance

# /opt/ighethercat/examples/ec_multi_axis_example -r
  • Expected output

../_images/mass_rt.png

Tip

useful command parameters:

-r      Motor start running
-t      Set measure time for minutes, default is no time limitation

EtherCAT Analysis with Wireshark

Hardware Setup

1. Using KUNBUS TAP CURIOUS

  1. Overview

../_images/kunbus.png

Refer to TAP CURIOUS User Manual

TAP_CURIOUS_User_Manual.pdf

  1. Application Example

../_images/kunbus_setup.png

Software Setup

Step 1: Start IgH ethercat master stack

Step 2: Start EtherCAT IO sample code

# /opt/ighethercat/examples/ec_ecatdio_example -t 100
  • Note: useful command parameters:

    -t         Set horse light cycle tick
    

Capture ethercat packages with wireshark

Step 1. All available Ethernet interfaces are listed in the main window. Click on the required Ethernet interface to select it.

../_images/wireshark_start.png

Step 2. It is possible to use Wireshark to analyze the data.

Note: if ECAT packets cannot be captured, please disable security software.

../_images/wireshark_pcap.png

Step 3. I/O graph can be shown as below.

../_images/wireshark_io_graph.png

Jitter analysis by wireshark

Step 1. Find the timestamp in KUNBUS TAP and apply it as column.

../_images/tap_timestamp.png

Step 2. Filter the packages from master.

../_images/filter_master.png

Step 3. Export the data as .csv format.

../_images/export_data.png

Step 4. Open the data file by Excel and find the timestamp column. Fetch the last 9 digits (in ns) and then calculate the delta time between two cycles.

../_images/delta_time.png

Step 5. Plot the delta time graph and we can see the jitter +/-4us within 1ms per cycle

../_images/jitter_graph.png

EtherCAT Enablekit

EtherCAT Enablekit Overview

Ecat EnableKit provides tools that simplify the process of customizing the configurations of EtherCAT master, slave, and network topology. It provides APIs to develop EtherCAT application programs easily. With Ecat EnableKit, developers can focus on what is truly important and leave the tedious configuration process to the system.

EtherCAT EnablekitFeatures

Based on this version, the following features are included:

  • Based on IgH EtherCAT Master Stack

  • Support Preempt-RT and Xenomai

  • Provide functions to parse EtherCAT Network Information (ENI)

  • Provide functions to parse EtherCAT Slave Information (ESI)

  • Provide APIs to develop EtherCAT application program easily

  • Provide example code to driver EtherCAT IO slaves

  • Provide example code to driver EtherCAT CoE slaves (SOE is not currently supported)

EtherCAT Enablekit Architecture

The architecture is as following:

../_images/arch.png

EtherCAT Enablekit Code Sample

EtherCAT Enablekit Requirements

The software can run on commodity PC or Server. Because the software is developed primarily in C language, it should be straightforward to port to other operating systems.

EtherCAT Enablekit Sanity-Check testing

The following section is applicable to:

../_images/target1.png

Sanity-Check #1: ESI Parsing

Step 1: Navigate to the directory: /opt/ecat-enablekit

# cd /opt/ecat-enablekit

Step 2: Test the ESI file, e.g. esi_xxx.xml, with option -s

# ./test-motion -s esi_xxx.xml
  • Expected output

../_images/esi_test.png

Sanity-Check #2: ENI Parsing

Step 1: Navigate to the directory /opt/ecat-enablekit

# cd /opt/ecat-enablekit

Step 2: Test the ENI file, e.g. eni_xxx.xml, with option -n

# ./test-motion -n eni_xxx.xml
  • Expected output

../_images/eni_test.png

Real-Time Vision with EtherCAT

The real-time vision provides a deterministic way to complete synchronization between motion control and image capture even the objective is in high-speed moving. Then the stopping time can be saved, thus to improve efficiency and productivity.

The key to achieve the synchronization is the time-aware IO. And an EtherCAT IO with timestamping can be utilized to trigger a deterministic capturing for an accurate image. Then the accurate image can be processed by machine vision to provide precise position offset and angle offset for next-step motion control.

Usage case

../_images/usage.png

In the SMT production line, this kind of operation is always shown, that the gantry with a sucker sucks a chip from the plate and then mounts on the PCB. But it’s not always able to hit the expected point and the expected angle of the chip during the suction. Even little shift can lead to deviation, so that the chip cannot be mounted in the right place later. Then the machine vision does help after the image capturing, to computer position/angel offset value of the chip for perfect mounting.

In the tradition way, the gantry will stop above the camera and wait for a while for image capturing. Now is not necessary anymore when applying real-time vision. And the efficiency can be improved significantly.

Work Flow

The application controls the motion by EtherCAT and synchronizes with IO. When reaching the target timing, IO will trigger the camera to capture an image. And then the image will be processed with machine vision to provide the position value and the angel value. By data exchanging, the application continues the motion control with position information.

../_images/workflow.png

Solution principle

../_images/trigger_timing.png
../_images/moving.png
  • T0 is the time when CPU sends shooting command

  • S0 is the position to prepare trigger shooting, which can be read in cyclic task. It corresponds to T0.

  • T1 is the time to trigger the picture shooting

  • S1 is the expected fixed position to trigger shooting.

  • △T can be calculated with ∆𝑇=(𝑆_1−𝑆_0)/𝑉

  • T2 is the time when the image is captured on CMOS

  • S2 reflects the real position where the image is capturing.

  • The time between T2 and T1 is used for camera exposure and image generating

  • Real-time vision should make the time intervals (T2 - T1) and (T1 T0) deterministic

Demo example

The demo code is integrated into IgH EtherCAT stack components as an example in examples/fly_trigger_poc