Adding EtherCAT devices

EtherCAT slaves are created via CreateChild on an EtherCAT master or a higher-level slave node. The SubType and device name from the ESI catalog determine the device type.

Requirements

Creating EtherCAT devices

To create an EtherCAT master or slave, call CreateChild on the I/O node TIID. The SubType determines the type. EtherCAT masters use 111, while EtherCAT slaves use 130. Configuring network variables via an automation protocol is described in a separate article.

C#:

ITcSmTreeItem devices = sysManager.LookupTreeItem("TIID");

// EtherCAT master (SubType 111)
ITcSmTreeItem etherCatMaster = devices.CreateChild("EtherCAT Master", 111, null, null);

// EtherCAT slave (SubType 130)
ITcSmTreeItem etherCatSlave = devices.CreateChild("EtherCAT Slave", 130, null, null);

PowerShell:

$devices = $systemManager.LookupTreeItem("TIID")
$ethercatMaster = $devices.CreateChild("EtherCAT Master", 111, $null, $null)
$etherCatSlave = $devices.CreateChild("EtherCAT Slave", 130, $null, $null)

Creating EtherCAT Boxes and Terminals with SubType 9099

With a few exceptions, all subordinate devices connected to an EtherCAT master use the common SubType 9099. The exact device variant is specified via the vInfo parameter as a product revision, which is stored in the device's ESI file.

// Create EK1100 coupler
ITcSmTreeItem ek1100 = etherCatMaster.CreateChild("Term 1 (EK1100)", 9099, "", "EK1100-0000-0017");

// Create EL-terminals under coupler
ek1100Item.CreateChild("Term 2 (EL2004)", 9099, "", "EL2004-0000-0017");
ek1100Item.CreateChild("Term 3 (EL2004)", 9099, "", "EL2004-0000-0017");

// Create EL-terminal at specific position (after "Term 3")
ek1100Item.CreateChild("Term 4 (EL2004)", 9099, "Term 3 (EL2004)", "EL2004-0000-0017");

PowerShell:

$ethercatMaster = $systemManager.LookupTreeItem("TIID^EtherCAT Master")
$ethercatMaster.CreateChild("EK1100", 9099, "", "EK1100-0000-0017")
Adding EtherCAT devices 1:

In addition to a full product revision, a wildcard can also be used. If only "EK1100" is specified as vInfo, the Automation Interface automatically detects the latest revision number. The bstrBefore parameter contains the name of the previous child element, not the full path.

CU1128 multi-port coupler

The CU1128 is an EtherCAT switch that consolidates multiple separate EtherCAT segments into a single master connection. After creating the CU1128 node, TwinCAT automatically creates the physical ports as child nodes. Slaves are created directly on the CU1128 node, not on the generated port nodes.

C#:

// Create CU1128 multi-port coupler
ITcSmTreeItem cu1128 = etherCatMaster.CreateChild("A2P (CU1128)", 9099, "", "CU1128");

// Add slaves directly on the CU1128 node (not on child port items)
cu1128.CreateChild("X2 (EK1100)", 9099, "", "EK1100-0000-0001");
cu1128.CreateChild("X3 (EK1100)", 9099, "", "EK1100-0000-0001");

PowerShell:

$cu1128 = $ethercatMaster.CreateChild("CU1128", 9099, $null, "CU1128")
$cu1128_devA = $cu1128.get_Child(1)
$cu1128_devB = $cu1128.get_Child(2)
$ek1100_1 = $cu1128_devA.CreateChild("EK1100-1", 9099, $null, "EK1100")
$ek1100_2 = $cu1128_devB.CreateChild("EK1100-2", 9099, $null, "EK1100")

Exceptions for ItemSubType 9099

Some terminals require a different SubType. The following table lists exceptions:

I/O

ItemSubType

EP6002

9101

EL6001

9101

EL6002

9101

EP6001-0002

9101

EP6002-0002

9101

EL6021

9103

EL6022

9103

EL6021-0021

9103

BK1120

9081

ILXB11

9086

EL6731

9093

EL6751

9094

EL6752

9095

EL6731-0010

9096

EL6751-0010

9097

EL6752-0010

9098

EL6601

9100

EL6720

9104

EL6631

9106

EL6631-0010

9107

EL6632

9108

EL6652-0010

9109

EL6652

9110

Configuring the EtherCAT topology: PreviousPort

The PreviousPort of an EtherCAT Terminal determines through which port and which device it is physically connected to the network. In branched topologies with multiple ports, such as those found in an EK1122 coupler, the PreviousPort determines the terminal's logical position in the EtherCAT segment.

<TreeItem>
  <EtherCAT>
    <Slave>
      <PreviousPort Selected="1">
        <Port>B</Port>
        <PhysAddr>1045</PhysAddr>
      </PreviousPort>
      <PreviousPort>
        <Port>B</Port>
        <PhysAddr>1023</PhysAddr>
      </PreviousPort>
    </Slave>
  </EtherCAT>
</TreeItem>

When inserting child nodes directly under a slave, the bstrBefore parameter of CreateChild can be used to determine the insertion position. On an EtherCAT master, however, the topology must be configured via ConsumeXml using the XML structure shown above.

Adding EtherCAT slaves to a HotConnect group

In the TwinCAT Automation Interface, the same result can be achieved on the EtherCAT slave using the following XML structure:

<TreeItem>
  <EtherCAT>
    <Slave>
      <HotConnect>
        <GroupName>Term 1 (EK1101)</GroupName>
        <GroupMemberCnt>4</GroupMemberCnt>
        <IdentifyCmd>
          <Comment>HotConnect-Identität lesen</Comment>
          <Requires>cycle</Requires>
          <Cmd>1</Cmd>
          <Adp>0</Adp>
          <Ado>4096</Ado>
          <DataLength>2</DataLength>
          <Cnt>1</Cnt>
          <Retries>3</Retries>
          <Validate>
            <Data>0000</Data>
            <Timeout>5000</Timeout>
          </Validate>
        </IdentifyCmd>
      </HotConnect>
    </Slave>
  </EtherCAT>
</TreeItem>

Activating the EtherCAT configuration

To activate a TwinCAT configuration via the Automation Interface, you can use ITcSysManager::ActivateConfiguration(). Since the previous steps create an offline configuration without real addresses, the real addresses must be determined and entered using ScanDevices + ProduceXml/ConsumeXml before activation.