The project "Simple demo" will be assumed for the steps described below.
Copy from the installed SDK the device description ESI file(s) :
YOUR_SDK_VERSION_DIRECTORY/source/industrial_comms/ethercat_slave/stack/esi/TI AM243X.R5F Simple
to the TwinCAT3 directory :
YOUR_TWINCAT_INSTALL_DIR/TwinCAT/3.1/Config/Io/EtherCAT
Start the TwinCAT XAE Shell application.
Set the Name and click on the button OK.
In case you are using a PLC then the TwinCAT shall connect first to it
Click on the button Choose Target
Click on Search (Ethernet)..
Type the IP address of the PLC, e.g. 192.168.0.12. And click on the Enter Host Name /IP
Note: The IP address and the subnet on the PC network adapter must be also properly set.
Choose the radio button IP Address. And click on the Add Route
Type login data for your PLC and click OK
Go to TwinCAT -> Show Real Time Ethernet Compatible Devices and Install TwinCAT RT Ethernet intermediate driver.
For the best performance, it is recommended to use a compatible NIC card listed in Supported Network Controller by Beckhoff Ethernet Driver .
Select the network device to be connected to the the development board and close the window
The ethernet adapter should be listed in the Installed and ready to use devices before attempting to scan the slave.
Note: If your computer go to sleep and after awake then the TwinCAT may loose a connection with slave(s) and/or may not be able to discover EtherCAT IO devices. You can fix this issue by going in the TwinCAT to your Ethernet adapters, and Disabling / Enabling your NIC.
In the Solution Explorer, go to TwinCAT project -> I/O -> Devices. Right click on Devices and select Scan. Press OK in the next dialog to start scanning for EtherCAT devices.
A dialog box with a hint will be shown.
Read a text and click on the button OK.
Once an EtherCAT compatible device has been detected, the following dialog shows up.
Note: There is a tick mark next to the adapter to which the target board is connected.
Press OK and confirm to start Scan for boxes.
A new device will be found. Press Yes
Note: If the related ESI file for a detected slave will not be found than please check again the TwinCAT Software Installation steps
A new detected EtherCAT slave will show up in the Device tree. And a dialog box will be shown to activate a free run.
The EtherCAT device state can be displayed by selecting a Device (Double click on Device) and then selecting the Online tab.
The user can control 4 digital output LEDs using the TwinCAT in the i2c-leds. Each LED can be turned on and off by selecting "Online write 1/2/4/8" and "Online write 0" respectively.
Above steps test the slave in Free Run Operation Mode. For testing a Distributed Clock (DC) Synchronization mode, refer to the Testing DC Synchronization mode section.
With a deactivated distributed clock (DC) these frames are exchanged LRD,LRW, ...
Click on the tab Adapter and set the cycle time. For the PC choose a real time manageable value, e.g. 4ms.
To see a new set cycle time value you need e.g. to go to one available slave and back.
There are now two additional frames at the beginning NOP, ARMW. In the second one is transferred an actual reference time.
In the Settings tab, choose the desired Base Time. With compatible NIC cards, a base time of as low as 50 us can be chosen.
Right-click on SYSTEM -> Tasks. Click Add New Item on the pop-up menu.
Select TwinCAT Image with Task in the next dialog box. Type a name for the task, and choose OK.
In the "Task" tab for the created task, select Auto Priority Management. Press OK in dialog box saying "Global Priority Management should be turned on".
Choose Auto start for the task. Choose 2 cycle ticks’ frequency for the task.
Add an output variable to the task. Right-click on [Task name] -> Outputs, and choose "Add New Item".
Link the variable to an output for the last slave in the chain. Right-click on [Variable name] and choose Change Link....
You can launch into Run mode by clicking the Activate Configuration button on the toolbar.