04-04-2013 05:44 PM
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.
04-04-2013 06:08 PM - edited 04-04-2013 06:18 PM
Build the booleans into an array, then use boolean array to number. Wire the number to the case selector.
04-05-2013 03:18 AM
Hello
nice, I was looking for a similar solution, this is what I implemented:
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.
04-05-2013 03:36 AM - edited 04-05-2013 03:37 AM
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!
04-05-2013 04:23 AM
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 😛
04-05-2013 04:24 AM
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
04-05-2013 06:56 AM
Interesting. Thanks !
04-05-2013 08:53 AM
I suggest using radio buttons.
04-05-2013 09:58 AM - edited 04-05-2013 09:58 AM
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.
Lynn
04-06-2013 09:39 AM
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.