LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can i see elapsed time (in every seconds) in a while loop...

I want to see "elapsed time" (update in every seconds. 0,1,2..).I put this func. in a while loop but this while loop also include something other.In my elapsed time.vi i put an flat sequence.This flat sequence spend 3 seconds and so the time indicator update itself in every 3 seconds..(0,3,6,9,..). But i need to see every seconds..Is there anyway to do? Thanks..
0 Kudos
Message 1 of 6
(3,501 Views)
Hi ifo.

A solution could be a parallel loop only for elapsed time, allowing plenty of time for other purposes.( see attached).
If usinf labview 7.1, this could be a good case for "timed loop"

Hope it helps.
Alipio
---------------------------------------------------------
"Qod natura non dat, Salmantica non praestat"
---------------------------------------------------------
Message 2 of 6
(3,501 Views)
Hi alipio..
This is exactly what i need.Thank you..
But i want to ask you another question.
If i remove the wait func.( in your answer) it also works properly.so i did not understand why did you use this wait func.
Thanks again..
irfan
0 Kudos
Message 3 of 6
(3,501 Views)
Hi ifo
The "while loop" executes as soon as possible, grabbing as much processor time as possible. Since you only need it every 1 second, allow about 900 milisecons for other processes.
You can see this topic checking the processor % work (administration tools), and you will see what I mean.
So, when using while loops, is a good practice to allow some time for other things, if possible.
Hope it helps.

Alipio
---------------------------------------------------------
"Qod natura non dat, Salmantica non praestat"
---------------------------------------------------------
0 Kudos
Message 4 of 6
(3,501 Views)
Hello Irfan -

There are two ways of seeing the time indicator update every second. I am including two simple VIs to show you what I mean:

1. In Irfan1 you will see that there is a for loop inside the while loop. With the wait outside the for loop I am simulating your code that takes 3 seconds to execute. Since there is no dependency between that wait and the for loop, they both run in parallel. The disadvantage is that when you hit the stop button, the program will run for 9 more seconds, because it has to come out of the for loop (3 seconds) to read the new value of the stop button (True) and three more seconds to finish executing the current loop.

2. In Irfan2 you will see that there are two parallel while loops. One will take care of keeping
track of the seconds elapsed and the other one of the execution of your code.

Other than that, the only option is to break your three second of execution code into one second of execution pieces, so that you can measure the time at every piece, and then get 1 second intervals.

Hope this helps!

S Vences
Applications Engineer
National Instruments
Download All
0 Kudos
Message 5 of 6
(3,501 Views)
Hi Alipio..
This information is so illustrative. Thank you again..

irfan
0 Kudos
Message 6 of 6
(3,501 Views)