12-06-2014 11:04 AM
When I try and run this state machine I get the 1st state in my state tyoe Def array then it runs the default state but it does not run any of the oters I have 36 states in the array. Any idea why?
Thanks
12-06-2014 11:48 AM
12-06-2014 01:41 PM
o how do I make the rest of the states functional?
12-06-2014 02:56 PM
Do you understand how a state machine works?
Technically a state machine makes a decision in each state to determine which state will execute next based on the values of data available to the current state.
Only a few of your "states" do that - the LED k states. All the others depend on what is in the arrays of states. In the "All tests" setting of Automatic/Manual Test it uses the array constant at the top left corner of the block diagram. That array has one element, Initialize. So the program will empty the array and execute the Initialize state followed by the Exit state. In Single Tests mode it will execute the states in the front panel Array control. That control only displays six elements and does not give the user any way to put more elements in.
Not knowing exactly how you want this to work, it is difficult to suggest ways to fix it. It seems rather awkward to me.
Lynn
12-08-2014 07:22 AM
I recommend using a Queue to store your states. The Queue is a little more efficient than using an array. You just enqueue the states as you know you need to add them and then dequeue to get which state to run.
Do you have a good State Diagram? The state diagram should show you the flow of your state machine. From there, it becomes a lot more clear of how you need to enqueue your states.
12-08-2014 09:42 AM
crossrulz is right you have created a "Queued State Machine" and you are makign it harder by trying to use an array.
12-08-2014 02:16 PM
Like crossrulz suggests, use a queue. Easier to manage. If you want to add an extra state, just enqueue another element. You also don't have to worry about the whole 'delete from array' bit - just 'Dequeue element'
Check out the simple example attatched. If you run out of states in queue, the 0 enum is called - so would recommend adding an idle state.
good luck.