12-14-2011 06:13 PM
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.
12-14-2011 06:28 PM
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").
12-14-2011 10:21 PM
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.
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.
12-14-2011 11:10 PM
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.
12-14-2011 11:38 PM
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
12-15-2011 03:30 AM - edited 12-15-2011 03:32 AM