This example shows how to generate EtherCAT network information (ENI) files to use in Simulink Real-Time with EtherCAT devices.
The example shows the generation process steps in EtherCAT Configurator and the process steps in the TwinCAT XAE plugin for Microsoft Visual Studio®.
The hardware connections are:
EK1100 -- EtherCAT coupler
EL3062 -- EtherCAT terminal
EL4002 -- EtherCAT terminal
EL9011 -- Bus End terminal
The EK1100 coupler connects EtherCAT with the EtherCAT terminals (ELxxxx). One station consists of an EK1100 coupler, any number of EtherCAT terminals, and a bus end terminal.
To provide power connections, connect the 24 V and 0 V terminals of the EK1100 to a 24 V regulated power supply (RPS) +Ve and -Ve terminals.
The EL3062 analog input terminal processes signals in the range of 0-10 V. The voltage is digitized to a resolution of 12 bits and is transmitted.
The EL4002 analog output terminal generates signals in the range of 0 and 10 V.
To configure the EtherCAT network, connect the EtherCAT devices to the development computer on which the EtherCAT configurator is running. This connection permits scanning and discovery of the EtherCAT devices. After the configurator generates the XML file, you can reconnect the EtherCAT devices to the target computer. This diagram shows the suggested connections.
To install the EtherCAT configurator ET9000:
Go to https://www.beckhoff.com/ and select Download.
Select ET9000 and download the setup.
Install the ET9000 configurator and start the software.
Run the configurator and select the correct license keys or select the evaluation option.
The EtherCAT configurator creates an EtherCAT network information (ENI) file from the standardized slave description files (ESI - EtherCAT slave information). To generate the ESI files for the slaves:
Start the ET9000 software.
Right-click I/O Devices and select Scan Devices. Click OK.
Select the correct network interface card (NIC) in your system and click OK.
When the dialog box asks whether to scan for boxes, select Yes. As the EtherCAT devices in your network are scanned, they appear in the System Pane.
When the dialog box asks whether to activate free run mode, select No.
When the scan is complete, expand the Device Hierarchy under I/O Devices in the System Pane. The EL3062 and the EL4002 devices appear under the EK1100 device.
The configurator uses the ESI to configure the EtherCAT master node. This operation includes creating a task, configuring the task, and adding the I/O to the task.
To create an EtherCAT task:
Under SYSTEM - Configuration, right-click Additional Tasks > Append Task.
Provide a name for the task and click OK. In this example, the name of the task is
Click the task. The value Cycle Ticks determines the cycle time. In the settings, it is set to
To configure an EtherCAT task outputs:
Click and drag the node Analog output (under AO Outputs Channel 1) to Outputs (under
Select Analog output (under Outputs) and select the Variable tab.
Click the Linked to button and select the corresponding entry (Analog Output under AO Outputs Channel 1 under Term 3).
By using distributed clocks (DC), the EtherCAT real-time Ethernet protocol can synchronize the time in all local bus devices within a narrow tolerance range. Only some EtherCAT devices support DC. When the device supports DC, it is important to configure a device for DC. For example, in the example configuration, the EL4002 supports DC. To configure the EL4002 for DC:
Click Term 3 (EL4002) in the System Pane and select the DC tab. By default, the Operation Mode is set to SM-Synchron. Change Operation Mode to DC-Synchron.
Click the Advanced Settings button and set the Distributed Clock options as shown.
Device import is often part of the workflow for third-party (different manufacturer) devices. Use this process to configure a device that is not present in the Beckhoff system. Numerous motors and their drives fall under this category. Sometimes, you must configure a device that is not present in the Beckhoff system. The TwinCAT EtherCAT master or System Manager uses the device description files for the devices to generate the configuration in online or offline mode.
The device descriptions are contained in ESI files (EtherCAT Slave Information) in XML format. These files can be requested from the respective manufacturer and are made available for download. An XML file can contain several device descriptions.
The ESI files for Beckhoff EtherCAT devices are available on the Beckhoff website and are stored in the TwinCAT installation folder. The default for TwinCAT2 is
C:\TwinCAT\IO\EtherCAT. The files are read (once) when you open a new System Manager window and if they have changed since the last time that you opened the System Manager window.
If using a TwinCAT configurator, the TwinCAT installation includes the set of Beckhoff ESI files which were current at the time when the TwinCAT build was created. For TwinCAT 2.11, TwinCAT 3, and later, you can update the ESI folder from the System Manager if the programming PC is connected to the Internet (Option > Update EtherCAT Device Descriptions).
To import a device from an ESI file:
For the ET9000 Configurator, the ESI folder is
C:\Program Files (x86)\EtherCAT Configurator\EtherCAT. Paste the file from the manufacturer into this location.
After adding the XML file, restart your configurator and select Actions > Reload Devices.
If the device is connected, you can scan again to add the devices. (See Install and Apply Beckhoff EtherCAT Configurator ET9000.)
If the device is not connected, you can also add the device in Offline mode. If you want to add the device to the same term, right-click your device in the hierarchy and select Append Box. A dialog box appears asking which device to add.
Click the square icon next to Beckhoff Automation GmbH to collapse the hierarchy. You now see the manufacturer whose devices you added.
Select the device that you want to add and click OK. Your device should now appear in the System Pane on the left.
Repeat the steps under Configure EtherCAT Master Node Data to add the Outputs to your task. In this example, drag the available outputs under your drive to Outputs under
slrt_task. Remember to make the appropriate DC Configurations for your device.
DC configuration information is available from the manufacturer. In this case, enable DC.
Continue with configuration of the terminals.
To generate the ENI file and save the configuration:
Click the node for your EtherCAT device, then click the EtherCAT tab.
Click Export Configuration File.
In the file save dialog box, enter an XML file name, such as
BeckhoffAIOconfig.xml for this example, and then click Save. This XML file is the ENI file. The ENI file and the Simulink® Real-Time™ model that uses the ENI file cannot have the same name. They must have different names.
Save the configuration as an ESM file. Click File > Save. If the ESM file corresponding to the ENI file is not present, the Beckhoff ET9000 program cannot open the ENI file.
In the File Save dialog box, enter an ESM file name, such as
et9000config.esm, and then click Save.
When you install TwinCAT 3.1 eXtended Automation Engineering (XAE), you can use the integration of this software with Microsoft Visual Studio to program automation objects with IEC 61131-3 and C/C++ languages.
To install the TwinCAT 3.1 XAE:
Go to https://www.beckhoff.com/ and select Download.
Select TwinCAT 3 and download the setup.
Install TwinCAT 3 and start Microsoft Visual Studio.
From the TwinCAT menu, select Show Realtime Ethernet Compatible Devices.
Select the Ethernet adapter for your EtherCAT device, then select Install.
To open a new TwinCAT project in Visual Studio:
Start Visual Studio. Go to File > New > Project.
Under Templates, select TwinCAT Project.
Verify whether the project has been created successfully in the status bar of Microsoft Visual Studio.
Enter your license if this instance is the first time that you are using TwinCAT. If you are using TwinCAT in evaluation mode, fill in the Captcha.
Observe the Solution Explorer pane the right side of Visual Studio.
Go to TWINCAT in the menu and select Scan. You can also right click Solution Explorer > your TwinCAT project > I/O > Devices > Scan.
A dialog box opens with the message All devices may not automatically be found. Click OK and wait for the scan to complete. You now see a dialog box saying New I/O devices have been found.
Ensure that the check box is selected, then click OK. A dialog box appears with a Scan for boxes? message. Click Yes. The EtherCAT devices in your network are scanned, and the devices appear.
You see a dialog box that asks whether to activate free run mode. Select No.
Observe the Solution Explorer and verify that the devices were scanned correctly.
To configure the EtherCAT master node, create and configure a task, then add the inputs and outputs to the task.
To create an EtherCAT Task:
In the Solution Explorer, right-click the Task node.
In the Insert Task dialog box, select TwinCAT Task With Image, provide a name for the task, and click OK.
Double-click the task that you created. The value Cycle Ticks determines the cycle time. In this example, it is set to 10 ms.
Create at least one cyclic input/output task. Link this task to at least one input channel and one output channel on each slave device.
By using distributed clocks (DC), the EtherCAT real-time Ethernet protocol can synchronize the time in all local bus devices within a narrow tolerance range. Only some EtherCAT devices support DC. It is important that if a device supports DC, you configured it accordingly. For example, in the example configuration, the EL4002 supports DC.
To configure EtherCAT DC:
Double-click the node Term 3 (EL4002) and select the DC tab.
By default, the Operation Mode is set to SM-Synchron. Change the Operation Mode to DC-Synchron.
Click Advanced Settings and set the Distributed Clock options as shown.
To export and save the EtherCAT configuration, generate the ENI file:
Double-click the node for your EtherCAT device and click the EtherCAT tab.
Click Export Configuration File.
In the Save As dialog box, enter an XML file name, such as
twincatconfig.xml, then click Save. This XML file is the ENI file. The ENI file and the Simulink® Real-Time™ model that uses the ENI file cannot have the same name. They must have different names.
If the Solution file corresponding to the ENI file is not saved, the TwinCat XAE program cannot open the ENI XML file. Save the Solution file as an archive (zip file). Select File > Save Project As Archive.
In the Save As dialog box, enter an ESM file name, such as
twincatproject, and click Save. The project is saved as a