LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

case selector

Good day all,

I have a state machine vi. I already selected certain cases in an earlier state of the state machine, Please how do I pass own the case selector from this stage to another state 2 steps away from where the first case selection was done?

Reason is that I want to still use the same case selector sometimes again in the state machine. Please any clue would be appreciated.

0 Kudos
Message 1 of 6
(3,026 Views)

Not sure what you are trying to do here. Do some states in your state machine need to specify a list of subsequent states to be performed? If so, then you may want to use an array of enum typedefs for your state machine shift register, then strip off the top element of the array for each loop iteration. You can also use a queue instead of an array (do a search on "queue state machine").

0 Kudos
Message 2 of 6
(3,025 Views)

Thanks I was able to do that. I got stuck with  the "wonders" of shift register, Thanks for your response.

But now I am stuck again. I ran a couple of state in a state machine and got two different result. Now I prefer the lowest result and command my program to run the state that gives the lowest result again before going to rest. Please any clue would be appreciated.Smiley Indifferent

 

To make it more clearer. I have this sequence written into a state machine.

1) initialize state

2)Drink water stage

3)Measure satisfaction from drinking water

4)Drink Coca cola

5)Measure satisfaction from drinking coca cola

6)Compare state (3) and (4) together and select the one with the highest satisfaction.

7)Redo the step again ( I mean if Coca cola gives highest satisfaction; then drink again and if Water gives highest satisfaction then drink water again)

8)End.

 

Please a clue on what logic to use and the appropriate function for state 6 and 7 would be appreciated.

Thanks all.

0 Kudos
Message 3 of 6
(3,008 Views)

You store the results from step 3 and step 5 in shift registers.  When you get to state 6, compare the shift registers.  Then you can use that to determine whether to repeat step 3 or step 5.

0 Kudos
Message 4 of 6
(3,002 Views)

Thanks Raven,
I already stored the result as you advised using Shift register. But my problem is after comparing the values what function would I use to now run either states.

Attached are the vis

Download All
0 Kudos
Message 5 of 6
(2,996 Views)

Hi osmosis,

 

You can just use a 'select' function along with equal/greater functions in comparison palette under programming. The below image may help you.

 

comp.JPG

0 Kudos
Message 6 of 6
(2,981 Views)