Start stop while loop with tab control

I want to be able to start and stop a while loop by entering and leaving a tab.  I am using an event structure to do so but it doesn't seem elegant or the right way to do this.  The only way I was able to get it to kind of work is by unchecking the lock front panel box in the event structure.  I have attached a sample vi of what I have so far.
Solved!
Go to Solution.
Attachments:
Loop test.vi ‏16 KB

The problem is that you can't even stop the program by hitting the stop button until you leave the tab, which is not a friendly user interface.
Event structures should just handle basic user events.  Any given event case should not take a long time to run.  While you are in the diagnostics tab, your code is stuck in that while loop.  Although fixing the lock front panel allows you to do other things, the LabVIEW is just queuing up all of those other UI events (like Stop button value change) and can't handle them until the inner while loop stops and allows the outer while loop to iterate again.
You should have a parallel while loop to handle the waveform graph.  You can use notifiers or queues or an action engine FGV (see Ben's Action Engine Nugget) to pass the starting or stopping of the waveform graph update to the parallel while loop.

Similar Messages

  • Problem to stop my loop with tab command

    Hi everybody,
    I have problems to implement my VI.
    I would like to STOP my case "Scenario_en_cours" before to change of tab.
    Anyone can help me please ?
    Cordially
    Attachments:
    Mode_Auto_Final(1).vi ‏216 KB

    That looks like it will take some time to fix.  But what you need to do is seperate your different loops and functions into modules that run all on their own.  You should have one loop for nothing but GUI events.  One of these events should be your tab value change.
    So if you have your other loops outside of this main loop, they just run on their own.  What I normally do is use a queue to tell those loops what to do: run, stop, change some data, etc.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • Stop While loop

    Hi
    I have a while loop with a cycle time of 100 sec, when I stop it I have to wait 100 sec untill the while loop stops.
    There is any manner to stop it immediatly?
    Thanks

    Why are you using a property node for a control that is not accessed within the loop?  And the conditional terminal is set to run if True. 
    Your while loop doesn't make sense.. Can you post the entire code (attach your vi) and explain what you are trying to do?
    R

  • How to stop while loop for particular time

                    public void test()
                   new Thread(new Runnable()
                        public void run()
                             //Thread.currentThread().setPriority(Thread.MIN_PRIORITY);
                             System.out.println("test");
                             //System.out.println("test ..."+i);
                             try
                                  Thread.sleep(3000);
                             catch (InterruptedException e)
                   }).start();
            public void startTest()
                    while(i < marquee_Str1.length)
                   marLbl1.setValue(marquee_Str1); //set value to textbox for perticular id
                   marLbl2.setValue(marquee_Str2[i]);
                   marLbl3.setValue(marquee_Str3[i]);
                   test(); // call thread function
                   i++;
    in this code while loop don't stop
    plz help me to stop while loop for certain period by using thread or other technique                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Yes.. the original problem would be your test() method put the sleep in an entirely separate thread of execution. So the thread is created then the method just keeps waiting. The while loop should directly call Thread.sleep... which you have apparently figured out!

  • Why writes LabVIEW only every 2 seconds the measured Value to a Excel (In a while loop with 100 ms tact)?

    Hi everybody,
    I use the myDAQ to measure speed, ampere, and voltage of a battery driven motor. (For Current measurement, i use a Sensor which outputs a 0-10 V signal). I placed all DAQ-Assitants in a while loop with a [Wait until next ms multiple] clock and set a value of 100 ms. I thougt, Labview will now write into my text file 10 times a second all values. In fact, as you can see in the attached text file, Labview only writes in a unsteady interval of 1-2 seconds a value, which is too less.
    The question: Did I do anything wrong, how can you create VI that writes you lets say 10 values a second into text file? Or is simply the DigitalMultimeter input of the myDAQ not able to sample a rate of 10 Hz? I couldn´t find any information in the specification handbook about the sample rate of the DMM?
    If anyone can help me would be great! Thanx a lot, Markus
    Attachments:
    Measure Speed+Current+Voltage into Excel.vi ‏175 KB
    Test7.txt ‏1 KB

    File I/O is not very efficient. I recommend that you do you file logging in a parallel task. Have one task do your data acquision. This task would then pass the data to be logged to the logging task via a queue. That way your file operations do not impact your data acquision. Also, express VIs are not very efficient. You would be better off accessing that directly using the DAQ VIs. The express VIs contain lots of steps that do not need to be done every time you call it such as initializing the device.
    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

  • Please give me a idea with sample code explainingBDC  with TAB control

    Hello,
    Can anybody give me a idea of doing BDC with TAB control.
    Regards
    Mave

    hi, you need to show the BDC script in TAB control?
    then you can reference to the screen of SHDB, maybe
    thanks

  • Unxepected behaviour with clusters inside of while loop with shift register

    Colleagues,
    I just would like to post here small, but important bug (I guess this is the bug), which was found by coworker today morning. Just would like to share knowledge, and probably this will save some debugging time for you...
    So, the problem that you can get wrong content of the cluster in some cases. The cluster used inside of while loop with shift register (we using this construction for functional globals), and after bundle operation you can get data, which are not expected:
    See also attached code for details (LabVIEW 8.6.1, WinXP Prof SP3).
    best regards,
    Andrey.
    PS
    Bug report already sent to NI.
    Message Edited by Andrey Dmitriev on 10-16-2008 12:30 PM
    Attachments:
    BugwithClusters.png ‏15 KB
    BugwithClusters.zip ‏10 KB

    Thanks Andrey for brining this to our attention!
    The "Show Buffer Allocations" reveals that LV is not processing the code in the right order.
    Under ideal conditions, all of the data should be manipulated using the buffer "A". But as this demo shows the data is being processed in the wrong order.
    The previously posted workaround get around this by forcing the array operation to happen first, but this resluts in two additional buffers "C" and "D" and then copy this back into "B".
    Using an "Always Copy" is another workaround that uses a seperate buffer "F" to hold the data being moved from the first cluster to the second inside "E".
    I think you won a shinny new CAR* Andrey!
    Ben
    CAR = Corrective Action Report
    Message Edited by Ben on 10-16-2008 08:05 AM
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction
    Attachments:
    Cluster_Bug.PNG ‏57 KB

  • 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

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

  • How to stop a while loop with long delay

    Hi everyone,
    I am building a simple program for turning on and off a single Bit.  The task is to turn ON the Bit for a period length T1, and OFF the Bit for a period length T2. T1 is normally different from T2, and can be controlled  by users. 
    Since T1 and T2 can be variable, they sometimes can be very long.
    If I use a Wait function inside a While loop, it needs long delay to be able to Stop the Main program.
    The same situation happens when I use Timed loop.
    Can anyone suggest me how to do this task?
    Thanks a lot. 
    Message Edited by tatuan on 04-12-2010 12:56 AM

    Here's another possibility using OpenG Wait ms:
    Ton
    Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
    Nederlandse LabVIEW user groep www.lvug.nl
    My LabVIEW Ideas
    LabVIEW, programming like it should be!

  • Stop dependant while loops with 1 button

    Hi,
    I am developing a utility that allows a user to configure up to 2 devices (both use same driver with a different board number), click initialize, which then brings up a file dialog and displays arrays for the data to be collected and some error messages for each measurement.  The user then clicks the Start/Stop button to begin collecting and logging data.  Currently i have a Wait(ms) block to allow the user to set often the measurement should be made.  Currently the Start/Stop button allows collection to be started, paused, and started again.  My problem is trying to have a master stop button that should stop all loops immediately when it is pressed.
    I tried using a global variable for the stop button, but the measurement and logging while loop doesnt stop until after the wait(ms) block times out.  Can anyone give suggestions.  If i need to restructure the VI into different loops, I can do that.  I just want to understand the right way to program something like this.
    The VIs are attached.  I removed the device specific measurement VI so that anyone can open the vis and run them to see how it works.
    Attachments:
    2Devices_withoutMeasurementVI.vi ‏112 KB
    BuildOutput.vi ‏27 KB
    stopGlobal.vi ‏5 KB

    Ok.  I had a chance to take a look at your code and I think you don't quite understand the concept of "dataflow".  Let me see if I can help.
    First of all...when I refer to your upper structure, I am referring to the first while loop, sequence structure, and subsequent while loops.  When I refer to your lower structure, I am referring to the while loop containing the event structure.  Just so we get our terminology straight.
    I believe that you are under the illusion that your upper structure contains three parallel while loops.  It does not.  It contains three SERIAL while loops.  There is dataflow dependency between the while loops.  The sequence structure requires data that is not available until the first while loop has finished executing, so the sequence structure cannot start executing until the first while loop has terminated.
    The second while loop requires inputs from the first frame of the sequence structure (which, by the way, you don't need and should get rid of...the sequence structure, I mean), so it cannot start executing until the first frame of the sequence structure has terminated.  The third while loop requires inputs from the second while loop...so, again, the third while loop cannot run until the second while loop has finished executing.
    Now, for your stop button.  You have that global stopping all three loops.  So here's what is happening in your program:
    Your program starts.  The first while loop executes in parallel with the loop which contains the event structure.
    At some point you press the "stop" button.  Both the first while loop and the loop containing the event structure finish executing.
    The first frame of your sequence structure executes.
    The second frame of your sequence structure executes.  The second while loop reads the "stop" value from the global, so it executes once and then finishes.
    The third while loop starts executing.  Again, the loop reads the "stop" value from the global, so it executes once and then finishes.
    Then your program terminates.
    You need to restructure your program, because right now it doesn't make any sense at all.  Your block diagram would benefit from some serious tidying up as well, your wiring is a mess.  I suggest you look into a state machine architecture for this program.

  • Stopping a while loop with a button in cvi

    Hi people,
    I am a newbie with CVI but I have used LabView Heaps. The issue I have is I want to be able to use a toggle button or a command button to stop a while loop. I used GetCtrlVal on the toggle before the while loop. I then enter the while loop and then GetCtrlVal at the end to see if the button has been pressed. The issue I have is that once I enter the loop I am unable to press any buttons on the Panel. I would normally have put a delay in the loop but the issue is I am wanting to control a robot in "realtime", thus any delays in the program results in the robot moving further than what I wanted it to. Any ideas? If you have any suggestions that would be much appreciated thank you.

    This should be in the CVI group but...
    At the tail end of your while loop add a call to function ProcessDrawEvents():
    When your program executes in a callback function or in code that does not call RunUserInterface or GetUserEvent, LabWindows/CVI does not update the user interface. Functions that are overly time-consuming can "lock out" user interface updates. To allow LabWindows/CVI to process these updates, call ProcessDrawEvents.

  • Code golf: stop two while loops with guaranteed iteration ratio

    Proposal
    In the vein of the Perl tradition, I'd like to see if there's any interest in solving short programming puzzles in LabVIEW. Anyone can post a problem and define the rules for solving it.
    Here's a beginning/intermediate question to whet your "palette".
    Description
    With one user-action, how would you stop two while loops such that the ratio of their iterations is the always the same? One concrete way to visualize this situation is in taking measurements: two instruments use the same timing source to take measurements, but second divides the clock down so that it is an integer factor slower than the first. For example, if the slower instrument is four times slower, then at the end of the VI, if the slower instrument takes 100 measurements, the faster instrument has taken 400.
    Rules
    You may only use vi.lib
    You cannot include any other subVIs
    Your solution must pass for loop1 interval as low as 25 ms
    Template (attached in LabVIEW 2009)
    If folks are interested in this, then let's figure out how to make future problems better. Please post your suggestions and critiques, but only if you also post a submission ;-)
    Solved!
    Go to Solution.
    Attachments:
    Multirate Loop Code Golf.vi ‏11 KB

    Norbert_B wrote:
    a) You work with an integer factor of speed. While this matches many application areas, there are still cases where the factor has to be floating point (e.g. 2.5). Additionally, the factor might "invert", so the master loop runs slower than the slave (factor 0.5 for instance).
    It sounds like you're about to post another code golf question. If you think the problem scope is too small, you're welcome to fashion one to your taste. Thanks for volunteering :-D
    Norbert_B wrote:
    b) This example does not take into account that the hardware has to be synchronized with more accuracy than the software supplies (PXI?). If hardware synchronization is required, there are two possible ways:
    - The factor can be included in the synchronization (using PLL for instance)
    - The factor has to be software implemented by data reduction for the task running at the lower pace.
    Hrm, maybe puzzles aren't really your thing after all. You are correct: I did not define every constraint that can lead to a provable best closed-form solution, but that does not prevent people from stating their assumptions and forming creative, well-reasoned, and still correct designs. I overlooked this reading of the description and neglected to add a statement that said solvers were free to add their own conditions. I will do so in the fugure :-)
    If we choose the first of your suggestions, the VI must still retrieve the data at different rates. You can dedicate a loop for each instrument to decouple any jitter and latency introduced by their connectivity or internal operation; this adds some margin of safety when there is thread and driver contention. You can also implement a single counting loop like altenbach and forego the multiloop complexity.
    Norbert_B wrote:
    c) You don't state anything about "what happens with the data". Is this time consuming? Does it introduce additional delay in loop iterations? Is it OK to have data loss?
    I don't know -- you decide, you disclose, and you solve :-)
    In my specific situation, the measurements are time consuming and do add delay (each data "sample" is 5-20 megabytes), none can be lost, and the data must be available for others to analyze later. In addition, the amount of data is saturating the hard disk throughput. If a particular write takes too long, the instrument driver may overwrite a yet unfetched sample, which is unacceptable. I did not add these details to the problem discripton becuase they don't impact the puzzle.
    I don't want to burden people with my situation and ask them to solve my problem: I want to encourage them to bring their intuition and experience to a discussion. This is the design process at its heart: understanding why and how constraints affect your decisions. If a person states the additional conditions they've assumed, readers can learn why, and more importantly, when a Notifier might be more desirable than an Occurance or a Queue more robust than a Data Value Reference.
    The best NI-published advice for stopping multiple while loops (https://www.google.com/search?q=labview+stop+multiple+while+loops) is laughable (and is the "solution" in my template).
    Would you care to re-approach and contribute to this puzzle? I suspect you have a lot to offer :-)

  • Stop a while loop with a interrupt

    I' m using a while with a delay time of 60 seconds to perform a sub vi.
    So when I press the stop button it could take in extrem 2 minutes to stop the vi. I want to use something like an interrupt or jump order to stop the vi without waiting for the end of delay time.
    How can I create an interrupt in lab view 6.1.
    Thanks for help. bye uli

    If the delay is in the calling VI using Wait (mS), you can run a smaller delay multiple times (a while loop inside your main while loop), checking Stop between each of the smaller delays until the smaller delays add up to your bigger delay. See the attached DelayWithStopCheck.vi.
    But this technique doesn't stop the sub-VI: it just stops the loop in the main VI which will still run until the sub-VI is done. You could connect the Stop button to a global which the sub-VI checks in a loop to know if the calling VI pressed Stop.
    Attachments:
    DelayWithStopCheck.VI ‏41 KB

  • How to stop while loop from looping

    Hi, need a little help in the respect to while loops. Basically i have a while loop within an while loop within another while. So what i want to do is run the program within the outer while loop. The problem is that when i start the program it runs once, which is ok, but its the runs again and again and again. I need it to only run once untill i press the inner while loop bolean to set it going and to stop and to restart, but i can not manage to keep the inner loop from initerating. I just wonder if its a problem with the field point? because i know it works, but using a different example. Any help greatly appreciated.
    Thanks Stuart
    Attachments:
    examplealib.llb ‏199 KB

    Use case structures around your middle and inner loops tied to the booleans you want to control the loops. Inside each loop, use a local variable of the boolean tied to the continue terminal of the loop.
    You need to use local variables because an input to a loop (wired from outside the loop) is read only on the first loop iteration. Any subsequent change to a control terminal outside of the loop is not seen by the loop.
    To create a local variable, on the diagram, right click on the terminal of interest, then select Create >> Local Variable. Then right click on the local variable and select Change to Read.
    P.S. You know your stop button is wired to an empty case and doesn't do anything.

Maybe you are looking for