Real Time Clock (RTC)

The real-time clock (RTC) is read out via the function blocks FB_LocalSystemTime and can be set with the function block NT_SetLocalTime (see TcUtilities.lib). The RTC is supplied by the battery and can thus continue to run in the power-off state.

Real-time clock (RTC) running too slow

TwinCAT uses its own real-time driver. This has the advantage that the quality of the real-time has been much improved, and the jitter of the task has been reduced to a minimum. This calls the operating system from TwinCAT. The RTC on the operating system is controlled via TwinCAT and must be called at certain times.

If the task cycle time on the TwinCAT side is very long and the CPU load is high, the operating system is no longer called with sufficient frequency. As a result, the RTC on the operating system is slow. If you have noticed that the RTC is slow and the time on the CX8180 is also slow, you can apply the following troubleshooting procedure.

Remedy

The call of the RTC is always linked to a reading of the hardware RTC. This has the disadvantage of a slightly higher CPU load, but since the CPU load is already high due to your application, the additional CPU load is negligible. Adjust the settings in the registry:

[HKEY_LOCAL_MACHINE\Platform]
    “SoftRTC"=dword:0

Description of the SoftRTC registry key

Value

Description

0

The hardware RTC is always read out when the Windows time is requested.

1

The hardware RTC is read out once at startup. From then on, the Windows clock continues to run via the internal system tick.

Standard setting: "SoftRTC"=dword:1