2. Getting Started

2.1. EC-Master Architecture

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

The MainDevice stack is divided into modules, see diagram and descriptions below:

  • EtherCAT® MainDevice 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® MainDevice is configured using an XML file whose format is fixed in the EtherCAT® specification ETG.2100. EC-Master contains an OS independent XML parser.

  • Real-time Ethernet Driver Layer: This layer exchanges Ethernet frames between the MainDevice and the SubDevices. 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® MainDevice has to know about the EtherCAT® bus topology and the cyclic/acyclic frames to exchange with the SubDevices. 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® SubDevice vendors, from EtherCAT® MainDevice 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® MainDevice 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

  • MainDevice 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 Real-time Ethernet Driver must be specified.

EcMasterDemo -ndis 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] [-maxbusslaves cnt] [-flash address] [-sp [port]] [-rec [prefix [frame cnt]]] [-junctionred]

The parameters are as follows:

-f <ENI-FileName>

Path to ENI file

-t <time>

Running duration [ms]. When the time expires the demo application exits completely.

<time>

Time [ms], 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>

Set License key.

<key>

License key string

-oem <key>

Use OEM key

<key>

64 bit OEM key.

-junctionred

Enable junction redundancy (automatic mode)

-flash <address>

Flash outputs

<address>

0=all, >0 = SubDevice 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

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

Packet capture file recording

<prefix>

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> is a placeholder for the architecture. Different architectures are supported.

2.5.1. EtherCAT® MainDevice Software Development Kit (SDK)

The EtherCAT® MainDevice development kit is needed to write applications based on the MainDevice stack. The MainDevice 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 MainDevice 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 are located in the following directories:
<InstallPath>/SDK/LIB/<OS>/<ARCH>