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

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

  • 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

  • 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

  • While loop doing AO/AI ... Performanc​e?

    Hi!
    I have been trying to get a VI to do concurrent Analog
    data in and out and both the input and output rates and
    waveforms can change while the VI is running. My problem
    is this:
    (a) If I try putting the read and write operations in
    separate while loops, one or the other loop will
    die in a buffer over/underrun.
    (b) If I put both into the same loop, then this works
    but I am limited in the choice of data-rate parameters
    because eventually one or the other DAQ VI will take
    too long.
    At this point I have only one loop and the buffers are big
    enough to hold 10 iteration. Every time one of the loops
    dies I reset it. Still this seems awkward. Is there a
    way of improving on the loop overhead and putting t
    he
    input and output in separate loops? Or any other way to
    improve performance?
    Rudolf

    Ok, I knew that ocurences did something useful but I am
    still a bit confused:
    * Can you set an occurrence for an output event. None
    of the examples I've seen say so but it looks like
    it should work
    * How do occurrences actually help with the "hanging"
    problem. Does the compiler see the occurrence in
    a loop and change the wait parameters?
    I looked at devzone but most of the stuff I found there,
    even the promising looking stuff was all about
    synchronizing and triggering, not about occurrences.
    Rudolf
    JB wrote:
    : Once in the read function, the program "hangs" until the number of
    : data points is in the buffer. The same applies to the write function.
    : This means that most of the time, your program is waiting.
    : To sol
    ve this problem, you must use DAQ occurrences (--> hardware
    : events).
    : For examples for using daq occurrences, type "daq occurrence" in the
    : search of the LabVIEW help or even better, at
    : http://zone.ni.com/devzone/devzoneweb.nsf
    : Hope this helps

  • 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

  • While loop does not execute

    I wish to write a text file that is tab separated for viewing in UNIX, however the tab character provided in Labview is read as a ^M in the UNIX file and in notepad. If you have any suggestions, they would be appreciate

    In article <506500000008000000206F0000-1042324653000@exchange​.ni.com>,
    "smd169" wrote:
    > I wish to write a text file that is tab separated for viewing in UNIX,
    > however the tab character provided in Labview is read as a ^M in the
    > UNIX file and in notepad. If you have any suggestions, they would be
    > appreciate
    When I write a tab delimited file on my Linux box I just get tabs. The
    only time I see the ^M is when I use a carriage return instead of a tab.
    To suppress the ^M in Linux I've been told to use line feeds or the combo,
    carriage return/line feed. I tried it and it works. Sorry if this
    doesn't answer your question. Perhaps results are different on a pure
    Unix system? Maybe it's the text viewer... I used less and joe to verify
    my results
    -Kevin

  • Event Structure Freezes Vi After Capturing The First Event

    My Event structure catches the first instance of my button press but then it freezes my Vi.  The reason is because of the while loop but I need the while loop to constantly read from a serial port and send data to a serial port. The vi included is stripped down to be just a while loop that does nothing.  I have also tryed putting the event structure in the while loop, but the same thing is happening.
    Any ideas?
    Thanks,
    Cason Clagg
    SwRI
    LabView 7.1, Windows XP

    Also, put the button inside the event structure where it is acted upon, from LV help (suggest you read the entire events section of help):
    When you trigger an event on a Boolean control configured with a latching mechanical action, the Boolean control does not reset to its default value until the block diagram reads the terminal on the Boolean control. You must read the terminal inside the event case for the mechanical action to work correctly. As a reminder, a note appears in the Edit Events dialog box when you configure a Value Change event on a latched Boolean control.
    Refer to the Handling a Latched Stop Boolean Control in an Event Structure caveat for information about how to handle a latched Boolean control.
    When you trigger an event on a Boolean control configured with a latching mechanical action, the Boolean control does not reset to its default value until the block diagram reads the terminal on the Boolean control. You must read the terminal inside the event case for the mechanical action to work correctly. As a reminder, a note appears in the Edit Events dialog box when you configure a Value Change event on a latched Boolean control.
    Refer to the Handling a Latched Stop Boolean Control in an Event Structure caveat for information about how to handle a latched Boolean control.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~
    "It’s the questions that drive us.”
    ~~~~~~~~~~~~~~~~~~~~~~~~~~

  • How to handle event structures for two buttons and two counters.

         *I have two buttons A and B, and have to compare the difference in hits between them.  So do I place an event structure within a while loop for each button (2 buttons, 2 event structures, 2 while loops), or does it need to be one event structure with cases for both buttons whithin one while loop? 
         *How do I pass the values of buttons A and B's hit counters out of the while loop in order to calculate the differences between them after each increment, not just the final count after the stop button is hit? 
         *How would I make one stop button work to handle both buttons A and B?   I tried to place the actual stop button in one button A's structure and its global in B's structure, but It wont seem to let me use a local variable for a latchable control
    Checker

    You should probably have not started a new thread and waited until your question in the original thread was answered. You can modify altenbach's example for a second button. You have a single event structure with a new event for the second button. You have a second shift register to track the number of times the second button is pressed. Inside the while loop but outside the event structure, you just have a subtract function in or to report the difference. do not modify the posted example for the stop button. It works perfectly as is.

  • Using an event structure to reset a boolean control with ring menu value change

    I am trying to get two boolean buttons to reset when the value of a ring menu changes.  For this I am using an event structure set to execute with a ring value change.  However I have other code that needs to be executing while the event structure waits for the value change.  I place my event structure inside the while loop the buttons reset as expected but my other code does not run (except at the moment of value change). If I place it outside the loop the rest of the code functions as expected but the buttons do not reset.  Any help you can offer is much appreciated.
    Solved!
    Go to Solution.
    Attachments:
    event structure reset.vi ‏11 KB

    try this
    Attachments:
    event structure reset_edit.vi ‏14 KB

  • Buttons stay pressed when using event structure

    I have an event structure in a while loop to handle various buttons the user can press.  I used this instead of case structures on the buttons because I have some advanced events I want to happen to the controls as well.  Code wise it is working fine, but the buttons are not release when you press them.  They only change once when pressed.  So if they are released and you click them they stay pressed.  If you click on them again, they release.  This is very ugly.  What am I doing wrong?  I have tried changing thier type to switched vs latched and it makes no difference.  I tried changing the event on them as well and that doesn't seem to matter.  Currently I have "mouse released" on the button as the event trigger.

    Hello Muffin,
    If you have the buttons configured for "latch" operation (reset after being read, which sounds like what you want), the button will only reset when it is actually read within the code- are they connected to anything or read somewhere within your application?  The simplest way to ensure the buttons are read when the event is triggered is to place them within the mouse-up event.
    Regards,
    Tom L.

  • Run event structure on startup

    i have an event structure in a while loop.
    when I run the vi i wish to run one of the events 1 time without a user input.
    can this be done?? and if so how??

    This does not work with latch action booleans, you need to fake latch action with a switch action and a local variable. The attached modification show a working version of your VI.
    Of course I typically prefer a solution similar to George's.
    The need for a generic "first run" event has been discussed before, see my example and discussion in this old thread:
    http://forums.ni.com/ni/board/message?board.id=170&message.id=108599#M108599
    Message Edited by altenbach on 03-17-2006 08:20 PM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    InitEventMOD.vi ‏14 KB

  • How to make an Event Structure work with a webcam feed?

    Hello,
    I'm pretty new to LabVIEW, and I really need some help on a school project.
    In the program, a webcam contantly streams video.  At the same time, I am trying to add an event structure inside of the while loop that contains the webcam information.  An event structure seems to be just the thing I need to add to make my program work, but after adding it, the webcam stopped showing its feed.  My guess is that it's specifically not working with the webcam part, because I've used event structure inside of while loops before.  How can I prevent the event structure from interfering with the webcam?
    I cannot take a screenshot of the back panel at this time, although I can do it within the next 24 hours, if necessary.  Otherwise, I can try to describe the program to the best of my ability.

    i did this a while back for my school project.
    see if its what you need
    Best regards,
    Krispiekream
    Attachments:
    Executive.zip ‏183 KB

  • Can I use Event structures in a subVI?

    Hi,
    I have a subVI (ProvaEv1.vi) that use an event structure inside. But when I use it in a VI (ProvaVI.vi) the event structure in the subVI doesn't catch the events.
    I tried to insert the event structure in a while loop but it doesn't work too.
    Could you help me?
    Thanks Ius
    Attachments:
    ProvaVI.vi ‏11 KB
    ProvaEv1.vi ‏15 KB

    "iusn" <[email protected]> wrote in message news:[email protected]...
    Thanks to all for your answers!
    Wiebe! I tried to do as you suggested but I am not able to link the Event Reference Number inside te SubVI with the Event Register Number of the Register for Event in Main VI. There is e class conflict. Another question: how the SubVI can know the structure of the Register event outside?My aim was to create a modular structure but it seems very difficult, wath do you think about these problems?
    The broken wire is related to your question. The event structure inside the sub vi knows about the events you register in the main, because the reference wire/control has a "strong" type. It contains information about the registered events. That is also why the wire is broken. You have to register all events, then create an indicator/control of the output. Use that control in the subvi. You have to do this every time the events change (you might use a type def if you use the control a lot).
    Usually, the events that you would want to put inside subvi's are those related to user interface objects. I've had this a lot. You make a nice interface, but it's not reuseable, because the events are mixed with all the other events. Only solotion is to manually add the needed event cases in your program, and copy the code.
    Even if you can put the events in a sub vi, I'd expect hanging vi's when more subvi's are registered for the same event. It's hard to tell without trying. So it's not a real solution either.
    Like Chrisger suggested, the event callback might help a little, but they are tricky, and actually ment for this (they are intended for activex callbacks).
    Perhaps you should look at XControls (if you use 8.2). It would be more work to replace your code to XControls, but once you're done, you have reusable code.. Haven't worked with them jet, but they are invented for this problem...
    Regards,
    Wiebe.
    I have already create my application using event structure just in Main VI but it seems very complicate to read and keep update, I would have wanted to give modularity to my application.
    Thanks Ius
    SubVIEventMain.vi:
    http://forums.ni.com/attachments/ni/170/203225/1/SubVIEventMain.vi
    SubVIEvent.vi:
    http://forums.ni.com/attachments/ni/170/203225/2/SubVIEvent.vi

  • Event Structure need to reset?

    Refer mini vi I made attached. I click on the x button at top right, a message box pops up for confirmation. But if I click second time on x, no more message box pops up.
    Now do i need to reset some properties or do some extra wiring at the vi? I have been refering to the examples but cant figure it out.
    Thanks.
    Solved!
    Go to Solution.
    Attachments:
    test.vi ‏8 KB

    Hi,
    You must put the event structure into the while loop. Otherwise, it runs just once.

Maybe you are looking for