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.
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.
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.
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.
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.
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).
The EcSimulatorHilDemo is an EC-Simulator example application that handles the following tasks:
Showing basic EtherCAT communication
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,
Operating system configuration: See the section Operating system configuration for how to prepare the operating system
cd /opt/EC-Simulator/Bin/Linux/x64 LD_LIBRARY_PATH=. ./EcSimulatorHilDemo -f exi.xml -i8254x 2 1 -perf
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 link-layer 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 Link Layer settings.
EcSimulatorHilDemo.exe -ndis 192.168.157.2 0 -f exi.xml -t 0 -v 3
- 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]] [-auxclk period] [-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 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.
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.
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).
Depending on level the performance histogram can be activated as well.
- -log <prefix> [<msg cnt>]
Use given file name prefix for log files.
- <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.
RAS server port
- -auxclk <period>
Use auxiliary clock
Clock period in µs (if supported by Operating System).
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 exi.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.
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
….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:
<InstallPath>Examples<ExampleName> (whith e.g. <ExampleName>=EcSimulatorHilDemo)
<InstallPath>ExamplesCommon<OS> (where <OS> is a placeholder for the operating system)
<InstallPath>SDKINC<OS> (where <OS> is a placeholder for the operating system)
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).
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:
- Extra library paths to the main EtherCAT components (replace “x86” according to ARCH):
- Extra libraries (in this order)
AtesRasSrv EcSimulator pthread dl rt
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