How to out from infinite while loop in sub VI

Dear Sir,
how to out from infinite while loop in sub VI from main VI
attached photo for solution but I can't understand it and i can't find the function in photo 
please help
Attachments:
stop_subVI_frm_main.JPG ‏36 KB

Asking how to get out of an infinite loop is like asking how to find the end of a circle. I'm not trying to be sarcastic but by definition, if there is a way out of the loop, then it is not infinite. I think what you are asking is how to avoid creating an infinite loop. Is there something about the suggestions you have been given that you do not like? My favorite suggestion is the notifier but maybe you just need an example. Turn on context help and read about the notifier functions in the code below.
This is your top level VI
And this is your subVI
If this seems too complex then a global variable will work too. But what seems simpler can cause much more complex bugs. You can code fast and spend lots of time debugging or you can code slow and spend less time debugging. Personally I perfer writing productive code than looking for bugs any time.
=====================
LabVIEW 2012

Similar Messages

  • Re: exit from a while loop in sub vi

    I think the mail didn`t get through first time. Repeat posting - Sorry if
    this occurs twice
    Shane
    Hallo,
    Can the use of occurrences solve this problem?
    The Main program can create an occurrence which can be passed to the
    sub-VIs. Upon pressing the button to cancel the loop, the occurrence can be
    set, instantly transmitted to all other VIs sharing which were passed the
    same occurrence. Of course a small handling routine has to be written (say
    a sequence parallel to the executing while loop waiting for the occurrence
    and then setting the exit parameter to "true") but this is trivial.
    I have checked this with a small program splitting an occurrence to three
    seperate VIs and it works.
    If you want, I can send a cop
    y of it.
    It may well be possible with notifiers or something else, but I have far
    less experience with them.
    Hope this helps
    Shane
    >pcu schrieb in Nachricht
    ><[email protected]>...
    >>Main vi has several sub-vi's. Each sub vi has a while loop and Boolean
    >>button. When program runs, sub-vi front panel appears, and I can
    >>stop/continue the while loop. But when I stopped a while loop in a
    >>sub-vi, I cannot control other while loops in other sub vi.
    >>I need exit function from a while loop, not stop function of entire
    >>program.
    >>Thanks.
    >
    >
    Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)

    The notifier is probably better than occurence at this case - than it is not neccessry to write a parallel sequence.
    The use of notifier is very simple, just follow an example in Help/Search example -> Advances -> Execution control -- Synchronization -> SubVI notification.
    Good luck
    Ferda

  • Exit from a while loop in sub vi

    Main vi has several sub-vi's. Each sub vi has a while loop and Boolean button. When program runs, sub-vi front panel appears, and I can stop/continue the while loop. But when I stopped a while loop in a sub-vi, I cannot control other while loops in other sub vi.
    I need exit function from a while loop, not stop function of entire program.
    Thanks.

    Hallo,
    Can the use of occurrences solve this problem?
    The Main program can create an occurrence which can be passed to the
    sub-VIs. Upon pressing the button to cancel the loop, the occurrence can be
    set, instantly transmitted to all other VIs sharing which were passed the
    same occurrence. Of course a small handling routine has to be written (say
    a sequence parallel to the executing while loop waiting for the occurrence
    and then setting the exit parameter to "true") but this is trivial.
    I have checked this with a small program splitting an occurrence to three
    seperate VIs and it works.
    If you want, I can send a copy of it.
    It may well be possible with notifiers or something else, but I have far
    less experience with them.
    Hope this helps
    Shane
    pcu schrieb in Nachr
    icht
    <[email protected]>...
    >Main vi has several sub-vi's. Each sub vi has a while loop and Boolean
    >button. When program runs, sub-vi front panel appears, and I can
    >stop/continue the while loop. But when I stopped a while loop in a
    >sub-vi, I cannot control other while loops in other sub vi.
    >I need exit function from a while loop, not stop function of entire
    >program.
    >Thanks.
    Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)

  • How to close FPGA reference out from different while loop

    Hi Friends,
                  I`ve different while loop which performs the FPGA read port on different loops I`ve the FPGA out on every terminal at the end of the while loop. I`ve just connected the merge error function in which all the error out of the FPGA are combined and given to simple error handler. How to close the FPGA Reference.

    Can you attach your VI?  I'm not clear on what you mean.  Are you saying that you are using the FPGA reference which is passed into multiple loops, and then continuing the reference wire to pass the ref out of each of the multiple loops?
    If that is the case, I don't believe you can't merge references like you can error clusters.  You will just need to wire one of the reference to the close FPGA VI.  Additionally though, I'd recommend that you use your error clusters in some manner to ensure data flow so that all the other loops stop first, and you are sure you are closing the reference after all the other loops are done with the ref. 

  • How to restore iphone 5 from infinite recovery loop?

    How to restore iphone 5 from infinite recovery loop? I keep on getting error while undergoing restore in itunes and i could not use my phone anymore since it is in recovery mode? Need help badly. :(

    Btw, it is not jailbroken. Everything was purchased on the apple store. It happened days after i update my software to ios 7.04.
    It restarted then it crashed down on the next day and now it is in recovery mode which keeps on getting error on itunes while restoring

  • How do I store 4 hours of data and get it out of the "while loop" into a spreadshee​t file for documentin​g purposes? "See additional Text for additonal info"

    What a have is a VI that uses the following SUbvi's, starts with FP OpenVI, then FP Create TagVI, into a "While Loop" which contains a FP ReadVI outputting data into a Index ArrayVI outputting to a Display (DBL). This shows the output of a FP-AI-100 monitoring a 9v battery. I have to monitor this battery for a 4 hour period my problem is storing the 4 hours of data and getting it out of the "while loop" into a "Write to Spreadsheet File VI" all I seem to accomplish is just one data sample which I get into a spreed ship file with no problem. I just can't get 4 hours worth. By the way this is my first VI and I'm self
    trained so have mercy.

    I figured it out thanks.
    John Morris
    Glendinning Marine

  • How do I store 4 hours of data and get them out of the "while loop" into a spreadsheet file for documenting purposes? "See additional Text for additonal info"

    What a have is a VI that uses the following SUbvi's, starts with FP OPENvi, then FP Create Tagvi, into a "While Loop" which contains a FP READvi outputting data into a INDEX ARRAYvi outputting to a Display (DBL). This shows the output of a FP-AI-100 monitoring a 9v battery. I have to monitor this battery for a 4 hour period my problem is storing the 4 hours of data and getting it out of the "while loop" into a "Write to Spreadsheet File vi" all I seem to accomplish is just one data sample which I get into a spreed ship file with no problem. I just can't get 4 hours worth. By the way this is my first VI and I'm sel
    f trained so have mercy.

    I figured it out Thanks.
    John Morris
    Glendinning Marine

  • UI flickrs continously jdk1.7.25 EventdispatchThread's pumpEventsForFilter goes to infinite while loop

    I am migrating a project from Java 1.3 to Java 1.7 update 25 and there is one search button functionality in which search is performed correctly but the UI flickers continuously because EventdispatchThread's pumpEventsForFilter goes to infinite while loop.
    This same code works correctly in java 1.3.
    Below is the part of the code related to searchbutton. Can you please suggest regarding this because the issue is within java api and not sure how to solve this.
    SearchButton.java:
    private JButton searchButton; 
    private String textsearchButton = 
          search.util.Language.getString("buttonStartSearch"); 
    searchButton = new JButton(textsearchButton); 
    buttonPanel.add(searchButton); 
    searchButton.addActionListener(this); 
    searchButton.addActionListener(actionListener); 
    actionListener.actionPerformed( 
                   new ActionEvent( 
                      searchButton, 
                      ActionEvent.ACTION_PERFORMED, 
                      "toFront")); 
                actionListener.actionPerformed( 
                   new ActionEvent( 
                      searchButton, 
                      ActionEvent.ACTION_PERFORMED, 
                      "searchComplete")); 
    setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); 
        if (hasSearch) { 
                actionListener.actionPerformed( 
                   new ActionEvent( 
                      searchButton, 
                      ActionEvent.ACTION_PERFORMED, 
                      "searchComplete")); 
             else { 
                actionListener.actionPerformed( 
                   new ActionEvent( 
                      searchButton, 
                      ActionEvent.ACTION_PERFORMED, 
                      "search")); 
    searchButton.setEnabled(!hasSearch && hasCriterions()); 
    public void actionPerformed(ActionEvent ae) { 
          Object source = ae.getSource(); 
          else if (source == searchButton) 
             startSearch(); 
          else if (source == exportButton) 
             exportSearch(); 
          else { // ActionEvents from the panels occur 
             changesOccured(); 
    EventDispatchThread:
    void pumpEventsForFilter(int id, Conditional cond, EventFilter filter) { 
            addEventFilter(filter); 
            doDispatch = true; 
    //This while goes to infinite loop 
           [b] [color=red]while (doDispatch && !isInterrupted() && cond.evaluate()) { 
                pumpOneEventForFilters(id); 
            }[/color][/b] 
            removeEventFilter(filter); 

    Please provide your code example as SSCCE . I'm not going to spent time guessing what your application code (other than shown) meigt do or not do.
    bye
    TPD

  • Infinite While-loop!

    Hey there! I'm trying to do some data input validation but I haven't been able to figure it out. First I need to check if the user entered anything, that one works. Then I need to check if what the user entered was a number. But I'm getting an infinite while loop in when I try to validate if the first character entered is a letter. . . .
    Thanks for your help!
    public class methods
    public static void main(String args[]) throws IOException
      String input ="";
      int qoh=0;
      boolean error=true;
      Scanner keyboard = new Scanner (System.in);
      //while (error)
                    //   error=true;
                            while (error==true)
                                System.out.print("\nEnter Quantity on Hand: ");
                                input = keyboard.nextLine();
                                if (input.length() <1)
                                    System.out.println("\n**ERROR06** - Quantity on hand must be between 0 and 500");
                                    error=true;
                                    System.out.println(qoh);
                                    System.out.println(input);
                                else
                                    error=false;
                            error = true;
                            while (error==true)
                                if (Character.isLetter(input.charAt(0)))
                                    System.out.println("\n**ERROR06** - Quantity on hand must be between 0 and 500");
                                    error=true;
                                    System.out.println(qoh);
                                    System.out.println(input);
                                else
                                    qoh = Integer.parseInt(input);
                                    error=false;
            }

    1. add in breakpoints to your program.
    Eg. put print statements before and after loops to confirm which loop is producing the inf loop error.
    also add in print statements in your if and else blocks.
    2. You should consider using keyboard.next() instead of nextLine()
    Eg. how are you going to handle "500 orange crush"?
    3. I have a feeling that the real problem lies at the 2nd loop where you tried to do a parseInt
    What happens if you have "5lmao" charAt(0) check is passed, but it wont produce a int will it?
    You might want to loop through every char in the input string to confirm they are a number.
    4. I suggest
    If(input.length() > 0) error = false
    else print msg
    OR
    assume no errors before loop.
    if(length() <1) error=true
    else error = false
    5. use the keyword "break". By that i mean set up your loop to be infinite loops, use the break operator under specified condition (error=false)
    I didn't identify the error for you, but i'd say the above methods should help you with your problem

  • How can I build a table with the time values of a timer from a while loop

    Hi:
    I have a question concerning building a table:
    Every 100ms I read a value from a sensor (while loop with a timer). I would like to build a table with the actual time and the concerning value. For example:
    0msec         1V
    100msec     2V
    200msec     3V
    300msec     4V
    etc.
    If I use the Express VI for building a table, I always get the date and time, but I don't need the date and the time is in the following format: HH:MMS, which is nonsensical for me as I can't differentiate within msec. Can I change the format anywhere?
    Can I also save the table to a file or even to an Excelsheet? How can I do that?
    Thanks for your help!

    Hi Craig:
    thank you very much. To solve the mystery : ) :
    I want to drive a stepper motor with a specific frequency. To get the current degree value of the motor I would like to measure the current time (from the beginning of the move on). (With a formula I get the degree value out of the time)
    Concurrently I would like to get data from a torque sensor and from a pressure sensor. That's why I asked you about the time and the table. The measurement should start with the movement of the motor. How can I do that? Right now I have different block diagrams (different while loops) (see attachment) and I would like to put them in one.
    I haven't done the block diagram for the pressure sensor yet, so there is only the one for the torque sensor and the one for the motor.
    I also would like to set a mark in the table when the voltage value of an analog input gets under a specific threshold value. Is that possible?
    I'm sorry, I'm a novice in LabVIEW. But maybe you can help me.
    Thank you very much!
    Steffi
    Attachments:
    motor.vi ‏238 KB
    sensor.vi ‏59 KB

  • How to export a continous waveform data from a while loop?

    Hello there,
    I need to add noise signal to my waveform which is read from a binary file. I use noise generate vi (deleted the density part) from NI example as my sub VI, and put it into a while loop in order to get the continous noise signal, but I don't know how to export this data. There's no waveform come out from the noise waveform output tunnel (on the while loop). I used output tunnel, didn't work, tried shift register, didn't work... Can anybody help?
    Also, how to fix the dt problem for the noise generate vi and my original data ( from binarty file)
    Thanks in advance!
    Wendy

    hi
    I think notifier can do the trick (an example is shown in the master-slave template).
    Another possibility can be a FG (or action engine, look for the nugget ActionEngine, it will change your LV-coding life !)
    N

  • How do I exit a while loop which has a 'read from spreadshee​t' pop up in it?

    I have a while loop which calls 'read from spreadsheet'. My problem is that after entering a filename the loop repeats too quickly for me to hit the end loop button. How do I exit the loop without adding a delay after the read thereby slowing the loop when I don't want to exit. If I select cancel I get 'error 43'. Is there a way to to use an error handler to prevent this from popping up and use it to end the loop?

    It's the error handler inside Read From Spreadsheet that creates the message. Specifically, one of the VIs called is Read Lines From File. The last VI in there is General Error Handler. You can delete it and save it with a different name. You should also modify it to return the error cluster. You'll also want to modify Read From Spreadsheet to return the error cluster so that you can trap the error in your VI. When cancel is selected, error code 43 is generated. Stop the loop when you see 43.

  • Break out of a while loop from outside the loop

    Hello,
    I have an application where I have some nested while loops. Is it possible to break the innermost loop from a control that is outside of the inner loop? My inner loop is running a scan and read operation on the serial port and is reading data as it somes in. I need this loop to break when the user presses a button located in one of the outer loops so that another section of the vi can execute. Thanks in advance.
    Greg
    Gregory Osenbach, CLA
    Fluke

    Greg,
    You should place the terminal of the button in the innermost loop and wire out from there to the other locations the value is needed. If these are nested loops, the controls will not get read until the outer loop iterates again and this can only happen if the inner loop has ended anyway. Thus your scheme will not work.
    Alternatively, you can place the control in a loop that executes in parallel,then use local variables of it in the other locations, but the above solution is better.
    LabVIEW Champion . Do more with less code and in less time .

  • How can I write waveform data from a while loop?

    Alright, I have a NI-5122 high speed digitizer that I need to acquire 10,000 waveforms. I am currently using the NI example code "niScope EX Multi Record Fetch More Than Available Memory.vi" to do this and then onto that later. I set the Number of Records to 10,000, min record length to 8192, and the min sample rate to 100M (S/s). On the Fetch vi,  I set it to get a 1D Dbl array and then send it to the while loop edge for auto indexing. What I want is to take each waveform and write it to a file next to the previous waveform not append it to the bottom of the previous one. I can do 100 and sometimes 1000 waveforms with my current setup and then use "write measurement to file.vi" to save the data, but at 10,000 it says that the memory is full. I have 256 MB on the NI-5122 and 4G of memory on my host computer. My reasoning is that if the NI-5122 can hold all that data then why can't my host computer. I have tried to fetch using 2D Dbl and transpose that matrix and send the data to "write measurement to file.vi" inside the loop and append the data that way, but when I do this the card does not acquire any data. Which seems like a software problem. I know this is probabaly worded poorly, so just post a response if further explanation is needed.
    Thank you.

    Hello,
    It sound like you might have received a LabVIEW: Memory is full message.  Are you also graphing this data as it is being acquired?  Are you building an array inside the loop?  At the 100 MS/s rate, you are using a lot of memory to acquire, graph, build and transpose array data, and then write to file.  If you are saving to file and do not necessary need to see the data, I would suggest taking the graphical indicator out of the code.  Please review some of the KnowledgeBases linked below about the LabVIEW: Memory is full.
    KB 36QD14V3: Why Do I Receive a "Memory is Full, VI Stopped at Loop Tunnel 0xXXXX" Error?
    KB 3ZNDGRS9: LabVIEW "Memory is Full" Error
    Samantha
    National Instruments
    Applications Engineer

  • How to get the loop sequence time (i) out of the while loop in the sub-vi to the main vi?

    I tried to search for the answer but no much luck.  My situation is that I used a sub-vi containing a while loop in my main vi. Now I need to see the while loop sequence number (i) from that sub-vi in my main vi.  In the sub-vi I have the indicator to show this loop sequence flawlessly, but that's inside the loop itself.  If I use this indicator as a terminal in the sub-vi, I can only see the last sequence number in the main vi after the loop finished its execution.
    Is there a way to accomplish this? Thanks.

    Hi nobody,
    well easiest (but error prone) way is to use globals to move data from subvi to main vi. You can also give the reference of the main vi indicator to the subvi to write to a "value" property node. You can also use queues, and there are other techniques too
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

Maybe you are looking for