Prepare EtherCAT SubDevice
Import and build EtherCAT SubDevice Simple-401 demo example project in CCS and flash the application binary onto AM263Px target.
TwinCAT Test Setup Overview
The test setup shall be as shown below.
TwinCAT Test Setup with AM263Px
Note: The EtherCAT SubDevice can be directly connected to PC with TwinCAT and scan the SubDevice and activate Free Run mode. In this case, the section Connect to Beckhoff PLC can be skipped and it is not possible to test the EtherCAT SubDevice in DC synchronous mode as described in the section Testing in DC Synchronization Mode.
TwinCAT3 Software Installation
- Install TwinCAT3 [Version 3.1 and Build 4024.68] on your PC. A 7 days free trial license is available for free download from the Beckhoff's software and tools website.
- Select the eXtended Automation Engineering (XAE) mode of installation.
- Copy the device description ESI file(s) from the installed Industrial Communication SDK for AM263Px target.
- From ind_comms_sdk_am263px_2025_00_XX/examples/industrial_comms/ethercat_subdevice_demo/device_profiles/401_simple/esi to the TwinCAT3 directory C:/TwinCAT/3.1/Config/Io/EtherCAT/
Copied ESI file to the TwinCAT folder
Create a New TwinCAT Project
- Launch the TwinCAT XAE Shell application.
Launch TwinCAT XAE
- Create a new TwinCAT XAE Project (XML format) by clicking on New TwinCAT Project... on the start page or by navigating through File -> New -> Project -> TwinCAT Projects.
Create a new TwinCAT Project
- Set a Name, for example TwinCAT Simple Demo, for a new TwinCAT project and click OK.
Name new project as 'TwinCAT Simple Demo'
- A new project named TwinCAT Simple Demo shall be created.
A new 'TwinCAT Simple Demo' project
Connect to the Beckhoff PLC
A PLC, for example Beckhoff C6015-0010, shall be connected to TwinCAT at first.
- Click on the SYSTEM in the Solution Explorer and click the button Choose Target. A popup window named Choose Target System shall appear.
Choose Target System
- Click on Search (Ethernet)... button. A popup window named Add Route Dialog shall appear.
- Enter the IP address of the Beckhoff PLC connected (in this case 192.168.0.100) and click on Enter Host Name /IP button. A detected PLC with the host name shall be listed.
- Make sure to check box Advanced Settings and the radio button IP Address is selected. Click on Add Route button.
Note: The IP address and the subnet on the PC network adapter must be also properly set.
Detected Beckhoff PLC
PC IP Address and Subnet
- A new popup window named Add Remote Route shall appear. Enter the Beckhoff PLC user login credentials and click OK.
Enter Beckhoff PLC Login Credentials
- Now a newly added target system shall be listed on Choose Target System window. Select the added target system and click OK.
Select Added Target System
- The Beckhoff PLC shall be now connected to TwinCAT.
PLC connected to TwinCAT
Setup a Network Interface Controller (NIC) in TwinCAT
- Navigate to TwinCAT -> Show Real Time Ethernet Compatible Devices....
Show Realtime Ethernet Compatible Devices
Note: For the best performance, it is recommended to use a compatible NIC card listed in Supported Network Controller by Beckhoff Ethernet Driver .
- Install TwinCAT realtime ethernet intermediate driver by clicking the Install button.
Install and enable selected realtime ethernet compatible device
- The ethernet adapter should be listed in the Installed and ready to use devices (realtime capable) before attempting to scan any EtherCAT SubDevice. Select the network device to be connected to the the development board and close the window.
Scanning EtherCAT SubDevice in TwinCAT
- In the Solution Explorer, navigate to TwinCAT Simple Demo -> I/O -> Devices. Right-click on Devices and click on Scan to scan the EtherCAT SubDevice/s connected.
Scan for EtherCAT SubDevice/s
- A popup dialog box with a hint shall appear. Click OK to start scanning for EtherCAT SubDevice/s.
Hint Window
- Once all EtherCAT compatible devices have been detected, the following window shall appear. Select the adapter to which the target board is connected and click OK.
Found I/O Device/s
- A popup window shall appear to get confirmation to start Scan for boxes. Click Yes
Scan for Boxes
- If a corresponding ESI file for a detected SubDevice is not found under C:/TwinCAT/3.1/Config/Io/EtherCAT/ then the following popup window shall appear with the details of the new found SubDevice/s. Click Yes.
Note: If this window appears then please check again the TwinCAT Software Installation steps.
New Device Type Found
- A newly detected EtherCAT SubDevice shall appear under TwinCAT Simple Demo -> I/O -> Devices and a dialog box shall appear to get confirmation to Activate Free Run. Click Yes to activate Free Run. This shall place the SubDevice into OP mode.
Activate Free Run
- The EtherCAT SubDevice shall be loaded into TwinCAT project with a name Box 1 (TI EtherCAT Toolkit for AM263PX.R5F).
- The EtherCAT SubDevice's current state can be found in the Online tab. Double click on the Box 1 (TI EtherCAT Toolkit for AM263PX.R5F) under Devices and navigate to Online tab.
EtherCAT SubDevice in OP Mode
Note: After activating Free Run, the SubDevice should be in the OP state with no Lost Frames or Tx/Rx Errors. If there are any errors then the details can be found in the Error List at the bottom.
- The user can control the Industrial Applications LEDs available on the target evaluation board using the RxPDO i2c-leds. Each LED can be turned ON/OFF by writing to PDO object i2c-leds with corresponding bit set/reset. Click on i2c-leds and select Online tab and click Write... button and update the values and click OK.
Writing to RxPDO 'i2c-leds'
Value updated in RxPDO 'i2c-leds'
Above steps are followed to test the EtherCAT SubDevice in Free Run Operation Mode. For testing EtherCAT SubDevice in Distributed Clock (DC) Synchronization mode, refer to the Testing EtherCAT SubDevice in DC Synchronization Mode section.
Testing EtherCAT SubDevice in DC Synchronization Mode
- Click on the Device 2 (EtherCAT) and navigate to EtherCAT tab. In Free Run mode, with a distributed clock (DC) disabled, the frames types LRD, LRW and BRD are exchanged.
Frames exchanged in Free Run Mode
- Navigate to the Adapter tab and observe Free Run cycle time. Users can adjust this Free Run cycle time if necessary. For a PC, choose a real time manageable value, e.g. 4ms.
Set Free Run Cycle Time
- If Free Run cycle time has been modified then click on the Reload Devices icon on the toolbar. Navigate to EtherCAT tab again and observe the new Free Run cycle time for the LRD, LRW and BRD frames.
Free Run Cycle Time
- Click on the SubDevice Box 1 (TI EtherCAT Toolkit for AM263PX.R5F) and navigate to the DC tab and set the operation mode as DC-Synchron mode. If there are many SubDevices in the chain then repeat this step for all the SubDevices.
Enable DC-Synchron Mode
- Click on the Device 2 (EtherCAT) and navigate to EtherCAT tab again. In Free Run mode, with a distributed clock (DC) enabled, additional frames types NOP and ARMW are exchanged. The frame ARMW is responsible for transferring the actual reference time.
DC releated Frames
- In the Solution Explorer, navigate to TwinCAT Simple Demo -> SYSTEM -> Real-Time. Click on the Settings tab, select the desired Base Time from the drop down. With compatible NIC cards, a base time of as low as 50us can be chosen.
Selecting a Base Time
- Navigate to TwinCAT Simple Demo -> SYSTEM and right-click on Tasks and click Add New Item on the pop-up menu.
Create a new Task
- In a popup window select TwinCAT Task With Image and provide a name for the task if required, and click OK to create a new task.
Rename a Task
- Navigate to TwinCAT Simple Demo -> SYSTEM -> Tasks -> Task 2 and click on Task tab and check Auto Priority Management and click OK on the popup window saying Global Priority Management should be turned on. Also, make sure that Auto start is checked.
Task Priority Management
- Adapt the Cycle ticks for the task Task 2 and shall be reflected as DC cycle time.
Set DC Cycle Time
- Add an output variable to the task Task 2. Navigate to TwinCAT Simple Demo -> SYSTEM -> Tasks -> Task 2 and right-click on Outputs and click Add New Item on the pop-up menu.
Create a Output Variable
- In the window Insert Variable, provide a variable name and select the data type and click OK. This variable will be linked to RxPDO i2c-leds hence a data type of USINT is chosen.
Rename Output Variable
- To link this variable to an output for the SubDevice, for example RxPDO i2c-leds, navigate to TwinCAT Simple Demo -> SYSTEM -> Tasks -> Task 2 -> Outputs and right-click on Var 34 and select Change Link....
Change Link of Output Variable
- Choose an output from the SubDevice. and click OK.
Link Output Variable to RxPDO
- Now, to activate the run mode with DC click the Activate Configuration button on the toolbar.
Launch Activate Configuration
- A popup window shall appear to confirm Activate Configuration for the current project. Select the added PLC as a Target and click OK.
Select target PLC for Activate Configuration
- Another popup window appears saying Restart TwinCAT System in Run Mode, click OK. This shall place the SubDevice into OP mode.
Restart TwinCAT System in Run Mode
- The EtherCAT SubDevice current state can be in the Online tab. Double click on the Box 1 (TI EtherCAT Toolkit for AM263PX.R5F) under Devices and navigate to Online tab.
EtherCAT SubDevice in OP Mode
Note: After activating Free Run, the SubDevice should be in the OP state with no Lost Frames or Tx/Rx Errors. If there are any errors then the details can be found in the Error List at the bottom.