Diagnostics on the slave side

The status of the EtherCAT communication is monitored using the state variable on the CX8110 side. Use the variables DcToTcTimeOffset, DcTimeDiff and Dc State to monitor the status of the distributed clocks (DC). These variables are created automatically when you enable distributed clocks (DC).

State (WORD):

The state variable is used to monitor the status of the EtherCAT communication. The communication is active when the state is 0x___8.

0x___1 = Slave is in 'INIT' state
0x___2 = Slave is in 'PREOP' state
0x___4 = Slave is in 'SAFEOP' state
0x___8 = Slave is in 'OP' state

Other bits are reserved and do not have to be checked.

NetId (ARRAY[6] OF BYTE):

the NetId is the ADS number for the EtherCAT slave.

DcToTcTimeOffset (LINT):

indicates the time difference between master and slave clock. The slave clock is the clock of the CX8110 and can be read with _TaskInfo[1].

Code:

VAR
    PlcTaskSystemInfo    :PlcTaskSystemInfo;
END_VAR

PlcTaskSystemInfo:=_TaskInfo[1]; //Task Info wird and die PlcTaskSystemInfo Struktur übergeben

GVL.DcTimeFromCX8110:=PlcTaskSystemInfo.DcTaskTime; //Die DC Zeit wird ermittelt und einer Globalen Variable zugewiesen

DcTimeDiff (DINT)

The DcTimeDiff variable indicates the accuracy of the distributed clocks (DC). The unit of measurement is ns. Depending on the PLC program, the CX8110 takes approx. 1 to 2 seconds to adjust. In exceptional cases, the CX8110 may take longer.

The shorter the sync task, the faster and better the CX8110 is tuned. The disadvantage is a higher CPU load. So the rule is: as fast as possible, but without overloading the CPU. Make sure the CPU load is below 60%.

You can determine when the CX8110 is synchronized by reading the value of the DcTimeDiff variable. A control configuration can be regarded as optimal with a task time of 1 ms and a DcTimeDiff of less than 10 ns. A DcTimeDiff of less than 100 ns is regarded as adequate.

1 ms = 1,000 µs = 1,000,000 ns

These demands are quite high. Depending on the application, a lower accuracy may be acceptable. You should always determine whether the control quality is adequate for your application.

DcState (UINT):

With the CX8110 the value is always 0x___2.

0x___1 = TwinCAT Time Controlled by EtherCAT Slave Dc time
0x___2 = TwinCAT Time Controlled by CCat time