RTC_Compare:= EQUAL_ARINT(Hours_6,Hour_memory_6);
(*EQUAL_ARINT(Hours_6,Hour_memory_6) > -1*)
IF (RTC_Compare > -1) THEN (*if time/date set words were changed, then set clock*)
SET(%S50);
%SW50 := INT_TO_BCD(Hours_6[2] * 100);(*seconds*)
%SW51 := INT_TO_BCD((Hours_6[0] * 100) + Hours_6[1]);(*hours and minutes*)
%SW52 := INT_TO_BCD((Hours_6[3] * 100) + Hours_6[4]);(*month and day*)
%SW53 := INT_TO_BCD(Hours_6[5]);(*year*)
ELSE (*if no change in set words, just update them to the clock values*)
(*display hh mm ss mm dd yyyy MW2161-MW2166 *)
Hours_6[0] := BCD_TO_INT(%SW51 / 256);(*hours*)
Hours_6[1] := BCD_TO_INT(%SW51 MOD 256);(*minutes*)
Hours_6[2] := BCD_TO_INT(%SW50 / 256);(*seconds*)
Hours_6[3] := BCD_TO_INT(%SW52 / 256);(*month*)
Hours_6[4] := BCD_TO_INT(%SW52 MOD 256);(*day*)
Hours_6[5] := BCD_TO_INT(%SW53);(*year*)
IF (%S50) THEN
RESET(%S50);
END_IF;
END_IF;
Hour_memory_6 := Hours_6 ;(*set memory words to detect any change next scan*)