Stopping a loop

Hi,
How do I stop a while loop that collects data from a home made instrument. I don't know how many bytes of data it is collecting. I want to repeat this loop n times but have to stop it after each cycle. Your help is appreciated. 
thanks
sbz

Hi sbz,
If I understand you correctly, you want to pause at the end of each iteration to check that data has come in on a UDP port.
 I am by no means an expert on this, but Labview does have some UDP functionality which might be what you need. The UDP Read function will wait for data until a specified timeout.
To find the UDP functions, go to Functions->Data Communication->Protocols->UDP or on the Functions palette, search for UDP.
These pages have more information:
http://zone.ni.com/devzone/cda/tut/p/id/4950
http://zone.ni.com/reference/en-XX/help/371361B-01/TOC28.htm 
Hope this helps.

Similar Messages

  • How to stop while loop when a specified function is terminated?

    I want to make a program which has 2 thread, one of which is to control some devices, and the other is to measure outputs of the devices.
    To do that, I should make a 2 independent loops, but there comes a problem here.
    I want to terminate 2 loops at the same time, but it's difficult for me to do that, because when I try to notify upper sequence's termination to lower loop by some value change, they have some dependency.
    That's why I need your help. I want to know how to stop lower loop when the upper sequence's termination keeping their independency.
    Please let me know. Thank you.
    Attachments:
    help.JPG ‏200 KB

    Is the upper loop commanding the lower loop at all?  I would think you would have some type of communication between the loops.  Just use that communication to send a stop command.  Or the next best way is to just simply use a notifier.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • What is the best way to stop parallel loops at the same time, from any loop?

    If there is a vi with two or more parallel while loops, what would be a good method to simultaneously stop parallel loop execution, from any of the parallel loops? My intent was to try and do this without local variables, so I used notifiers. This seems like an ok method for two loops, but how about for n loops?
    In addition, my code has a flaw. I use an OR block to compare the stop status of each of the loops. This works fine most of the time, but if both loops are triggered to stop at the same time,the boolean result will be false, causing the loops to never stop. How can this be avoided?
    Thanks,
    Curt
    Attachments:
    parallel_loop_w-stop.vi ‏54 KB

    I think you have the right idea, notifiers are one of the better ways to stop parallel loops. You can simplify things by using 1 notifier for everything. I modified your VI to use 1 notifier, it will set the notifier to True ONLY if the loop is stopping, then it stops. The other loop will read the notifier status, and stop based on it the next time it executes.
    I also changed the second loop to stop and notify if it has an error (that is usually a good idea, especally if you have I/O or other things that can cause problems)
    I also changed the switch mechanical action, that will eliminate the problems for your second question.
    The VI's attached are written in Labview 7.0
    P.S. If you have 7.1, the Queues are polymorphic, meaning that the typecast operat
    ions are NOT needed!
    Attachments:
    parallel_loop_w-stop7_0.vi ‏45 KB

  • I have a for loop inside of while loop.when i press stop for while loop, i also would like to stop for loop.how can i solve this problem?thanks

    i have a for loop inside of while loop.when i press stop for while loop, i also would like to stop for loop.how can i solve this problem?thanks

    Hi fais,
    Following through with what JB suggested. The steps involved in replacing the inner for loop with a while loop are outlined below.
    You can replace the inner for loop with a while by doing the following.
    1) Right-click of the for loop and select "Repalce" then navigate to the "while loop".
    2) Make sure the tunnels you where indexing on with the for loop are still indexing.
    3) Drop an "array size" node on your diagram. Wire the array that determines the number of iterations your for loop executes into this "array size".
    4) Wire the output of the array size into the new while loop.
    5) Set the condition terminal to "stop if true".
    6)Drop an "OR" gate inside the while loop and wire its output to the while loops condition terminal.
    7) C
    reate a local of the boolean "stop" button, and wire it into one of the inputs of your OR gate. This will allow you to stop the inner loop.
    8) Drop a "less than" node inside the inner while loop.
    9) Wire your iteration count into the bottom input of the "less than".
    10) Wire the count (see step 4 above) into the top input of the less than. This will stop the inner loop when ever the inner loop has processed the last element of your array.
    Provided I have not mixed up my tops and bottoms this should accomplish the replacement.
    I will let others explain how to takle this task using the "case solution".
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • MASTER/SLAVE PATTERN: how to stop slave loop without stop main loop

    Hi All, I am studying the master/slave loop and saw an examples are like this (only master block shows)
    From this case, as I understand, if we click "set" button, slave loop will run. If we click this button again to mak it "Flase", the slave loop will be stopped as well as the main loop will be stopped as well.
    Now if I have a multi-function main loop, I just want to start or stop slave loop when click "set" button, how can I do it? Thank you very much! 

    bhl3302 wrote:
    From this case, as I understand, if we click "set" button, slave loop will run. If we click this button again to mak it "Flase", the slave loop will be stopped as well as the main loop will be stopped as well.
    Your understanding is completely wrong.  There is nothing in the image you show that would stop either loop.  In this situation the "set" button would normally have a latching mechanical action, meaning that when it is pushed, it will stay true until it is read once, at which point it will return to false.  Placing the control terminal inside the event case causes the terminal to be read and resets the button to false.  With a latching mechanical action, there will be only one event generated even though the boolean will change value twice (from false to true, and from true to false).  You'll never have a situation where you push the button once to set it true, and again to set it false.  However, even if the mechanical action is switching, not latching, it still won't make a difference here - the event case does the same thing whenever the value changes, regardless of whether it's true or false.

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

  • Stop a loop

    hi im having a bit of trouble stopping a loop
    captor.loopPacket(10, new PacketPrinter());i have no idea how to stop this kinda loop

    nicchick wrote:
    captor.loopPacket(10, new PacketPrinter());
    This is a method call and not a loop. Perhaps you have a loop in the loopPacket method. If so you can stop it the same way as any other loop using break or continue. Or maybe you want to exit the method completely then use return.
    public void someMethod() {
        loop {
            if(condition) {
                return;
            // other code
    }

  • Starting and stopping a loop

    I am importing a list of 10,000 emails into memory and then
    comparing them to a database which holds over 400,000 records. It
    doesnt take long for the <cfquery> to time out. I know there
    must be a way to loop thru 20 or so, then stop, then loop thru the
    next 20, etc. I cannot lengthen the timeout so I need to figure out
    a way to process the data in chunks. Thanks.
    <cfhttp method="Get"
    url="
    http://192.168.14.51/matt/email.CSV"
    columns="Email"
    name="importCSV"
    delimiter="#chr(10)##chr(13)#"
    textqualifier="">
    <cfset counter = 0>
    <cfloop index="element" list = "#CFHTTP.FileContent#"
    delimiters="#chr(10)##chr(13)#">
    <cfset counter = counter +1>
    </cfloop>
    <cfset start = 1>
    <cfset end = 20>
    <cfset lastRow = #counter#>
    <cfloop from="#start#" to="#end#" index="loop">
    <cfset ThisEmail =
    listGetAt(cfhttp.filecontent,loop,"#chr(10)##chr(13)#")>
    <CFQUERY NAME = "CheckEmail" DATASOURCE="t">
    SELECT Email
    FROM Subscriber_Info_New
    WHERE Email = '#ThisEmail#'
    </CFQUERY>
    <CFIF CheckEmail.RecordCount EQ 0>
    <CFQUERY NAME="Insert" datasource="t">
    INSERT INTO Subscriber_Info_New
    (Email)
    VALUES (<cfqueryparam cfsqltype="CF_SQL_VARCHAR"
    value="#Trim(ThisEmail)#">)
    </CFQUERY>
    </CFIF>
    </cfloop>

    quote:
    Originally posted by:
    Newsgroup User
    I cannot lengthen the timeout so I need to figure out a way
    to process
    the data in chunks. Thanks.
    Are you sure you can not lengthen the timeout. The
    <cfapplication ...>
    tag allows one to define a specific timeout for a given page,
    as long as
    that is less then the maximum timeout defined in the
    administrator.
    If this is not sufficient for your needs you will need to
    break up your
    process over multiple requests. Just starting and stopping
    the loop in
    a singe request does nothing for reducing the timeout
    threshold of the
    page. You can do this with scheduled tasks, web services,
    and|or the
    <cflocation ...> tag. You will need to pass through
    relevant data about
    what iterations to process, and use some kind of extra
    request storage
    for the results, such as server|application|session scopes,
    databases or
    files.
    Hope that gives you some help.
    Ian
    Sounds like more than I know how to do. I cant change the
    timeout because its set that way on purpose. I think Ill leave this
    alone for now. Thanks.

  • [svn:osmf:] 17980: Fix FM-1092: Calling stop when loop is true breaks looping.

    Revision: 17980
    Revision: 17980
    Author:   [email protected]
    Date:     2010-09-30 17:42:23 -0700 (Thu, 30 Sep 2010)
    Log Message:
    Fix FM-1092: Calling stop when loop is true breaks looping.
    Ticket Links:
        http://bugs.adobe.com/jira/browse/FM-1092
    Modified Paths:
        osmf/trunk/framework/OSMF/org/osmf/media/MediaPlayer.as

    Hi Experts,
    After i tried a few times, i can successfully start prepare with upgrade asistant monitor - Administrator >> Start Prepare,
    Thanks

  • Stop Playback Looping During Editing

    Can't seem to find where to set the loop/don't loop option. At the end of the timeline, the playback goes to the beginning and starts playback again. I want it to stop at the end and not loop (during editing). Can you help me find the setting to stop it from continuing playback from the beginning of the clip (stop playback looping during editing).
    Premiere Elements 10
    Win7(64)

    There is no direct way to stop playback AT the last Frame.
    Does the End key not work on your computer?
    Once playback has been stopped, the PageUp and PageDn keys will take you to the first Frame of the last Clip, or to the first Frame of that last Clip. The Cursor keys will also step you, Frame-by-Frame, inside the Clip.
    Good luck,
    Hunt

  • Stopping Timed Loop inside a Reentrant VI

    I just converted a project over from 8.5 to 2009 and I found that some of the funtionality that was working in 8.5 no longer works in 2009 (probably for good reason...).
    Anyway, I found that if I tried to use the stop timed loop vi to stop any timed loops in reentrant vi's that I get a -804 error. The stop timed loop sub vi was in the same reentrant vi in the application, but I found it also did not work if it was outside the reentrant vi.
    It does get a little hairy when thinking which loop you are trying to stop because of the reentrancy, but if the names passed into the instances are different for the loops then it shouldn't be a problem right?
    See attached for a very simple example of this occuring.
    Note: Just running in windows...not in RT
    Solved!
    Go to Solution.
    Attachments:
    Stop Time Loop.LLB ‏41 KB

    I resorted to using an alternative way to stop the loops as well.  Does anyone at NI know if this is a feature or a bug or if there is anyway to use the stop timed loop function with a timed loop in a reentrant vi?
    Thanks.
    Whoops... Just read your post.  Thanks for the update.
    Message Edited by klessm1 on 01-06-2010 10:55 AM

  • Stopping multiple loops

    If I have two while loops and I want the same button to stop them
    both, how do I do it? I know I can't put the button in one loop and a
    local variable to it in the other, I also can't put the button outside
    both loops. I'm using LabVIEW 7.
    Thanks,
    Jason

    Jason wrote:
    > If I have two while loops and I want the same button to stop them
    > both, how do I do it? I know I can't put the button in one loop and a
    > local variable to it in the other.
    You say you can't? Why not? Please explain.
    When you click on the button, the other loop will read the
    change and then stop the loop. I don't understand your
    hesitation.
    Thank You
    Michael Aivaliotis
    http://mmwis.com
    http://forums.lavausergroup.org
    http://niweekblog.com
    Michael Aivaliotis
    VI Shots LLC

  • Is there a way to stop all loops( While and For )at once or close the big application with just a button?

    How to sop all loops in the application (While, For and subvis ) with a single button? Use the event sturucture?

    Yes, if you just need to kill the running application, you can use an event structure in a parallel loop. (See attached code image). Pressing the stop button stops everything! :-)
    (Alternatively, you could even call "quit labview".)
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    Killall.png ‏6 KB

  • How to stop while loop

    I can't figure out how to stop a while loop in my labview program. 
    When the user presses the Run arrow in the toolbar I want my program to begin reading the serial port for GPS messages.  These messages should be displayed on the front panel.  Currently I have this read/display in a while loop.  The program is also waiting for an extrenal trigger.  When that trigger arrives, I want to grab the current string from the serial port and save it and continue reading and displaying the serial/gps string.  This trigger starts the other parts of the program- signal generation, recording, and saving data which need to run concurrently with the serial/gps reading/displaying.  Once the AO and AI have finished and the data have been written to disk, I want the program to stop.  The serial/gps messages should be updating this whole time.  Only when the data are written to disk should the whole program end.  This whole sequence of events should only be done once when the user preses the Run arrow. 
    So far I'm unable to pluck the serial string when the trigger comes in if I'm watching the serial port all the time.  The program also doesn't stop when it finishes writing to disk because the read serial while loop is still running.  I don't want to use a front panel stop button.  The program should stop itself when the data havebeen written. 
    I'm really stumped on this one but I'm new to LabVIEW so I'm sure there's an easy solution to this. 
    Thanks for any and all help. 
    Attachments:
    SPoleLakeChirp.vi ‏199 KB

    Dennis and altenbach-  Thank you both for your patience. 
    I was trying to do just what Dennis suggested-"As I said, setting a local variable is one way." even before posting to this forum, but I couldn't get my local variables to reflect changes made elsewhere in the program and I wasn't able to wire from them because they were writes.  The critical part I was missing was how to change a local variable from a write to a read.  It was staring me in the face the whole time- just right click.  When I finally found it, my problems were solved. 
    altenbach- thank's for putting the figures together.  I do understand the logic and wiring there, but I was really trying to avoid stop buttons.  The program should be smart enough to figure out when to stop.  And using local variables turns out to be one way of solving this.  I still have some clean up to do, but I've included my current working version just so you can see how I implimented your suggestions.  There's still a lot of clean up to be done, but I'm delighted to be able to watch the serial/gps messages until I'm done reading in data.  At first I had this stop variable set in the final sequence frame.  That didn't work because I wasn't getting to the final frame because the loop wasn't finishing.  Once I placed the stop variable in the same frame as the while loop it began stopping when it should. 
    If you have other comments/critiques about the wiring diagram I'm earger to hear them.  I'm considering the structure finished, however.  It still needs cleaning up and commenting, but I'm satisfied with the functionality. 
    Thanks,
    Peter
    Attachments:
    SPoleLakeChirp.vi ‏210 KB

  • Start and stop a loop automatica​lly subtractin​g at each iteration

    Hi there,
    I know that there are some topics about it, but I could not find any solution, especially because I use the version 7.1 and cannot open new version files.
    My problem is as follows:
    I need to charge a tank from 6 to 10 in the morning, every day during 3 days. The process must start and stop automatically, which means, no bottoms to start or stop. The start and stop conditions come from the hour.
    I start with a big loop of 72 iterations, which corresponds to 72 hours.
    The tank must start at level 6 every time it starts.
    After the start, 1 unit must be subtracted in each iteration. Which means, that at 6 am the tank has level 10, at 7 am level 9 and so on. In the end, at 10 am the tank level is equal to 2.
    In the next day, the process must start again and the tank must start at level 6.
    Any suggestions? Thanks in advance.
    Solved!
    Go to Solution.

    While this may work it can be improved significantly. This really isn't a state machine. This is basically the same as your flat sequence with the exception of using a While loop with a Case statement to implement each frame.
    You should define what your actions are and create a typedefed ENUM naming them. State names of 1 through 24 are meaningless. Not to mention in your code many of the cases are duplicates of others. That would mean that all of those can be one state with logic to determine what action/state comes next. A properly defined state machine would not need the outside For loop. Without knowing your specific needs some examples of reason state names would be the following: Start, Stop, Exit, Error, Initialize, Get Tank Level, Fill Tank, Drain Tank, Idle, etc. Can you see how these are easier to understand than 1 through 24.
    There are lots of examples of state machines here. Try a search and take a look at some of them.
    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

  • 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

Maybe you are looking for