LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

case structure multiple inputs

Hi

I have been working on a project and trying to solve a problem for it for a while but can't seem to find a solution.

So this my simplified problem:

I have 6 different boolean buttons: A, B, C, D, E, F

If A is on, a certain case occurs.. lets call it "yellow"
If B is on, case "red" occurs
If A and B is on, case "pink" occurs
If C is on, case 'blue" occurs
...etc

Basically there are many different cases and I have multiple inputs to put into the case selector.  I tried using boolean arithmetic and different case structure for each case but didn't like either approaches.

What is the best way to do this?   I have attached a simplified vi. with inputs A, B, C.

0 Kudos
Message 1 of 22
(18,866 Views)

Build the booleans into an array, then use boolean array to number. Wire the number to the case selector.


LabVIEW Champion Do more with less code and in less time
Message 2 of 22
(18,858 Views)

Hello

nice, I was looking for a similar solution, this is what I implemented:

 

boolean_case_selector.jpg

 

Although I wonder, isn't there a a much more elegant way of indexing a case struct with mutually exclusive booleans?

 

I'd like something equivalent to the concatenated IF-THEN-ELSIF....ELSIF.... ELSE statements in C-like languages....

 

Thank you so much.

 

0 Kudos
Message 3 of 22
(18,820 Views)

Hi captain,

 

a case structure can have more than just 2 cases, so you don't need any IF-THEN-ELSEIF-ELSEIF-...-ENDIF monsters...

 

When your 3 InRange-tests always test the same input "BP" and the ranges don't overlap you might also use Threshold1DArray, which immediatly results in a number!

Best regards,
GerdW
CLAD expired, using 2009SP1 + LV2011SP1 + LV2017 (+LV2018 sometimes) on Win7+cRIO
Kudos are welcome Smiley Wink

Message 4 of 22
(18,813 Views)

Hello thanks for the input.

Well my very first implementation of the program was using nested TRUE/FALSE cases so it was ugly, I agree :-)

I know that I can use multiple choices in the case struct, my issue was to index the choices with an array of booleans (yes, as per your question, in my case they are not overlapping intervals so if one boolean is true all the others are zero).

I'm not sure my current implementation (see pic in the last message) is the best, I splitted the cases in a minor case converting the decimal conversion of the boolean array to a string label which pilots the *real* big case struct. I think it is much more "readable", but I feel still missing something.

 

Sorry if all of this sounds silly but I'm still learning to work with LV :-P

 

 

0 Kudos
Message 5 of 22
(18,804 Views)

A nice feature of the Case structure is that you can change the radix of the selector label to binary.  It makes it easier to see what's going on

 

Example_VI_BD.png

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

Message 6 of 22
(18,802 Views)

Interesting. Thanks !

0 Kudos
Message 7 of 22
(18,788 Views)

I suggest using radio buttons.

Message 8 of 22
(18,765 Views)

To expand on what pcardinale suggested, the radio button acts like a set of mutually exclusive booleans on the front panel and like an enum with numeric output and button label text in the case structure selector labels on the block diagram.

 

Radio button.png

Lynn

Message 9 of 22
(18,749 Views)

Whenever I try to make a case 011, 010 or 000 or anything case starting with a 0, it becomes red and in a string.  Anybody know why and how i can stop it? See attached.

0 Kudos
Message 10 of 22
(18,714 Views)