LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to exit from the DO-while loop in the event structure

Hi all
 
I am just a beginner for Labview
 
I want to build a loop in the event structure, but when I enter in the loop, it seems the system is dead, and I can't exit the loop.
 
here I attached a simple sample.
 
 In the sample.  when I press the start_calculation button , the calculation start, but the system is dead, and I can't exit calculation loop.
 actually, i just want switch the different operation by changing the event action.
 
anybody has a good idea about it??
 
thanks so lot
 
 
0 Kudos
Message 1 of 6
(3,052 Views)

Have a look at the attached code.  Try running it with Highlight Execution turned ON to understand how it works.

Ask any questions in this thread.

R

0 Kudos
Message 2 of 6
(3,043 Views)
The first answer is probably best but just so you know, edit the event for the start calculation and at the bottom uncheck the lock front panel for that event. If that is on it locks out front panel activity when the event starts so when you press the Stop loop it doesnt react to the input because its prevented from doing so.
 
 
0 Kudos
Message 3 of 6
(3,024 Views)

Your problem is that you are trapped inside an event case. It is not a good idea to run extended code inside event cases, else the event structure cannot service other events.

Why don't you use the outer loop for everything? Now things don't step on each others toes. 😉 What good is an event structure if it cannot react at all times???

 

 



Message Edited by altenbach on 07-25-2008 12:26 AM
0 Kudos
Message 4 of 6
(3,012 Views)

That's an ingeneous way to use the Timeout, Altenbach..  Simple yet very effective.

It selects -1 as a timeout if you stop calculations, therefore the loop waits until another event before it resumes.  Nicely done.  You could make a nugget of this example.

The other suggestion I was about to make was to consider an state machine instead, but I think this thread is about learning more on Event Structures.. 

R

0 Kudos
Message 5 of 6
(2,969 Views)
I second the suggestion for a nugget. I stumbled across a post (I believe it was Altenbach's, if not, forgive me for not giving credit to whomever made the post!) about a year ago with that, and have been delightfully implementing it since. Very useful 🙂
-Cory
0 Kudos
Message 6 of 6
(2,965 Views)