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.
Real-time Ethernet Driver 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 Real-time Ethernet Drivers.
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. 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.
See also
EC_T_SIMULATOR_INIT_PARMS::apLinkParms
at esInitSimulator()
.
2.5. 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.6. Running EcSimulatorHilDemoGuiDotNet
EC-Simulator HiL for Windows contains an .NET example application, the EcSimulatorHilDemoGuiDotNet.
Selecting the appropriate network adapter and providing an EtherCAT Network Configuration file (ENI / EXI) is mandatory before clicking “Start” to run the EC-Simulator:

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,
See also
2.7.1. Setting up and running EcSimulatorHilDemo
2.7.1.1. Linux (EcSimulatorHilDemo)
Operating system configuration: See the section Operating system configuration for how to prepare the operating system
Starting EcSimulatorHilDemo
cd /opt/EC-Simulator/Bin/Linux/x64
LD_LIBRARY_PATH=. ./EcSimulatorHilDemo -f exi.xml -intelgbe 2 1 -perf
2.7.1.2. Microsoft Windows (EcSimulatorHilDemo)
Windows configuration: See the section Operating system configuration for how to prepare the operating system
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 192.168.157.2 0 will be using the network adapter card with the IP address 192.168.157.2 .
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.
Copy all of the example application files into one directory: The application EcSimulatorHilDemo.exe together with the stack DLL EcSimulator.dll, the Ethernet Driver DLL emllPcap.dll and the EXI file have to be copied into one directory.
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 Real-time Ethernet Driver settings.
EcSimulatorHilDemo.exe -ndis 192.168.157.2 0 -f exi.xml -t 0 -v 3
2.7.2. Command line parameters
- EcSimulatorHilDemo <LinkLayer> [-f ENI-FileName] [-t cycle time] [-b time] [-a affinity] [-v level] [-perf [level]] [-log prefix [msg cnt]] [-lic key] [-oem key] [-flash address] [-sp [port]] [-rec [prefix [frame cnt]]]
The parameters are as follows:
- -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
- -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.7.2.1. Link Layer
Using one of the following demo application Link Layer options, the EC-Simulator will dynamically load the network driver for the specified network adapter card and use the appropriate network driver to access the Ethernet adapter for EtherCAT©.
ShowSyntaxLinkLayer()
in Common/EcSelectLinkLayer.cpp
is called automatically if the Demo application is started without parameters and lists the possibilities.
Note
Not all link layers are available on all operating systems or architectures. A detailed view in the form of a matrix can be found in the developer center.
- -alteratse <instance> <mode>
- <instance>
Device instance 1 = first, 2 = second, …
- <mode>
0 = Interrupt mode | 1= Polling mode
- -bcmgenet <instance> <mode>
- Hardware: Broadcom BcmGenet
- <instance>
Device instance 1 = first, 2 = second, …
- <mode>
0 = Interrupt mode | 1 = Polling mode
- -bcmnetxtreme <instance> <mode>
- Hardware: Broadcom NetXtreme
- <instance>
Device instance 1 = first, 2 = second, …
- <mode>
0 = Interrupt mode | 1 = Polling mode
- -bpf <instance> <mode> <interface> [<prefix>]
- Hardware: Berkeley Packet Filter, Hardware independent
- <instance>
BPF instance (0=first), results to e.g. /dev/bpf0
- <mode>
0 = Interrupt mode | 1 = Polling mode
- <interface>
Name of Ethernet Interface, e.g. wm0
- Optional:
- <prefix>
Prefix of the BPF instance path, e.g. /alt
- -ccat <instance> <mode>
- Hardware: Beckhoff CCAT
- <instance>
Device instance 1 = first, 2 = second, …
- <mode>
0 = Interrupt mode | 1= Polling mode
- -cpsw <instance> <mode> <portpriority> <masterflag> <refboard>
- Hardware: TI CPSW
- <instance>
Device instance 1 = first, 2 = second, …
- <mode>
0 = Interrupt mode, 1 = Polling mode
- <portpriority>
Low priority (0) or high priority (1)
- <masterflag>
Master (Initialize Switch), (s) Slave
- <RefBoard>
bone | am3359-icev2 | am437x-idk | am572x-idk | 387X_evm | custom | osdriver
- If custom:
- <CpswType>
am33XX | am437X | am57X | am387X
- <PhyAddress>
0 … 31
- <PhyInterface>
rmii | gmii | rgmii | osdriver
- <NotUseDmaBuffers>
0 = FALSE | 1 = TRUE
- -dpdk <instance> <mode> <port>
- Hardware: Hardware independent, only available for Linux (including the NXP DPAA).
- <instance>
Device instance 1 = first, 2 = second, …
- <mode>
0 = Interrupt mode (not implemented), 1 = Polling mode
- <port>
DPDK port ID, e.g. 0
This option supports a large variety of NICs. Whether a NIC is supported depends on its network driver. For a list of supported network drivers see https://www.dpdk.org.
- -dw3504 <instance> <mode> <RefBoard>
- Hardware: Synopsys DesignWare 3504-0 Universal 10/100/1000 Ethernet MAC (DW3504)
- <instance>
Device instance 1 = first, 2 = second, …
- <mode>
0 = Interrupt mode | 1 = Polling mode
- <RefBoard>
Reference Board: intel_atom | lces1 | rd55up06 | r12ccpu | rzn1 | socrates | stm32mp157a-dk1 | custom
- If custom:
- <DW3504Type>
intel_atom | cycloneV | lces1 | stm32mp157a-dk1
- <PhyInterface>
fixed | mii | rmii | gmii | sgmii | rgmii | osdriver
- <PhyAddress>
0 … 31 (don’t use if osdriver)
- -eg20t <instance> <mode>
- Hardware: Intel EG20T Gigabit Ethernet Controller
- <instance>
Device instance 1 = first, 2 = second, …
- <mode>
0 = Interrupt mode | 1 = Polling mode
- -emac <instance> <mode> <refboard>
- Hardware: Xilinx LogiCORE IP XPS EMAC
- <instance>
Device instance 1 = first, 2 = second, …
- <mode>
0 = Interrupt mode | 1 = Polling mode
- <RefBoard>
MC2002E | custom
- If custom:
- <RegisterBase>
Register base address as hex value
- <RegisterLength>
Register length as hex value
- <NotUseDmaBuffers>
0 = FALSE | 1 = TRUE
- -fsletsec <instance> <mode> <refboard>
- Hardware: Freescale TSEC / eTSEC V1 / eTSEC V2 (VeTSEC)
- <instance>
Device instance 1 = first, 2 = second, …
- <mode>
0 = Interrupt mode | 1 = Polling mode
- <RefBoard>
p2020rdb | twrp1025 | istmpc8548 | xj_epu20c | twrls1021a | tqmls_ls102xa | custom
- If custom:
- <PhyAddress>
0 … 31
- <RxIrq>
Default depending on ETSEC type
- <NotUseDmaBuffers>
0 = FALSE | 1 = TRUE
- -fslfec <instance> <mode> <refboard> [nopinmuxing] [nomacaddr]
- Hardware: Freescale FEC/ENET
- <instance>
Device instance 1 = first, 2 = second, …
- <mode>
0 = Interrupt mode | 1 = Polling mode
- <RefBoard>
mars | sabrelite | sabresd | imx28evk | topaz | imxceetul2 | mimxrt1064-evk | imx93evk | custom
- If custom:
- <FecType>
imx25 | imx28 | imx53 | imx6 | vf6 | imx7 | imx8 | imx8m | imxrt1064 | imx9
- <PhyInterface>
fixed | mii | rmii | rmii50Mhz | gmii | sgmii | rgmii | osdriver
- <PhyAddress>
0 … 31, default 0 (don’t use if osdriver)
- Optional:
- nopinmuxing
no pin muxing
- Optional:
- nomacaddr
don’t read MAC address
- -gem <instance> <mode> <refboard> [osdriver] [clkdivtype_k26] [nopinmuxing]
- Hardware: Xilinx Zynq-7000/Ultrascale (GEM)
- <instance>
Device instance for GEM, 1 = GEM0,…
- <mode>
0 = Interrupt mode | 1 = Polling mode
- <RefBoard>
zc702 | zedboard | microzed | zcu102 | zcu104 | KR260 | custom
- If custom:
- <PhyAddress>
0 … 31
- <PhyConnectionMode>
MIO (0) or EMIO (1)
- <UseGmiiToRgmii>
Use Xilinx GmiiToRgmii converter TRUE (1) or FALSE (0)
- <GmiiToRgmiiPort>
GmiiToRgmii converter PHY address 0 … 31
- <GemType>
zynq7000 or ultrascale
- Optional:
- osdriver
PhyInterface osdriver
- Optional:
- clkdivtype_k26
Clock divisor
- Optional:
- nopinmuxing
Don’t use pin muxing
- -intelgbe <instance> <mode> [tts <SendOffset>|tmr] [--nophyctrlonconnect]
- Hardware: Intel Pro/1000 network adapter card
- <instance>
Device instance 1 = first, 2 = second, …
- <mode>
0 = Interrupt mode | 1 = Polling mode
- Optional:
- tts
Enables Real-time Ethernet Driver Time Triggered Send (TTS)
- <SendOffset>
TTS cyclic frame send offset from cycle start (usec)
- Optional:
- tmr
Enables Real-time Ethernet Driver Timer
- Optional:
- --nophyctrlonconnect
Disable PHY control (e.g. PHY reset, PHY PM settings, Gbits Ctrl) on link connection detected
- -i8255x <instance> <mode>
- Hardware: Intel Pro/100 network adapter card
- <instance>
Device instance 1 = first, 2 = second, …
- <mode>
0 = Interrupt mode | 1 = Polling mode
- -icss <instance> <mode> <masterflag> <refboard> [<PhyInterface> <PhyAddress>] [nophyreset] [tts <SendOffset>]
- Hardware: Texas Instruments Board with PRUSS
- <instance>
ICSS Port (100 Mbit/s) 1 … 4
- <mode>
0 = Interrupt mode | 1 = Polling mode
- <MasterFlag>
Master (Initialize board, mdio, both phy) or (s) Slave
- <RefBoard>
am572x-idk | am571x-idk | am3359-icev2 | am574x
- Optional:
- <PhyInterface>
mii | osdriver
- <PhyAddress>
0 … 31 (only for mii)
- Optional:
- nophyreset
NoPhyReset
- Optional:
- tts
Enables Real-time Ethernet Driver Time Triggered Send (TTS)
- <SendOffset>
TTS cyclic frame send offset from cycle start (usec)
- -icssg <instance> <mode> <masterflag> <refboard>
- Hardware: Texas Instruments AARCH64 Board with Gigabit PRUSS
- <instance>
ICSSG Port 1 … 6
- <mode>
0 = Interrupt mode | 1 = Polling mode
- <MasterFlag>
Master (Initialize board, mdio, both phy) or (s) Slave
- <RefBoard>
am654x-idk
- -l9218i <instance> <mode>
- Hardware: SMSC LAN9218i/LAN9221
- <instance>
Device instance 1 = first, 2 = second, …
- <mode>
0 = Interrupt mode | 1 = Polling mode
- -lan743x <instance> <mode>
- Hardware: Microchip LAN743x
- <instance>
Device instance 1 = first, 2 = second, …
- <mode>
1= Polling mode
- -ndis <IpAddress> <mode> [--name <AdapterName>] [DisablePromiscuousMode] [DisableForceBroadcast]
- Hardware: Hardware independent, only available for Windows.
- <IpAddress>
IP address of network adapter card, e.g. 192.168.157.2 or 0.0.0.0 if name given
- <mode>
0 = Interrupt mode | 1 = Polling mode
- Optional:
- --name
Select network adapter by name
- <AdapterName>
Service name from HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards
- Optional:
- DisablePromiscuousMode
Disable promiscuous mode
- Optional:
- DisableForceBroadcast
- -multiplier <instance> <mode> [--type <type>] --port <port> --link <link parms>
- Hardware: Beckhoff CUxxxx Ethernet-Port-Multiplier
- <instance>
Device instance 1 = first, 2 = second, …
- <mode>
0 = Interrupt mode | 1 = Polling mode, for now only polling mode is supported
- <port>
used CU2508 downlink port 0 = X1, 1 = X2, …
- <link parms>
link parms of network adapter connected to the uplink port e.g. -intelgbe …
- Optional:
- <type>
cu2508 = CU2508 Ethernet-Port-Multiplier
- -r6040 <instance> <mode>
- Hardware: RDC R6040
- <instance>
Device instance 1 = first, 2 = second, …
- <mode>
1 = Polling mode
- -rin32m3 <instance> <mode>
- Hardware: Renesas R-IN32M3-EC
- <instance>
Device instance 1 = first, 2 = second, …
- <mode>
1 = Polling mode
- -rtl8139 <instance> <mode>
- Hardware: Realtek RTL8139
- <instance>
Device instance 1 = first, 2 = second, …
- <mode>
0 = Interrupt mode | 1 = Polling mode
- -rtl8169 <instance> <mode>
- Hardware: Realtek RTL8168 / RTL8169 / RTL8111
- <instance>
Device instance 1 = first, 2 = second, …
- <mode>
0 = Interrupt mode | 1 = Polling mode
- -sheth <instance> <mode> <RefBoard>
- Hardware: Renesas RZG1 or Armadillo-800 EVA
- <instance>
Device instance 1 = first, 2 = second, …
- <mode>
1 = Polling mode
- <RefBoard>
rzg1e | a800eva
- -snarf <adapterName>
- Hardware: Hardware independent, only available for VxWorks
- <adapterName>
Adapter name, e.g. fei0
- -sockraw <device> [<mode>] [--nommaprx] [--promiscuousmode]
- Hardware: Hardware independent, only available for Linux.
- <device>
Network device, e.g. eth1
- Optional:
- <mode>
0 = Interrupt mode | 1 = Polling mode
- Optional:
- --nommaprx
Disable PACKET_MMAP for receive
- Optional:
- --promiscuousmode
Enable promiscuous mode
- -sockxdp <instance> <mode> [queue] [xdpmode]
- Hardware: Hardware independent, only available for Linux.
- <device>
Network device, e.g. eth1
- <mode>
0 = Interrupt mode | 1 = Polling mode
- Optional:
- <queue>
Queue Id, e.g. 0
- Optional:
- <xdpmode>
1 = SKB | 2 = DRV | 3 = HW | 4 = DRV_ZEROCOPY
- -stm32eth <instance> <mode>
- Hardware: STM32H7 Ethernet
- <instance>
Device instance 1=first, 2=second, …
- <mode>
1 = Polling mode
2.8. 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.
….\SDK\INC: header files to be included with the application
….\SDK\LIB: libraries to be linked with the application
….\Sources\Common: 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:
<InstallPath>\Examples\<ExampleName> (whith e.g. <ExampleName>=EcSimulatorHilDemo)
<InstallPath>\Examples\Common\<OS> (where <OS> is a placeholder for the operating system)
<InstallPath>\Examples\Common
<InstallPath>\SDK\INC\<OS> (where <OS> is a placeholder for the operating system)
<InstallPath>\SDK\INC
<InstallPath>\Sources\Common
Preprocessor macro
The demo applications are the same for all operating systems. The appropriate pre-processor macro has to be set for the operating system.
See also
Libraries
The libraries located in <InstallPath>\SDK\LIB\<OS>\<ARCH> have to be added (<OS> is a placeholder for the operating system used and <ARCH> for the architecture if different architectures are supported).
2.8.1. OS Compiler settings
2.8.1.1. 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
):
aarch64 (ARM 64Bit), armv4t-eabi (ARM 32Bit), armv6-vfp-eabihf (ARM 32Bit), armv7-vfp-eabihf (ARM 32Bit), PPC (PPC 32Bit with “-te500v2”), riscv64 (RISC-V 64Bit), x64 (x86 64Bit), x86 (x86 32Bit)
The ARM 32Bit architectures armv4t-eabi and armv6-vfp-eabihf/armv7-vfp-eabihf are incompatible with each other. An ARM VFP 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):
<InstallPath>/SDK/LIB/Linux/x86
- Extra libraries (in this order)
EcSimulatorRasServer EcSimulator pthread dl rt
2.8.1.2. Microsoft Windows
The following settings are necessary to build the example application for Windows:
- Library path of the main EtherCAT components:
<InstallPath>/SDK/LIB/Windows/<Arch>
- Include path:
<InstallPath>/SDK/INC/Windows <InstallPath>/SDK/INC <InstallPath>/Sources/Common
2.9. Real-time Ethernet Driver configuration for EcSimulatorHilDemo
The different Real-time Ethernet Driver modules are selected and parametered by a common structure (shared by all Real-time Ethernet Driver) and a Real-time Ethernet Driver specific structure, pointed to by an element within the common structure. This parameter set is given to the EC-Simulator stack with the call of esInitSimulator()
.
See also