LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Pause and Resume Time Elapsed with Events

Hi eveybody,

 

I am trying to develop a simple function where I can pause and resume elapsed time. The main idea is to pause and resume a Fluke 2638A Hydra scan and simultaneously pause and resume the elapsed time. The elapsed time allows the main VI to timeout (return an error) if no scans appear after 16.67minutes. This is done with button presses therefore an event structure is used.

 

The Timeout of the event structure is to check if the scan has been completed and to read the time elapsed.  I took the approach of creating this function seperate from the Fluke VI in order to optimize it. The while loop is a producer in the main VI, and the event strcutures are vital to the VI.

 

This Timing VI works, but has a huge drawback. Everytime I press button Resume (after pausing it) the while loop iterates twice (or more depending on the time of pause and resume) before continuing the timing. Therefore, I am lagging behind the actual time. In other words, as soon as I press resume I want the time elapsed to start and not have a delay.

 

The actual VI has a timeout of 200ms not 2s. The 2second timeout was enter for troubleshooting purposes.

 

My main idea was to create a function that can pause and resume elapsed time within an Event structure. I don't know how I can initiate a Tick count with the time it had when the button Pause was pressed. This would simplify the VI down below. Instead, I had to calculate the time difference between the moment the Pause button was pressed and the current Tick count value after Resume was pressed (Case Structure "1").

 

Is there a way to simplify this function while keeping the Event Strcuture inside the Producer Loop? 

 

Front panel Timing.JPG

 

Timing VI.png

Timing VI2.png

Timing VI3.png

Timing VI4.png

Timing VI5.png

 

 

 

Here is a snippet of the Producer Loop from the Fluke DAQ VI I am developing. The Timing function (Elapsed time) has not been implemented. It has a elapsed time function where the Pause and Resume functions are not taken into account.

Prodcuer Loop.JPG

 

 

Thank you.

0 Kudos
Message 1 of 6
(6,647 Views)

Jcesar,


I'm not sure exactly what you want to do, but the CLD prep material goes over how to create a function that keeps track of elapsed time and can be paused.

 

https://decibel.ni.com/content/docs/DOC-35414

 

The VI is a basic action engine which makes it pretty easy to use.

Matt J | National Instruments | CLA
0 Kudos
Message 2 of 6
(6,600 Views)

Ouch. That looks difficult. It's best not to put code in your event structure but rather you should put functions. That way you can reuse them and more easily test them. 

 

I wrote this timer class a while ago. Open the project and run the Test Timer vi. It should be pretty self explanitory what the functions do.

0 Kudos
Message 3 of 6
(6,585 Views)

Jcesar1029,

 

If I understand your problem correctly, the extra loop iteration after you press resume is causing your problem. Take a look at the code snippet I have added. I moved the resume value change event structure case so that it would be combined with the timeout case.  Now the while loop will not need to take an extra iteration before entering the timeout case with a "current value" of 1. Hope this helps! Otherwise, I would look into some of the resources that have already been posted here by Jacobson and StevenChandler.

Aimee Matland
Applications Engineer
ni.com/support
0 Kudos
Message 4 of 6
(6,521 Views)

Yeah this looks overly complicated.  The CLD would recommend a functional global that is called for holding the information like is paused, is stopped, and time remaining.  Then just provide input in the form of an enum stating if the timer should be reset, paused, resumed, or queried.  I usually start with the Elapsed Time express VI, convert it to a subVI, then make the changes to it.

0 Kudos
Message 5 of 6
(6,506 Views)

Attached is a stop watch timer program I made a while ago. The logic can probably be improved. The stop watch has a start/stop button and a reset button. Hit the start button to start the timer, and the stop to stop it. If you hit start again, the timer will start again withou resetting the elapsed time. Hit reset to zero the elapsed time. Hope this helps.

 

Cheers,

mcduff

 

 

0 Kudos
Message 6 of 6
(6,487 Views)