Implementing Distributed Clock Synchronization in EtherCAT: A Step-by-Step Guide

EtherCAT (Ethernet for Control Automation Technology) is a powerful tool for real-time industrial Ethernet applications. One of its standout features is the Distributed Clock Synchronization, which ensures precise synchronization across devices. Let’s dive into the implementation process.

1. Slave Onboard Pulse Generators:
Before delving into distributed clocks, it’s essential to understand the ec_dcsync0() and ec_sync01() functions. These program the onboard pulse generators of the slave. Slaves have their local clocks, generating sync pulses. There are two generators – sync0 and sync1. While sync0 has an absolute start and repetition time, sync1 acts more as its subordinate. For an in-depth understanding, refer to the Beckhoff slave controller datasheet.

2. Synchronizing Local Clocks:
Most slaves come equipped with a hardware mechanism to synchronize their local clocks with an external one. The master can simply read the local clock value from the slave’s register. To synchronize with an external clock, write the external clock’s value into the slave’s register. The slave then calculates the drift and offset (including programmed propagation delay) and corrects its local clock. In order to have a stable synchronization this read once and write multiple clock (multiple slaves) must be repeated on a regular basis. The most obvious spot being the PDO cycle.

3. Combining onboard pulse generator and syncing local clocks:
When combining step 1 and 2, you achieve system-wide synchronized pulses.

4. Simplifying with SOEM:
SOEM, or Simple Open EtherCAT Master, is designed to simplify the complex bookkeeping surrounding DC and Sync. Executing ec_configdc() initiates several processes, from scanning all DC capable slaves to designating the reference slave. Once the PDO cycle runs, it automatically manages the DC work. However, the responsibility falls on the user to verify that all slaves all slaves are synchronized and remain synchronized.

5. Important Considerations:
It’s crucial not to execute ec_dcsync0() before ec_configdc(). This could lead to unexpected behaviors. The slave local clock’s offset and drift are managed by its hardware, while propagation delays are overseen by ec_configdc().

6. Additional Steps:
While the primary set-up for DC synchronization and pulse generation is complete, some slaves might need extra configurations. Always consult the slave’s documentation for this. Also, while DC and sync focus on slave synchronization, the master’s synchronization to the reference slave remains a separate concern.

In conclusion, Distributed Clock Synchronization in EtherCAT is a systematic process, and while we’ve covered the basics here, there’s much more to delve into for those looking to master the nuances.