LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Coincidence logic

Solved!
Go to solution

Hey all, I'm new to LabVIEW and have what I think is a pretty straightforward question.

 

Basically I have 8 outputs, each a single scalar value. I expect 6 of the outputs to be ~0 and the other 2 to be some positive value, and which combination is non-zero signifies some arbitrary thing which I would like to identify i.e. if 1&2 > 0, then A, 1&3 > 0, then B, .... if 7&8 > 0, then _. So that is 36 possible combinations/outcomes total (8+7+6+5+4+3+2+1). If >2 or <2 outputs are non-zero, I would like to ignore.

 

I assume the first step is to run each output into a 'greater than' comparator, but I'm not sure where to go from there except a complex system of booleans. Does anyone know a better way to accomplish this? Thanks for reading!

0 Kudos
Message 1 of 4
(1,133 Views)
Solution
Accepted by topic author JPilot

You can convert the array of 8 Booleans to a scalar integer  (one bit per Boolean) and use it to index into a lookup table containing all possible 256 cases.

 

Now sure what prevents you from having more than 36 28 cases. Can you always guarantee that only two booleans are TRUE and all other false under all conditions? What if none are TRUE? What if 1&2&6 are TRUE?

 

(Note that there are only 28 possibilities of picking any two from eight (7+6+5+4+3+2+1)).

 

You cannot "ignore" (your words) a case, but you can initiate special handling. You can fill the lookup table with a sentinel value for all cases that should not occur (e.g. empty string, "ERROR", or similar) and proceed accordingly.

Also be aware that equal comparisons with floating point values can be tricky. What' the definition of ~0?

0 Kudos
Message 2 of 4
(1,105 Views)
Solution
Accepted by topic author JPilot

See if this can give you some ideas (using a map with a boolean array as key and a string as value).

 

altenbach_0-1667682675986.png

 

Message 3 of 4
(1,086 Views)

This looks like exactly what I need, thank you so much!

0 Kudos
Message 4 of 4
(1,069 Views)