Configuring EtherCAT SyncUnits
EtherCAT slaves are assigned to a SyncUnit so that they can be organized into a common task cycle. All slaves in the same SyncUnit are synchronized within the same real-time context. The assignment is performed via ConsumeXml on the respective slave node.
Requirements
- An EtherCAT master with at least one slave is present.
- A SyncUnit is defined in the EtherCAT master.
Simple SyncUnit assignment
C#:
ITcSmTreeItem ecSlave = sysManager.LookupTreeItem(@"TIID^EtherCAT Master^EK1100");
ecSlave.ConsumeXml(@"<TreeItem>
<EtherCAT>
<Slave>
<SyncUnits>
<SyncUnit>SyncUnit1</SyncUnit>
</SyncUnits>
</Slave>
</EtherCAT>
</TreeItem>");PowerShell:
$ecSlave = $sysManager.LookupTreeItem("TIID^EtherCAT Master^EK1100")
$ecSlave.ConsumeXml("<TreeItem><EtherCAT><Slave><SyncUnits><SyncUnit>SyncUnit1</SyncUnit></SyncUnits></Slave></EtherCAT></TreeItem>")Advanced: SyncUnit with task assignment via SuTask
If the assigned task is known, the task OID can be passed directly as a SuTask attribute. This links the SyncUnit directly to a specific task without requiring TwinCAT to automatically resolve the assignment. The task OID can be determined using ProduceXml on the EtherCAT master.
// SuTask value = OID of the task (e.g. "#x2010020") — read from ProduceXml on the EC master
ecSlave.ConsumeXml(@"<TreeItem>
<EtherCAT>
<Slave>
<SyncUnits>
<SyncUnit RepeatSupport=""true"" SuTask=""#x2010020"">MySyncUnit</SyncUnit>
</SyncUnits>
</Slave>
</EtherCAT>
</TreeItem>");The corresponding task OID can be read from the EC master using ProduceXml. Sample:
<Cdls><Cdl><TaskOid>#x2010020</TaskOid></Cdl></Cdls>![]() | If the specified SyncUnit name does not yet exist, TwinCAT automatically creates a new SyncUnit with that name in the EtherCAT master. This behavior is defined by the TwinCAT implementation and occurs consistently. A slave can belong to only one SyncUnit. The SuTask OID must match the task OID in the EtherCAT master exactly. |
