difference between 2 times and showing remaining time

Join Date
Dec 2008
Location
Toronto
Posts
42
Processor : PLC5

I have an situation where I need to set a time into the Panelview HH:MM:SS (N7:10, N7:11, N7:12). This time is the total time to keep the water pump running. Next they want a running time(counts up)for how long the pump has been running displayed on the panelview (N7:20, N7:21, N7:22). Now for the really complicated part is they want to display the time remaining(counts down) (N7:30, N7:31, N7:32). This is the SET TIME(N7:10, N7:11, N7:12) minus the RUNNING TIME (N7:20, N7:21, N7:22).

I spent about 12 hours tring to figure this out. My numbers are all over the place for the Time Remaining. They turn positive, sometimes negitive. Please help. Any response would be greatly appreciated.
 
Think about how it's supposed to work. There's more math than just subtracting. If it's supposed to run for, say, an hour and a half, at 31 minutes into the run, you're showing a negative minutes if all you're doing is straight subtraction...
 
Do you need to set a time that runs for more than 9 hours?

This will determine the basic approach due to the 32767 preset limit of a basic timer. After that the calculations aren't hard.
 
I would convert HH:MM:SS to seconds and for times of more than 9 hours but less than six months, I would use a floating point register to hold the seconds.
A timer increments the floating point register once every second, but you have to be careful how you do this. If you reset the timer then you will loose however much time your scan time is every second. At the end of a day that could add up several minutes off (~15 minutes with a 10mS scan). I've shown one way to deal with that by adjusting the timer ACC instead of resetting the timer in the attached programs.

Then the floating point elapsed time and the time remaining has to be converted back to three separate integers, one for hours, one for minutes, and one for seconds. But you have to remember to account for rounding when its converted to an integer.

See the attached for an example of just one way to do it.
 

Similar Topics

Hello, I have a problem with AO- and AA-Tags. When I use for example the tag AO_Test with the address 200 and type the value 1,2 in, the AA-Tag...
Replies
7
Views
1,411
As per the title. This might seem like a basic question to many, but I'm unclear about the difference between a coil ( ) and an application...
Replies
28
Views
4,034
Good Morning , I have 2 Frequency Drive panels to build and commission . It is for 2 pump systems . Just wondering , what is the...
Replies
4
Views
1,971
Hi Experts, Good day! What are the differences between PCS7 SIMATIC Batch and PM Control? Do you have any manual like "Getting Started "...
Replies
0
Views
809
I have a Automation Direct Click Plus that you can buy option CPU slot modules for input/outputs. The slot modules have the options of sinking...
Replies
9
Views
2,820
Back
Top Bottom