Subtracting minutes from time stored as a decimal.

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:

Similar Topics

Hi I am trying to find the simplist way to add/subtract/multiply/divide from all the dint's in a 42dint array. The timing on our main oven loads...
Replies
3
Views
3,002
Hello: I'm working in the Connected Component Workbench environment with a Micro820 PLC. Is there a way to add-subtract date & time values. Thanks
Replies
7
Views
3,535
Basically I have a digital value I need to scale down using this equation: 'end_value = (D1-1000)/100' but I'm having trouble writing it down to...
Replies
3
Views
2,184
in a slc 5, Is there a way to subtract one counter acc from another one and then say if the subtraction is over 5 that it would trigger and output...
Replies
3
Views
1,592
Rslogix 500 Im trying to subtract 10 from the level of a tank we have and then use a less than or equal compare to start a pump. How can I...
Replies
11
Views
2,051
Back
Top Bottom