SetRTCDrift: Adjust the Real Time Clock Each Week

Function Description

This function adds or subtracts to the Real Time Clock (RTC) a specified number of seconds, each week, at the specified day of the week and time (hour:minute).

NOTE: The SetRTCDrift function needs to be programmed to be executed only during the First Mast Cycle.

Graphical Representation

G-RU-0010362.2.gif-high.gif

 

 

IL and ST Representation

To see the general representation in IL or ST language, refer to the chapter Function and Function Block Representation.

I/O Variables Description

This table describes the input parameters:

Inputs

Type

Comment

RtcDrift

SINT(-29...+29)

Correction in seconds (-29 ... +29)

Day

DAY_OF_WEEK

Day of change.

Hour

HOUR

Hour of change.

Minute

MINUTE

Minute of change.

 

NOTE: If the values entered for RTCDrift, Day, Hour, Minute exceed the limit values, the logic controller firmware sets all values to their maximum values.

This table describes the output variable:

Output

Type

Comment

SetRTCDrift

RTCSETDRIFT_ERROR

Returns RTC_OK (00 hex) if command is correct otherwise returns the ID code of the detected error.

Example

In this example, the function is called only once during the first MAST task cycle and 20 seconds is added to the RTC every Tuesday at 5:45

VAR
   MyRTCDrift : SINT (-29...+29) := 0;
   MyDay : DAY_OF_WEEK;
   MyHour : HOUR;
   MyMinute : MINUTE;
END_VAR    

IF IsFirstMastCycle() THEN
   MyRTCDrift := 20;
   MyDay := TUESDAY;
   MyHour := 5;
   MyMinute := 45;
   SetRTCDrift(MyRTCDrift, MyDay, MyHour, MyMinute);
END_IF