2. Getting Started

2.1. EC-Simulator Architecture

The EC-Simulator library 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 stack can be used in ANSI-C as well as in C++ environments.

There are two different architecture editions as described below. The architectures contain the following:

  • EC-Simulator stack 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 EC-Simulator stack is configured using a XML file whose format is fixed in the EtherCAT specification ETG.2100 (ENI) with extended information (EXI). The EC-Simulator contains an OS independent XML parser.

  • Ethernet Link Layer: This layer exchanges Ethernet frames between the master and the simulator. 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. Extended EtherCAT Network Configuration (EXI)

The EC-Simulator stack 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 master stack vendors and from EtherCAT configuration tools. Thus inter-operability between those vendors is guaranteed.

Because the ENI file does not include information about the slave hardware, the EXI (EtherCAT Extended Information) file includes EEPROM content and Slave Object Dictionary from ESI and ESC register values from real network is typically needed. The EXI file can be exported using EC-Engineer.

2.3. HiL Simulation Software architecture

The EC-Simulator software is ready-to-run on various operating systems, e. g. Linux and Windows, and makes use of the acontis Real-time Ethernet drivers, the so called link layers.

The EC-Simulator offers a “C” language API for integration into a Software PLC (LogicLab, logi.cals) or into professional simulation software like ISG Virtuos, etc.

2.4. SiL Simulation Software architecture

The SiL Simulation Software architecture does not need a physical network interface for slave simulation. The EC-Simulator is loaded as Link-Layer instead to simulate the EtherCAT Network on a System controller running the EC-Master.

2.5. Mixed mode of real slaves and simulated slaves

In order to implement restbus simulation it is possible to mix real slaves and simulated slaves like this:

All real slaves must be configured accordingly:

See also /EtherCATConfig/ExtendedConfig/Slaves/Slave/Simulated in the EXI file:

The EC-Simulator will automatically assign the network adapters to the corresponding ports in order of configuration.

2.6. Operating system configuration

This chapter is about preparing the operating system for usage with the EC-Simulator stack. 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. Only network adapters which support at least 100 MBit are supported. First the Link Layer drivers must be chosen as for some, the Operating system must be configured with special steps.

2.7. Running EcSimulatorHilDemo

The EcSimulatorHilDemo is an EC-Simulator example application that handles the following tasks:

  • Showing basic EtherCAT communication

  • Stack initialization

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

  • Periodic diagnosis task

  • Periodic Job Task

  • Logging to EcSimulator0.log, error0.log

The EcSimulatorHilDemo is available “out of the box” for different operating systems. The operating system must be prepared for running EtherCAT® applications,

2.7.1. Setting up and running EcSimulatorHilDemo Linux (EcSimulatorHilDemo)

  1. Operating system configuration: See the section Operating system configuration for how to prepare the operating system

  2. Starting EcSimulatorHilDemo

cd /opt/EC-Simulator/Bin/Linux/x64
LD_LIBRARY_PATH=. ./EcSimulatorHilDemo -f exi.xml -i8254x 2 1 -perf Microsoft Windows (EcSimulatorHilDemo)

  1. Windows configuration: See the section Operating system configuration for how to prepare the operating system

  2. Determine the network interface: Using the command line option the network interface card used by the example application can be determined. For example the option -ndis 0 will be using the network adapter card with the IP address .

  3. Simulating EtherCAT modules: The simulator has to be connected with the target system using an Ethernet switch or a patch cable. Local IT infrastructure should not be mixed with EtherCAT modules at the same switch as the master will send many broadcast packets! EtherCAT® requires a 100Mbit/s connection. Gigabit-Ethernet connections between simulator and master can be typically used, too.

  4. Copy all of the example application files into one directory: The application EcSimulatorHilDemo.exe together with the stack DLL EcSimulator.dll, the link-layer DLL emllPcap.dll and the EXI file have to be copied into one directory.

  5. Run the example application: EcSimulatorHilDemo.exe has to be executed. The file name of the EXI file has to be given as a command line parameter as well as the appropriate Link Layer settings.

EcSimulatorHilDemo.exe -ndis 0 -f exi.xml -t 0 -v 3

2.7.2. Command line parameters

EcSimulatorHilDemo <Link Layer>
[-f configFileName] [-t time] [-b time] [-v level] [-perf [level]] [-log prefix] [-flash address]

e.g. EcSimulatorHilDemo -ndis 0 1 -f exi.xml -t 0 -v 3

The parameters are as follows:

-f <configFileName>

Path to ENI file. Note: On some OS the absolute file path is needed.

-t <time>

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


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

-b <cycle time>

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

<cycle time>

Bus cycle time in µsec

Note: The master cycle time must be at least 2x of the simulator cycle time

-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.


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


Enable max. and average time measurement in µs for all EtherCAT jobs (e.g. ProcessAllRxFrames). Depending on ‘level’ the performance histogram can be activated as well.

-sp [port]

If platform has support for IP Sockets, this commandline option enables the Remote API Server to be started with the EcSimulatorHilDemo. 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. This option is included for attaching the EC-Lyser Application to the running simulator.

-log prefix

Use given file name prefix for log files.

-flash <address>

Flash outputs


0=all, >0 = slave address

2.8. Using emllSimulator (SiL)

The EcSimulatorSilDemo example program as well as all EC-Master example programs like EcMasterDemo, EcMasterDemoDc, etc. support the EC-Simulator (SiL) link layer emllSimulator. In this case no physical link layer is passed to the EC-Master. Instead the emllSimulator (SiL) simulates the physical network. The command line syntax is for example:

EcSimulatorSilDemo -simulator 1 1 <exi-file> -f <eni-file> -t 0 -sp

The EC-Simulator Instance ID when calling EC-Simulator APIs is the Link Layer Instance ID given at command line:

EcSimulatorSilDemo -simulator <Instance-ID> 1 exi.xml -f eni.xml -t 0 -sp

Valid values for Instance ID of emllSimulator are 1 … 24 .

emllSimulator is dynamically loaded within ecatInitMaster() . In contrast to HiL, in case of SiL, ecatInitMaster() automatically calls esInitSimulator(), so the EC-Simulator SiL application may not call esInitSimulator() for the given Instance ID.

The EC-Simulator APIs can be used in the EcMasterDemo, too. The APIs are declared in SDK\INC\EcSimulator.h and EcSimulator.lib / libEcSimulator.so must be linked to the application to import the EC-Simulator APIs.

The EC-Simulator SiL Protected version with MAC based protection needs the corresponding link layer settings provided.

2.9. EC-Simulator Software Development Kit (SDK)

The EC-Simulator SDK is needed to write applications based on the EC-Simulator stack. The EC-Simulator stack is shipped as a library which is linked together with the application.

The following components are supplied together with an SDK:

  • ….Bin: Executables containing the EC-Simulator stack

  • ….Doc: Documentation

  • ….Examples: Example application(s)

  • Libraries and header files to build C/C++-applications.
    • ….SDKINC: header files to be included with the application

    • ….SDKLIB: libraries to be linked with the application

  • ….SourcesCommon: Shared C++-files

For all operating systems the same principal rules to generate the example applications can be used.

Include search path

The header files are located in the following two directories:

  1. <InstallPath>Examples<ExampleName> (whith e.g. <ExampleName>=EcSimulatorHilDemo)

  2. <InstallPath>ExamplesCommon<OS> (where <OS> is a placeholder for the operating system)

  3. <InstallPath>ExamplesCommon

  4. <InstallPath>SDKINC<OS> (where <OS> is a placeholder for the operating system)

  5. <InstallPath>SDKINC

  6. <InstallPath>SourcesCommon

Preprocessor macro

The demo applicatons are the same for all operating systems. The appropriate pre-processor macro has to be set for the operating system.


The libraries located in <InstallPath>SDKLIB<OS><ARCH> have to be added (<OS> is a placeholder for the operating system used and <ARCH> for the architecture if different archtitectures are supported).

2.9.1. OS Compiler settings Linux Compiler settings

The following settings are necessary to build the example application for Linux.

  • Possible ARCHs (see ATECAT_ARCHSTR in SDK/INC/Linux/EcOsPlatform.h):

armv4t-eabi, armv6-vfp-eabihf, x64 (aka amd64), x86 (aka i686), PPC (with “-te500v2”)

armv4t-eabi and armv6-vfp-eabihf are incompatible with each other. A potentially armv6-vfp-eabihf-compatible system returns success on “readelf -A /proc/self/exe | grep Tag_ABI_VFP_args”. If “readelf” isn’t available on the target, the matching ARM version can be figured out by trying to run EcSimulatorHilDemo.

  • Extra include paths:

    <InstallPath>/Examples/EcSimulatorHilDemo <InstallPath>/SDK/INC/Linux <InstallPath>/SDK/INC <InstallPath>/Sources/Common

  • Extra source paths:

    <InstallPath>/Examples/EcSimulatorHilDemo <InstallPath>/Sources/Common/EcTimer.cpp

  • Extra library paths to the main EtherCAT components (replace “x86” according to ARCH):


  • Extra libraries (in this order)

    AtesRasSrv EcSimulator pthread dl rt Microsoft Windows

The following settings are necessary to build the example application for Windows:

  • Library path of the main EtherCAT components:


  • Include path:

    <InstallPath>/SDK/INC/Windows <InstallPath>/SDK/INC <InstallPath>/Sources/Common