Example: Software clocks (RTC, RTC_EX, RTC_EX2)

The complete sources can be found here: RTCSample.zip

 

In the following example, the three software clocks are synchronized each 5 seconds with the local Windows system time (the local Windows system time is displayed in the task bar).

PROGRAM MAIN
VAR
    fbGetLocalTime  : NT_GetTime;
    bBusy       : BOOL;
    bError      : BOOL;
    nErrID      : UDINT;
    presetTime      : TIMESTRUCT;

    syncTimer       : TON;
    syncTrigger     : F_TRIG;
    bSynchronize    : BOOL;

    fbRTC       : RTC;
    bValid_RTC      : BOOL;
    time_RTC    : DT;

    fbRTC_EX    : RTC_EX;
    bValid_RTCEX    : BOOL;
    time_RTCEX      : DT;
    nMilliseconds   : DWORD;

    fbRTC_EX2       : RTC_EX2;
    bValid_RTCEX2   : BOOL;
    time_RTCEX2     : TIMESTRUCT;
    nMicroseconds   : DWORD;
END_VAR

 

Example: Software clocks (RTC, RTC_EX, RTC_EX2) 1: