Event structure + while loop

Hello, I'm trying to figure out for a half a day how to unite two while loops in attached VI
The first while loop creates solid state machine that reacts on each button press and executes one of the case structure events. (this part works fine)
The second while loop, all the time generates random number, but it stops the generation during the time when one of the case structure events are executed. (this is the ticky part)
Any suggestions?
Solved!
Go to Solution.
Attachments:
SSM_v1.1.vi ‏15 KB

If you want your random number to stop while the user triggered events are executing you should be able to simplify your design quite a lot.
It can be done with one while loop using the timeout case.
Troy
CLDEach snowflake in an avalanche pleads not guilty. - Stanislaw J. Lec
I haven't failed, I've found 10,000 ways that don't work - Thomas Edison
Beware of the man who won't be bothered with details. - William Feather
The greatest of faults is to be conscious of none. - Thomas Carlyle
Attachments:
SSM_v1.2.vi ‏16 KB

Similar Messages

  • 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

  • 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

  • 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

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

  • 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

  • SubVI with while loop + event structure not working in multi tab VI

    Hello Everyone,
    I am developing an interface for the control of a prober using Labview 2012, and I am stuck with some issue.
    To start with I provide you with a simplified version of my control interface VI, and with the sub-VI used to build and manage the wafer maps.
    The VI consists of several tabs: Prober Initialization, Wafer Handling, Wafer Map, Status, Error.
    The sub-VI can:
    1/ initialize the grid to display the map (sub VI Init Grid not provided here)
    2/ import XY coordinates from a txt file (sub VI Wafer Map Import)
    3/ display the coordinates and index of the die below the cursor
    4/ and when a die position is double clicked, and the boolean "Edit Wafer Map" is true, then the user can change the state (color) of the die between On-wafer die and Selected Die
    My issue:
    If I use the sub-VI by itself, it works fine. However when I use it as a sub-VI in the tab "Wafer Map", the map does not build up and I can no further use the embedded functionalities in the sub-VI.
    I suspect the while loop + event structure of the sub-VI to be the bottleneck here.
    However I don't know which way to go, that's why I'd be glad to have some advice and help here.
    Thank you.
    Florian
    Solved!
    Go to Solution.
    Attachments:
    Control Interface.zip ‏61 KB

    Hi NitzZ,
    Thank you for your reply.
    I tried to save the VIs in LV10, please tell me if you can open them now.
    Inside he event structure there is quite some code, and since I don't want to make the main vi too bulky, I would like to keep it as a sub-VI. 
    As you can see from the sub-VI, the event structure is used for extracting cursor position and tracking the double click action. These events are linked, through a property node, to the image "Wafer Map" which is passed to the main vi through connector pane.
    All values are passed this way as well (through connector pane). Is there another way?
    Maybe "refnum", but I don't really understand how to use them...
    If I use the event structure in the main vi, the wafer map is still not working. I tried it earlier.
    To implement the multi tab front panel, I used a tab control, and a for loop + case structure. For each element of the case structure, there is a corresponding action.
    For the case where I put the code (element=2) for Wafer Map, I also control the execution of the code with a case structure activated by the button "REFRESH". Otherwise I end up with a freezing of the panel right after the start.
    I hope these comments help you understand better.
    Regards,
    Florian
    Attachments:
    Control Interface.zip ‏104 KB

  • 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

  • While loop inside a event structure

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

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

  • 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

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

  • 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

  • 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

Maybe you are looking for