LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

pausing and continuing of a time function

Hello fellow engineers!
I would like some help from all of you. I am implementing a GUI in labview. Among the many things it requires, is a time diplay in minutes and seconds. The GUI must allow the user to set the time. For example, the user sets the time as 5 minutes. Then the VI must start a count down display of time. For example. it will start counting down from 5:00, 4:59, 4:58 and so on unil 0:00. I wish to implement two functions-
 
pause
 
continue.
 
When the user presses pause, the timing source should pause. and when the user presses continue, the time source should continue from where it has paused.
 
For example, the user presses pauses when it is 3: 59 and after ten seconds, presses 'continue', then the timing source should continue it's countdown from 3: 59.
 
I am not able to implement a pause and continue functionality on a timing function. I would apprecitae helpful ideas and suggestions from all fo you.
Thank you so much!
0 Kudos
Message 1 of 7
(3,534 Views)
That functionality is easy to create in a couple different ways. But given the limited information at hand (you are building a GUI) I think I would start with an event-driven implementation. The event structure would have a timeout event case (for decrementing the time); an event case to handling a value change event on the pause button (it would disable the timeout); and an event case to handling a value change event on the continue button (to reenable the timeout).

Rather than coming from a constant, the timeout value would be carried in a shift register and be initialized to 1000 msec. To disable the timeout, the pause event would change the value in the shift register to -1. To reenable it, the continue event would reset it back to 1000.

With this basic structure you could add additional events to handle other things that the interface needs to do.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 2 of 7
(3,527 Views)
Attached is an example, along the lines of what Mike suggested.  I was whipping it together when he responded, so you may already have one working... Example posted in LV8.0.  I realize there are a couple of bugs in the string display of the countdown... but hey... that is what you get paid for... LOL   Hope it helps you.

Paul
0 Kudos
Message 3 of 7
(3,522 Views)
Thank you so much! It was very helpful!

With warm regards,
Aparna.
0 Kudos
Message 4 of 7
(3,517 Views)
Thank you so much! It was very helpful!

With warm regards,
Aparna
0 Kudos
Message 5 of 7
(3,517 Views)
Here's another take on the solution. To simplify things a bit I combined the operation of Pause and Continue into a single button...

(By the way, when doing timing functions you want to use the time VIs not the tick count. The problem is that the tick count is simply a 32-bit counter that starts when LV launches and rolls over when it maxes out. Admitedly this doesn't happen very often but if you are creating an application that will be running for months at a time, it will happen.)

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 6 of 7
(3,505 Views)

@mikeporter wrote:

By the way, when doing timing functions you want to use the time VIs not the tick count. The problem is that the tick count is simply a 32-bit counter that starts when LV launches and rolls over when it maxes out.

Actually, I believe it's the OS counter, so it starts when you launch the OS. It wraps around after about 49 days, but for something like this it should be fine, because rollover math works fine when substracting.

Of course, if your timed period is larger than 49 days, then it won't be fine and you need the absolute time functions.


___________________
Try to take over the world!
0 Kudos
Message 7 of 7
(3,481 Views)