Distributed Clock
Oversampling requires a clock generator in the terminal that triggers the individual data sampling events. The local clock in the terminal, referred to as distributed clock, is used for this purpose.
The distributed clock represents a local clock in the EtherCAT slave controller (ESC) with the following characteristics:
- Unit 1 ns.
- Zero point 1.1.2000 00:00.
- Size 64 bit (sufficient for the next 584 years); however, some EtherCAT slaves only offer 32-bit support, i.e. the variable overflows after approx. 4.2 seconds.
- The EtherCAT master automatically synchronizes the local clock with the master clock in the EtherCAT bus with a precision of < 100 ns.
In the EL4732 only the lower 32 bits with are realized (~4.2 seconds).
![]() | EtherCAT and Distributed Clocks A basic introduction into EtherCAT and distributed clocks is available for download from the Beckhoff website: the “Distributed clocks system description”. |
Sample:
The fieldbus/EtherCAT master is operated with a cycle time of 1 ms to match the higher-level PLC cycle time of 1 ms, for example. This means that every 1 ms an EtherCAT frame is sent to the EL4732 for transferring the process data. The local ESC clock therefore triggers an interrupt in the terminal every 1 ms (1 kHz), in order to read the process data provided by the EtherCAT frame. This first interrupt is called SYNC1.
The EL47xx may be set to oversampling n = 10 in the TwinCAT System Manager. This causes the ESC to generate a second interrupt in the terminal with an n-times higher frequency, in this case 10 kHz or 100 µs period. This interrupt is called SYNC0. With each SYNC0 signal the output voltage is transferred to the DAC (digital to analog converter) as a digital value.
![]() | Voltage output Both output voltages (channels 1 and 2) are always output simultaneously. This is ensured by the DAC type that is triggered by the SYNC0 pulse. No other operation mode is possible. |
Generation of the SYNC0 pulse from the local synchronized clock within the distributed clock network ensures that the analog values are sampled at highly equidistant intervals with the period of the SYNC1 pulse.
The maximum oversampling factor depends on the memory size of the ESC. In the EL47xx it is n = 100.
![]() | Maximum sampling frequency A smaller period than 10 µs is not permitted for the EL47xx. The maximum sampling frequency for the EL47xx is therefore 100 kSps (samples per second). |
Sample:
For SYNC1 = 1 ms oversampling factors such as 1,2,5 or 100 are permitted, but not 3. If implausible values are used the terminal will still reach the OP state but will not output correct process data. This may result in a working counter error.
With 2 channels and n = 100, 2 x 2 x 100 = 400 bytes of process data must be transferred to the EL47xx during each EtherCAT cycle.
Working with DC times in the controller
From the perspective of the controller the distributed clock time has the following characteristics:
- Unit 1 ns
- Universal zero point 1.1.2000 00:00, i.e. for variable evaluations an offset of 2000 years has to be added
- Scope up to 64 bit (sufficient for 584 years). However, some EtherCAT slaves only support a 32 bit scope, i.e. the register overflows locally after approx. 4.2 seconds and starts again at 0.
The following 3 data types are recommended for handling DC times
- T_DCTIME from TcEtherCAT.lib
This is based on T_ULARGE_INTEGER and is therefore unsigned. It can be used for linking with suitable hardware variables - T_ULARGE_INTEGER from TcUtilities.lib
Unsigned 64-bit data type - T_LARGE_INTEGER from TcUtilities.lib
Signed 64-bit data type, negative numbers are represented in two's complement notation (underflow below 0 --> 0xFFFF FFFF FFFF FFFF etc.)
TcUtilities.lib (section INT64) provides numerous relevant functions. Of particular significance are the cast functions LARGE_TO_ULARGE and vice versa.
This type should be used when working with time differences that may be negative.
If TwinCAT is used for external synchronization, negative times will inevitably occur in the offset values.
![]() | 64- vs. 32-bit representation Some EtherCAT slaves can only handle 32 bit values for representing the DC time or handle it as a process data. In order to prevent problems caused by overflow (every 4.2 seconds), we strongly recommend using 64-bit times in the controller.
|
This sample project
(Download) contains a function block that cyclically adds the high part to a 32-bit DC time to make 64 bits.