TwinCAT time sources
The Beckhoff TwinCAT automation suite can analyze several independent time sources. See also the sample program.
Information regarding the architecture:
Name |
BIOS motherboard |
CPU time |
Windows/NT time |
TwinCAT/TC time |
Distributed clocks/DC time |
---|---|---|---|---|---|
Description |
RTC (RealTimeClock), battery-operated on the motherboard |
CPU counter from the controller hardware, not regulated Initialized by RTC |
Local system time of the Windows operating system (NT) Initialized by RTC |
Running TwinCAT clock Initialized by Windows |
The system returns the start time of the current task cycle. Initialized by TwinCAT. |
Data |
|
64 bit |
from 1.1.1601 00:00 |
from 1.1.1601 00:00 |
from 1.1.2000 00:00 |
Reference |
|
|
Local |
Local time taking into account the set time zone, i.e. usually UTC |
Local time taking into account the set time zone, i.e. usually UTC |
PLC format |
|
T_ULARGE_INTEGER |
TIMESTRUCT |
T_FILETIME |
T_DcTime |
Call |
|
GetCpuCounter |
NT_GetTime() |
GetSystemTime() |
F_GetActualDcTime()
F_GetCurDcTickTime()
F_GetCurDcTaskTime() |
Update |
|
With each call, possibly several times within a PLC cycle |
|
with each base tick (System Manager | BaseTime) |
ActualDcTime
|
Sample application |
can be used by the PLC block Nt_SetTimeToRtcTime for correcting the NT time |
relative time measurements |
Logging, time stamping at operating system level |
High-precision, relative time-based tasks within one or across several task cycles |
- High-precision, relative time-based tasks within the EtherCAT system |
Manipulation options |
|
|
- It can be changed to the current RTC time by the PLC function block Nt_SetTimeToRtcTime; this also triggers a correction of the RTC time |
|
Synchronization with external reference time from TwinCAT 2.11 |
Table 1: time architecture, required libraries: TcEtherCAT.lib, TcUtilities.lib, TcSystem.lib
Application scenario 1: Local control system without forced synchronization via the network
The local Windows clock is free-running and can be coupled to the RTC via Nt_SetTimeToRtcTime. This option is not recommended when using distributed clocks components!
We recommend using the TC or DC clock if absolute time references are required.
Ideally, the DC time should be coupled to an external reference time via suitable EtherCAT components.
Application scenario 2: Local control system with forced synchronization via the network
The local Windows clock is cyclically synchronized with the world time through a network clock/server/Internet time server.
Coupling of the Windows clock to the RTC through Nt_SetTimeToRtcTime is not recommended.
We recommend using the TC or DC clock. The reference to the absolute time can be established via the application through offset calculation at the NT time.
Ideally, the DC time should be coupled to an external reference time via suitable EtherCAT components.
Application scenario 3: Local control system with external reference time via EtherCAT
A frequency- and phase-synchronized analog time is available through coupling of the DC time to an external time source (GPS, radio clock, PTP/IEEE1588, EtherCAT). The NT and TC time are not required in the application.
Common time synchronization The usual time synchronization at operating system level works in discrete intervals ranging from several seconds to days. In the synchronization case this leads to an erratic/unsteady change of the subordinate time! The usual network synchronizations (SNTP, NTP and similar) or even Nt_SetTimeToRtcTime are affected by this. The application must be able to anticipate these sudden changes in the "absolute" time. |