2. Getting Started

2.1. EC-Master Architecture

The EC-Master EtherCAT Master Stack is implemented in C++ and can be easily ported to any embedded OS platforms using an appropriate C++ compiler. The API interfaces are C language interfaces, thus the master can be used in ANSI-C as well as in C++ environments.

The Master Stack is divided into modules, see diagram and descriptions below:

  • EtherCAT Master Core: In the core module cyclic (process data update) and acyclic (mailbox) EtherCAT commands are sent and received. Among others there exist some state machines to handle for example the mailbox protocols.

  • Configuration Layer: The EtherCAT master is configured using a XML file whose format is fixed in the EtherCAT specification ETG.2100. EC-Master contains an OS independent XML parser.

  • Ethernet Link Layer: This layer exchanges Ethernet frames between the master and the slave devices. If hard real-time requirements exist, this layer has to be optimized for the network adapter card in use.

  • OS Layer: All OS dependent system calls are encapsulated in a small OS layer. Most functions are that easy that they can be implemented using simple C macros.

2.2. EtherCAT Network Configuration (ENI)

The EtherCAT master has to know about the EtherCAT bus topology and the cyclic/acyclic frames to exchange with the slaves. This configuration is determined in a configuration file which has to be available in the EtherCAT Network Information Format (ENI). This format is completely independent from EtherCAT slave vendors, from EtherCAT master vendors and from EtherCAT configuration tools. Thus interoperability between those vendors is guaranteed.

Additionally some static configuration parameters have to be defined like the identification of the network adapter card to use, the priority of the EtherCAT master timer task etc.

2.3. Operating system configuration

The main task is to setup the operating system to support the appropriate network adapter for EtherCAT usage and for some systems real-time configuration may be needed.

The operating system-specific settings and configurations are described in Platform and Operating Systems (OS).

2.4. Running EcMasterDemo

The EcMasterDemo is available “out of the box” for different operating systems. It is an EC-Master example application that handles the following tasks:

  • Showing basic EtherCAT communication

  • Master stack initialization into OPERATIONAL state

  • Process Data operations for e.g. Beckhoff EL2004, EL1004 and EL4132

  • Periodic diagnosis task

  • Periodic Job Task in polling mode

  • Logging

Start the EcMasterDemo from the command line to put the EtherCAT network into operation. At least a Link Layer must be specified.

EcMasterDemo -winpcap 192.168.157.2 1 -f eni.xml -t 0 -v 3

See also

2.4.1. Command line parameters

EcMasterDemo <LinkLayer> [-f ENI-FileName] [-t time] [-b cycle time] [-a affinity] [-v level] [-perf [level]] [-log prefix [msg cnt]] [-lic key] [-oem key] [-flash address] [-sp [port]] [-auxclk period] [-rec [prefix [frame cnt]]]

The parameters are as follows:

-f <configFileName>

Path to ENI file

-t <time>

Running duration in msec. When the time expires the demo application exits completely.

<time>

Time in msec, 0 = forever (default = 120000)

-b <cycle time>

Specifies the bus cycle time. Defaults to 1000 µs (1 ms).

<cycle time>

Bus cycle time in µsec

-a <affinity>

The CPU affinity specifies which CPU the demo application ought to use.

<affinity>

0 = first CPU, 1 = second, …

-v <level>

The verbosity level specifies how much console output messages will be generated by the demo application. A high verbosity level leads to more messages.

<level>

Verbosity level: 0=off (default), 1..n=more messages

-perf [<level>]

Enable max. and average time measurement in µs for all EtherCAT jobs (e.g. ProcessAllRxFrames).

<level>

Depending on level the performance histogram can be activated as well.

-log <prefix> [<msg cnt>]

Use given file name prefix for log files.

<prefix>

<msg cnt>

Messages count for log buffer allocation

-lic <key>

Use License key.

<key>

26 characters long license key.

-oem <key>

Use OEM key

<key>

64 bit OEM key.

-flash <address>

Flash outputs

<address>

0=all, >0 = slave station address

-sp [<port>]

If platform has support for IP Sockets, this command-line option enables the Remote API Server to be started. The Remote API Server is going to listen on TCP Port 6000 (or port parameter if given) and is available for connecting Remote API Clients.

<port>

RAS server port

-auxclk <period>

Use auxiliary clock

<period>

Clock period in µs (if supported by Operating System).

-rec [<prefix> [<frame cnt>]]

Record network traffic to pcap file

<prefix>

pcap file name prefix

<frame cnt>

Frame count for log buffer allocation

2.5. Compiling the EcMasterDemo

The following main rules can be used to generate the example applications for all operating systems.

  • <OS> is a placeholder for the operating system used.

  • <ARCH> for the architecture. If different architectures are supported.

2.5.1. EtherCAT Master Software Development Kit (SDK)

The EtherCAT master development kit is needed to write applications based on the master stack. The master stack is shipped as a library which is linked together with the application.

The following components are supplied together with an SDK:
<InstallPath>/Bin
<InstallPath>/Doc
<InstallPath>/SDK
<InstallPath>/SDK/INC
<InstallPath>/SDK/LIB
<InstallPath>/SDK/FILES
<InstallPath>/Sources/Common
/Bin

Executables containing the master stack

/Doc

Documentation

/Examples

One or more example applications using a predefined EtherCAT-configuration. It is easily adaptable to different configurations using an appropriate EtherCAT configuration XML file.

/SDK

EtherCAT Software Development Kit containing libraries and header files to build C/C++-applications.

/SDK/INC:

Header files to be included with the application

/SDK/LIB:

Libraries to be linked with the application

/SDK/FILES:

Additional files for platform integration (e.g. Windows CE registry files)

/Sources/Common:

Shared .cpp-files

2.5.2. Include search path

The header files are located in the following directories:
<InstallPath>/SDK/INC
<InstallPath>/SDK/INC/<OS>/<ARCH>
<InstallPath>/Sources/Common

2.5.3. Libraries

The libraries located in the following directories:
<InstallPath>/SDK/LIB/<OS>/<ARCH>