LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Counting Boolean Transition

Solved!
Go to solution

Hi. I'm new to labview. I have managed to do a boolean transition and it works. But now I want the boolean 3 true and the false 3 to count as 1. I thought it would be easy but haven't figured a way to do it.

0 Kudos
Message 1 of 11
(3,057 Views)

Hello,

 

for me it is not really clear what you want to achieve.

It is good that you attached your code. You can store your example data in the boolean array with context menu of the array control, "Data operations / Make current value default". Then explain what you expect with your example data.

 

P.S. Transitions are recognized with an Exclusive OR (even a Not Equal works).

Greets, Dave
0 Kudos
Message 2 of 11
(3,044 Views)

nasha0101_0-1671090347342.png

Hello,

Instead of this image, I want to make 1 transition for 3 true boolean and 3 false.

0 Kudos
Message 3 of 11
(3,038 Views)

@User002 wrote:

 

Hello,

Instead of this image, I want to make 1 transition for 3 true boolean and 3 false.


You now have +1 if current is true and previous is false).

 

If you want to add 1 when going from true to false, simply invert the logic:

wiebeCARYA_0-1671095981778.png

 

That shift register is not initialized. So it will keep the last value of the array for the next run. The first run the value in the shift register is false, the 2nd time (and thereafter) it will be true since the last value in the array is true.

 

Not sure if that is what you want...

 

Note that you are reinventing Boolean Crossing PtByPt.vi, which isn't bad...

0 Kudos
Message 4 of 11
(3,022 Views)

I still haven't booted my laptop this morning but, 

  • If the input is a scalar value use Value Changed.vim in an acquisition loop and increment a counter if TRUE [hint: bool to 0,1 + previous val = previous val++ if TRUE for a running count] or just sum array elements after the loop
  • If it is an array use Count Edges or Count Transitions (I dissremember the exact name)

"Should be" isn't "Is" -Jay
0 Kudos
Message 5 of 11
(2,989 Views)

But the output still same as my code.

 

This output should be 0 because I want only 3 true and 3 false as 1 transition 

nasha0101_1-1671153334842.png

 

This is that output I want

nasha0101_2-1671153427430.png

 

0 Kudos
Message 6 of 11
(2,957 Views)
Solution

This should work for you:

Transitions.png

It takes the next 6 elements starting from the ith element and compares it to the transition requirement. 1 if equal, 0 if not.

0 Kudos
Message 7 of 11
(2,927 Views)

@User002 wrote:

But the output still same as my code.

 

This output should be 0 because I want only 3 true and 3 false as 1 transition 


That wasn't clear. I thought you mentioned 3 just to refer to the example, not as a specification.

 

It still is underdefined. Is 3 the minimum number or the exact number Of trues and\or falses?

 

If you only want exactly 3, add a false\true before\behind the reference array.

0 Kudos
Message 8 of 11
(2,919 Views)

Yes. This is what I want. Thank you for the help.

Message 9 of 11
(2,916 Views)

@User002 wrote:

Yes. This is what I want. Thank you for the help.


Your first kudo for accepting an answer!

0 Kudos
Message 10 of 11
(2,908 Views)