LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

State machine states do not execute

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

Download All
0 Kudos
Message 1 of 7
(2,946 Views)

The array constant on your block diagram just have the initialize state. Make the index display visible and have a look.

 

Ben64

0 Kudos
Message 2 of 7
(2,931 Views)

o how do I make the rest of the states functional?

0 Kudos
Message 3 of 7
(2,913 Views)

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

0 Kudos
Message 4 of 7
(2,893 Views)

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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 5 of 7
(2,828 Views)

 are makign it harder by trying to use an array.

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 6 of 7
(2,791 Views)

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.  

0 Kudos
Message 7 of 7
(2,759 Views)