ecmasterlib and EtherCATInterface

Overview

The „ecmasterlib“ and „EtherCATInterface“ offer a relative easy way to use EtherCAT with EEROS or in standalone project.

  • EEROS: The robotic framework
  • EtherCAT stack: The EtherCAT stack from Acontis, see The Acontis EtherCAT Stack.
  • ecmasterlib: This library provides an easy interface to the EtherCAT stack. The library initializes the stack and takes over the periodic sending and receiving of the bus data. It provides the following basic interface: EtherCATInterfaceBase
  • EtherCATInterfaceElmo: An interface based on EtherCATInterfaceBase designed for Elmo drives. See EtherCATInterfaceElmo for details. You may need to implement your own interface for different drives. the interface further includes to EEROS blocks for the control system:
    • getDrivesBlock: It has a signal output for every PDO input value (i.e. encoder values). You may need to modify this block in your application.
    • setDrivesBlock: It has a signal input for every PDO output value (i.e. setTorque). You may need to modify this block in your application.

Installation

Please make sure that you have previously installed the EtherCAT stack software and EEROS beforehand. Install EEROS as described in this tutorial, but use the command line option -DUSE_ETHERCAT=TRUE when calling cmake.

...
cmake -DCMAKE_INSTALL_PREFIX=/absolute/path/to/working/directory/install-x86-64 -DUSE_ETHERCAT=TRUE ..
...

Install ecmasterlib

Once the EtherCAT stack has been installed and the demo application is running, the ecmasterlib can be installed.

$ cd path/to/working/directory
$ git clone https://github.com/ntb-ch/ecmasterlib.git
$ cd ecmasterlib
$ mkdir externalLib
$ cp ''<classB_path>''/SDK/LIB/Linux/x64/libAtemRasSrv.a externalLib
$ cp ''<classB_path>''/SDK/LIB/Linux/x64/libEcMaster.a externalLib
$ mkdir build-x86-64
$ cd build-x86-64
$ cmake -DCMAKE_INSTALL_PREFIX=/absolute/path/to/working/directory/install-x86-64 ..
$ make
$ make install

Install EtherCATInterfaceElmo

$ cd path/to/working/directory
$ git clone https://github.com/ntb-ch/ethercatinterfaceelmo.git
$ cd EtherCATInterfaceElmo
$ mkdir build-x86-64
$ cd build-x86-64
$ cmake -DCMAKE_INSTALL_PREFIX=/absolute/path/to/working/directory/install-x86-64 ..
$ make
$ make install

Functionality

The „ecmasterlib“ provides a callback function (void callbackFct(…)) which is called by the Acontis stack once per EtherCAT cycle. This method:

  • Copies the received data from the stack into the receive buffer of „ecmasterlib“
  • Copies the data to be sent from the send buffer of „ecmasterlib“ to the stack.

The receive and send buffers of „ecmasterlib“ are byte arrays (uint8_t* inBuffer; uint8_t* outBuffer;) which are the same size as the PDOs.

The „ecmasterlib“ also provides a condition variable (std::condition_variable cv;) to synchronize the user application (i.e. EEROS).

When an „ecmasterlib“ object is created, an instance (monotonic) is created. The stack is started in the same way as in the „EcMasterDemoDC“ of Acontis.

Adaptions

Overview

The components EtherCATInterfaceElmo_config, getDrivesBlock and setDrivesBlock need to be adjusted whenever you change the variables, which are transmitted via PDOs (periodic sent/received messages by the EtherCAT bus). These components must also be adapted when creating a new EEROS application.

Steps

  1. Study produced ENI file carefully (use XML viewer). Under <config><processimage><inputs> and <outputs> you find bitsize and offset of all transmitted values.
  2. Adjust headerfile accordingly, negative offset values indicate that the entry is not going to be used.
  3. Make necessary adaptions in getDrivesBlock and setDrivesBlock.

Attachment