What are Distributed Clocks?
EtherCAT uses Distributed Clocks (DC) to synchronize the timing of the slaves. To achieve this each slave needs its own local time which is provided by an local clock source. The first DC-capable slave in the network is usually used as Reference Clock. All other slave synchronize their clock based on this reference clock. To handle it the EtherCAT master regularly send a telegram which is filled with the time of the reference clock and it is read by all other slaves.
Run time measurement
Both the slaves as well as the cable cause a short delay of the telegrams on the network. To get a precise synchronization it is required to measure these delays and to take them into account. The master sends during the start-up phase a certain frame to determine the delays. Each slave writes the point of time of the reception of the frame into the frame – in both ways. Based on these timings the master is able to calculate the delays between each slaves.
In addition to the Reference Clock there is also a Master Clock which contains the real time. This clock can be used to adjust the Reference Clock at startup or later.
Thus the following effects can be compensated:
- difference between local time and reference clock
- difference between Reference Clock and Master Clock
- run time delays caused by the cables or salves
- drift of slave clocks by continuous correction of slave clocks
Usage of Distributed Clocks
Normally the EtherCAT Slave Controller (ESC) has two time triggered interrupts SYNC0 and SYNC1. Using these interrupts it is possible for the application to react at a certain point of time or to trigger cyclic actions.
Such actions may be the setting of output data or reading the inputs. Thus it can be ensured that all outputs of all slaves are set at the same time or all input data – e.g. used for a control loop controller – a taken at the same point of time.
A graphical tool such as the EtherCAT DeviceDesigner is recommended to configure the Distributed Clocks