NT_SetTimeToRTCTime

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

NT_SetTimeToRTCTime 1:

The function block "NT_SetTimeToRTCTime" can be used to synchronise the local Windows system time (displayed in the task bar) with the real-time clock of the PC (RTC time in the BIOS).

 

Remarks

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 based on the difference that was determined. Time zones and daylight-saving/standard time bias (difference) are considered. 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 also 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 in the millisecond range, i.e. each time NT_SetTimeToRTCTime is called a small error is introduced in the real-time clock. In order to minimise deviations over a prolonged period, the compensation should be carried out every 24 hours, for example, rather than during each PLC cycle.

 VAR_INPUT

VAR_INPUT
    NETID       :T_AmsNetId;
    SET         :BOOL;
    TMOUT       :TIME := DEFAULT_ADS_TIMEOUT;
END_VAR

NETID: It is possible here to provide the AmsNetId of the TwinCAT computer on which the local Windows system time is to be synchronisized. If it is to be run on the local computer, an empty

SET: The block is activated by a rising edge at this input.

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

VAR_OUTPUT

VAR_OUTPUT
    BUSY         :BOOL;
    ERR          :BOOL;
    ERRID        :UDINT;
END_VAR

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

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

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

 

Further time, time zone functions and function blocks:

FB_TzSpecificLocalTimeToSystemTime, FB_TzSpecificLocalTimeToFileTime, FB_SystemTimeToTzSpecificLocalTime, FB_FileTimeTimeToTzSpecificLocalTime, FB_GetTimeZoneInformation, FB_SetTimeZoneInformation, NT_SetLocalTime, NT_GetTime, NT_SetTimeToRTCTime, F_TranslateFileTimeBias, FB_LocalSystemTime

Requirements

Development Environment

Target System

PLC Libraries to include

TwinCAT v2.7.0 Build > 508

PC oder CX (x86)

TcPlcUtilities.Lib; Standard.Lib; PLCSystem.Lib; TcPLCAds.Lib; PLCHelper.Lib;

TwinCAT v2.8.0 Build > 715

PC oder CX (x86)

TcUtilities.Lib