Samples | I/O 6.6.18 Creating a TwinCAT RT UDP device | Creating a TwinCAT RT UDP device A TwinCAT RT UDP device consists of two levels in the I/O configuration tree: an RT Ethernet adapter as the higher-level I/O device and the RT UDP module as the subordinate element. Both are created via CreateChild , but using different mechanisms: The RT Ethernet adapter is created using a SubType value, while the RT UDP module is created using a GUID , similar to the creation of TcCOM objects. Requirements TwinCAT XAE is installed and started. A DTE connection to the target instance is active. ITcSysManager is initialized in an STA thread. The IO configuration tree can be accessed via the TIID path.
Creating an RT UDP device The RT Ethernet adapter is created directly as a child of the IO configuration tree ( TIID ). The RT UDP module is then created as a child of the adapter. For GUID-based generation, nType is set to 0 ; the fourth parameter of CreateChild contains the GUID as a plain string. ITcSmTreeItem ioDevices = sysManager.LookupTreeItem("TIID"); // Step 1: Create RT Ethernet Adapter (SubType 109) ITcSmTreeItem rtAdapter = ioDevices.CreateChild("RT-EtherNET Adapter", 109, "", null); // Step 2: Create RT UDP module via GUID (analogous to TcCOM objects) // GUID must be read from ProduceXml of an existing RT UDP module // Format: plain GUID string, e.g.
"{080D0399-6A65-408D-80E1-18D8F699496A}" ITcSmTreeItem rtUdp = rtAdapter.CreateChild( "RT UDP", 0, // 0 for GUID-based creation (as with TcCOM) "", "{080D0399-6A65-408D-80E1-18D8F699496A}" ); 6.6.19 Adding third-party EtherCAT devices | Adding third-party EtherCAT devices Third-party EtherCAT devices that are not included in the TwinCAT ESI catalog can be added via CreateChild using the identification values from the manufacturer's ESI file. TwinCAT identifies each EtherCAT device based on three values from the ESI file: VendorId, ProductCode, and RevisionNo. These are passed either as an integer array or as a compact string representation.
In order for TwinCAT to locate the third-party ESI file, it must be copied to the correct folder before the device is created. Requirements The third-party ESI file is located in the directory %LOCALAPPDATA%/Beckhoff/TwinCAT/3.1/ Config/IO/EtherCAT or C:/Program Files (x86)/Beckhoff/TwinCAT/3.1/Config/Io/ EtherCAT The TwinCAT solution is open with an EtherCAT master. TE1000 270 Version: 1.7.0