Countdown Timer Logic

FSPT_Tech

Member
Join Date
Jan 2007
Location
Compton, CA
Posts
42
Can someone help with me create the correct logic that would display a countdown timer on a Panelview. I need to create a timing function that counts down fro a set time to zero and have it displayed on a panelview screen. The operator needs to be able to enter a certain time via the panelview (in hours, minutes and seconds), start the timer which will turn on the conveyor, then have the conveyor stop when the timer times out, and an output to notify that the sequence is complete.

I'm using a SLC 5/03 processor with a Panelview 600 touch screen. I've tried different ideas, including using several timers and even using the realtime clock as a timer but can't seem to correctly make the timer count down properly as well as display the values as they count down. It seems pretty easy to create a timer where the display counts up but creating one that counts down to zero, which also shows the seconds, minutes and hours, count down on the Panelview is giving me a hard time. I'm sure it is very easy but I need some help. If I could get a sample that I can download it would be great.

Thanks for your help.
 
As for the countdown, subtract your timer acculated value from its preset
value while it is timing.
What is the max time the operator will enter?
 
This is a fairly common thing to do. You can use some simple math instructions (or a compute instruction) depending on the length of time you need to count.

For ex. (Hours * 3600) + (Minutes * 60) + (Seconds) and then move this value in to the timers preset value.

The only issue you might run into is the time is greater then the timers max value (32767 seconds or 9 Hours 6 minutes 7 seconds).

As for the countdown, Mickey is right, just do a (Timer.Pre - Timer.Acc)
 
The maximum time would be 24 hours. I'm using three counters to display the time values (seconds, minutes and hours). Will these counters work if I display the ACC values? Or should I use something different to tally the elapsed times?
 
This is a fairly trivial matter, so maybe just getting an extra set of eyeballs on your code will help. I've lost rack of the number of times I've missed something obvious in my own code. Can you post your program, either a screen snapshot or zip it up and attach it?
 
Will these counters work if I display the ACC values?
Well it can be made to work if you use 3 Count Down Counters (CTD) instead of Count Up Counters (CTU).
 
Last edited:
Thanks Christoff84 for your example. But please be patient with me. I’m sort of brand new when it comes to programming. I took some courses that my company sent paid for to do little modifications like these on our small units. I understand that this stuff is a piece of cake to you and others who’ve been doing this for years and do this for a living so please bear with me. I hate having to be held by the hand like this but I’d rather be honest than think I fully understand when I don’t.

I tried your example on my little processor trainer (a practice SLC with 32 I/O – switches and indicator lights connected to a Panelview).

The problem I’m having now is correctly displaying accurate values on the Panelview. Here’s how I’m simulating the program you sent (I hope I’m understanding this right):

The operator wants to run the cycle for 4 hrs. 45 minutes. So on the Panelview, in the minute numerical entry field (N7:1), I entered 45. In the hour numerical entry field (N7:0) I entered 4.

On the Panelview, I associated N17:0 with the numerical data display for hours and N17:1 for the minutes. These display the time.


When I start the timing sequence the PanelView display is showing -20 hours and -15 minutes. I’d like it to display 2 hours 45 minutes and keep displaying the countdown accurately. What I mean by that is I’d like to see the countdown change as would a conventional timer component (show the time counting down from so many hours to zero then time out).

Also, the values in N17:0 is not changing after 60 seconds. The counter counts up one but my minute display is the same.





What I’m I not seeing here? Sorry for seeming like an idiot and for the stupid questions but thanks for even attempting to help.
 
FSPT_Tech,

I wrote the program very very quickly as I was on my way out the door, so it is entirely possible I did something wrong.

However, N17:0 should be mapped to the hours remaining on the panelview. N17:1 would be the minutes on the panelview.

I did notice my mistake however, the SUB functions should use C5:x.ACC NOT c5:x.PRE. They were not changing because the preset value did not change.
 
FSPT_Tech said:
When I start the timing sequence the PanelView display is showing -20 hours and -15 minutes. I’d like it to display 2 hours 45 minutes and keep displaying the countdown accurately. What I mean by that is I’d like to see the countdown change as would a conventional timer component (show the time counting down from so many hours to zero then time out).

Also, the values in N17:0 is not changing after 60 seconds. The counter counts up one but my minute display is the same.

What I’m I not seeing here? Sorry for seeming like an idiot and for the stupid questions but thanks for even attempting to help.
FSPT, here is a revised version that works. I cleaned it up and added a Cycle Start, Manual Reset, automatic Sequence Reset, and also used a RTO Timer, so that you can start and stop the cycle without affecting the elapsed time.

I noticed that your I/O was not configured, showing no Input and Output Modules. I set up some fake I/O modules, so that the annoying error message would go away. You need to configure the I/O to match your PLC Trainer.
 
Last edited:
There is an error in Rung 000. In the EQU comparison statements, N7:3 should be N17:0, and N7:4 should be N17:1. These erronous addresses were accidently left in when I tested and converted the program from the LogixPro Simulator, which does not allow the N17 addresses.
 
Thanks Lancie1, for your example. The RTO timer is a good idea because we may need to pause the cycle at times. But I think something’s missing in your example. On rung 0, N7:3 and N7:4 are always zero. I’m setting my countdown time at 4 hrs. 15 min.

I enter 4 for N7:0 and 15 for N7:1.

When I start the cycle, the sequence ends after 60 seconds (when the Rotating 60-Second Timer ends).

The minutes and hours display (N17:0 and N17:1) never change. Also, the minute and hour counters (C5:0 and C5:1) ACC values are always zero. I think we’re on the right track but, like I said, there maybe something missing or maybe I’m not doing something right on my side.

I’ll work with this example a little more as well as with the one Christoff84 sent me. If you can correct yours and re-post it or let me know what I’m doing wrong I’d appreciate it.

Thanks guys!
 
Sorry Lancie1, I posted the last reply before I saw your reply with the corrections you mentioned. I'll make the changes and give it a try again. Thanks again.
 
Here are the last two rungs of the working version in LogixPro. You can see that the Display Time in N7:3 and N7:4 has decremented from 4 Hours 15 Minutes down to 4 Hours 5 Minutes. If you insist on using the N17 addresses, then change the appropriate addresses back. LogixPro does not allow N17.

Count-Down_Display.jpg
 
Thanks but another problem I'm noticing is that when the remaining minutes countdown to zero, instead of the hour changing to from 4 to 3 for the next hour countdown, it stays at 4. Also, instead of the minutes changing from zero to 59 for the next hour countdown, it changes from zero to -1. And every minute after that, the minutes remaining display is counting negative values (-2, -3, -4, etc.). I'll try to see what I can do with this problem (or if you can help with that I'd appreiate it). Thanks.
 

Similar Topics

Hello all, I am working on an old machine that has a hydraulic filter that must be replaced every so often. When the filter needs changing, a...
Replies
7
Views
1,556
So I'm fairly new to PLC programing. in my PLC class my task right now is to write some logic that uses a thumbwheel to set the timer thats...
Replies
29
Views
4,314
I have an unwinding roll process. On a display (7 inch Comfort) is a timer that shows "Time to Splice" in seconds. In the PLC (S7-1500), this is...
Replies
7
Views
2,314
Hi guys, Thought I might ask here if anyone knows, currently have tech support looking for a solution. I have a micro820 and wanting to...
Replies
8
Views
2,547
I did not create the program but I have a weird countdown timer problem. it is user input, say it is set for 5 minutes; it will countdown to...
Replies
9
Views
4,444
Back
Top Bottom