evilthorne
Member
OP
Of course.
Maybe a decision was taken to have operators enter a time, as hours and minutes, via a single 1- to 4-digit number, and that is the overriding concern; all of the problems blossomed from there, but the OP is still stuck looking for a cleaner way to handle it.
As others have said, the cleanest approach would be to convert the HHMM DINT as soon as it is entered to, and store it as, minute-of-day (0-1439), and then there is a simple conversion from RTC hours and minutes to the same scale that has a simple formula for adding 2: ((RTC_hours * 60) + RTC_minutes + 2) MOD 1440; or subtracting by replacing that 2 with 1438.
I finally had time to come back to this issue and thanks to the above idea (thank you drbitboy)came up with a slightly better solution to my first attempt.
First MOD (Breaktime_Finish)/100 Then CPT (Breaktime_Finish/100*60)+the MOD value of the previous instruction gives me the time in Minutes
I have a separate subtract instruction (so I can change it easier)where I take the final value and remove 2 from it.
Then I basically reverse again. MOD Final value by 60 and then CPT ((final value/60)*100)+Final value of 2nd MOD Seems to work for every thing but 000
I see a lot of posts as to why I am not using the RTC and the reason is I am getting these values over a network via consumed tags that are in DINT format. I pretty much have to play with what I have.
Thanks everyone for the help!
Last edited: