Event Structures and Do /While Loops

I have an Event Structure inside a Do/While Loop.  One of the buttons in the event is STOP which stops the do while.  The Stop Button itself is inside the event as suggested in the help.  My problem is when I hit the stop button everything inside the Do/While runs 1 more time.  Other than than the code works perfectly.  is this normal behavior for a Do/While ..Event Structure??

The attached file is the code in a nutshell.  I know it can sometimes be diffcult to TS w/o the actual code.  Prob is I wrote it in LV2011 on the Lab PC and I have LV2010 at my desk.  I don't have internet access in the Lab..of course.
If I hit the OK button 2x's it "does something...does something...build array" then again a second time.  The build array is added to with each click of a button in the event structure.  If the user hits the STOP it dumps the 2x's worth of data out to excel..except I get 3 rows of data rather than 2...as if the inner loop ran one more time.
Anyways. the only thing that caught my eye is the fact that I don't have a sequence structure around the "build data here" portion of the code.  Would that affect how the STOP inside the do while loop is handled??
Attachments:
event_Do_While.JPG ‏90 KB

Similar Messages

  • 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

  • Stopping an event structure inside a while loop.

    I am relatively new to LabView, and especially the event structure. I have been looking at previous posts regarding the event structure and people having trouble stopping it. In my VI, I have two event cases in addition to the timeout. I am using this VI for stepper motor control. I have 2 buttons (for each case), one for movement to the left, the other to the right. It runs like it is supposed to, but when I try to stop it I have to press both buttons before it stops. As if the loop has to execute everything inside before stopping.
    In my VI, how can I make the execution stop when I press the stop button? I tried many setups of the stop button and boolean logic (which I believe was correct) but am now stuck.
    Thank you very much ,
    Alek
    Solved!
    Go to Solution.
    Attachments:
    motor control2.vi ‏24 KB

    OK, here's my simplified version. All you need is two event cases.
    Note that (with a tiny difference), the "left" and "right" cases are identical, so they can be handled in one event, reusing most of the shared code.
    We don't need a timeout event
    Just some extra tweaks...
    Message Edited by altenbach on 06-23-2008 05:09 PM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    RightLeft.png ‏13 KB
    motor_control2MOD.vi ‏15 KB

  • Event structure in a while loop does an extra iteration

    In this program, after the user has measured all the values, he or she will press a calibration complete button and the results of the measurement will be displayed.  However when the program runs and this button is pressed, the event structure does one more iteration.  Is there a way for the while loop to read the control before the event structure executes to prevent this?
    p.s.  I know that the wiring is probably a lot more complicated than it needs to be so if there is a better way to place values into a particular space in an array let me know
    Thanks
    Chris O.

    Probably just a matter of the order of execution in your data flow.
    Please post a VI so we can see what is going on now.
    Never mind.  You have since posted it.  SMerucurio's suggestion of a separate event case for the other button should work fine.
    Message Edited by Ravens Fan on 06-30-2008 01:20 PM
    For putting an element into a specific location of an array, look at "Replace Array Subset".  This should allow you to replace your groups of shift registers with a 1-D array since you are basically building 1-D arrays after your case structures anyway.
    Message Edited by Ravens Fan on 06-30-2008 01:24 PM

  • Front panel locks with event structure loop and another while loop

    Hi,
    Why is the front panel locking after changing the value of the "boolean switch" twice? This problem disappears if I uncheck the "lock front panel" option in the event case. However I don't understand why that is the case since the event structure loop has already finished executing.
    thanks

    Do you really want the event handling to stop after detecting the first event? If so then as Christian says the event structure will cause the front panel to lock. What you can do is dynamically register and unregister the events. You right click on the event structure and enable "Show Dynamic Event Terminals" Then  you can programatically register and unregister events.
    Here is your vi modified to do that.
    Edit: Just in case - right click on the control and create a reference. When selecting the source of the event in the structure look under the dynamic section.
    =====================
    LabVIEW 2012
    Attachments:
    event structure test.vi ‏13 KB

  • Event structure and waveform graph cursor

    I am utilizing a waveform graph and I need to programatically manipulate multiple cursors based upon the movement of a primary cursor.  I would like to use the event structure to avoid processor usesage. 
    My approach is to create an While Loop/event structure where it goes into a it when there is a "mouse down" on the waveform graph.  Once in it, there is another While Loop/event structure that has two cases: Time Out (set to 25) and a "Mouse Up" on the waveform graph.  In the Time Out case, the primary cursor is read and modifies the location of the secondary cursors.  In the "Mouse Up" case, the primary cursor location is read, other cursors are manipulated, and the While Loop is exited.
    When I code this up and perform a "mouse down" on the waveform graph, the index on the inner While Loop/Event Structure is advancing but there is no control (can't move it) of the primary cursor on the waveform graph.  When I "Mouse Up", the inner While Loop exits.
    Obviously, my approach is flawed here based on my lack of understanding of the characteristics of the waveform graph and cursor manipulation.  Has somebody come up with a way to achieve what I am trying to do?

    This is basically the method I typically used in LabVIEW 7.1 and below as described in this old post.
    Of course you could upgrade to LabVIEW 8.0 and none of this is necessary! LabVIEW 8.0 has events for "Cursor Move".
    Now you only need the "cursor move" and "stop" cases. Isn't that cool!
    Message Edited by altenbach on 12-12-2005 07:05 AM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    LV8CursorMove.png ‏6 KB

  • Use event structure and while loop in parallel

    Hello, I would like to use an event structure in parallel with a while loop. I have a camera that needs to constantly take pictures and I have that setup in the while loop. I also however need to do other functions in conjunction with the picture taking. I have about 50 or so events that need to have access to while the pictures are taken. Is there any way to do this? If not is there any way to have a global stop variable that is attached to all 50 of the events. I know I can do this the hard way and have each boolean event in the event structure be attached to the while loop stop control. This is however very inefficient. I would also like to know if I can simply use a mouse click as the stop of the while loop. Am I able to have a variable that goes from false to true on mouse click without using the event structure to do this? Thanks.

    Yes, just place the event structure in a second while loop.
    Add a stop button to the other while loop and add an event for the stop button to stop both loops. For a simple example, see my VI posted here:
    http://forums.ni.com/ni/board/message?board.id=170&message.id=176367&jump=true
    Simply add more event cases as needed.
    LabVIEW Champion . Do more with less code and in less time .

  • Stop and start while loop on order

    Hallo everyone,
    I have this small IV, it means nothing but I want to know if it's possible to control each while loop. what I wish to do is to press the boolean button, then the while loop starts running and when i press it again the loop stops but when I press it again it works again, not that the program stops running at all. not only that but I need it for both loops. so i run one and stop the other then stop one and run the other and so on...
    I dont know if this is possible and its not necessary to be done with loops, I just wrote loops because this is what I can do and understand, if there are any other possibilities then please feel free to share it with me.
    Attachments:
    Unbenannt 3.vi ‏178 KB

    pcardinale wrote:
    Perhaps something like this.
    I don't think we need to involve such a huge amount of code and new concepts (timed loop, notifiers, subVIs, clusters, arrays, event structures, etc.),  to solve such a simple problem. (This might turn off a beginner!).
    Here's what I would do.
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    TwoCharts.png ‏14 KB
    Unbenannt 3Mod.vi ‏17 KB

  • Event structure and automatic queueing of events.

    I have found out the long way that the event structure queues all the events taken place while it has been executing yur most current event.
    In other words... I understand why the locking of the front panel is an automatic option that is selected. As it will prevent you from queueing more events,  and causing yur program to execute endless event structure runs, when you wanted it to stop 15 button presses ago.
    case in point.... is in this simple VI i attached.
    My question is ... is there a way to turn off this automatic queueing of events??
    Attachments:
    EventStructureHUH.vi ‏53 KB

    Well ... the problem for me... was, for example, in the VI I posted....
    The OK button in the VI I posted, has an event triggered to it in the event structure.... So when I enter that loop after hitting the enter loop button... it registers those OK clicks...
    Say the OK button and NOT the continue button takes me out of the little loop and back into the big loop. Now, after leaving the little loop and entering into the big loop, I will immediatly enter back into the event structure to handle the OK button click.
    Basically I wanted one button to control the termination condition of the little loop, but also have an event in the event structure associated with it, so basically one button to exit the little loop AND the big loop.
    I hope Im making sense. I found a solution, by just making two buttons, when entering into the little loop, the one button dissapears... and vice versa when entering into the big loop. So to the USER it appears like ONE button... but in the code its actually two.
    I just wasnt sure if there was another way around it... it was tough to figure out what was really happenening in my code... took my about an hour or two to track down.
    EDIT: Yea.. thanks for the reply....  as for the comments in my code... yea, I get a little crazy towards the end of the day... after 6-8 hours of straight labview programming. 
    Message Edited by MJBrehm on 06-30-2006 02:21 PM

  • Calling a VI in a subpanel with parameters inside an event structure and using an abort button

    Hi all,
    I have a control panel with a tab control and two tabs have a sub panel in them.  At runtime I load the VIs I want in to the sub panels.  In the control panel event structure I want to start each of the VIs and monitor the execution state so I can abort the VI while it is running.  One method I use can run the VI and the abort event will work (see example).  The second method I use does not and this is what I want to do!  I have many inputs to the VI I want to pass so placing the VI in the event blocks everything else and it has to wait until the VI has completed, so I cannot monitor the execution state.
    I have attached an example of what I want to do.
    Any help appreciated.
    Martin
    Solved!
    Go to Solution.
    Attachments:
    SubPanel.lvlib ‏2 KB

    Hello,
    You can do this with queues. 
    The main vi and subpanel vi's should be based on the producer/consumer (events) and you handle the front panel events accordingly in the respective vi's. 
    Name the queues in obtain queue , for example the Main being MainQ, subpanels SubPanel1Q, SubPanel2Q. When you start the application, initialise the main vi and also run both of the subpanels (just to make sure that the queues are first obtained by themselves). Then you can use obtain queues to do inter vi communication.
    For example if you need to send data from main to subpanel1, use obtain queue and use the name SubPanel1Q, pass the required data & command and voila. Subpanel1 vi will receive your message. You can do this anyway you want. Hope this helps.
    Beginner? Try LabVIEW Basics
    Sharing bits of code? Try Snippets or LAVA Code Capture Tool
    Have you tried Quick Drop?, Visit QD Community.

  • Execution conflict between a SubVI and a while loop

    Hi,
    I have wired the conditional terminal of a while loop with a boolean control. The same boolean control is responsible to terminate a SubVI (not inside the while loop) which also contains a while loop (I am using a reference to the control here). When I first use the boolean control, the SubVI is being terminated, but the while loop in the main VI is not. In order to terminate the main VI, I have to use the boolean control once more. In order to avoid that, I created a "status"-indicator within the SubVI, which is set to true once the SubVI is terminated, and wired that from outside the main VI's while loop to its conditional terminal. Of course, now the while loop does only execute once the subVI transmits the status value.
    The thing is, I want both the while loop to execute before the status value is being transmitted (so, only the conditional terminal is supposed to wait for the value) and use the boolean control only once in order to terminate the VI.
    Any ideas?

    Ok.  I kind of expected to see this.
    First of all, change the "Control: Mouse Down" event into "Control: Value Change".  DO NOT USE  A LOCAL VARIABLE!!!  Wire the result straight out to the termination terminal.  You want something like this:
    Your writing to a local is a race condition.  The control was read before you wrote to it.  Therefore the loop was going an extra time around.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines
    Attachments:
    Stop loop.png ‏13 KB

  • Problem with avi recording and parallel while loops

    Hi,
    I made a test-VI which captures my webcam and save it to an AVI. (based on a sample I found somewhere)
    This works pretty fine so far (except the fact that the "frames per second"-constant has no effect and I am not able to change the resolution, but that's not the problem).
    I have a VI which controls some hardware and I want to record this with the webcam. For testing I made a dummy-VI which should run in parallel with the VI above:
    The 1st while loop should capture the webcam.
    In the 2nd while loop is a dummy-VI which generates some random values and waits 5000ms (to simulate the hardware).
    The problem is that those while loops do not work in parallel. When the execution is finished I get an AVI-file which is about 100ms long (so I guess it captures just 1 frame).
    If I replace that whole dummy-VI thing with a stop button it works nicely, but if I try to use a "Wait (ms) Function" or a "Wait Until Next ms Multiple Function" the video is always just about 100ms.
    Any idea how to implement multitasking or maybe even multithreading ?
    Attachments:
    lv_avi-recording.png ‏23 KB

    Hi Chris3,
    Just a random suggestion but have you tried removing the sequence structure? You can wire the error cluster from the IMAQdx Configure Grab.vi to both of the VIs for it to start parallely. 
    If you put it in a sequence like that, it is most likely that the middle sequence has to complete execution before it can go to the next sequence but it couldn't because of the wait.
    Let me know how it goes.
    Warmest regards,
    Lennard.C
    Learning new things everyday...

  • Pause and restart while loop after defined time

    Hello,
    What I need is to find a way to run a while loop that is acquiring and analysing a movie, to pause this while loop for a time I specify, and re-run it after that time has passed.
    I'm attaching a picture of the relevant parts of my VI. In the case structure of the "true" or "false", the program is checking, online, if the eye (my camera is focusing on the eye) is open above some threshold and for a certain duration of time. When "condition to start" is met, two things happen: one, the case structure changes to "false" and waits for some time; second, the loop of my state machine is triggered. Problem is, because I'm not really pausing my while loop (it's still running even when it's the "false" case), my state machine runs really slowly - for example, I have a part of video acquisition in my state machine, and saving the frames to avi takes forever. 
    Does anyone have any idea of how I could stop the while loop for x time?
    Thanks in advance!
    Attachments:
    help_pauseWhileLoop.png ‏112 KB

    Hi,
    I'm attaching (hopefully) better pics, if you still can't see let me know and I'll attach the code. About the frame saving and acquistion, I'm already doing that in a separate loop - you can't see my entire code in the pics, but what I have is a state machine that works as a producer loop and then a consumer loop, where video acquisition is happening. Now I'm working on a third loop (the one in the picture), that starts before the others and where I don't even want to save the movies - I just want it to check, online, if the condition is met (e g, the eye is open for a specified time) and if so, start the state machine and stop running, until the state machine has finished running. Then do the same, after waiting a specified time. I know that the problem is that the while loop keeps running after triggering the state machine, because if I remove that part and trigger it manually, the VI runs just fine and really fast. So how can I run, stop and restart the while loop?
    Attachments:
    help_pauseWhileLoop1.png ‏56 KB
    help_pauseWhileLoop2.png ‏32 KB

  • Code driven event handling in a while loop

    I have an event driven while loop. Is there any way to trigger an event by code and not by any user action? Sometimes I need to execute the while loop once but I don't like to use the timeout event because it causes some trouble in my timecritical application.
    Thank you in advance,
    Andreas Langer

    Andreas,
    The following page has an example on how to accomplish this:
    Generating an Event in LabVIEW Programmatically
    http://zone.ni.com/devzone/explprog.nsf/6c163603265406328625682a006ed37d/c0128a70970d0a0386256b48008366be?OpenDocument
    Zvezdana S.
    National Instruments

  • Start, stop and restart while loops

    Hi, my qustion is i have 2 example a and example b. Example b lets u start counting up in seconds when u want to. as long as the toggle switchs are in correct position. it also lets u start, stop and restart if need be. i want to be able to that with example a, but for some reason the while loop always sets of running independent of what position the the toggle switch. Any help greatly appreciated.
    Thanks Stuart
    Attachments:
    examplealib.llb ‏202 KB
    exampleb.vi ‏25 KB

    An example as the attachment.
    Attachments:
    switch.vi ‏23 KB

Maybe you are looking for

  • Home screen and open apps

    Some thoughts/suggestions after playing with Passport for two days: - Home Screen:  confusion of "home screeen":  in browser "Add to Home Screen".  it refers to the first left scroll of "Open Apps" screen. But the mini icon at the bottom of the scree

  • Iphoto disk is full.......and other issues

    good morning, tried to load some new pics into iphoto today and i get the following probs: icon bounces but no iphoto screen on desktop. message states - your iphoto is almost full (i have 188g free on system - so confused). then message - repair per

  • Prevent Flash from Exporting content outside border?

    Hi, I'm rather new with Flash, and although i can comfortably get on and develop the animations I need, onething is baffling me and I can't find the answer here in the forums... Basically, I've imported some photos and added some motion to them - I'v

  • Itunes crashes during sync

    Just about every time I modify playlists and try to sync to either my Touch or Nano I end up spending HOURS trying to determine which new selection causes the sync process to crash. I end up doing binary searches by dividing the playlist in half, the

  • Workflow roles and the worklist

    All, I need to have users that are assigned to multiple roles. It would be really nice if the user could view their worklist by role. For example, we have one role for 'normal' work to do, and another role for 'errors/problems' items. I would like to