LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using Event Structure in an Enum State Machine

Solved!
Go to solution

Hello!

I am new to labview(~10 months). I tried my best to searched on the forum/net but did not get an explanation.
I simplify the code to demonstrate the problem. I'am using Labview 2013 ver 13.0f2 (32-bit).

The attached "EventStructure_Trigger_in_EnumStateMachine.vi" is an Enum state machine.
The "idle" state contains an event structure which detect value change evnet of 3 buttons:

Do something button:  just show somthing at the Display indicator
Start Running  button:  bring the program into "run" state
End                    button:  bring the program into "end" state and close it afterwards


The "run" state is a while loop, which will be stopped only by cliking the 4th button - Stop Running button and bring the program into "idle" case again.

The problem is at "run" state, any click on the irrelevent 3 buttons ( buttons only detected by event structure in "idle" case) will make program crash.
By comparision, I create another vi attached as "WhileLoop_in_EnumStateMachine.vi", which is almost same except the event structure is replaced by a while loop (and Do something button has no function). In this vi, everything works fine -- clicking on the irrelevent buttons won't crash.

I can't figure out why.

 

P.S. I failed at attaching .vi file onto this post... a compressed zip instead.

0 Kudos
Message 1 of 3
(5,505 Views)
Solution
Accepted by topic author MRChou

A problem that looks similar to yours : http://forums.ni.com/t5/LabVIEW/why-does-simple-case-structure-code-hang/td-p/3176592

 

I think the answer from Stuart will help you to understand how your code handles this situation.

You should handle your events outside of your main loop to let your structure run on any caught event.

CLAMaxime -- Kudos are a great way to say thank you
0 Kudos
Message 2 of 3
(5,458 Views)

Thanks!

 

After reading the thread, I found that NI actually had created a page for noobs like me 🙂

 

Event structure just not works as the way I thought. I should  have read this...
http://zone.ni.com/reference/en-XX/help/371361K-01/lvhowto/event_struct_outside_loop/

 

from http://zone.ni.com/reference/en-XX/help/371361K-01/lvhowto/caveatsrecmndtnsevnts/

 

Thanks again for responding!

 

 

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