Real-Time Clock (RTC)

The CX7293 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. If the CX7293 is switched off for longer than 30 days, the time is lost and must be reset

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

Sample

The sample below shows how you can 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 (Win10: TC RT x86/x64, WEC6/7: TC RT x86, WEC7: TC CE7 Arm®V7, TC/BSD: TC RT x64, TC OS Arm®T2)

Tc2_Utilities (System)