Real-Time Clock (RTC)

The CX7050 has an internal, capacitor-buffered real-time clock (RTC) for time and date, which continues to run in the switched-off state. The capacitance of the capacitor is sufficient for at least 30 days and, unlike a battery-backed solution, is maintenance-free. The time is lost and must be reset if the CX7050 is turned off for more than 30 days

The following settings are possible in the boot.conf file:

Sample

The sample below shows you how to read the time. In the sample, the time is output as UTC time and one hour is added to get the CET time.

VAR
    FB_LocalSystemTime    : FB_LocalSystemTime;
    DATEANDTIME           : DATE_AND_TIME;
    DATEANDTIME_Add1h     : DATE_AND_TIME;
END_VAR

PROGRAM:
FB_LocalSystemTime(
        sNetID:= ,
        bEnable:=TRUE ,
        dwCycle:= ,
        dwOpt:= ,
        tTimeout:= ,
        bValid=> ,
        systemTime=> ,
        tzID=> );

DATEANDTIME:=SYSTEMTIME_TO_DT(TIMESTR:=FB_LocalSystemTime.systemTime );    (*UTC Time*)
DATEANDTIME_Add1h:=DATEANDTIME+T#1H;    (*UTC Time + 1h*)

Requirements

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, WEC6/7: TC RT x86, WEC7: TC CE7 ARMV7, TC/BSD: TC RT x64, TC OS ARMT2)

Tc2_Utilities (System)