Cannot stop while loop

Hello,
I want to count how many times the Boolean state has changed. But somehow the stop button cannot abort the statement.
Solved!
Go to Solution.
Attachments:
counter test.vi ‏8 KB

Your code is way too constipated. Here's one simple solution.
LabVIEW Champion . Do more with less code and in less time .
Attachments:
counter test_MODCA.vi ‏9 KB
CountTransitions.png ‏4 KB

Similar Messages

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

  • 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

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

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

  • Dsc periodic I/O "stop while loop" usage?

    I'm using LabView 8.5.1 with DSC.  I have created a working periodic I/O server VI and successfully deployed it. 
    The one glitch I am running into is what happens when the Shared Variable Engine I/O process is terminated.  I normally terminate it by using "remove process" from Variable Manager.
    The I/O server wizard lets me choose the while loop for termination during the build process, but any code following the while loop is not executed.  In fact, the process continues running for 10 seconds until the "abort VI timeout" is reached, at which point the VI stops.  The "stop" terminal of the main while loop is wired to a "create control" "STOP" button on the front panel.  Publishing or not publishing the "STOP" control during the I/O wizard process has no effect.
    I'd like to do cleanup steps after the while loop terminates.  Unfortunately the "Heat Exchanger" example has no code after the while loop to illustrate the concept.
    What am I missing? 
    Thanks,
    Mike

    Hi Van - let me clarify my question...
    I don't believe that the termination portion of the DSC "periodic I/O server wizard" actually works properly, or at least an example is needed of how to make it work.
    It appears to me that the wizard functionality of "choosing the server termination method" might not work.  Within the wizard, the two options are to abort the running server VI, or to choose a "while loop" to be forcefully-terminated with a standby timeout value to force a VI abort anyway, if the while loop does not exit.
    I set up a simple server VI with one main while loop that does RS-232 I/O with a "running" beep on a 1 second timer.  After the while loop is another small block of code that closes the serial port, and a different "terminating" beeper.  When I run the VI interactively, both beeps work fine.  When I use the wizard to turn it into a server and it is deployed to the SVE, the beeps begin normally.  When I stop the SVE process via "remove process" in Variable Manager, the "running" beeps continue for another 10 seconds until the abort timeout occurs, even though with the wizard I specified the only while loop in the VI to be aborted.
    The heat exchanger example works fine.  Unfortunately it does not have any code following the while loop, so it doesn't shed any light on this issue.  Ideally that example would be updated a little to show how to use the "while loop termination" feature.
    Basically my request comes down to this:  is there a way to actually make this work, or is it another in the list of bugs in 8.5.1?
    Thanks,
    Mike

  • 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

  • Stopping while loop after last element of 2d array is passed through

    I posted something similar to this before, but what I got didn't work.  So this time I'll try to be more clear with what I am trying to do.  What I have done is combine two 1d arrays into a 2d array, and am using it to run an experiment.  I split the 2d array into a 1d array by column, and am trying to get the while loop that the array is in to stop after  the last element of the array is indexed.  I need to use a while loop because the array is constantly updating because the number of elements can be changed while the program is running.  What I am having trouble with is getting the while loop to stop after the last element has run, because the last element is subject to change.  Any ideas?
    Thanks 

    I am trying to run a measurement using labview to control different instruments.  The program is suppossed tp work in that it runs a measurement for each current setpoint inputed, for 1 magnetic field setpoint.  So for example, if the magnetic field setpoint is 8000 gauss, and the two current setpoints are .00001 amp, and .0001 amp, it will run the meauserement twice for the 2 current setpoints for each magnetic field setpoint.  What I am trying to do is that sometimes, I might have to edit the magnetic field setpoints while the program is running.  I am having trouble with refreshing the magnetic field setpoints, which allows the user to input a new magnetic field setpoint while it is running.

  • 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

  • Stop while from outside loop

    Hello
    I hava an application with a while loop. Outside this loop there is a subVI, that contains also a while loop. This subVI can be stoped when the main VI loop stops. This works correctly.
    But the subvi, can also stop itself, and when it happens I want the main VI loop to stop also.
    How can I do this?
    (The idea is that the loop in the subvi has to stop the main VI loop)
    Thank you very much!!

    Hello.
    A simple way would be to use global variables, but here is another way. Please note that in this example, the main VI cannot stop the loop in the subVI; since you said you had already achieved that I didn't worry about that part, just the part of the subVI stopping the main VI's loop.
    Here are a pair of VIs. When the subVI's loop finishes, the subVI finishes execution (which is a requirement for this method) and changes an indicator in the main VI. The value of this indicator is read by a local variable and used to stop the loop in the main VI.
    Hope this helps.
    Attachments:
    TopLevelVIwithLoop.vi ‏17 KB
    subVIwithLoop.vi ‏14 KB

  • Cannot stop looping

    Hi
    I'm have imported a 30 second clip for the menu screen but I cannot stop it looping after only 10 seconds of play. Menu Info only acknowledges the first 10 seconds of the clip.
    Perhaps I'm missing something very obvious....
    tia
    k

    Kinda solved!
    I put a 30 second silent sound file which adjusted the movie length to 30 seconds.
    An odd workaround for an odd problem.
    Still, why didn't it adjust to the movie clip length????

  • How to create a time control for while loop?

    Hello all,
    I would like to control my while loop's execution time. In other words I want to stop while loop's execution after time (in ms) which is set by user. For example user sets 5 seconds to front panel control and a while loop runs and stops after 5 seconds.
    I am not sure is it possible with the while loop. I succeed with the timed loop but it suits badly to my application. Is there any other loops for timed control if it is not possible with while loop? There is also a simple while loop with Random Number (0-1).vi as attachment.
    Best Regards,
    Jick
    Solved!
    Go to Solution.
    Attachments:
    execution time loop.vi ‏6 KB

    hi,
    see this, may be it will help.
    Best luck
    Gaurav k
    Gaurav k
    CLD Certified !!!!!
    Do not forget to Mark solution and to give Kudo if problem is solved.
    Attachments:
    execution time loop.vi ‏9 KB

  • Multiple while loops

    I have two while loops in my application which run seperately. The program looks as follows
    :   while loop 1           :       :  while loop2        :
    I want to stop while loop 2 as soon as while loop 1 stops. I tried to connect the stop condition of while loop1 to the stop of while loop2, but the loop stops immediately after one iteration. How to go about it.
    Regards,
    Giridhar Rajan
    Automation Engineer
    Cruiser Controls
    Mumbai, India

    The big concept in LV is dataflow - a piece of code will execute when all its inputs are available. When you connected the two loops you caused a data dependency - the data in the wire coming out of loop one will only be available when the loop ends. So what happens is that you run loop 1 and when you stop it, the T value goes over to the second loop, which only starts running now. Since it gets T, it stops after one iteration. You can see this if you turn on Highlight Execution (the light bulb button). There are several ways to go around this - the simplest is a local variable - right click the stop button and select Create>>Local Variable. You can change this to be read and put it in the second loop. You will need to change the mechanical action of the button and make sure you set it back to false. A more advanced method is the event structure.
    These are the basics in LV. To learn more, I suggest you read the LabVIEW user manual. Also, try searching this site and google for LabVIEW tutorials. Here and here are a couple you can start with. You can also contact your local NI office and join one of their courses.
    In addition, I suggest you read the LabVIEW style guide.
    Try to take over the world!

  • How to use Boolean values from 2 different sources to stop a while loop?

    I am working on a program for homework that states E5.4) Using a single Whil eLoop, construct a VI that executes a loop N times or until the user presses a stop button. Be sure to include the Time Delay Exress Vi so the user has time to press the stop botton. 
    I am doing this right now but it seems as though I can only connect one thing to the stop sign on th while loop. It won't let me connect a comparision of N and the iterations as well as the stop button to the stop sign on the while loop. So how would I be able to structure it so that it stops if it receives a true Boolean value from either of the 2 sources (whichever comes first)? 
    Basically, I cannot wire the output of the comparison of N and iterations as well as the stop button to the stop button on the whlie loop to end it. Is there a solution?
    Thanks!
    Solved!
    Go to Solution.

    Rajster16 wrote:
    Using a single Whil eLoop, construct a VI that executes a loop N times or until the user presses a stop button. 
    Look in the boolean palette for something similar to the word hightlighted in red above.
    LabVIEW Champion . Do more with less code and in less time .

Maybe you are looking for

  • What is the processor family for an Intel T2080?

    Hi everyone, I'm compiling my own kernel and I'm stuck on the part regarding processor family. I got a weird sort of CPU. It's an intel pentium dual core T2080. It's not a Core 2 Duo or any of that. According to wikipedia, the model name is 'Yonah' a

  • Analog audio to ipod

    I have successfully transfered analog audio (reel to reel) to mp3 files and have heard them on my computer in I-toons, however when i transfer them to my video i-pod, although they list, they will not play. any thoughts??

  • XY graph: write an error

    Hello, I wish to write a character like an "x" or a null character (like a empity space) when my VI generate a read error. How can I do? Thanks

  • Final invoice indicator for Service based IV

    Hello, For invoice verification based on Service entry, the system proposes the final invoice indicator checked.  I'm trying to uncheck this indicator as in our case, vendors usually sends partial invoices. We have FM implemented and applied Link: [n

  • Time zone MST not valid in country US  warning message in SC

    Hi Gurus, When we are trying to create the SC, we are getting the warning message as "Time zone MST not valid in country US (several possibilities)". we need to switch off this message.  Message no: AM 482 Some one can help me how to switch of this m