Configure EtherCAT Network with TwinCAT 3

To configure the EtherCAT® network using TwinCAT® 3, execute the following steps.

This procedure assumes that you are familiar with TwinCAT 3 and its documentation.

Before configuring the network, carry out the steps in Install TwinCAT 3.

Scan EtherCAT Network

The rest of this example assumes that your EtherCAT network consists of Beckhoff® EK1100, EL3062, and EL4002 modules connected in that order, followed by a terminator.

To scan an EtherCAT network with TwinCAT 3:

  1. Connect your EtherCAT network to the development computer Ethernet port dedicated to EtherCAT. Turn on the network.

  2. Start Microsoft® Visual Studio® and create a TwinCAT 3 project.

  3. In the TwinCAT menu, start the device scanner.

    The scanner reports that new I/O devices have been found.

  4. In the list of Ethernet devices that the scanner detects on the development computer, select the Ethernet device into which you plugged your EtherCAT network.

    If you do not see an Ethernet device identified as an EtherCAT device, check your EtherCAT network configuration and power supply.

  5. Scan for EtherCAT boxes on your network.

    The scanner reports the EtherCAT devices on your network.

  6. Disable free run mode.

  7. In your TwinCAT project, check that the scanner downloaded the required information about your EtherCAT devices.

Configure EtherCAT Master Node Data

Before configuring the master node of an EtherCAT network, scan the network with TwinCAT.

To configure the master node, execute the following steps.

Create EtherCAT Task

To create and configure an EtherCATtask:

  1. In TwinCAT 3, add an item to your system task list.

    Provide a name for the task, for example Task 1 and configure Task 1 as a task with image.

  2. In the task list, select Task 1 and set its cycle ticks value to a value in milliseconds, such as 10 for 10 milliseconds.

  3. Record the cycle tick in milliseconds.

    In the Model Configuration Parameters dialog box, use the cycle tick to calculate a value for the Fixed-step size (fundamental sample time) box. To allow Simulink® to calculate the sample time, select Auto.

Configure EtherCAT Task Inputs

To configure the task inputs:

  1. In TwinCAT 3, under Term 1, access the nodes Term 2 and AI Standard Channel 1.

  2. Drag the Value node of AI Standard Channel 1 to the Task 1 inputs.

  3. Configure the Term 1 inputs as variables.

  4. Link the AI Standard Channel 1 variable to Term 2.

Configure EtherCAT Task Outputs

To configure the task outputs:

  1. In TwinCAT 3, under Term 1, access the nodes Term 3 and AO Outputs Channel 1.

  2. Drag the Analog output node of AO Outputs Channel 1 to the Task 1 outputs.

  3. Configure the Term 1 analog outputs as variables.

  4. Link the Analog output variable to Term 3.

Configure EtherCAT Distributed Clocks

To configure the Term 3 distributed clock:

  1. In TwinCAT 3, under Term 3, access the DC tab.

  2. Change the DC operation mode to DC Synchron.

Export and Save EtherCAT Configuration with TwinCAT 3

The EtherCAT Network Information (ENI) file represents the master node of an EtherCAT network. To create the ENI file, scan and configure the network withTwinCAT 3.

To export the ENI file from TwinCAT 3, execute the following steps.

  1. Under the Device 1 (EtherCAT) node, in the EtherCAT tab, execute the command to export the configuration file.

  2. In the file save dialog box, enter an XML file name, such as BeckhoffAIOconfig.xml.


    The ENI file is formatted as an XML file, with the XML file extension. Building the real-time application produces an XML file with the same name as your model. To avoid a conflict, use an ENI file name that is different from the name of your model.

  3. Save the Microsoft Visual Studio TwinCAT project file.

    In the file save dialog box, enter an SLN file name, such as BeckhoffAIOconfig.

To review or modify your configuration, open the project SLN file using Microsoft Visual Studio. If you modify the configuration, save both the XML and SLN files.

The next task is Install EtherCAT Network for Execution.