11-05-2009 10:57 AM
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
Solved! Go to Solution.
11-05-2009 10:58 AM
11-05-2009 11:05 AM - edited 11-05-2009 11:05 AM
11-05-2009 11:07 AM - edited 11-05-2009 11:08 AM
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
11-05-2009 11:24 AM
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
11-05-2009 11:31 AM
11-05-2009 01:43 PM
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.
11-05-2009 01:46 PM
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.
I do the same thing, but set the radix of the case display to Binary.
11-09-2009 04:22 PM
11-10-2009 09:26 AM
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.