How this while loop is stopped

The attached VI is an LabView example VI and I did a little modification. If I want to stop this VI, I will have to click the Wait loop stop button then click Set Occurrence button twice, finally click the Set loop stop button to stop the program. My question is, if we click the Wait loop stop button and click Set Occurrence button once, the conditional terminal sees the True signal, it's supposed to stop, but it doesn't stop until we click the Set Occurrence button again then click the Set loop stop button. We can see it from the Wait and Wait 2 LEDs. Any one can give some explanation? Thanks.
Guangde
Attachments:
Generate Occurrence2.vi ‏23 KB

Thank you for responding to my question.  I think I understand it now. The first click of the Set Occurrence button, the lower loop gets out of the current iteration. At next iteration, even though the conditional terminal sees the True signal, it can not exit because it's waiting for the loop to finish. Only after we send the Occurrence again then the loop will finish it's task and exit. Again, thank you for your help.
Guangde

Similar Messages

  • How do i implement this while loop

    I need to implement this while loop, i tried it using the case structure but i am not able to do it, i am getting a error saying that Missing alignment to tunnel , Case Structure : Unwired selector...
    the while loop is :
    while ((eps>EPSTol)&(iter<iterMAX))
       Ew = Ew.*(sqrt (F./Fr));         
       Ew (find (isnan (Fr))) = 0;       
       Fr = normalise (Fr);
       eps = chi2 (F, Fr);
    end
    can you please help me on this....
    Attachments:
    untitled.jpg ‏1909 KB

    It's been said many times before, but it bears repeating;
    DO NOT POST BITMAPS TO THE FORUM. DO NOT CHANGE THE EXTENSION OF A FILE TO .jpg, .gif, OR ANYTHING ELSE JUST TO GET IT PAST THE FILTERS.THE FILTERS ARE THERE FOR A REASON.
    You will not be able to connect the output of your OR function to the case structure. That would create a circular condition, which you cannot have. Think about it. You want to execute the True case if the output of the Boolean operation is true, but you cannot evaluate the Boolean operation until you have the value generated by the True case. You must have an initial value for eps in order to be able to evaluate the Boolean operation. A shift register (or feedback node) should be used for the eps value, and you can initialize the shift register (or feedback node) to set the initial condition. Example:
    It's also worth saying this: To learn more about LabVIEW it is recommended that you go through the tutorial(s) and look over the material in the NI Developer Zone's Learning Center which provides links to other materials and other tutorials. You can also take the online courses for free.
    Attachments:
    Example_VI_BD.png ‏5 KB

  • While loop never stops after reading the result

    I 'amattaching the program with thismessage in which while loop never stops, going on continuing until I stops it manualy using the off button What i have to do to get it off automatically afetr execution and reading the query and getting the result in Read in Front panel
    Attachments:
    PMd VI.vi ‏33 KB

    Your stop condition is "continue if true". This means that, unless you press the button, the while loop will stop after one iteration.
    First, you should change the termination condition to "stop if true".
    Then you should make the stop button "latch when released" (right-click..mechanical action). Else you don't have a well defined state after the program stops.
    You should decide on a reasonable loop rate and enter it for the wait control. (beter use a diagram constant if the value is always the same).
    Why do you need to continue reading in a loop? Are you expecting the response to change over time?
    Do you want to keep appending to the string indicator or only show the latest characters received?
    Maybe you also need a wait between the writing and reading?
    Delete the ms timer value indicator, it is completely useless.
    Do you get any error codes?
    Don't use the run continous button. Use the plain run button.
    What device are you communicating with? Do you have documentation?
    LabVIEW Champion . Do more with less code and in less time .

  • How to stop execution in while loop without stopping execution of other loops in the same vi

    HI
    I am quite a novice in Labview.
    I have a problem in my project. I used a while loop inside my vi to build an array of ten values along with other loops. Then I used a stop button to stop manually the while loop. But it seems like the loop doesn't stop in the middle of the array building and so other loops in the vi doesn't work until the while loop finishes building the array and as soon as while loop execution is over, the complete vi stops. But all that I wanted was to build the array using the shift register along with the control to stop building array anytime. And not to stop execution of other structures when the while loop finishes.
    Can anyone help me?
    Rahul

    Hi Rahul,
    Modified ur Vi to work with single button.
    But the subtract case is not in any loop.
    So, once both the loops stop, the subtract case will execute only once. Depending on state of subtaract boolean at that time, corresponding case will be executed and the Vi will stop.
    so think of a logic where u can put this also in a new loop.
    Or you can also incorporate it in one of the two loops and pass the other loop's data to it.
    Let us know how you will proceed in this regard
    I am posting your VI as well a VI with my modifications VI in Labview 7.0 so that Thomas can give his suggestions too
    Plus, always keep a time delay in your while loops.
    Oh sorry, the "arrayinouttestnewfinal.vi" is the modified vi
    Regards
    Dev
    Message Edited by devchander on 01-10-2006 06:15 AM
    Message Edited by devchander on 01-10-2006 06:19 AM
    Attachments:
    arrayinouttestnewfinalnew4.vi ‏59 KB
    arrayinouttestnewfinal.vi ‏63 KB

  • What's wrong with this while loop?

    Hi, folks. for the code fragment blow, resultSetArray holds two objects of type ResultSet. From those println statement, i can see the whole while loop(the most outter one) process goes alrite the first time right from begining to the end. However, when variable j increases from 0 to 1, the code stops executing at the the line while(rs.next). I just couldnt figure out what causes the problem while i've been fighting with it for several hours. Could someone plz throw me some lights? With your help, i could possibly go to bed before sun rises...
            while(j<resultSetArray.length)
              //for(int j=0; j<resultSetArray.length; j++)
    System.out.println("show me j is called twice " + j);
                   ResultSet rs = resultSetArray[j];
    System.out.println("the converting rs object is called twice and it is not null " + rs);
                  int numWantedColumns = wantedColumnNames.size();
                  //if it's about go or single trip
                  if(j==0 && rs != null)
                      go = new Element("Go");
                       //go.setText("go");
                       //result.addContent(go);
                  //if it's about return trip
                  else if(j==1 && rs != null)
                      back = new Element("Back");
                       //back.setText("back");
                       //result.addContent(back);
                  if(rs!= null)
    System.out.println("this hell is called twice coz it's not null");
                   while(rs.next())
    System.out.println("what about here?");
                        Element flightInfo = new Element("FlightInfo");
         System.out.println("while rs.next() is called");
                        for (int i = 0; i < numWantedColumns; i++)
                           String columnName   = (String)wantedColumnNames.get(i);
         System.out.println("column name is " + columnName);
                           String value = rs.getString(columnName);
          System.out.println("column value is " + value);
                           flightInfo.addContent(new Element(columnName).setText(value));
                        if(j==0)
                           go.addContent(flightInfo);
                        else if(j==1)
                             back.addContent(flightInfo);
                   else if(rs == null)
                        break;
                   j++;
             }

    i've got the problem sort out, eventually. there was actually nothing wrong with the while loop. it was caused by a typo in databse, instead of having Brisbane, i typed Bisbane. The single letter r cost me more than 6 hours to figure it out. it was such a painful feeling while i realized i made a such stupid mistake.
    by the way, as jnw777 mentioned, output rs.next() info instead of the test line. i did try it, however i didnt realize even System.out.println(rs.next()) would cause the cursor move down one row from its current position. so, plus the original while(rs.next()) statement, it was moving the cursor two rows down at a time! And i just couldnt think of this caused me the fact i was only getting the even number row of the ResultSet while i was sniffing the bug from a class with 700+ lines of code. I was so excited and just couldnt stop yelling at the moment i got over it! That was a damn execiting moment...
    now, i am wondering if anyone in this wonderland would like to share his/her stories.

  • 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 many while loops in an applicatio​n is appropriat​e?

    Hi,
    I am writing an application that is growing and now I'm about to add the 5th while loop on the root level. So far, I have loops for:
    1. Receiving data
    2. Transmitting data
    3. Processing commands
    4. Handling front panel events
    5. (about to be added) background timed events
    My question is this - is there any "recommended" maximum number of while loops in the base VI or is it purely up to the application? I am wondering if it matters, or if I can simply add loops as needed. Other than combining the transmit and receive data which I don't want to do due to speed, there's not much else to combine.
    Any comments?
    Thanks,
    Jason

    Isn't LabVIEW wonderful? It is so easy to write applications that do many things seemingly at the same time in paralell.
    I would not worry too much about the number of loops. Make sure that each loop is well behaved and only spins if there is really something to do. A single empty loop without any wait statement can be very taxing for the CPU and hurt responsiveness in all other loops.
    As long as the UI is nicely responsive and the CPU is not pegged at 100% you're fine.
    LabVIEW Champion . Do more with less code and in less time .

  • Does anyone here knows how a while loop works?

    The following code works...
    DECLARE
    zz NUMBER := 1;
    BEGIN
    While zz < 10
    LOOP
    zz := zz + 1;
    END LOOP;
    END;
    If I put a prompt in it like so it does not....
    DECLARE
    zz NUMBER := 1;
    BEGIN
    While zz < 10
    LOOP
    prompt Look THEO I am looping...;
    zz := zz + 1;
    END LOOP;
    END;
    I get the following error...
    prompt Look THEO I am looping...;
    ERROR at line 6:
    ORA-06550: line 6, column 14:
    PLS-00103: Encountered the symbol "LOOK" when expecting one of the following:
    := . ( @ % ;
    I get the same kind of error if I put a create, select or pretty much any other statement than an assignment in the loop.
    Am I to believe that a while loop in SQL*Plus is particular to what kind of statement is in it?
    Any help would be appreciated.

    PROMPT is a SQL*Plus command. If you would like to output text to the screen while looping in a procedure you should use DBMS_OUTPUT.PUT_LINE(). This will also require you to use the following command at the SQL*Plus promptSET SERVEROUTPUT ON;Your code will look like thisDECLARE
        zz NUMBER := 1;
    BEGIN
      While zz < 10
        LOOP
          DBMS_OUTPUT.PUT_LINE('Look THEO I am looping...');
          zz := zz + 1;
      END LOOP;
    END;This will output Look THEO I am looping... 9 times. If you would prefer that it only be displayed 1 time then you can move the DBMS_OUTPUT.PUT_LINE between the BEGIN and WHILE commands.

  • How do i stop a while loop

    I'm new to labview and I'm having a problem stopping a while loop (running windows XP/2000 with the student edition of labview express 7).
    I'm doing a data acquisition program where I'm constantly reading in voltage and comparing it to a set point value, when the input voltage goes above the set point, i want the while loop to stop. How do I do this? I already have an LED going on when the criteria is met, but I'm not sure how to actually stop the loop (i.e. change the iteration value from true to false-i guess). If anyone can please assist me with this I would very much appreciate it.
    I've included my program too.
    Attachments:
    CO_Detection_Monitoring_System_Modified.vi ‏60 KB

    Hello Everyone-
    I've just posted a message about stopping a while loop and it was answered accurately and quickly- thanks to LV_Pro and PauloM- thanks much- its nice too see that there are many helpful people out there! Unfortunately, I have 2 more questions to ask of the forum.
    My application is almost completed- I just need to add an elapsed time counter that will tell me how long it took for my LED to trigger (from my set point-i.e. when from 0:00:00 until when my loop stopped).
    Now I've found a perfect elapsed time counter on the NI web site contributed from Mike Hall from Ohmeda Medical- the page is here.... http://sine.ni.com/apps/we/niepd_web_display.display_epd4?p_guid=D37E2493DC333076E034080020E74861&p_node=DZ52032&p_source=external
    So my first question is, it looks like I can just extend the while loop box in my 'CO detector... .vi' and paste just the code from the 'elapsed time.vi' while loop into my loop and I will be set- but do I need to change my wait until next multiple to be a 1000 too in my program? Probably, but I'm not sure hence the question- or other ideas would appreciated.
    My second question is now that my application is complete (after I add the elapsed time above), I need to exactly duplicate this process for 7 other DAQ inputs (i.e. right now I'm using only 1 of 8 analog inputs on the FP-AI110). So should I make my 'CO detector.. .vi' a separate program (I remember reading something about this in one of the posts earlier).
    Any help is very appreciated.
    Thank you again,
    Daniel
    Attachments:
    CO_Detection_Monitoring_System_Modified.vi ‏60 KB

  • How to make a button to stop and run a while loop?

    Hi all,
    I am a beginner in the Labview. I did a program that contains a while loop, its stop condition is connected to button. I selected “switch when pressed” to be the operation of this button. Our teacher asked us to make this button stops the loop if it is pressed and its name is converted to run instead of stop. And if it is pressed then again it starts the loop from the point it stopped in.
    Can anybody help me, please?

    First, please use a smaller font when composing your messages.
    You will need two while loops.  An inner loop which has its stop terminal attached to the stop button.  Put that in the False case of a case structure.  Wire a local variable of that stop button to the case selector of the case structure.  Put the case selector inside another while loop which is the one that keeps the program running no matter what the state of the original Stop button.  You will need a master stop button to stop the outer loop when you are ready to end the whole program.  Don't forget to put small millisecond waits in each of the loops so that the loops don't eat up all the CPU resources.
    For that stop button, you could rename the True title to Run, so that when it is pressed to stop the inner loop, the button will show the word Run.  Pressing it again pops it back out, allows the false case to execute and the innermost while loop to run.
    You could also change the words on the buttons by using property nodes.

  • How can I opearate indicator outside while loop?

    I do small program, I have many while loops and I want to connect wire (in my application) from each loop to AND gate then to another while loop, but how can I operate these wires to agree with the change of my application inside while loops.
    If not clear :
    In another words, suppose I want to operate indicator ouside the while loop. How can I operate indicator outside while loop, so when my application become TRUE (inside while loop) the indicator will be ON (outside while loop) and when my application become FALSE(inside while loop) the indicator will be OFF (outside while loop).
    Help me if you have any idea please..........................

    Hi Rammo,
    For the wire to carry the boolean condition from the while loop to an 'and' gate outside, the while loop must stop running
    If you want the while loop to keep on running and still pass a boolean value to a destination outside the while loop, use any one of these: property nodes, global or local variables.
    i am still not clear as to what you intend to say by this sentence
    " I want the wire that comes out from the while loop will become TRUE if it in my application is TRUE inside while loop and the opposite is true. Because I want to connect the wire that comes out from while loop to AND gate than to another application"
    plz tell me if the first part of this mail of mine answers your doubt or do you need more information?
    regards
    Dev

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

  • 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 do i exit a while loop using event handler

    Hello,
    I have an event handler structure within which i run a while loop for a particular event. I would like to interrupt the execution of this while loop as soon as another event occurs, even if the while loop has not finished execution. I have tried so many ways, the best i could get is exiting one itteration after the new event occurs which is no good for me.
    Any suggestions???
    Thanks
    Me

    Instead of having a task while loop in an event case, put your task while loop in parallel with the loop surrounding the event structure. When the event which should start the task occurs, you can signal the start of the task while loop. You could use local variables of references to start/stop the loop when an event occurs. You could also use notifiers instead of variables to pass signals to start/stop the while loop. In general you should have a while loop for the event structure, and a parallel while loop to do the tasks. The parallel loop is controlled by variables or notifiers which are set in the event cases.
    - tbob
    Inventor of the WORM Global

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

Maybe you are looking for

  • Esr obj in 7.1

    Hi Friends, I am new to PI 7.1. I have imported swcv into ESR and after creating namespace,I see models,namespace and imported objects under my swcv. I am confused how to create the design objects,as in lower versions of xi once we create namespace a

  • Stock transport order with BAPI_PO_CREATE1

    Hi, can anybody give me an advice how to use the function BAPI_PO_CREATE1 to create stock transport orders? I´m getting some errors when I run it. Here is my test data I have used: poheader-comp_code: NO10 poheader-doc_type: UB poheader-langu: EN poh

  • Previous period posintg

    Greetings!!! I have maintained authorization group F_BKPF_BUP to restrict posting in previous period.. It works fine for all tcodes except CO11 Any solution plz Regards

  • Append data to a waveform graph

    I am using the Acquire N - Multi-Digital Trig to acquire a series of data. I wish to store the data acquired, by saving them into a file (Export Waveforms To Spreadsheet File) however, the waveform graph data are not appended. I have tried to see the

  • Apple id changed settings

    I had a previous apple id that I used on an ipod, but all the security questions have been changed (perhaps when my young daughter had a go at updating it herself and now has no memory of any questions...).  Is there any way either: i) to cancel my o