Please note as of Wednesday, August 15th, 2018 this wiki has been set to read only. If you are a TI Employee and require Edit ability please contact x0211426 from the company directory.

Configuring TwinCAT For AM335x

From Texas Instruments Wiki
Jump to: navigation, search

Configuring TwinCAT For AM335x


This article describes how TwinCAT software running on a PC can be used to control AM335x based EtherCAT slave controller, and monitor inputs from it. TwinCAT is a software system from BeckHoff which turns almost any compatible PC into a real-time controller with a multi-PLC system. TwinCAT can be used to control the digital ouputs and monitor the digital inputs on AM335x over EtherCAT. There are eight digital LED's on AM335x IDK/ICE which represents eight digital outputs; there are eight pairs of jumper pins respresenting eight digital inputs.

Configuring TwinCAT For AM335x

1. Install TwinCAT (One month evaluation is available for free download from Beckhoff website - select PLC mode of installation and check IO drivers box. TwinCAT works best on 32 bit Windows XP/Vista machines.

2. Copy sdk\protcols\ethercat\ecat_appl\esi\TI_ESC.xml and sdk\examples\ethercat\esi\TiEtherCATLib.xml to <Drive>:\TwinCAT\Io\EtherCAT folder

3. Start TwinCAT system manager

4. Goto Options > Show Real Time Ethernet Compatible Devices and Install TwinCAT RT Ethernet intermediate driver. For best performance - it is recommended to use compatible NIC card listed here, If the network interface is listed as incompatible device, you can still proceed by installing the driver, enabling it and use TwinCAT.

TC pic0.JPG

TC pic1.JPG

5. Goto I/O - Configuration > I/O Devices - right click and select Append device and then select EtherCAT > EtherCAT. Device1 (EtherCAT) will be added to I/O devices

Append device.JPG

Append device2.JPG

6. Connect CAT5 Ethernet cable from TwinCAT PC to ECAT IN/Port0(J8 of IDK, J2 of ICE) . If you have multiple ICE/IDKs in chain, please connect from ECAT OUT/Port1 (J9 of IDK, J3 of ICE) to Port0 of next ICE/IDK.

7. Now right click Device1(EtherCAT)> select Scan Boxes.

Scan box.JPG

8. Or to scan a device right click on 'I/O Devices' and Select 'Scan Devices'. A dialog box will appear for 'Scan for boxes'. Select Yes.

Scan device.JPG

TC pic3.JPG

9. TI Boxn(ti-esc) (full application) or Box n(TIESC-00m) (demo application) will be detected automatically.
10. Now select Device1 (EtherCAT) and goto Actions > Select Set/Reset TwinCAT to Config Mode or use shortcut SHIFT-F4
11. A dialog will pop asking Load I/O Devices, select Yes
12. Next dialog asks confirmation to Activate Free Run - select Yes. This will put the Slave into OP mode

TC pic4.JPG

TC pic5.JPG

Activate free run.JPG

Demo device expanded.JPG

Controlling Digital LED's On AM335x (running Full application) Using TwinCAT

1. Now user can control digital out leds using TwinCAT. Select TI Boxn(ti-esc)>DO Outputs > LED1-8 to control the output LEDs .

TC led1.JPG

2. To turn an LED on/off right click on the LED, select 'Online Write' and enter the value 1/0.

TC led2.JPG

TC led3.JPG

Controlling Digital LED's On AM335x (running Demo application) Using TwinCat

1. Now user can control digital out leds using TwinCAT. Select Boxn(TI-ESC)>RxPDO >32Bit Output to control the output LEDs .

TI Demo Box.JPG
2. To turn an LED on/off right click on the 32Bit Output, select 'Online Write' and enter the value 1/2/4 etc to turn on the first second or third LED. A value of 0xFF would turn all LEDs on and 0x0 would turn all of them off.

Online write.JPG

Write value.JPG

Monitoring Digital Inputs on AM335x Using TwinCAT

1. There are jumper pins marked J9 (ICE) and J15 (IDK) on the AM335x board next to the digital output LEDs. The last 8 of them (adjacent to resistors) can be used to supply Digital Inputs.

2. If you are running the Demo application, go to Box (TIESC-001) > TXPDO > 32Bit Input. If you are running the Full application, go to TI Box (ti-esc) > DI Inputs > Switch n. Open the Online Tab.

Digital input demo.JPG

Digital input full.JPG
3. In the Demo version, placing jumpers across the Digital Input pins sets bits in the LSB of the Value. Placing a jumper across the first pair of pins will set the least significant bit (bit 0), placing a jumper across the second pair of pins will set bit 1, and so on. In the full version, placing a jumper across the first pair of pins will set Switch 1, placing a jumper across the second pair of pins will set Switch 2, and so on. The value can be read by choosing the appropriate switch, and opening the online tab.

4. The following reading will be obtained with jumper placed across the sixth pair of pins.

Digital input capture.JPG

Online Application upgrade from TwinCAT

TI PRU-ICSS EtherCAT Slave running on supported platforms can be upgraded online using FoE.

      To use this feature from TwinCAT, EtherCAT Slave Information (ESI) file needs to be updated to have the FoE feature enabled.

Steps to modify the ESI file are as follows:

  • Go to ${TWINCAT_INSTALL_FOLDER}\3.1\Config\Io\EtherCAT
  • Open ESI file (TI_ESC.xml or TiEtherCATLib.xml) with an editor and search for ‘CoE’.
  • Add a new tag <FoE /> after to CoE tag as given below.

<Mailbox DataLinkLayer="true">
<CoE SdoInfo="true" SegmentedSdo="true" CompleteAccess="true" />
<FoE />



  • Save the file.
  • Restart TwinCAT

Note: In order to have the option to upgrade TI EtherCAT slave application via FoE you need to run full-fledged EtherCAT slave.

The following section describes the procedure to upgrade TI EtherCAT slave application during runtime.

  1. Configure TwinCAT as mentioned in previous sections.
  2. Click on TI Box, Select "Online" tab.
  3. Click "Bootstrap" (Label 1 on picture) button. ( This will take the Slave to BOOT state).
  4. Once the state has changed to 'BOOT', Click 'Downoad' button ( Label 2 on picture). TwinCAT firmware download 1.JPG
  5. Rename your EtherCAT application binary (.bin) as ECATFW__, and use this file as your new EtherCAT application firmware.TwinCAT firmware download 2.JPG
  6. Locate the new firmware to be dowloaded click 'Open'.
  7. Click OK on the new dialog shown.
  8. This will downlload the new firmware. The progress bar will show the status of download.
  9. Once the download has finished, change the state back to "Init" by clicking 'Init' button. This will cause a reload of the application.

Generating EEPROM binary file

The following steps explain how to convert the ESC configuration file into an EEPROM binary file. This binary file can later be used for generating equivalent header file to be used to build the EtherCAT Application.

 1. Configure TwinCAT as mentioned in previous sections.

2. Click on the TI Box. Select EtherCAT. Click on the tab 'Advanced Settings'.


3. Select ESC Access->E2PROM->Hex Editor. Select 'Write to File' and save the binary as a '.bin' file.

NOTE: Please make sure that upload button is not clicked any time before during this step - this will load the EEPROM data from TI ESC to TwinCAT memory.




TwinCAT is a software product developed and supported by BeckHoff. For further product details and for support information on TwinCAT please visit