NT_SetTimeToRTCTime 1:

This functionality is not available in the PLC runtime system under Windows CE!

NT_SetTimeToRTCTime 2:

The function block "Nt_SetTimeToRtcTime" can be used to synchronize the local Windows system time (displayed in the taskbar) with the real-time clock of the PC (RTC time in the BIOS).


When the function block is called, the real-time clock of the TwinCAT PC is compared with the local Windows system time, and the local Windows system time is corrected by the difference. Time zones and summer time are taken into account. Please note that the correction can lead to time jumps during measurements or log book entries.

When the local Windows system time is set, the operating system automatically sets the RTC time to the new local Windows system time. Due to the conversion and delay the new RTC time is inevitably subject to a small error. The error is in the millisecond range. This means that the real-time clock is falsified a little each time NT_SetTimeToRTCTime is called. In order to minimize deviations over a prolonged period, the compensation should be carried out every 24 hours, for example, rather than during each PLC cycle.


    NETID  : T_AmsNetId;
    SET    : BOOL;

NETID: This parameter can be used to specify the AmsNetID of the TwinCAT computer on which the local Windows system time is to be synchronized (type: T_AmsNetID). If it is to be run on the local computer, an empty string can be entered.

SET: the block is activated by a positive edge at this input.

TMOUT: States the length of the timeout that may not be exceeded by execution of the ADS command.


    BUSY  : BOOL;
    ERR   : BOOL;

BUSY: When the function block is activated this output is set. It remains set until a feedback is received.

ERR: If an error should occur during the transfer of the command, then this output is set once the BUSY output was reset.

ERRID: Supplies the ADS error number when the ERR output is set.

Further functions and function blocks for time and time zone:


Development environment

Target platform

PLC libraries to be integrated (category group)

TwinCAT v3.1.0

PC or CX (WES7/Win7/Win10: TC RT x86/x64)

Tc2_Utilities (System)