EtherCAT diagnosis and configuration optimization


Beckhoff users use EtherCAT extensively, and usually do not need to have a deep understanding of EtherCAT, as most projects only use automatic scanning and default settings.However, when a communication error occurs and troubleshooting is required, engineers need to understand some common knowledge of EtherCAT and learn how to optimize configuration.

This article aims to introduce the EtherCAT diagnostic function and several of the most common optimization measures that are built into TwinCAT in a simple way.
Diagnostic functions include:
EtherCAT Online interface diagnosis of network hardware errors
View the graphical EtherCAT status on the EtherCAT Topology page
View the Ebus current on the Adapter page
Program code for PLC diagnosis of EtherCAT status
Optimization measures include:
Sync Unit settings
Servo drive WcState disabled
Check the grounding of EtherCAT network
Modify Shift Time of Substation
Hot Connect Settings
Layout principle of EL module
The technical documents provided by ETG and Beckhoff regarding EtherCAT diagnosis and principle are more detailed and complete. Interested users can download them here:
EtherCAT Fundamentals
EtherCAT Diagnostics
EtherCAT synchronization
1 EtherCAT diagnostic function
The easiest EtherCAT diagnostic tool is TwinCAT, of which the most commonly used diagnostic interfaces are EtherCAT Online, EtherCAT Topology, and Adapter, which are introduced below.
1.1 Diagnosing network hardware errors on the Online interface

The most commonly used functions in this interface are:
View and switch the status of the master and slave stations, and view the status of the master station Lost Frame.
Check the status of all slave stations and the CRC check of each port
View the number of status changes for each slave
View the state machine errors from the station
If both the master and slave stations are in the OP state in this interface, but the signal of individual slave stations is still abnormal and the software reports an error, it is likely due to invalid data reported by WcState.Please jump to the next section: Using Sync Unit
The status monitoring of the master station is intuitive and requires no explanation.The following explains only the three remaining situations:
1.1.1 Checking the status of the slave station and the port CRC check
When the slave state is OP and the CRC check value is 0, it is in a normal state.If the slave state is not OP, locate the InfoData|State of the slave, as shown in the figure:
On the Variable page shown in the image above, the meaning of the four section values of the status word can be displayed. Switching to its Online page displays the current value of the status word.


The value of CRC is related to the module type. All EL modules have only two ports.The left value of the CRC check represents the interface status with the previous module, while the right CRC value represents the interface status with the next module.
1.1.2 Number of changes in slave station status
Checking the number of slave status changes is to track the situation where individual slave status errors are automatically recovered.Because after the status is restored, it will appear normal in the Online interface, but the moment of error may not be monitored by humans:


If the number of changes in an individual module is significantly higher than that of other modules, then the probability of errors in this module is higher.
1.1.3 State machine error

You can check the 0134 "AL Status Code" in the previous window to view the error code:
- 0x0003 : Invalid Device Setup (The KL module sequence configured on the BK1xxx is incorrect)
- 0x001D : Invalid OutputConfiguration (the configured output process data is invalid)
- 0x001E : Invalid Input Configuration
- 0x0035 : Invalid Sync Cycle Time (not supported by the CycleTime set in DC mode)
- 0x001A: Synchronization error (the network jitter causes the loss of synchronization of the slave station)
- 0x001B: Sync manager watchdog (The slave did not receive periodic data for a period of time, and the watchdog time has expired.)
- 0x002C : Fatal SYNC error (ESC did not receive a SYNC hardware interrupt again)
If it is any other value, refer to the definition of AL StatusCode in the ETG official manual.
1.2 EtherCAT Topology interface
In the EtherCAT | Topology window of the master station, you can view the EtherCAT network topology online or offline:


If the Online page mentioned above is a text version, this is a graphical version of the Online page.When the cursor hovers over a module, the name of the module is displayed.When displayed online, the markers above each slave indicate the CRC status, all of which are green for normal.

1.3 On the Adapter page, view the available Ebus current


According to experience, the available Ebus current should not be used to 0, but should reserve a margin of about 300mA.For example, in the above figure, before the first EL4112, an Ebus power module EL9410 should be added.

1.4 Demo program for PLC diagnosis of EtherCAT status
See the document for the specific implementation:

2 Sync Unit and WcState
2.1 Principle of Sync Unit
When configuring an EtherCAT master station with TwinCAT, configure the frame according to the task.For example, if the PLC task 0 has a cycle of 10ms, there is a corresponding frame with a sending cycle of 10ms.If the NC cycle is 2ms, there is a corresponding frame with a sending cycle of 2ms.Each task enters the output stage after the calculation stage is complete, and sends the corresponding frame.
Each frame refreshes the IO data of the slave station through three commands: LRW (read-write), LWR (write), and LRD (read).The theoretical value of the Working Counter (WC) is determined by which slave station data is refreshed by each command (Cmd).As shown in the figure:


According to the configuration of the master station, each Frame includes several SyncUnits, and each SyncUnit includes several Slaves. After the Frame passes through the Slave and is successfully read and written, the Cmd Working Counter of the SyncUnit to which the Slave belongs will be incremented accordingly.When the Frame returns to the master station after passing through all the slave stations, the master station can determine whether all the slaves of the Cmd operation are successful based on whether the actual Working Counter of each SyncUnit's Cmd is consistent with the theoretical value.If it is not successful, the WcState status of all the slaves of this Cmd operation will be True, indicating Data Invalid.
Suppose that the PLC task is to control all the IO modules in the following figure, and that the LRD command is used to refresh all the data of EL1004. The accumulation process of the Working Counter is as follows:


In the image above, the red!marked EL1004 failed to exchange data successfully, so the Frame passed through 4 EL1004 modules, but the returned WKC was 3.The master station determined that these data were invalid, and TwinCAT discarded them. The data for these 4 EL1004 modules were not refreshed during this cycle.

2.2 Optimization configuration principle of Sync Unit
Each Frame includes all the data of the IO slave controlled by the Task. These slaves are placed in the same Sync Unit by default.However, in practice, EtherCAT allows a Frame to have up to 15 slaves in the same Sync Unit.In order to avoid the error of one slave affecting the invalid data of the entire SyncUnit, can each slave be set as an independent synchronization unit?If the slave is less than 15, there is no problem.However, in typical TwinCAT projects, the number of slaves far exceeds 15. If each slave is set as an independent synchronization unit, multiple Frames will be required, and each Frame is very short, which will greatly reduce the efficiency of communication.Therefore, it is necessary to balance the requirements and configure the synchronization unit reasonably.
According to experience, the following principles can be used to optimize the settings of synchronization units:
EL module, each Station (coupler and connected EL module) is a Sync Unit
EtherCAT servo, each driver is set as an independent SyncUnit.
2.3 Setting of Sync Unit
To view and set the synchronization unit:
Suppose there are 4 drives, all linked to the NC axis with a 2MS cycle.When the default synchronization unit is set, the Ethernet frames are two, with Cycles of 2MS and 10MS.In the 2ms frame, there is one LRW command (Cmd) with a Len of 56.


Click Sync UnitAssignment, and you can see the default settings are:

b. Modify the Sync Unit.
Select an AX5203 and enter the character directly in the Sync Unit Name column, which is the specified sync unit name.

Click OK to return to the main interface.
When four drives are designated as different synchronization units, the Ethernet frame is two, and the Cycle is 2MS and 10MS respectively.In the 2ms frame, there are four LRW commands (Cmd), with lengths of 20, 12, 12, and 12, for a total length of 56 bytes.

2.4 Disable the WcState of the servo drive
Often, customers report NC axis failure 0x4655 (18005) with a message that the data is invalid for 3 consecutive cycles.This is due to a working counter error in the synchronization unit, indicating that at least one slave in the synchronization unit has not successfully read or written data.If an independent synchronization unit is assigned, and a certain axis still reports this error, it is usually caused by a flashing EtherCAT communication.

Motion control is highly sensitive to communication, and the default setting is ETHERCAT type NC axis. Once there are 3 NC cycle data invalid, the NC axis will report an error.If the network quality is poor and there is significant interference on-site, users may wish to have the control system ignore occasional communication anomalies. In this case, the variable can be cleared as shown in the figure.

After canceling this link, if WcState remains invalid, the drive or NC axis will report higher-level faults, such as excessive tracking error.
3 Check the grounding of the EtherCAT network
Diagnosing EtherCAT faults is one aspect, and sometimes some expedient measures can be taken, such as disconnecting the NC axis from the servo drive's WcState link. However, this is only a temporary solution that addresses the symptoms but not the root cause. The fundamental solution is to investigate the source of the problem, including checking for grounding, shielding, and other EMC issues.
The first thing to check is to ensure that the EtherCAT network devices share the same ground, as circulating currents between different grounds can cause data corruption.

Set Shift Time for the Drive
The common error of servo driver, besides 0x4655 Invalid Data, is Sync Lost.This is due to the EtherCAT data packet of individual cycle not arriving within the specified offset time of the synchronization pulse.This error usually occurs on the slave station at the end of the network.
In order to reduce the sensitivity of synchronization signal errors in ETHERCAT communication, the synchronization offset time of the servo drive can be extended.As shown in the figure:
In practical applications, the default Shift Time has generally been sufficient in most cases.Only when the cycle is particularly short (less than 1ms) and the number of nodes is large (greater than 10) does it become necessary to manually adjust the Shift Time.When adjusting, it is possible to increase by 20% of the main station cycle.
Setting method:
On the EtherCAT page of the slave station, click Advanced Settings, and on the DistributedClock page, set the Shift Time for Sync 1.


5 Setting of Hot Connect
If you use the CU2008 or EK1122 to form a star network, you can set up a Hot Connet Group so that removing the network cable from any drive will not affect the operation of other drives.
In linear topology, if users need to exit and join individual sites at any time, such as to bridge some sites without affecting the work of other slave stations, Hot Connect function can also be considered.
See the document for the specific implementation:
Http://www.baclizzy.com.cn/20180320EtherCAThot connection/
EtherCAT network HotConnect settings.pdf
6. Layout principle of EL module
The EL module, which serves as the DC reference clock, should be installed as close as possible to the main station.
EL modules that consume more Ebus current should be installed as widely dispersed as possible in IO stations to avoid concentrated heating.
The typical high-power consumption module is the EL6xxx communication module, while the typical low-power consumption module is the EL1xxx and EL2xxx digital modules.