From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Simple timer

Solved!
Go to solution

I'm trying to time an event as part of larger VI, I've attached the bit I want to do the timing, it's based on the example VI. My input will be initially true then go false for a period of time (which I want to measure) and then go back to true at which point I want to stop the timing and stop this VI so it then moves on to the next step. I can see why my timer doesn't work, but I can't see what to do to make it work. Basically when the case structure goes back to true it goes back to outputing a zero, so it always just returns the value of the final timer. Is there some way i can make it store the initial value and save that to then subtract off the final value?

Cheers

 

0 Kudos
Message 1 of 6
(3,167 Views)

You need a shift register or feedback node to store the millisecond timer value at which the boolean input first goes false.  If the existing feedback node is equal to 0, and the value from the DAQ assistant is false, store the millisecond timer value - that's the point when the input first changed to false.  Otherwise, just pass through the value from the shift register (or feedback node).

0 Kudos
Message 2 of 6
(3,162 Views)

Cheers, but I've already tried that and can't make it work. The feedback node only stores the last value, but I need it to store the first value. The problem is that each time my while loop runs it re-runs the true/false case structure and overwrites the value in the feedback node. I can right click the tunnel on a case structure loop and say "Default if unwired" but what I really need is "use the previous value if unwired" or some equivalent way of doing that.

 

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

This sounds like the perfect application for an action engine (AE) with timing capabilities.  This is a extended type of functional global variable.


Regards,

Peter D

0 Kudos
Message 4 of 6
(3,135 Views)
Solution
Accepted by topic author timswait

@timswait wrote:

I can right click the tunnel on a case structure loop and say "Default if unwired" but what I really need is "use the previous value if unwired" or some equivalent way of doing that.


Again, you need a feedback node, as shown below:

Simple Timer.png

0 Kudos
Message 5 of 6
(3,122 Views)

Cheers, I see now, I've tried it and that does just what I need. That timer VI looks like it would be pretty handy too, but the feedback node option works fine for me.

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