LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

increment loop counter

Hi Sir/Madam,

 

Does anyone know how to write a increment loop counter base on a boolean input?

Basically I would like to track the number of transition of a boolean start from 0 to 3. Once it reaches 3 I would like the counter to reset to 0 again.

 

Your help is much appreciated. thanks in advance.

 

Regards,

Alfred Tan

0 Kudos
Message 1 of 4
(2,100 Views)

Hi Alfred,

 

you should use a shift register to create your own counter:

check.png

The example detects transitions of your bool input, counts them and limits to counter to a range of 0...3.

Best regards,
GerdW


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

GerdW,

 

You are totally ROCK!!!! thanks for sharing.

By the way, why are you using the shift register before the Xor gate?

I connect my Boolean to the Boolean converter and follow by the + gate. It still work fine.

Please advise. Just want to learn more.

 

Thanks.

 

Regards,

Alfred Tan

0 Kudos
Message 3 of 4
(2,055 Views)

Hi Alfred,

 

you said you wanted to track transitions of the boolean - but not the state of the boolean itself.

 

To detect transitions you can use a feedback node with an XOR. Or use the corresponding point-by-point function...

Best regards,
GerdW


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