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

Similar Messages

  • Change the condition in event structures

    Hi all,
    I am a student, currently doing a project. I'm very new to labview and I don't really know much of the function in labview. Anyway, I have this timer made using event structure if I'm not mistaken (I downloaded this timer from one of the post in this forum). This timer will start at 0s, count to 20s, then stop. So what can I do to change the end time of this timer?? Let's say stop at 50s??
    Attached is the program. Kindly please explain to me or modify the program and attached back as a reply. I've been trying to figure it out from the help function, but still don't understand.
    Thank you very much in advance!!!
    Solved!
    Go to Solution.
    Attachments:
    TIMER s.vi ‏13 KB

    Hi,
    Thanks for your inquiry. The VI attached uses a couple of programming structures: While loop, Event structure and Case structure. What you would have to change is actually the case structure. Before we go to that, let us go through the different structures. Open up the block diagram by going to the Menu bar of the front panel and navigate to Window->Open block diagram.
    The While loop is like a Do Loop in text based programming. It will execute until a condition is met. From the attached VI, it stops running when you click the exit button.
    The Event structure is a structure which consists of subdiagrams. The structure responds to interactions with front panel objects. For example, if you click the start or stop button in the front panel, the event structure will switch to a case which corresponds to this interation. In the attached VI, the case, which corresponds to intreaction with the start or stop button, is called  "Start", "Stop": Value Change. Each case will contain an event-handling routine.
    Case structures are like switch statements in text programming. Take a look at the "Start", "Stop": Value Change event. It contains a routine which consists of a case structure. The case structure responds to the input terminal called Start (which is actually the start button on the front panel). The case structure switches between cases according to this input. To view the different cases just cycle through the case structure by clicking the left and right buttons. There are only two cases: True or False as the input is a boolean.
    Now lets take a look at the VI. Take a look at the "Timeout" case of the event structure. This is where the modification needs to be made. Modify the case structure by editing the cases. Change the numbers in case structures: ..20000 to ..50000  and 20001.. to 50001.. This should do the trick.
    Regards,
    Alan Bong

  • Stop events structure

    Hi all!
    Here I am! I'm using a events case in a while loop. The problem is that
    I should press twice on the stop button to stop the while loop...WHY!!!
    That my question...I set Switch when release for my stop button...(I
    must use a local variable of it...) Now, I can't stop my VI it seems
    that the value of my Stop booleen must be read before the while loop
    begin...then, when I press once my Stop booleen, then, it stay at true
    value, end it seems that the while loop start an other time...So, I
    press the control again, and the Vi stop correctly...( By closing, I
    send a false value to the stop booleen, to recover a ready to use
    control Like a latch mechanical action...)
    Now there is the problem...To figure out where is the problem,  I
    highlight this...and now,  I got no problem! each time it is highlight,
    my VI stop correctly, but in normal mode, I should push twice on the
    control to stop it...Is it common? Do you know something weird with
    event case? By the way, I need to have an event case with no time out,
    because I use some shift registry each time I make an event action...
    An other weird tings, is when I recreate the "same" thing in an other
    VI, Or even I copy paste the inner part of my VI in a brand new VI, it
    working...
    In addition, I can't send you an example, because it is a part of a
    very huge program...(So I should send you too many subVI and special
    driver...So...)
    Nevertheless, I took a picture
    Thanks for help this...
    Fakstory
    Attachments:
    Doc12.doc ‏77 KB

    Look, if you only attach a picture, we can only comment on what we see!
    The main diagnosis ("race condition"!) has already been mentioned. The point about the event structure inside a case structure is serious and could possibly cause problems like you observe, but it is not possible to tell from the picture for sure. Your picture shows very little, but what it shows does not make sense. I just pointed out the two most glaring observations. Since you say yourself that you are a noob, such comments can help. A program that is clear and does not contain unecessary things is much easier to debug.
    Typically, the quality of the answer cannot be better than the quality of the question. You don't provide enough details and the image you posted is useless to pinpoint the problem.
    Analogy:
    You don't bring a picture of your motor to the mechanic and ask why the car does not start. Unless the picture show that the motor is missing or on fire, nonbody will be able to tell what's wrong.
    All we can say for sure so far is that have a race condition. Provide some code (even broken) and we can give a more detailed analysis.
    LabVIEW Champion . Do more with less code and in less time .

  • Start stop event structure queue

    Hello,
    I would like for the attached vi to start logging/displaying data when the Start button is pushed, not when the VI starts. So I did some research and was led to the Event Structure (this is my 1st time using an event structure). I have been trying all sorts of things over the last few hours so what I have now is probably somewhat convoluted, however, my latest error is that my dequeue is receiving an "invalid refnum".
    Could someone guide me on what I am doing wrong?
    Thanks.
    Solved!
    Go to Solution.
    Attachments:
    InitFile.vi ‏20 KB
    CNAP Daq Event Structure.vi ‏109 KB

    Hi Nouse,
    I had some free time and was bored so took a look at your vi for you. You was on the right track, had started with a good architecture which is half the battle, just needed some fine tuning:
    I took your code and added it to this. All that i have taken out is the Sub vi's that get your data, i replaced this with a random number just to see some data on the wavechart and also being logged in your file. A point to notice is that your 'CNAP INIT FILE' vi has no error cluster propogation. If you run this subvi and there isnt the 'C:CNAP\' Directory (As there wasnt on my computer at first) the 'OPEN File' vi errors and halts the program, as you have no error propogation or handling in this vi you cannot handle this error.
    I changed the vi slightly and added a 'Start' 'Stop' and 'Exit'. This allows you to start acquiring/logging data, stop (without exiting the program), restart acquiring/logging or exiting the program. A point to note is that if you do 'Stop' and then 'Start' again, relatively quickly your 'CNAP INIT FILE' Vi will append a previously written file, which is fine, but it will also send out a new start time. So your readings in the same file will start from 0 time. You may want to catch this and not update the new start time if appending an old file.
    I have attached the VI in both LV2009 and LV8.6 as you never stated your version.
    Hope this helps,
    Rgs,
    Lucither
    Message Edited by Lucither on 03-27-2010 03:32 AM
    "Everything should be made as simple as possible but no simpler"
    Attachments:
    Data Logger VI 2009 and 86.zip ‏229 KB

  • Unable to stop event structure manually

    Hello,
     I have a fully functional State machine program to control a stepper motor.
    However, I face a problem where I am not able to break the program inbetween execution by clicking the stop button for while loop MANUALLY.
    I dont know why it cannot exit upon User input.
    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 ]
    Solved!
    Go to Solution.
    Attachments:
    Motor-UNI_Directiona Dev 3.vi ‏53 KB
    Control 1.ctl ‏6 KB
    Control 2.ctl ‏6 KB

    Uggh. I typed a response here to your note but NI website timeout kicked me out and I lost everything I typed.
    What RavensFan mentioned is shown in attached image, you have to unclick that option on every case of your events structure so that it doesn't lock up the front-panel.
    But more importantly as Lynn and other folks mentioned, you have a bigger problem with your design implementation.  My previous example was to show how a state-machine based design can be made clean/small/efficient/etc.  I have two 30" monitors on my Mac and your block diagram extends well into my second monitor!! :-)  (I'm a bit of a neat-freak so I like making things look nice/wires laid out properly/into straight lines, no unnecessary wires crossing/etc - all that makes it easier for yourself and others to see the design.)
    Sorry, back to the main point - you should definitely follow Lynn's advice on using Consumer/Producer (events) model - a simpler start would be to separate out your events structure into its own while loop that runs parallel to your existing loop.  With that, at least you will execute events structure at a regular interval.  Another strong advice is to simplify your design so that you don't use nested (one-inside-another) state-machine design. I have decades of LabVIEW experience yet I stay away from that kind of complication because it only causes more problems as you grow your design. Why not just add more cases to your existing state-machine design rather than adding a nested state-machine structure inside it?
    -DP
    New Controls & Indicators made using vector graphics & animations? Click below for Pebbles UI
    Attachments:
    Untitled.png ‏75 KB

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

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

  • Some frontpanel controls stop firing the Event Structure

    In my main vi,I have an event structure. I created a subVI that also has an event structure. I load the subvi via a subpanel in my main vi. It runs fine for a while. But sometimes after firing events on the subpanel, most but Not All controls on the main VI stop firing the Main Vi's event structure. The Subpanel's subvi event structure always works fine. When I reload the program it works fine again for a while.

    This is the problem that's been bothering me too (big time actually). Thanks for the insight!
    First of all I love the event structure and it totally changed the way I program labview. Together with the subpanel addition, it makes for very professional looking programs. Here's my version of the same problem:
    I have an event structure on the main VI, and ~20 subpanels. I load various subvi's in the subpanel of the main VI as required. Each subvi has an event structure to handle GUI and incoming user events. I found the problem in the full blown operation, but the problem also appears when I only have one subpanel running, so only one event structure in a subpanel and one event structure in the main program.
    I had the problem with a mouse down on a table, and with a doubleclick on a listbox. And indeed I had an attribute node (reference + property node in my case) to the listbox in the event case that handles the doubleclick. When removing the attribute node, no more buttons will stop to respond on the main panel. When you try to readout or access the listbox in any way in the event case that handles the double-click, it fails. It does not matter whether the "Lock front panel until the case for this event is completed" is true or false. After it fails, you have to unload all the code and reload before LV is able to see some of the buttons on the main panel again (LV7.1.1). You do not have to close LV just the VI's.
    So my first work-around after reading your story was to drive a user event from the doubleclick event case. That user event case then does the stuff I want to do with the listbox. Did not work. I then added a delay of 1000 ms before accessing the attribute node in the other event case, that worked. I then moved all my stuff back into the original event case and added a delay there before accessing the listbox. 100 ms failed, 500 ms works. So at this point I would tend to unexpected behavior from LV which is timing dependent, not "Operator error".
    There is never a problem in any of the ~200 events in the ~20 subpanels. It is always the main panel that is affected. The event handler simply does not "see" some buttons anymore (value change), for example the "mouse down" event would still work for a boolean buttton on the main panel whereas the "value change event" would consistently fail.

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

  • 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

  • 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

  • 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!"

  • Stop graph using event structure

    How could I stop the wavform chart during running the loop using event structure?

    duplicate post
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • How can I stop an event structure detecting keydown events until the vi has initialised?

    My application has a sequence structure with 3 frames. First one initialises some front pane objects and controls, the second communicates with an external device via a serial port to a start condition and waits for this to complete by polling the device. The third contains the event structure which reads the device when the spacebar is pressed. The problem is that any pressing of the spacebar when the application is in the first 2 frames of the secquence structure is stored and executed as soon as the third frame becomes active. I have tried using dynamic Event registration but to no avail. Am I doing something wrong? can the keyboard be disabled until the second frame complete
    s?

    I usually avoid sequence structures in favor of driving execution order through data dependency (error clusters are great for that). However, since you've already got one, you coul try to add another frame right before your event structure. In that frame, place another event structure that can trap that stray keyboard event. Put a tiny timeout value on it so it doesn't appear to "pause" your VI's response. That event structure will catch any bogus key presses that happen during initialization.
    Having said all that, I still think the behavior is not proper. The event should not be handled if it happened before your VI gets to the event structure. For now, you can try that workaround.
    Daniel L. Press
    PrimeTest Corp.
    www.primetest.com

Maybe you are looking for

  • Using non-smartphone to upgrade to the iPhone 4

    I recently bought myself a smartphone last September, which makes me not eligible for an upgrade. I want to get the iPhone 4 but don't really want to pay the retail price for something that I'll probably drop and break within a year. I was wondering

  • Transfer data from the PO to the invoice header data in MIRO (user exits)

    Hi. We are trying to transfer some basic information from the PO to the invoice header data by the time we process the logistic invoice verification (transaction MIRO). The information we want to transfer is: 1.     PO Text (screen field DRSEG-TXZ01)

  • Reading Multiple lines in a file Using File Adapter

    Hi All, Iam new to this technology.How to read multiple lines in a file using file adapter.Brief me with the methodology.

  • Pop up Messages on Opening CS6

    I get six pop up messages when opening CS6 on my Mac Lion computer-Could not load the Disable Get Info Comment Module/GLDrawing Module/Scratch Compression Module/VM Buffering Module/Enable Async I/O Module/Fast Core Routines Module. Any advice on how

  • Alerta An error occurred with the pop3 mail server. Mail server responded;

    Boa tarde, ao receber email´s aparece a mensagem: Alerta An error occurred with the pop3 mail server. Mail server responded; Não utilizo gmail nem yahoo, outros usuários recebem normalmente os emails. PAra enviar está normal sem problemas. Obrigado.