Hello,
I have a counter that increments an INT value once per minute
I want to display this value in Minutes until 60, then Hours/Minutes thereafter on the HMI
Codesys V3.5 SP16
I can divide the minutes by 60 to get hours, but then the minutes is still more than 60.
Example: a process has run for 350 Minutes. I need to display "5 Hours 50 Minutes"
But if it's only been 45 Minutes, I don't want "0 Hours 45 Minutes" , just "45 Minutes"
Last edit: Wiresplus 2024-05-25
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
I have a counter that increments an INT value once per minute
I want to display this value in Minutes until 60, then Hours/Minutes thereafter on the HMI
Codesys V3.5 SP16
I can divide the minutes by 60 to get hours, but then the minutes is still more than 60.
Example: a process has run for 350 Minutes. I need to display "5 Hours 50 Minutes"
But if it's only been 45 Minutes, I don't want "0 Hours 45 Minutes" , just "45 Minutes"
Last edit: Wiresplus 2024-05-25
hey
time := INT_TO_TIME(minutes * 1000 * 60);
update: forum show the math wrong
Last edit: nano 2024-05-26
You could use the Modulo function to get the minute part from the total minutes:
Minutes := TotalMinutes MOD 60;
Here a code for an Operation Counter with :
days,hours,minutes,seconds as an example, maybe it points you the right direction ?