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

Similar Messages

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

  • To exit from the while(1) loop

    Hi all ,
    I have a simple question that if in a callback function of a command button, i use a While(bLoop)
    loop , where bLoop is a boolean variable initially set to TRUE, then how can i break or exit from this while Loop by using a control on the front panel  , which exits the while loop by setting     bLoop = FALSE .
    I have tried it but it is not exiting  
    Solved!
    Go to Solution.

    The problem here is that CVI normally only executes one callback at a time. While you are in one control callback, no GUI processing and subsequent calls to other callbacks normally occurs.
    You can try the following approach - but it is not really the best method:
        while (b_loop) {              // Inside a callback
            ...                       // Perform your tight program loop
            ProcessSystemEvents ();   // Force CVI to see if any GUI controls need servicing
    If you have a different control callback to clear the global b_loop, this quick-and-dirty approach might work for you.
    You should only use this technique for very simple programs - it can rapidly spiral out of control and end up in a mess if you're not careful. NI recommends that you do not use ProcessSystemEvents() inside a control callback.
    JR

  • ReadUTF() and exiting a server while loop

    What I want to do is simple.. I want to be able to type "exit" into a client and send that message to the server... And exit the server while loop as a result.. Here is what I tried.
    //server code
    while(true)
    //bla bla bla
    //bla bla bla
    String message = socket.readUTF();
    if( message == "exit" )
    break;
    // bla bla bla
    however, when I type exit and send the message, this while loop doesn't break.. I'm new to java so I'm wondering if I'm messing up syntax somewhere.. It seems like it should work fine, whats going on?

    if(message.equals("exit"))

  • 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

  • Getting data from a while loop while running.

    Hello,
    I did a program that call a sub-VI which is doing experiment and have its own timer.
    The sub-VI is a while loop and the stop condition of this loop is the elapsed time of my timer.
    What I want to do is to be able to get the elapsed time in my main program during the execution of the sub-VI (every second of its execution).
    First I assign the elapsed time in the sub-VI as an output of it. But of course the elapsed time is only updated in the main VI only when the while loop has finished. So I tried several solution: property nodes, local variable, global variable.
    When I am using global variable, I can see the elapsed time being updated during the while loop when I open the global variable VI. But the result is always the same: in the main VI the elapsed time is only updated at the end of the while loop.
    I think that is the global variable is updated every time, I could be able to get its data to my main VI?
    Does anyone have an idea?
    Thank you,
    Meach

    I tried using shared variable and reference without succes.
    I will keep searching.
    I enclose my VI that I simplify the most but with still keeping the shape of my real program. If you can take a look I will really appreciate.
    The goal is on the top-level VI to be able to see the updating data time in real time.
    Thanks,
    Meach
    Message Edited by Meach on 07-23-2008 04:13 PM
    Message Edited by Meach on 07-23-2008 04:14 PM
    Attachments:
    Elapsed Time.zip ‏25 KB

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

  • Aborting from double while loops

    Hi,
    I am trying to do a X-Y movement with one of my piezostage automatically. It would be required for it to move in x-y direction for a certain user defined steps.
    However, I have problem with trying to abort the motion at will. Previously I have used a for loop and I know that there did not exist any stop condition for it and I have switched to a while loop. THe existing program structure has a double while loop with one while loop nested within another one.
    HOwever, I have a problem with terminating the program. The program will still finish the execution of the outer while loop before it goes out of the main while loop. I have used the same local variable which connects to the stop condition of both inner and outer while loop? Is there any methods to prevent any execution of the outer while loop and immediately looped out of the program?
    Thanks for your help!

    Yes, for the outer loop to regain control, the inner loop must finish first. It's all in the dataflow!
    (Of course the wait in the outer loop is not really necessary here because the outer loop speed is entirely governed by the inner loop, which must run at least once per iteration of the outer loop.)
    Don't confuse it with a situation where you have two parallel independent loops without any data dependency between them.
    Message Edited by altenbach on 01-06-2007 10:11 AM
    LabVIEW Champion . Do more with less code and in less time .

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

  • Exit a do while loop

    Hi,
    im new to this forum and new to java, but i have done a program thats gonna figure out the medium value of am unlimited amount of numbers i put in the system.. but my problem is i cant get to where i write out the result.. meaning i cant get out of the loop and reach the last part of my program. When i exit the loop it just exits the program
    import static javax.swing.JOptionPane.*;*
    *import java.util.*;
    public class Medel {
    public static void main (String[] arg) {
         String s;
         int number;
         int turn = 1;
         int total = 0;
         double result = 0;
    do {
    s = showInputDialog ("Ange heltal nummer "  +turn); // input of number+
    +     number = Integer.parseInt(s);+
    +Scanner sc = new Scanner(s);+
    +     sc.hasNextInt();+
    +     int i = sc.nextInt();+
    +     total = total+  i;
         turn = turn  +1;+
    +     result = total / (turn - 1);+
    +     if (s == null)+
    +     break;+
    +     }while (s != null);+
    +     if (result > 0) {+
    +     showMessageDialog(null, "Medelv&auml;rdet av dina "+  (turn - 1)
    +                              " tal &auml;r"+  "\n" + result); // output if you press cancel and there is a medium value
         else
         showMessageDialog(null, "Du har inte skrivit n&aring;gra tal!"); // output if you press cancel and hasnt written a number
    }hope someone out there can tell me what im doing wrong cause its doing my head in..
    //Claus

    yeah i think it was from one of my early attempts.. i cleaned up a bit and changed some so now it looks like this.. Cancel breaks the loop now but i never get the dialog at the end with the result
    import static javax.swing.JOptionPane.*;
    import java.util.*;
    public class Medel {
    public static void main (String[] arg) {
         String s;
         int turn = 1;
         int total = 0;
         double result = 0;
         boolean end = true;
    while (end == true) {
    s = showInputDialog ("Ange heltal nummer " + turn);
    Scanner sc = new Scanner(s);
         int i = sc.nextInt();
         total = total + i;
         turn = turn + 1;
         result = (double)total / ((double)turn - 1);
         if (end == false && result > 0) {
         showMessageDialog(null, "Medelv?rdet av dina " + (turn - 1) +
                                  " tal ?r" + "\n" + result);
         if (end == false && result == 0) {
         showMessageDialog(null, "Du har inte skrivit n?gra tal!");
    }any ideas?

  • Saving all data from a while loop

    I already asked a similar question but it might not be very clear and there were some concepts that I could not well understand.
    1. I have a key pad to generate DTMF stream signal (I call it stream because it contains multiple tones which make up of a complete phone number)
    2. I would like to save it as a wav file but I guess other format is okay and because the write to wav file does not support append so for this particular case, I use write to waveform instead of write to wav
    My approach is to have a queue structure so I can write each iteration result to a file.
    i)When I try to retrieve the data, there is nothing but 0.
    ii)my intention is to get 8000 sample per second (fs = 8,000) but it save the data so fast
    I attached the file so if there is way to solve the problems, please help me. 
    Solved!
    Go to Solution.
    Attachments:
    SignalGenerator.vi ‏52 KB

    I believe what is happening is that your producer loop is iterating even when there is no key press and sending blank or default data to the consumer and overwriting the test.wav file.  
    Easy way around this is to put an event structure in the producer that only enqueues data when there is a key press.   I can't see into the Mathscript node so I'm not sure what's going on there, but I suspect the default output (e.g all of the Booleans are false) is for zero-length arrays on f1 and f2 and this is getting enqueued and overwrites any real data that might have been in test.wav.
    It should be possible to append to a .wav.  I have attached a proposed method.  Caution that this in your consumer will take longer and longer as the file grows as it needs to read in the file every time.  
    Attachments:
    Untitled 3.vi ‏8 KB

  • Exiting a do while loop

    i want to repeatedly ask the user to enter information until they dont enter any data and press enter. so the while condition has to be while they dont press enter. how do i make this the condition with coding?
    thanks,
    Peter

    here is what i have so far, and it doesnt work
    String str;
              boolean done = false;
              do {
                   System.out.print("Enter a string: ");
                     str = console.next();
                     System.out.println();
                     if (!str.equals("")) {
                  System.out.println("The pig Latin for of " + str + " is: "+ pigLatinString(str));
                else {
                  done = true;
              } while (!done);
         }

  • Exit from CIN within Error Handling Sub-Function

    I have a CIN which has the code divided betwee the CINRun() function, a number of other functions & a #included .C file. I want to put some error handling into my CIN, so if an error occurs I want execution to return from the CIN to LabVIEW immediately... however, my error handling is currently done in one of the other functions, and may be called from CINRun,
    functions, or the #included .C file. Is there any neat/handy/nice way of universally/globally breaking out of or bombing out of the CIN if the error handling code gets called?

    Michael.Johnson wrote:
    I have a CIN which has the code divided betwee the CINRun() function, a number of other functions & a #included .C file. I want to put some error handling into my CIN, so if an error occurs I want execution to return from the CIN to LabVIEW immediately... however, my error handling is currently done in one of the other functions, and may be called from CINRun,
    functions, or the #included .C file. Is there any neat/handy/nice way of universally/globally breaking out of or bombing out of the CIN if the error handling code gets called?
    You seem to want to do structured ecxeption handling. This however is something only really supported by C++ and other object oriented languages. Standard C can do that only with quite some header macro magic and in general is done in a way, patented by Borland, if I remember correctly. To make things more complicated, writing CINs in C++ is not supported by LabVIEW and requires quite some knowledge about your specific compiler environment and linker to get it right on your own, and no NI won't support C++ creation of CINs.
    You will prabably have to modify your C code quite a bit to get it the way you want. Considering that you will have to make more or less involved changes to your C code anyhow, I would recommend you look into creating a shared library instead and calling that through the Call Library Node. CINs are from the past and support for them will be getting less and less with time as it adds almost no advantages to shared libraries anymore and has some disadvantages in comparison, such as proprietary solution, difficult to support and possible compatibility issues in the future.
    Rolf Kalbermatter
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

Maybe you are looking for