LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Keep Boolean on for a set number of loops

Solved!
Go to solution

I'm working on a program that is counting peaks.  I have a Boolean LED set to blink when a peak is detected.  My issue is that the timing resolution is so small (10ms) the LED flash from a detected peak doesn't stay on long enough to see it.  Is there a way to trigger a Boolean then latch it on for a set number of loops?  I don't want to use a separate timing loop, as I don't want to interfere with data collection.  Any help would be great.  Thanks!

0 Kudos
Message 1 of 7
(3,459 Views)

Hard to say without seeing how you've got it coded up.

One method would be to keep your LED update code in a separate loop and have your peak detection code send it a notifier.

If set up properly, this shouldn't have any effect on your data collection timing and your LED update code can use whatever duration you want.

0 Kudos
Message 2 of 7
(3,442 Views)

Maybe a combination of Boolean Crossing Pt by Pt to determine when it comes on, along with Elapsed Time Express VI that tells it when it should be off.  Set the timer for how long you want to turn it on, and use the pt by pt, to reset the timer.

 

You may need to invert the logic so that Time Elapsed? would turn off the boolean.

0 Kudos
Message 3 of 7
(3,428 Views)

Here is the main and sub VI.  To simulate connect a function generator or some other sine wave.

0 Kudos
Message 4 of 7
(3,425 Views)
Solution
Accepted by topic author athiggins

One possibility would be to have an array of N booleans in a shift register and always replace the oldest with the current value. Make a LED light up if at least one of the array elements is true (using "Or array elements").

 

Here's a quick example. You can adjust the duration by changing the initialized array size. This one keeps it lit for 200ms (20 x 10ms).

 

DelayOff.png

 

Message 5 of 7
(3,408 Views)

Hi Altenbach, this worked great.  Thanks!

0 Kudos
Message 6 of 7
(3,376 Views)

Note that if you can live with a small set of possible delays (8, 16, 32, 64 iterations), you can do the same with a single integer by changing the datatype of the shift register. (for 8 bits, you need to insert a "ToU8" after the "boolean to 0,1". (you might want to insert the correct conversion anyway to avoid the coercion dot)

 

DelayOffU16.png

 

 

0 Kudos
Message 7 of 7
(3,312 Views)