Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Looking to implement a timer inside a while loop

Hi,
 
I am trying to program a LabView application where I have a mail 'While' loop for continuous data acquisition. Data is continuously acquired and written to file in each iteration of this loop.
 
Upon meeting a certain condition in the data, I plan to implement the start of a timer. However, this timer should not interfere with the normal execution of the while loop. After this timer is complete, I check for a certain second condition and stop my data acquisition.
 
I tried using the 'Wait' function, but could not succeed programmatically in avoiding the delay with interfering with the normal functioning of the while loop.
 
Could there be a simple workaround?
 
Thanks,
-Dude
0 Kudos
Message 1 of 4
(3,091 Views)
The wait functions pause execution. What you want to use is one of the functions that return the current time. You can use Get Date/Time in Seconds or Tick count with a shift register and calculate the elapsed time or you can use the Elapsed Time function (LV 7.x). Reset it to restart the timer and when the target time has been reached, the Boolean output "Time has Elapsed" will go true.
0 Kudos
Message 2 of 4
(3,090 Views)

Hey Dennis,

Thats a nice option. I'm using the 'Get Date/Time in Seconds'. I have attached a scaled down version of what my code does. I check for a true condition inside my while loop, and only then I want to count the elapsed time. However, there is also an instance for the initial setting for 'Get Date/Time in Seconds', which is outside the while loop and which I would like to reset to synchronize with the one inside the loop.

If the true condition occurs at the first iteration of the loop, then both are synchronized. Else, I would somehow have to reset the one outside. Or maybe there is a simpler workaround??

Thanks,

-Dude

 

 

0 Kudos
Message 3 of 4
(3,067 Views)

Hey Dennis,

Nevermind. Figured it out via 'Elapsed Time.VI'. The best and simplest solution ever. Anyway, thanks for all your help buddy.

Regards,

-Dude

0 Kudos
Message 4 of 4
(3,060 Views)