LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to find valid cases in truth table?

Solved!
Go to solution

Hello,

 

I am trying to use a truth table to select the next case in my state machine. The number of possible cases is 256 with an 8 entry set of booleans. Below is a generic example.

 

Obviously I only need the passing conditions, but how do I weed them out of the table?

 

                          0          1          2          3          4          5          6          7          8          9          10        11        12        13        14            15in house?            F          T          F          T          F          T          F          T          F          T          F          T          F          T          F            Tpassed test?       F          F          T          T          F          F          T          T          F          F          T          T          F          F          T            Tscrapped?          F          F          F          F          T          T          T          T          F          F          F          F          T          T          T            T in inventory?      F          F          F          F          F          F          F          F          T          T          T          T          T          T          T            T

                                                                                                                                               

 

The numbers along the top refer to the result of the code just before the case structure in the attached vi.

 

 

Tay

0 Kudos
Message 1 of 10
(8,768 Views)
Sorry about the table formatting. Today hates me. I don't know how to edit the post.
0 Kudos
Message 2 of 10
(8,765 Views)
Could you be a bit more specific?  What do you mean that you need only the passing conditions?  Which passing conditions? Only where one or more or True?  Is there a priority of operation? Based on the names you gave each variable, I do not understand what the ultimate goal is or how the variables relate to each other.  Maybe there is a different approach that makes better sense?
Message Edited by PJS on 11-05-2009 12:05 PM

Paul
0 Kudos
Message 3 of 10
(8,761 Views)

slipstick wrote:
I don't know how to edit the post.

Select Edit post from the options menu located on the top right corner of the post which you want to edit. But please note the time for editing is only 10 minutes from the time of the actual post.

 

Mathan

Message Edited by Mathan on 11-05-2009 11:08 AM
0 Kudos
Message 4 of 10
(8,758 Views)

I think I follow-  You want to execute a case that does something for maybe 8-12 "Valid" combinations of your booleans and does nothing on other cases.

 

I'ld suggest using a "ring" control for your case selector, deselect the "sequential values" checkbox in the control's properties>edit itens tab,  and allow undefined values at runtime.  Yor case structure should contain a case for each "valid" value and a default case with null code in it to ingnore the "invalid" values


"Should be" isn't "Is" -Jay
Message 5 of 10
(8,750 Views)
Jeff's idea is a pretty good one, I would add that in your state machine, use text strings and then use the strings property of the rin and value to index the selction of the state.  this will keep you statemachine very readable.

Paul
0 Kudos
Message 6 of 10
(8,743 Views)

I often do this.  Take each of your eight booleans and bundle them into an array, convert the array to a number and select your case based on the number.  So, if the first, forth and fifth (from the top) boolean are true you have case 25 (10011000 = 25).  You can have one case handle multiple values by separating them with a comma in the selector.  It'll make you famous.

undefined  

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 7 of 10
(8,711 Views)
Solution
Accepted by topic author slipstick

jcarmody wrote:

I often do this.  Take each of your eight booleans and bundle them into an array, convert the array to a number and select your case based on the number.  So, if the first, forth and fifth (from the top) boolean are true you have case 25 (10011000 = 25).  You can have one case handle multiple values by separating them with a comma in the selector.  It'll make you famous.

undefined  


I do the same thing, but set the radix of the case display to Binary.

Message 8 of 10
(8,709 Views)
This is a good solution, with both the radix and the info about how the booleans relate to the case number. Creating the boolean array I had; where I was falling down was how to determine that cases 25, 34, and 214, for example , were the valid cases. Now I don't care; I simply use the binary number and know that the input of the array equates to the 1s and 0s. Thanks!
Message 9 of 10
(8,647 Views)
Great insight

slipstick wrote:
This is a good solution, with both the radix and the info about how the booleans relate to the case number. Creating the boolean array I had; where I was falling down was how to determine that cases 25, 34, and 214, for example , were the valid cases. Now I don't care; I simply use the binary number and know that the input of the array equates to the 1s and 0s. Thanks!

This is exactly why we have display properties for numeric values.  I saves a lot of 3-in-1 oil on your sliderule.


"Should be" isn't "Is" -Jay
Message 10 of 10
(8,596 Views)