Timing down remaining time

dbh6

Lifetime Supporting Member
Join Date
Jan 2013
Location
Central, NJ
Posts
552
This is using RSlogix 5000 programming software
so i have a CTU thats counting up number of seconds when it reaches sixty it reset and starts counting again, also i'am using the .DN bit of the one sec CTU to another CTU counter thats going to serve as my one min CTU. So every time the .DN bit of the one sec CTU goes true the one min CTU increments by one and that also resets at 60 which is really 60 mins = 1hr. Then i have another CTU counter for my number of hours so each time the .DN bit of the one min counter goes true the hour CTU increments by one. The hour CTU is not reset when a preset is reached but rather when a Normally open push button is set.

Now the question,
i am using this to display time remaining on the agitators run time before they can service the agitator. The Preset time the customer requested is 30 hrs.
the remaining time has to be displayed on the HMI for hours and minutes COUNTING DOWN! notice how so far my counters are up counters.

So logic wise to display the remaining time i subtracted 60 from the one minutes CTU.ACC to display RUNTIME MiNUTES . For the Hour CTU i used the preset of 30 subtracted by the .ACC of the Hour CTU to display REMAINING HOURS. Lastly i also used a rung such that when the RUNTIMES MINUTES tag = 60, I moved a 0 into RUNTIME MINUTES because when you are counting down say you are at 30:01 you would expect the next number to be 30:00, but the number jumped to 29:60 make sense.

Now finally the problem i'am having looks like this. Say you reset the counter and start counting down this is what my count down looks like
1. 30.00
2. shoulf display 29.59, but diplays 29:00, then after a minute elapses displays 29:59 then it counts down normally, thats basically where i am stuck on i even tried it on different intervals say at 13:00 next number is 12:00 instead if 12:95 then after a minute elapses displays 12:95, ive tried different thing but so far they lead to nowhere help would be nice. Sorry for the long post just wanted everything out their
 
You have made things a bit difficult by using a timer and multiple counters. One timer alone could have used unless you envision times greater than 24 days.

Your setup is ok though.

To display the 'time left' make sure this code is after the code for incrementing and resetting the counters.

Instead of '60' subtract the actual seconds and minutes from '59'. If this is placed after the incrementing code the accumulators (when the 'time left' code uses them) will never actually be '60' only '0 - 59'. Subtracting the actual from '59' gives you '59 - 0' which is what you want.
 
@ Bernie, i just wrote the code and thanks to you it works like i wanted it to. That 59 was the key my rung placements of the "minute remaining" was after the incrementing and resetting of the counters so that was fine but now it truly counts down nicely 30:00 to 29:59......29:00 to 28:59 thanks Bernie appreciate it.
 
Definitely Iam new to plc 's ,graduated as an electrical engineer with a concentration in control systems, I'm beginning to love writing logic, the "thinking like a machine" is the hard part but I guess experience will play its part, thanks for your help once again
 
@ bernie i just realized something, as per our discussion the counting down works fine, but say we reset back to our preset of 30 hrs, it displays 30:59 because we are using 59 to subtract. Instead i'am trying to let it display 30:00 when reset and then start counting down from there the next number being 29:59, your input is appreciated
 
@bernie i actually thought i had it working where when reset it should go to 30:00 then after one minute the reading should be 29:59, my issue is after it resets based on the logic we discussed it starts to count down from 29:59 as opposed to waiting one minute then going to 29:59, let me know what you think when you have the time.
 
At the start the 'time left' should be:

30 hours
0 Minutes
0 Seconds

One second later it would be

29 hours
59 minutes
59 seconds

Is this what you are seeing?

Thinking about this it is showing 1 second less than the time left, but i'm not sure how to correct it with the counters you are using. I'll think about it.
 
Last edited:
As Bernie is suggesting, since you are not displaying the 'seconds' value, it will display 30:00 for only a split second (and you may not see it), then 29:59 (AND 59 seconds, if you could see them).

🍻

-Eric
 
@ Bernie & Eric, i'am basing all the counters from a motor on bit when that motor on bit is true then the counters start counting. Now to what you both mentioned it starts at 30:00 but a seconds or split second later it goes to 29:59, to make sure this is happening i disabled the motor on bit and reset it and since it is reset and the motor on bit is false it did in fact reset to 30:00. I am only displaying hours and minutes, so considering all of that once its reset i want it to wait one minute before displaying 29:59 because technically speaking after a minute has elapsed is when we should read 29:59 not when a second or split second has elapsed. So thats what im currently stuck on, its a bit tricky, but im still trying let me know if you guys have a solution to this based on how we have done it thus far.
 
That's what my oven timer does also. From the time I enter it immediately drops to the next lower minute. Only in the last minute does it display seconds. I'm not sure how to help except show the seconds also. Maybe they'll understand.
 
This is how i currently wrote the logic

Rung 1
XIO (one_sec.dn)-------------------------------------TON (one_sec) preset = 1000

Rung 2
XIC (motor_on_bit)-------XIO (one_sec.dn)---------CTU (one_sec_ctr) preset = 60

Rung 3
XIC (one_sec_ctr.dn)---------------------------------CTU (one_min_ctr) preset = 60

Rung 4
XIC (one_min_ctr.dn)--------------------------------CTU(one_hour_ctr) preset = 30


Rung 5
XIC (one_sec_ctr.dn)---------------------------------RES (one_sec_ctr)
also on rung 5 a XIC (reset_pb) is branched under
the XIC (one_sec_ctr.dn) for the reset

Rung 6
XIC (one_min_ctr.dn)---------------------------------RES(one_min_ctr)
also on rung 6 a XIC (reset_pb) is branched under
the XIC (one_min_ctr.dn) for the reset

Rung 7
XIC (reset_pb)---------------------------------------RES (one_hour_ctr)

Rung 8
---------------------------------------------------SUB(59-one_min_ctr.acc)
store value in remaining minutes

Rung 9
---------------------------------------------------SUB(30-one_hour_ctr.acc)
store value in remaining Hours

Rung 10
EQU (one_min_ctr.acc = 0) AND EQU (one_hour_ctr.acc = 0)------MOV(0 into one_min_ctr.acc)


-
 
i actually went and tested the microwave i put in 10:00 but after a split second diplayed 9:59, its like it completely disregarded that one minute. Interesting.
 

Similar Topics

Hello, I am struggling to figure out some logic. I have an analog pressure sensor coming into the PLC and would like to have multiple timing...
Replies
4
Views
151
the plant I am supporting uses a siemens graph function to do some of the step procedures. in several steps it waits for the step to execute for...
Replies
1
Views
767
All Using a MicroLogix 1400. Not a huge program doing an auto stop function based on a calculated roll diameter Using encoder feedback for...
Replies
12
Views
3,242
Hi all, I'm trying to fully understand the different effects of the Loop Update Time parameter within the Logix PID instruction. I was always...
Replies
18
Views
4,604
Logix 1756-L82E processor. I am using the .ST bit to time how long a MSG takes to complete. This works fine except for every 10th MSG cycle takes...
Replies
5
Views
1,625
Back
Top Bottom