LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Event Structures

Hi,

I do not have that much experience dealing with labview so please excuse my ignorance. I am trying to figure out how a event structure works, but the test file that I have created does not run properly. Here is what I am trying to do. Whenever the application is running in the inner loop, I should press the inner loop stop button and it should break out of the loop. Also, if I want the capability to turn on/off the indicator if the application is running in the inner loop or the outer loop. However, I am not getting the results that I want. I probably did not configure the event structure correctly, but I don't know what I need to do. Could someone please help me? I am currently using LabVIEW 7.0. I have one other question. If an event has occurred, will the application go back to where it left off or where will it start at once the event is finished? Thanks
0 Kudos
Message 1 of 4
(2,961 Views)

I think you misunderstood the concept of the event structure. Once the event structure has "started", it waits for one of the registered events to occur, and only when it occurs will the event structure continue. In your case, the inner loop is not iterating at all, because it's still stuck on it's first run. It will iterate once for every time one of the events you configured will occur. If, in one of those iterations, it will see that the stop button is T, the loop will stop. Your outer loop is also not iterating because your inner loop is blocking it by not stopping. To do what you want, you have 3 options - move the event structure to a seperate loop (so the stop button is unaffected by it), add a timeout (the small hourglass on the top left corner) or add a case for pressing the stop button and then wire the T to the stop condition out of that case. To comply with both your requests, your best method is to move the event structure to an indepedent loop. You should keep in mind that the outer loop will not run as long as the inner one is running. Here [broken link removed] is an event structure tutorial. I'm sure you can find some others on this site. Also, look at the examples in the Example Finder (search for "events").


___________________
Try to take over the world!
Message 2 of 4
(2,953 Views)
The event structure in your program works like this:
when the program flow is in the inner loop it idles at the event structure and waits for one of the configured events to occur. Once that happens it processes the event and program flow continues. Since the event structure is in a loop it will, in the next loop iteration, idle again unless the event 'stop inner loop' occurred in which case the inner loop is left and the outer loop iterates to its next round.
NOW, you have a ten seconds wait in your outer loop, and that means that it takes 10 secs before the inner loop is reached again. During this time the event structure in the inner loop is not responsive!

Overall, I don't understand why you have two nested loops. I modified you VI a bit and it works in principle now. Especially I put the control terminals whose value changed events are processed within the event structure into the respective event frames. For latching type booleans (like the STOP buttons) this is important to make sure they are reverted after pressing them.

I attach the modified VI, but in order to help you with the nested loop idea it would be good if you tell in general words what functionality you want to achieve with your program.



- Franz
Message 3 of 4
(2,950 Views)
Thanks tst and fahlers for the clarifications on the event structure. The only reason why I used a nested while loop is so that I want to gain the functionality of calling a event outside of the loop that the event structure was in. What I should have done was used a separate while loop, instead of a nested loop, to obtain what I was looking for. I did not know that the inner while loop was idle because it was waiting on the event structure. Now I got a much better understanding of the purpose of an event structure. Thanks again.
0 Kudos
Message 4 of 4
(2,942 Views)