Executing an emergency scan on an EtherCAT device

An emergency scan sends a configurable number of EtherCAT test frames over a connection and evaluates the responses. The result provides insight into the quality of the connection. Lost frames or increased error rates may indicate cabling problems or faulty connectors. The scan is started via ConsumeXml, and the results are retrieved via ProduceXml.

Requirements

C# sample

If the scan is to run on a remote target system, the target NetID must first be set via SetTargetNetId. This method is available starting with ITcSysManager10, which is why the interface is obtained via Cast. This step is not necessary when running the application locally. The scan itself is initiated on the EtherCAT device using ConsumeXml, and the result is then read using ProduceXml.

// Switch to remote target (leave empty for local)
ITcSysManager10 sysManager10 = sysManager as ITcSysManager10;
sysManager10.SetTargetNetId("5.56.2.150.1.1");

ITcSmTreeItem ecDevice = sysManager.LookupTreeItem(@"TIID^Device 1 (EtherCAT)");

// Start emergency scan: 100 test frames
string scanXml = @"<TreeItem>
  <EtherCAT>
    <EmergencyScan>
      <TestFrames>100</TestFrames>
    </EmergencyScan>
  </EtherCAT>
</TreeItem>";

ecDevice.ConsumeXml(scanXml);

// Read scan result
string resultXml = ecDevice.ProduceXml();

PowerShell sample

# Switch to remote target
$sysManager10 = $sysManager -as [TwinCAT.Xae.Interface.ITcSysManager10]
$sysManager10.SetTargetNetId("5.56.2.150.1.1")

$ecDevice = $sysManager.LookupTreeItem("TIID^Device 1 (EtherCAT)")

# Start emergency scan: 100 test frames
$scanXml = @"
<TreeItem>
  <EtherCAT>
    <EmergencyScan>
      <TestFrames>100</TestFrames>
    </EmergencyScan>
  </EtherCAT>
</TreeItem>
"@
$ecDevice.ConsumeXml($scanXml)

# Read scan result
$resultXml = $ecDevice.ProduceXml()
Executing an emergency scan on an EtherCAT device 1:

TestFrames specifies the number of EtherCAT frames sent for the test. Typical values range from 10 to 1000. The XML response returned by ProduceXml contains status information about connection quality, such as lost frames and error rate.