Stop execution of a loop in an event structure

I tried searching the forums to avoid posting a duplicate, but most I could not open most of the vi's as they were higher version.
I put in a dummy while loop in an event structire i intend to use. Once I start executing the while loop, I am not able to stop it using a control for some reason from the fornt panel control.
I am not able to change the vale of the Stop control at all. I tried creating a seperate event for STOP, and I still could not stop the program when the While loop was executing.
I imagine I am missing something really small. I would appreciate your feedback on this.
Thanks,
Nevil
Solved!
Go to Solution.
Attachments:
FrontPanel.vi ‏34 KB

Right click on the event structure and choose "Edit Events" for the case that is giving you trouble.
Be sure the checkbox to lock the front panel is unchecked.
I suspect yours is checked, so your front panel is locked out until the event completes, thus you can never stop your loop.

Similar Messages

  • Event controll: How to stop a running while loop inside a event structure

    Hello,
    I have some problems with controlling a while loop inside a event structure (see attached VI).
    I habe 3 buttons ("Start Measurement, Stop Measurement, Quit Program"). When a measurement is running, it should be possible to stop the measurement by clicking on "Stop Measurement", but this does not work.
    Has anyone an idea?
    Thanks a lot and best regards,
    Michael
    Message Edited by MichaGue_01 on 04-23-2010 04:37 AM
    Solved!
    Go to Solution.
    Attachments:
    Event_Controll.vi ‏27 KB

    Hello,
    Try not to use while loops inside a Event structure.
    My approach is using two While loops (one will have only the Event structure).
    I had to use to Flag buttons that make it a bit more complicated but i am sure somebody will come up with a better idea, or you might want to have a think about it yourself.
    Have a look on the modified version on the attachment.
    Once you are happy how it works then you can Hide the 2 flag buttons from the Front Pannel by going to Block diagram right-click the indicators and choose option "Hide Indicators/Controls"
    I did it in LV 8.6 so i hope you can open it on your PC if not i can downgrade it.
    If you have any problem let us know.
    Regards
    Dimitrios
    Test Systems Computing Engineer
    Cummins Turbo-Technologies
    Attachments:
    Event_Controll[1]_modified.vi ‏18 KB

  • 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
    Attachments:
    event_problem.vi ‏17 KB

    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
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    event_problemMOD.vi ‏17 KB

  • How to stop execution in while loop without stopping execution of other loops in the same vi

    HI
    I am quite a novice in Labview.
    I have a problem in my project. I used a while loop inside my vi to build an array of ten values along with other loops. Then I used a stop button to stop manually the while loop. But it seems like the loop doesn't stop in the middle of the array building and so other loops in the vi doesn't work until the while loop finishes building the array and as soon as while loop execution is over, the complete vi stops. But all that I wanted was to build the array using the shift register along with the control to stop building array anytime. And not to stop execution of other structures when the while loop finishes.
    Can anyone help me?
    Rahul

    Hi Rahul,
    Modified ur Vi to work with single button.
    But the subtract case is not in any loop.
    So, once both the loops stop, the subtract case will execute only once. Depending on state of subtaract boolean at that time, corresponding case will be executed and the Vi will stop.
    so think of a logic where u can put this also in a new loop.
    Or you can also incorporate it in one of the two loops and pass the other loop's data to it.
    Let us know how you will proceed in this regard
    I am posting your VI as well a VI with my modifications VI in Labview 7.0 so that Thomas can give his suggestions too
    Plus, always keep a time delay in your while loops.
    Oh sorry, the "arrayinouttestnewfinal.vi" is the modified vi
    Regards
    Dev
    Message Edited by devchander on 01-10-2006 06:15 AM
    Message Edited by devchander on 01-10-2006 06:19 AM
    Attachments:
    arrayinouttestnewfinalnew4.vi ‏59 KB
    arrayinouttestnewfinal.vi ‏63 KB

  • While loop inside a event structure

    Dear
    I have no much concepts on event structure.
    Let's assume there is a dialog box with Okay and Cancel button.
    I put the event structure for Okay and Cancel button.
    In Okay event, there is a while loop for detecting some data continuously.
    In this case, I want to use Cancel button to stop the while loop during the detection.
    How can I do to receive signal from the Cancel button?
    Thank you in advance.

    I'm not sure that the event structure should be used to handle that situation : while the OK event is executing, either the Front panel is locked and new occuring event will be stored until the OK event is completed (so the Cancel button action will not be detected !) or the Front panel is unlocked (see below *) and the Cancel button action will stop the loop, but the Cancel button event case will not be executed, since the event has already been processed in the OK case !
    You should probably use a single button to run/stop the loop, as shown in the attachment
    * While editing the event case, unmark the "Lock front panel for this event complete" at the bottom. But of course, the code in the cancel case will not run, since the event occuredMessage Edité par chilly charly le 03-31-2007 05:27 PM
    Chilly Charly    (aka CC)
             E-List Master - Kudos glutton - Press the yellow button on the left...        
    Attachments:
    Event button.vi ‏11 KB

  • Simple example - Break FOR loop inside an event structure based on Front panel event change.

    I am running a for loop inside a state machine architecture that contains a FOR loop. How can I break this For loop based on Event change in front panel ??
    Abhilash S Nair
    Research Assistant @ Photonic Devices and Systems lab
    [ LabView professional Development System - Version 11.0 - 32-bit ]
    LabView Gear:
    1. NI PXI-7951R & NI 5761
    2. The Imaging Source USB 3.0 monochrome camera with trigger : DMK 23UM021
    OPERATING SYSTEM - [ MS windows 7 Home Premium 64-bit SP-1 ]
    CPU - [Intel Core i7-2600 CPU @ 3.40Ghz ]
    MEMORY - [ 16.0 GB RAM ]
    GPU - [ NVIDIA GeForce GT 530 ]
    Attachments:
    Case inside Event 3.vi ‏19 KB
    Case inside Event.ctl ‏6 KB
    Case inside Event 2.ctl ‏6 KB

    Okay. Accpeting that the design is not favorable and not advantageous when my program expands. I have begin to follow producer/consumer programming architecture.
    Please find the attached program which is a simple producer consumer with event structure. I wonder how could I stop looping around the producer and consumer loops over and over again. I am pretty sure that this ENQUEUE ELEMENT loops back to the consumer loop and starts from begining.
    I hope my first program in PC architecture with State machine and Event structure is correct. 
    Abhilash S Nair
    Research Assistant @ Photonic Devices and Systems lab
    [ LabView professional Development System - Version 11.0 - 32-bit ]
    LabView Gear:
    1. NI PXI-7951R & NI 5761
    2. The Imaging Source USB 3.0 monochrome camera with trigger : DMK 23UM021
    OPERATING SYSTEM - [ MS windows 7 Home Premium 64-bit SP-1 ]
    CPU - [Intel Core i7-2600 CPU @ 3.40Ghz ]
    MEMORY - [ 16.0 GB RAM ]
    GPU - [ NVIDIA GeForce GT 530 ]
    Attachments:
    Case inside Event 3.3-ProducerConsumer Event.vi ‏25 KB
    Case inside Event.ctl ‏6 KB

  • How to stop While Loop in Event Structure with same button?

    Hello,
    I have a problem. I want to use one control to activate an event in a event structure, and the same control to terminate a while loop in that event.
    It is possible to use 2 controls to do this, but I need it to be only one.
    Thank you  
    Message Edited by Heinen on 02-19-2009 06:16 AM
    Message Edited by Heinen on 02-19-2009 06:20 AM
    The Enrichment Center is required to remind you that you will be baked, and then there will be cake.
    Solved!
    Go to Solution.

    Hello,
    I have a bit different problem.
    I have a tab control, with several buttons on different pages.
    In the current situation, we can talk about two pages, where one page ("Settings") in the Image, has a START and EXIT button, while second page ("Wait") has an EXIT button.
    In a while loop, I have event structure, which handles events of the START and EXIT buttons of the Settings page. This is fine. But I also want to control the Exit button of the Wait page.
    The control works like this:
    When I click on Start in the Settings page, the front panel shows Wait page and attempts to connect to a datasocket server on the remote computer. If the user wants to stop this process, he can click on Exit on Wait page too. But, this doesn't give any immediate effect. On the even of Start button, the front panel is not locked, so the user can actually click the Exit button on the next page when it's visible. But it's of no immediate effect. Means, what the LabVIEW does is, finishes the execution of event in Start button's click, and while this executes, it doesn't consider the Exit button's refreshed value (shown in Red circle in the block diagram).
    Simple question: Is there any way to check the updated (latest/live) value of a control during some event's execution? Or if I write an Event "Value Changed" for the Exit button and pass it to some variable. Is it the only solution?
    Thanks ahead.
    Vaibhav
    Attachments:
    terminate event_diagram.jpg ‏200 KB
    terminate event_front_1.jpg ‏63 KB
    terminate event_front_2.jpg ‏63 KB

  • How to stop a while loop of event structure from a main vi

    Hello;
    sorry for my english
    I have to stop a subvi from my main vi, the subvi contains a while loop and an event structure so I need to stop this loop while directly from my main vi I have tried global variable but it did not work
    any help please or example !!!   
    Solved!
    Go to Solution.
    Attachments:
    stop a while loop and event structure from main vi.png ‏16 KB

    IYED wrote:
    Hello;
    sorry for my english
    I have to stop a subvi from my main vi, the subvi contains a while loop and an event structure so I need to stop this loop while directly from my main vi I have tried global variable but it did not work
    any help please or example !!!   
    If this is an example of how your code looks, I'd clean it up before the developer who has to work on it next hits you over the head with his LabVIEW Style Book. 
    Bill
    (Mid-Level minion.)
    My support system ensures that I don't look totally incompetent.
    Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.

  • While loop with stop button within event structure locks up front panel.

    I am not sure if this is a bug with my program or a bug within LabVIEW.  If you believe that this is a bug with my program then I will post my program to be looked at.
    The problem I am having is there is a while loop within an event structure that fires when a particular value changes.  Once the "Activate" button is pressed the while loop within the event structure starts going with a polling frequency of 1hz (1000ms wired to the "wait till next ms multiple" vi).  There is a "Deactivate" button that is wired to the stop control of the while loop and an outter while loop that resets the event structure so that the activate button is being listened to again.
    Once inside the while loop, however, none of the button are responsive within the front panel.  The VI continues to run, and only 60% of my CPU is being consumed, but none of the button or scroll bars work.  The only way for me to terminate the program is with the "Abort" button next to the "Run" button.  If I remove the event structure so that the while loop in question runs as soon as the program starts, the front panel remains responsive.  I've inserted probes within the while loop and verified that it is not running prior to the "Activate" button being asserted, and it is running after the assertion of the "Activate" button with the expected polling frequency set by the "wait till next ms multiple" vi.
    Can anyone help?  Do I need to post my code?
    -Nic

    It is typically not a good idea to stall an event structure by placing loops inside event cases. What good is an event structure if it is not free to repond to events?
    Have a look at some alternative solutions, such as in the following link:
    http://forums.ni.com/ni/board/message?board.id=170&message.id=224817#M224817
    LabVIEW Champion . Do more with less code and in less time .

  • Problems closing several loops in a state machine with an event structure

    I am having some problems closing three loops running in parallel in a state machine.  I have one loop for an event structure to monitor user controls to change the state.  The other loop is the state machine which will control an actuator, and the third loop is for data aquisition/analysis.  I want to be able to hit the stop button and go to a "shutdown" state where I can home the actuator then close the loops and finally go to the last "shutdown" subdiagriam in the flat sequence structure.  Currently when hitting the stop button it goes into the shutdown state and will end the state machine loop but it appears the other loops are not closing until I hit the stop button again.  Could this be due to using a local variable for the boolean to control the loop conditions? I attached a screenshot of the block diagram.  Any advice would be great!
    Attachments:
    example.png ‏108 KB

    You have a classic race condition due to overuse of local variables. If the stop event fires in the upper loop, the local variable connected to the loop termination condition has already been read (it is false!). This means that the upper loop will iterate once more and again wait at the event structure for the next event. At this time, the local variable connected to the loop termination is TRUE, but the loop cannot complete until the event fires again, for example if you press the stop button once more.
    The correct way is to connect the terminal of the stop button across the right event frame directly to the loop termination terminal. Now it will get the TRUE value correctly once the stop event fires for the first time.
    LabVIEW does not execute left to right, execution order is determined by the wiring.
    I also agree with the above message that you should rethink and re-architect your code using established coding guidelines. 
    LabVIEW Champion . Do more with less code and in less time .

  • Conditional stopping event structure

    Hi all
    Attached is my Vi , I want to stop the event structure in loop 1 , from the loop 2 which is continously running in parallel and getting digital input from a DAQ device.
    whats happening is first I am checking the status of teh digital input and then on that I am excuting the true structure. once I am in the True case , an event structure for user operations and a parallel while loop is used to monitor the digital input , what I  want to do is as soon as the digital daq input is low again i should be back to my fasle case in the main loop but the loop 1 with event structure is not stopping.
    help
    regards
    Regards
    Attachments:
    Untitled 1.vi ‏12 KB

    Snamprogetti wrote:
    You can't put an event structure into a case structure. It will run even if you are in the other case.
    See http://forums.ni.com/t5/LabVIEW/An-event-structure-can-freeze-the-front-panel-even-if-not/m-p/106629...
    What then, is a queued state machine? . The issue is the event structure still queues your events whether or not you are in your "idle" case. So if you don't promptly return to your idle case, events can back up in the event structure causing your program to act like it's lagging. Setting a busy cursor can help to solve this problem. I felt this should be clarified because a properly set up queued state machine is very powerful. This obviously isn't the solution for the parallel loops here but I thought I should add to your point..
    CLA, LabVIEW Versions 2010-2013

  • Quit while loop in event structure

    Hello,
    I used event structure in my application and I would like to quit a while loop in an event structure when I pressed a control. But I have a problem because I'm in the event.
    Do you have a solution.
    Sam.
    Attachments:
    Problem.vi ‏34 KB

    Hi,
    connect a true constant to the While loop conditional terminal in the STOP event case.
    See your example modified.
    Good luck,
    Alberto
    Attachments:
    Problem[2].vi ‏35 KB

  • Multiple event structure in a while loop

    Dear All,
                   I had a multiple event structure inside a while loop. The purpose of doing so is because I had a few 2D picture on the front panel. I would like to detect which 2D pictures had been click using the mouse down event structure for 8 of my 2D pictures.
                  The problem that I faced now is that when I of the event case or one of the 2D pictures had been click, it will not exit the while loop. I had to click on all the 8 2D pictures before it will exit the loop.
                  I had uncheck the under the "Edit Event" --> "Lock Front Panel (defer processing of user action) until this event case completes". But I am still stuck inside the loop.
                  Each 2D picture will perform different action therefore I cannot have an event case of all 2D pictures inside else I would know which 2D picture had been click.
                 Is there any other way out of this situation? Pls help. Thanks a lot

    A producer/consumer architecture (look at the examples that ship with LabVIEW) is comprised of two parallel while loops. One loop contains the event structure. The other contains your consumer which is basically a queued state machine. It receives messages from the producer via a queue. Your event structure can register a separate event for each 2D picture control or it can use a single event that would determine which spefic controls was clicked on. This is a more general approach and expands easily. Here is a basic example of what I am talking about.
    Mark Yedinak
    "Does anyone know where the love of God goes when the waves turn the minutes to hours?"
    Wreck of the Edmund Fitzgerald - Gordon Lightfoot
    Attachments:
    Event Producer-Consumer.vi ‏14 KB

  • How to use a event structure with a state machine

    First, I would like to inform you that I only work on LabView part time, and have much to learn.  Anything I do learn, I usually forget until I need it again, because I only work on it part time.
    Using your StopWhileLoopMOD[1].vi, I am trying to put a state machine inside the event structure.  
    Related link: http://forums.ni.com/t5/LabVIEW/How-to-stop-while-loop-in-Event-case/td-p/465564/page/2
    Here is my application:  on the front panel, the user can select any combination of 7 different tests.  I have created cases to perform each step of each test in the correct order, but if the user presses stop, the tests won't stop because some of the cases have a while loop inside the event structure (like you mentioned is a bad idea).  The user should be able to stop the test, reselect tests to perform, and re-start the tests. 
    When the start button is pressed for the event structure, I need all the cases to run in the proper order, unless stop is pressed.
    In the past I have indexed an array and used that to run the state machine, but it won't stop immediately.  
    I have sub VIs that are built in while loops because the outputs of the product needs time to stabilize.  The state machine stops and waits up to a certain number of iterations.  If it passes the test, the while loop stops and the next state starts.  If it takes too long, it exits and reports an error.  Maybe I need to just use the state machine and not an event structure?
    Is there a good example of an event structure?
    metzler CLAD
    Solved!
    Go to Solution.

    I'm not sure exactly what you are asking, but it sounds like you want to script a bunch of tests and if the user says stop, to immediately stop the current test and abandon the others?  I'm going to assume that you know how to clear the array so that it will abandon the others, so I'm guessing that you are having trouble abandoning the current test?  If this is indeed the case, then the problem is that you are not able to propagate the message from the main VI FP which is the GUI to the sub vi which is the test, where the test may or may not have a GUI (FP visible) of it's own.  Threading was the first thing to come to mind, but this may not be necessary using events.
    You can do this by passing a refnum of the stop button to the subVI, where you can then add that wait to the event case structure.
    I've attached 2 VIs, mainvi.vi which is just a loop displays the count*2 (number of seconds passed since running) that will call subvi.vi and then check to see if the stop button is pressed.  mainvi.vi is by no means a state engine, it is just a simple loop for demonstration purposes.  subvi.vi just waits 2 seconds and leaves, it is a better structured state engine with an init state to start a poll case to wait for events and an exit state to clean up.  You can modify this any way you wish to get it to do what you want.  You will note that even if subvi.vi is being executed, it will terminate immediately when the stop button is pressed.
    Hope this helps.
    A
    Attachments:
    mainvi.vi ‏17 KB
    subvi.vi ‏33 KB

  • Can I get the event structure to NOT queue events?

    I was wondering if it is possible to have the event structure not queue events that happen while the vi is executing code associated with another event. Basically, I have a toggle switch that, when "on", captures a live feed from a camera and displays it to the screen. This is done in a while loop that executes until the toggle switch is turned off. At this point, that event is done and the vi returns to the uppermost level of the event structure and resumes looking for events. The trouble is that the whole while the video capture was happening, the event structure was queueing events that were occuring during that time when the user was hitting other front panel buttons that had their own event associated with th
    em and would not execute at that time. When the video capture toggle is turned off the event structure then executes any other events that were queued during that time and I don't want it to. I can't lock the front panel while the video capture is happening so the user can't push buttons because they have to be able to push the button to turn the video capture off. Any suggestions? Thanks in advance.

    > I was wondering if it is possible to have the event structure not
    > queue events that happen while the vi is executing code associated
    > with another event. Basically, I have a toggle switch that, when
    > "on", captures a live feed from a camera and displays it to the
    > screen.
    I think there are lots of other articles about this on devzone.
    To summarize them, the key is that the event structure intentionally
    synchronizes events with diagram execution. The typical way to do what
    you want is to have the event start up another loop or subVI running
    asynchronously.
    Usually there ends up being one loop with an event structure in it.
    Another loop that executes a statemachine, possibly as simple as just
    two states of acquiring and not. Use the events to pr
    od the other loop
    between states via locals, globals, occurrences, etc.
    Greg McKaskle

Maybe you are looking for

  • Billing block is greyed out

    Hi Friends, Businmess does not want to create invoice for sales order. So they went back and cancelled the invoice, now in VA02 sales order billing block is coming greyed out. Why it is coming greyed out? How can I put billing block to the sales orde

  • Building applicatio​n exe USB-9215 DAQmxBase LabView7.1 errors

    Hello I've been building DAQ applications using the NI 4-channel USB 9215 module. It has a sampling rate of 20ks/sec and with four channels the maximum I can sample per channel is 5000s/sec. It works with no problems at this rate and lower rates, how

  • Photosmart 7520: Scan to Email

    Hi,  I have created my email adr on the printer, and veryfied my mail adr. with the PIN code, that was send to me from HP But when I start the process by cliking (on the printer), "Scan" --> "Scan to Email" --> Select my Email Account --> Select type

  • Heat, whine and returns

    hey all. I got my macbook pro a few weeks ago, i've noticed the whine. I've also noticed it gets incredibly hot, so hot i can't touch the area above the F keys. So this lead me to do a hardware test, low and behold i have the hardware error. Should i

  • JTree Focus Problem

    I am useing JTree component in my project Whenever i press the space bar that focus removed from the JTree Node. Please any one can help me.