LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how can i improve this 2min countdown timer?

Solved!
Go to solution

Hello

 

I'm trying to see if anyone has any ideas on how to improve this simple 2 minute countdown timer.  All suggestions are welcome!

 

Thanks in advance!

 

-noviceLabVIEWuser

0 Kudos
Message 1 of 4
(5,318 Views)
Solution
Accepted by topic author vjm-ndt

Only minor modification to the logic, major modification is adding a wait to the while loop.  No need for this to be a CPU hog.

 

2min Countdown Timer_Mod.png

Message 2 of 4
(5,296 Views)

As an alternative, I used a case structure to eliminate some calculations for Sample Time while Air Time is counting down and vice versa.  I don't know if this is necessarily better.  Your original code was simple and it worked fine.

 

False case showing:                                                                           True case showing:

 

2min%20Countdown%20Timer[1]_BD.png2min%20Countdown%20Timer[2]_BD.png

 

- tbob

Inventor of the WORM Global
Message 3 of 4
(5,289 Views)

If you are never going to change the time limits, you could extend tbob's idea further by converting the elapsed time to an integer and connecting the integer to the selection terminal.  Then change the cases to "..60, Default" and "61..120".  You do not need the comparisons.  However, changing the time limits requires a change to the code, not just to the value of a constant.

 

I would also place each constant only once and wire all uses of it to that one instance.  Then if you ever need to change the limit, it only needs to be changed at one place. It is very easy to miss one of three or four copies of a constant.

 

Lynn 

Message 4 of 4
(5,270 Views)