evilthorne
Member
OP
subtract 2 minutes (160 seconds) /QUOTE]
Happens to the best of us...
subtract 2 minutes (160 seconds) /QUOTE]
Happens to the best of us...
yes it converts time that production can enter into a PC into this value in a DINT. But if the time is 1100 (11:00am) when I subtract 2 minutes from it I get 1098 instead. The big one comes at 12:00am because if I subtract two minutes from this I need it to say 2358 (11:58pm)
turn them on again automatically two minutes before the end of their break.
Yes, I have a RTC hours *100 plus RTC minutes to get a value of the current time to match up with how our system keeps track of it.
So if I am to understand what you are saying, is to spoof the current time signal to get what I want instead of subtracting from my target time setting?
if RTC_minutes < 58 then
hmm = RTC_hours * 100 + RTC_minutes + 2
else
hmm = RTC_hours * 100 + RTC_minutes + 42
endif
hmm = (RTC_hours * 100) + RTC_minutes + 2 + ((RTC_minutes > 57) * 40)
hour:=(shifttime/100)*100;
minute:=shifttime-hour;
IF minute-2<0 Then
minute:=60+((minute-2)MOD 60);
hour:=(((shifttime/100)-1)MOD 24);
IF hour<0 THEN
hour:=(24+hour)*100;
ELSE
hour:=hour*100;
END_IF;
ELSE
minute:=minute-2;
END_IF;
offsettime:=(hour+minute);
This should work:
Code:hour:=(shifttime/100)*100; minute:=shifttime-hour; IF minute-2<0 Then minute:=60+((minute-2)MOD 60); hour:=(((shifttime/100)-1)MOD 24); IF hour<0 THEN hour:=(24+hour)*100; ELSE hour:=hour*100; END_IF; ELSE minute:=minute-2; END_IF; offsettime:=(hour+minute);
offsettime:=(hour*100)+minute;
hour:=(shifttime/100)/100;
minute:=shifttime MOD 100;
hour:=(shifttime-minute) / 100;
Storing a time variable as a DINT in the format HHMM is the real problem. Everything else is just masking the problem.
Storing a time variable as a DINT in the format HHMM is the real problem. Everything else is just masking the problem.