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

Similar Messages

  • 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.

  • 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

  • Loop with event structure

    I put an "event structure" inside of a while loop. My target is to keep the
    VI running and make selections to run different subVI. But I got two
    questions:
    1. how to use two button on front panel? I mean, when I press one button,
    step 1 runs, when I press the other button, step 2 runs. Is event structure
    the best way to do that? another side quesition is that how I can make the
    button jump back after I pressed it? It kept in the "down" position and I
    have to press it again to release it.
    2. When I test the VI, I found the while loop can't stop. The boolean input
    of false won't stop the VI. I wonder if there is a rule that the event
    structure must run at least once? or any other hidden properties I didn't
    notice?
    thank you very much!
    cheng

    "Michael Sachs" wrote in message news:...
    > You can change the boolean's mechanical action to a latched type and then it
    > will pop back up.
    > The event structure has a timeout input that defaults to infinite. If the
    > event loop is waiting for an event or timeout then your outer while loop
    > will not cycle. Use the hightlight execution lightbulb on the diagram to
    > see what the data flow is doing.
    >
    > Mike Sachs
    > Intelligent Systems
    >
    > "Cheng" wrote in message
    > news:[email protected]...
    > > I put an "event structure" inside of a while loop. My target is to keep
    > the
    > > VI running and make selections to run different subVI. But I got two
    > > questions:
    > >
    > > 1. how to use two button on front panel? I mean, when I press one button,
    > > step 1 runs, when I press the other button, step 2 runs. Is event
    > structure
    > > the best way to do that? another side quesition is that how I can make the
    > > button jump back after I pressed it? It kept in the "down" position and I
    > > have to press it again to release it.
    > >
    > > 2. When I test the VI, I found the while loop can't stop. The boolean
    > input
    > > of false won't stop the VI. I wonder if there is a rule that the event
    > > structure must run at least once? or any other hidden properties I didn't
    > > notice?
    > >
    > > thank you very much!
    > >
    > > cheng
    > >
    > >
    Hi Cheng,
    that's not quite the whole story. The event structure breaks down
    into two types. Those that get actioned between the start of the event
    (i.e. mouse down) and the result of that event (i.e. the button
    registers true) which are filtered events, and the other type (like
    mouse up) which occur after the event and the result of the event.
    With filtered events you can modify the result of the event as it
    happens. Whichever you choose to use, you need to do one of two things
    to get the button to pop back up (setting to latch when pressed on
    it's own won't work) - you can either read the FPTerm within the event
    itself with this set to Latch when pressed, or (my prefered method) is
    to use the CtrlRef that's available inside the event, and use the
    ActiveX method Reset to Default. This way the FPTerm for the button
    can be left somewhere else, and it's more obvious what the program is
    doing at this point.
    Your while loop is actually a do {} while loop, i.e. it must execute
    at least once before it checks to see if it should iterate again.
    Mike's suggestion of follow the hi-light execution is the best
    solution.
    Hope that helps
    Sash.

  • How to EXIT the while loop in Event response section?

    I'm writing a program to grab image using a NI card. The application uses the Event structure. When the GRAB button was pressed, it snaps image continually by putting the SNAP function in a while loop. Is there some way to exit the while loop?(Note :The while loop was put in the GRAB IMAGE event response section.)

    edit this event-case AND uncheck "lock front panel until the event case for this event completes".
    BTW, your thanks should go to Ankita, <a href='http://forums.ni.com/ni/board/message?board.id=170&message.id=151282'>here</a>
    cheers! 
    Message Edited by Dynamik on 11-13-2005 01:26 AM
    Message Edited by Dynamik on 11-13-2005 01:38 AM
    When they give imbeciles handicap-parking, I won't have so far to walk!
    Attachments:
    untitled.GIF ‏20 KB

  • How do i exit a while loop using event handler

    Hello,
    I have an event handler structure within which i run a while loop for a particular event. I would like to interrupt the execution of this while loop as soon as another event occurs, even if the while loop has not finished execution. I have tried so many ways, the best i could get is exiting one itteration after the new event occurs which is no good for me.
    Any suggestions???
    Thanks
    Me

    Instead of having a task while loop in an event case, put your task while loop in parallel with the loop surrounding the event structure. When the event which should start the task occurs, you can signal the start of the task while loop. You could use local variables of references to start/stop the loop when an event occurs. You could also use notifiers instead of variables to pass signals to start/stop the while loop. In general you should have a while loop for the event structure, and a parallel while loop to do the tasks. The parallel loop is controlled by variables or notifiers which are set in the event cases.
    - tbob
    Inventor of the WORM Global

  • LabVIEW 2012 while event structure cannot stop

    I am trying LabVIEW 2012.
    An example of while-loop with Event structure inside cannot be stopped with the boolean stop button.  Any thing wrong?
    Please see the attached VI.
    Thanks.
    Solved!
    Go to Solution.
    Attachments:
    Close VI prompt.vi ‏9 KB

    Yep, something is wrong. You need to add a event case to detect a value change on the stop button.
    The thing is now your event structure keeps waiting for one of the event that it handles, and ight now it only handles the "panel close" event, the "timeout" event is handled too but since you haven't connected anything to the timeout terminal (top left corner of the event structure) the timeout is -1. So when you run the VI the while loop is stuck in the first iteration and waits for a panel close, the stop button will only be taken into account after the even structure catches an event ; I think this is because LabVIEW will execute code linked to the stop terminal of the while loop only after all the rest of the code in it has finished executing.
    Hope this helps
    When my feet touch the ground each morning the devil thinks "bloody hell... He's up again!"

  • How should I set up my VI so that I can use the linear fit coefficient data analysis program, when my values are coming from while loops within a sequence structure?

    I'm attempting to create a calibration program, using the printer port, and a Vernier Serial Box by modifying a calibration program designed for the serial box.
    There are six calibration points, and to collect them, I have it controlled by while loops so that the numbers are taken when a button is pushed, and this is inside a sequence structure so that I can get the six different points. I feed these numbers into two different arrays (for x and y values) and then try to use the linear coefficient analysis on these points, but the values for the slope and intercepts it returns are not correc
    t.
    If I cut out the array and coefficient analysis, and feed the same numbers in directly without the while loop and sequence structures, it produces the proper values... I don't know why the numbers it is producing are different, and I'd really like to know.
    Thanks,
    Karinne.

    I would use a data manager sub-vi that would be called by each from of the sequence structure that produced a data point. The data manager sub-vi could auto append new items or could place items in a specific entry of an array. Later on when you want to calculate the linear fit, call the sub-vi to return the array of values.
    Stu

  • Event structure in "for loop" and stacked sequence

    I tried to put an event structure into a for loop sequence, then used a pause button to pause the program (one loop with event structure.vi). The pause button functioned normally since the program could be paused whenever the button was pressed. Then, I put this for loop sequence into a stacked sequence (Problem.vi), which has 2 frames and every frame has the for loop sequence in it. After the pause button was pressed once, the pause button and stop button will no longer effective anymore. Where should I modify so that this program will work properly? Thanks a lot.
    Attachments:
    Problem.vi ‏42 KB
    one_loop_with_event_structure.vi ‏27 KB

    Ah, at last something weird !
    The answer is simple : don't do that !
    You should either avoid having 2 event structures handling the same events, or learn how to process dynamic events.
    Why didn't you read the answers to a question posted a few hours ago (still on the overview page of this forum ?). See here.
    Chilly Charly    (aka CC)
             E-List Master - Kudos glutton - Press the yellow button on the left...        

  • 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

  • Extent of Coding inside Event Structure cases

    Hi all
    I am trying to understand the practices while using an Event Structure. I am used to developing most of my projects using an Event driven State Machine Architecture. Most times, I use Event driven-Queued State Machines. I have also used Producer Consumer Architecture with Event structure driving the producer.
    I have always believed that using lots of code, or lots of sub-vis inside one or more cases of an event structure is not a good practice. I reasoned that it will delay the capture of other events occuring while the current case is still executing. This was one of our points during design review, i.e., to reduce the code inside event strucutre cases to as minimal and necessary as possible. We used clusters/queues/LV2Gs inorder to pass on the required data, which will be processed in the other cases/loops.
    However, I happened to recently come across a couple of very old applications upgraded to LV2011. The applications used an event structure in one of the while loops, with one or more parallel while loops inside the Main VI. The event structure was the only code in this while loop, no case strucutres.
    These event structures had loads of code in each case, with sub-vis and nested sub-vis, even DLL function calls among them. Thats when I started to look for information on best practices using event structures and about any available details on the extent of coding allowed inside an event strucutre.
    One sub-vi which was called as a dialog box also had its own event structure (ending up as ensted event structures). I have read about nesting event structures and their disadvantages.
    Off course, the code is working and I am not sure if anyone had any execution problems with the applicaiton.
    However, I am wondering about the pros and cons of having the entire code inside event structure. I would have defined that code a nightmare. Its disturbing me to see that code and being unable to make it better.
    To my understanding, I wish to know if there is any definition or rule regarding the amount of code inside an event structure.
    Thank you

    The exception I use is User driven intefaces where every user action must get a response and each change must complete before the next. In those cases an event only implelmentation is generally fine.
    Now if that code does something that takes long enough for the user to question if the program is still alive should at least get a "Busy cursor" OR a progress bar OR an abortable progress bar where the user get s the option to abor out. THe last case may warrent a parallel process to crunch the numbers.
    But please keep in mind the above suggestions apply only to those User only" type things. Applcations that invlove the word "while" will generally get deamons and other common design patterns used to henld the implementation. But now I have drifted to design teory and away from the subject so ...
    Have fun!
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • Starting new while loop while old one still running

    Hi!
    I am attempting to write video images to AVI files. I want to give the user the option to decide when they want to begin to capture the images. I place the "start recording" button in one loop and the image acquisition and AVI Write subVIs in another loop. LabVIEW won't allow me to continue on with the image acquisition loop until I finish with the "start recording" loop. Any ideas how to fix this (to allow the image acquisition to start and continue having LabVIEW check for a button press on "start recording")?
    Attachments:
    Capture_and_Save_as_AVI.vi ‏177 KB

    Thanks. I suspected as much. In any event, I can't seem to find a good configuration of while loops and case structures which will produce the desired results. I want to start acquiring images and allow the user to choose to start recording at any time he desires. This issue is further complicated by the fact that the status of the "Start recording" must be checked at all times, but only initialized once, while the AVI Write Frame depends on that first initialization step but must be looped continuously aferwards in order to 'keep up' with the images being acquired. In the newly attached example, I placed the case structure inside the image acquisition while loop and the avi write frame inside a while loop inside of that case structure. unfortunately,
    labview decides to stay inside the avi write frame while loop after entering, instead of returning to the image acquisition while loop. i can't place the avi write frame inside the general image acquisition while loop because then labview will think i want to initialize the avi write frame right away and will return an error when avi write frame isn't provided with an avi refnum. Ideas?
    Attachments:
    Capture_and_Save_as_AVI.vi ‏174 KB

  • Run for loop inside event node

    Hi all, 
              We want to run for loop inside event node with 50ms delay. But when i am doing it the Labview is crashing. Please let me know if somebody did this.
    Thanks in advance,
    Regards,
    Harish. G
    Thanks & Regards,
    Harish. G.

    harishg92 wrote:
    Hi all, 
              We want to run for loop inside event node with 50ms delay. But when i am doing it the Labview is crashing. Please let me know if somebody did this.
    Thanks in advance,
    Regards,
    Harish. G
    You're implementing a For loop inside an event structure? (I don't know of any event "node" in which you can run a For loop)
    If so, that's a bad idea because LabVIEW won't be able to process any events while waiting for your For loop to get done, which might be why its crashing.
    There are tricks to accomplishing what you're trying to do without putting any for loops inside event structure. See what I have  attached and if it helps. "N" is number of times you run your For loop, timeout is whatever delay you want in each loop. This can be done in many ways without adding delays in events, another way could be to fire a separate subVI using Asynchronous call (without waiting for the VI to finish) during those delays, just make sure that such subVI finishes processing within your allocated time (that's how I'd ideally implement things). That method is better because you're doing minimal work inside events structure while using wait period wisely in a separate/parallel process.
    I hope that I understood you correctly and did not go off on a tangent.
    -BTC
    New Controls & Indicators made using vector graphics & animations? Click below for Pebbles UI
    Attachments:
    ForLoop inside Event Structure.vi ‏11 KB

  • Why the execution time increases with a while loop, but not with "Run continuously" ?

    Hi all,
    I have a serious time problem that I don't know how to solve because I don't know exactly where it comes from.
    I command two RF switches via a DAQ card (NI USB-6008). Only one position at the same time can be selected on each switch. Basically, the VI created for this functionnality (by a co-worker) resets all the DAQ outputs, and then activates the desired ones. It has three inputs, two simp0le string controls, and an array of cluster, which contains the list of all the outputs and some informations to know what is connected (specific to my application).
    I use this VI in a complex application, and I get some problems with the execution time, which increased each time I callled the VI, so I made a test VI (TimeTesting.vi) to figure out where the problem came from. In this special VI I record the execution time in a csv file to analyse then with excel.
    After several tests, I found that if I run this test VI with the while loop, the execution time increases at each cycle, but if I remove the while loop and use the "Run continuously" funtionnality, the execution time remains the same. In my top level application I have while loops and events, and so the execution time increases too.
    Could someone explain me why the execution time increases, and how can I avoid that? I attached my test VI and the necessary subVIs, as well as a picture of a graph which shows the execution time with a while loop and with the "run continuously".
    Thanks a lot for your help!
    Solved!
    Go to Solution.
    Attachments:
    TimeTesting.zip ‏70 KB
    Graph.PNG ‏20 KB

    jul7290 wrote:
    Thank you very much for your help! I added the "Clear task" vi and now it works properly.
    If you are still using the RUn Continuously you should stop. That is meant strictly for debugging. In fact, I can't even tell you the last time I ever used it. If you want your code to repeat you should use loops and control the behavior of the code.
    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

  • Event Structure Problems

    Hello all,
    Im using the following code trying to obtain voltages and then use the peak voltage to trigger an event. My event structure doesn't seem to be working properly and I'm not sure what I need to do.
    Take a look, and any help would be great!
    Attachments:
    Untitled 5.vi ‏43 KB

    hey,
    there are a couple of things wrong with your layout, other than the Event Structure isn't being called. What you have here doesn't do a lot and that is the beauty of LabVIEW: you can do the same thing in many different ways.
    Following the Event Structure design you are intending to go with I have attached a redesign of your code, including comments. I believe this should work for you now. I have followed the common State Machine approach, which quite nicely, uses the Event Structure - when in a 'stable' or non-working state.
    The main aspect you need to consider is how the Event Structure is called. It needs an interrupt in order to identify a state that it needs to address. In this case here, to increment a counter each time the peak voltage is detected.
    The Enumerated data type (the value that holds the state of the State Diagram) can be added to or changed. Normally you should 'Customize...' the data type (right click) and create a Type Def variable (ensures all changes are provided throughout the code, where it is used).
    There is more you can do with this structure, it is quite useful and powerful. There are quite a few examples online or within the LabVIEW help function to give you more. In regards to the DAQmx, there is a State Machine project already set up for you - with all type-defs and some events already created for you. After you've mastered this you should go along and check that out more.
    All the best. David.
    Attachments:
    Untitled 5.vi ‏25 KB

Maybe you are looking for

  • Error when running attached menu to form

    I have recently attached a menu to a form. It worked the first time, but not I just get the error : "form-10221: Cannot read file <menu filename>" I have recompiled "This section" as well as "compile all". According Oracle help, I should just recompi

  • Xml file parse  event base

    hello all, i am learning xml file with sap help sample. I have a FM, that change xml-file into if_ixml_parser, but when i wrote the xml " <person status="retired">Walt Whitman</person>" and debug it. event_sub was 312, <b>event was always initial</b>

  • Can't get my contacts from mac to iphone

    recently started to use icloud for my mac ipad and one iphone - no problems  My old 3g iphone (can't use icloud) no longer syncs using iTunes to address book on my mac and i have lost all my iphone contacts  Notes and calendar are fine any ideas?

  • SAVE PDF TO THUMB/FLASH

    HOW TO SAVE PDF DOWNLOAD TO THUMB/FLASH DRIVE?

  • FDM to load data in Essbase ASO cube

    Anybody have used FDM to load data in Essbase ASO cube? How do you clear and run calc on ASO cube? Thanks