LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

store value for later use in while loop

Hello,

I have a data acquisition VI that is time-controlled through a "wait until
next ms" subvi in a while loop. I want to add an option to have a boolean
switch inside the while loop that enables an output in my card. My problem
is that I want to count the time that this switch is set to true, so as to
control when it will be turned off.

For example my acquisition is already in the 30th second and I turn on the
switch (set to true). I want it set to false on the 40th second.

Using "tick count" I can count the time but I need the initial value of time
when switched to true to be stored somehow, so as to extract it from the
final one (switch to false).

Can anyone help me?

Thank you

g
0 Kudos
Message 1 of 3
(7,354 Views)
Hi G,

here's is an example that shows how to count elapsed time after switch on.

Good luck,
Alberto
0 Kudos
Message 2 of 3
(7,354 Views)
> Using "tick count" I can count the time but I need the initial value of time
> when switched to true to be stored somehow, so as to extract it from the
> final one (switch to false).
>

To maintain a value from one iteration of a loop to the next, your best
bet is a shift register. Popup on the right or left edge and Add a
Shift Register. Anything written to the right edge inside the loop can
be read from the left edge. A value written to the left edge outside
the loop is the initial value. Reading from the right edge outside the
loop is the value of the last iteration.

You want to use a shift register, writing the value when you read the
timestamp, then passing the value through unchanged until the comparison
with the current time shows enough t
ime has elapsed.

Be sure to look at examples that use the shift register too.

Greg McKaskle
Message 3 of 3
(7,354 Views)