Procedure to communicate over EtherCAT with an EtherCAT master in TwinCAT
Introduction
This guide will describe how to configure an EtherCAT master in TwinCAT to get live data from a Q.series controller (i.e. Q.station 101 or Q.station X EC) or the Q.series EtherCAT slave modules through a bus coupler (Q.series XE, Q.bloxx EC).
This has been tested with TwinCAT 2, as well as with TwinCAT 3 versions (integrated into Microsoft Visual Studio):
-
V3.1.4016.0
-
V3.1.4018.4
-
V3.1.4018.26
-
>= V3.1.4020.0 → running on Windows 10
Download
You can download TwinCAT directly from the Beckhoff website
Setup
- Install TwinCAT software to PC with EtherCAT compatible network interface card (NIC)
- Connect Ethernet cable from PC to EtherCAT IN port on Gantner controller or bus coupler. Please make sure, that the Fieldbus Interface of the Controller is set to EtherCAT.
- Copy configuration (ESI) file from Gantner software directory to TwinCAT directory
- GI.bench: C:\Users\Public\Documents\Gantner Instruments\GI.bench\additionals\EtherCAT\Gantner Instruments.xml
- test.commander: C:\Users\Public\Documents\Gantner Instruments\test.commander\Additionals\EtherCAT\Gantner Instruments.xml
- TwinCAT 2: C:\Program Files\TwinCAT\Io\EtherCAT
- TwinCAT 3: C:\TwinCAT\3.1\Config\Io\EtherCAT
Network Adapter
TwinCAT does not support all Ethernet cards in the PC as an EtherCAT master. It has to be an Intel chip, as that is the only chipset that Beckhoff supports. A list of Beckhoff EtherCAT compatible cards can be found here:
Support Network Controllers by Beckhoff
The Device-ID of a network adapter can be found in the properties of the device in “Details” → “Hardware Ids”:
After creating a new TwinCAT-Project in MS-Visual Studio, check if a TwinCAT compatible RT-Ethernet Adapter is installed. You can do this in the menu “TwinCAT → Show Real Time Ethernet Compatible Devices…”.
In the next window, at least one Ethernet Adapter has to appear in the section Installed and ready to use devices!
It might be necessary to change the following settings in BIOS:
-
Turn off Hyper-Threading (Intel Core-i7 specifically)
-
Turn on Intel Virtualization Technology Extensions (VT-x), which is required for the 64-bit version of TwinCAT 3
Stream Data
Scan Bus
Open a new TwinCAT project and right-click on I/O Devices. Select the network device (checkbox on EtherCAT), allow Scan for boxes, and Activate Free Run.
At I/O Devices a new device is created and set to OPERATIONAL. You can already see channel data by selecting a device:
Run Mode
After the Master is configured as described above, an additional task has to be created (see screenshot), and “Auto start” has to be activated, to set TwinCAT from “free run” into “run” mode.
Input Variables can be inserted (for example xxxx and yyyy) by right-clicking on Inputs. These variables must be configured accordingly to the desired controller variable with the corresponding data type. This variable can then be linked to a controller variable by clicking on the “Linked to…” - button.
To activate the Configuration and to switch to Run-Mode, click on the “Activate configuration” - button in the speed button bar.
Configuration
GI.bench (Bus Coupler)
The GI.bench full software features the ability to communicate with the TwinCAT master over FoE for the configuration of the DAQ system.
This is only possible with a bus coupler (e.g. Q.bloxx XE BC, Q.bloxx EC BC)
- With a fully licensed GI.bench click Import > TwinCAT master. If not running already, this should automatically start the TwinCAT service (GI.twincatfoe).
- Enter the NetID from the TwinCAT master. If connected directly to the system you can leave it blank for local service
- The configuration of the connected measurement modules will load into the GI.bench project window. The bus coupler will just appear as a virtual device
- Configure the modules and channels as needed
- To download the changes to the modules click Export > TwinCAT master. This exports the configuration directly to the TwinCAT master to be transferred to the modules
ICP 100 (bus coupler)
The bus coupler can be connected to the PC through its USB port for serial communication to configure the modules
- Connect a cable from the bus coupler's Micro USB port to the PC
- Take note of the COM port used on the PC for this connection
- Run ICP-100 software
- Go to Communication > Parameters. Change Interface Kind to RS232 Direct and select corresponding ComPort. Click OK.
- Go to File > Scan Bus to scan for connected hardware
- Select from the drop-down list the connected modules
- The module configuration will be loaded, and make required changes
- Go to File > Send to Module to download the configuration to the hardware
- Repeat steps 6 through 8 for any other connected module
GI.bench (Q.station)
Communication for configuration is done through the Ethernet port to the PC to the software
- Click Read and scan the network for the connected controller and click OK
- After configuration is loaded into the project window, make the required configuration changes
- Click Write to download the configuration to the hardware
- Rescan configuration in TwinCAT to show changes