LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Event structure in a State machine

Solved!
Go to solution

Hello all,

 

I've got a state machine with a sort of Stand-by state from where a user can select the next state using buttons. I tried using an Event structure with value change to select the next case but when the state machine is in a specific case and the button of an other state is pressed the whole thing blocks. I've attached an example, the LEDs just indicate what state you are in.

 

Thx for your time,

Bert

 

edit: Indeed, I miss-clicked

Download All
0 Kudos
Message 1 of 5
(3,285 Views)

You have posted your .lvproj file.  That doesn't provide any real information.  It is just a description of all the .vi files that make up your project.

 

Please attach your actual main .vi file.

0 Kudos
Message 2 of 5
(3,284 Views)
Solution
Accepted by topic author Bert_Hannon

1.  You don't need a while loop around your event structure.  With the timeout not wired, you will never get a timeout event.

2.  Your button events are set to "Lock Front Panel Until Event Completes".  Uncheck that.


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 3 of 5
(3,268 Views)

All your inner while loop should not be there, they just gum up the gears. It is a bad idea to trap the code inside inner loops, because during that time, events cannot be handled, whil they are still queued up. For example if you are in state 1 and press state 3 100 times, then exit state 1, state 3 will be entered 100 times in a row, witout a possibility of escaping.

 

Thus the use of an event structure is also ill advised here.

 

Here's is a quick draft showing the same code without inner loops and without the event structure just to give you an idea what I meant. See if it gets you some ideas. It is still not perfect ...

 

(Sorry, I had to disconnect the type definitions, because you did not include it)

Message 4 of 5
(3,244 Views)

Thanks crossrulz and altenbach. Both your posts were very usefull.

0 Kudos
Message 5 of 5
(3,197 Views)