SetRTCDrift: Adjust the Real Time Clock Each Week
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.
To see the general representation in IL or ST language, refer to the chapter Function and Function Block Representation.
This table describes the input parameters:
Inputs |
Type |
Comment |
---|---|---|
RtcDrift |
SINT(-29...+29) |
Correction in seconds (-29 ... +29) |
Day |
Day of change. |
|
Hour |
Hour of change. |
|
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 |
Returns RTC_OK (00 hex) if command is correct otherwise returns the ID code of the detected error. |
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