ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Counter with boolean input

Hi everyone, I'm trying to make a counter that has a boolean input. I would like the counter to work in the following way: the counter has to stop once I have 5 true samples in a row. How can I do?
I am attaching what I have tried to do in vain.

0 Kudos
Message 1 of 3
(2,703 Views)

Hi giu,

 

two easy options:

  1. Use an array with 5 elements. With each call of your counter you shift the array by one element and put the new boolean value in first place. When all 5 elements are TRUE then you got your condition found.
  2. Use a shift register to count the TRUE values. With each TRUE you count up by one, with each FALSE you reset to zero. When the counter is >=5 then your condition is met…
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 3
(2,681 Views)

@giu95se wrote:

I am attaching what I have tried to do in vain.


WIth each iteration the boolean needs to be true with a certain random probability. Use the dice.

 

The following is similar to the second suggestion above. For illustration I also added a chart. Make sure to study it in every detail.

 

altenbach_0-1602272439571.png

 

0 Kudos
Message 3 of 3
(2,664 Views)