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 .

Similar Messages

  • 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

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

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

  • 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

  • How can I use an iteration value from a "while" (or "for") loop as part of a filename?

    I am using the "Write To Measurement File" function  inside a while structure and would like to incorporate the iterative value from the while-loop as part of the file name. I'm not sure how to do it. Any suggestions?

    Like this:
    Edit: Oops. Sorry for the double answer.
    Message Edited by smercurio_fc on 05-22-2007 04:25 PM
    Attachments:
    Example_BD.png ‏3 KB

  • Plot XY graph from while loop

    I am trying to make a curve tracer with a DC power supply, DAQ, and Labview 7.1. Everything is ok, until I want to plot an x-y plot from a while loop. I can do this function fine using a for loop and cluster cells, but I need the while loop for the interruption function. When I change to the while loop, it had data formating issues, but I believe I have it to something that should work. It seems like my xy plots want to graph (the auto scale moves the axis respectively) but I do not get a line. I'm not sure if Labview is seing this as just one point and not an array, or if there is a labview bug. Attached is my code with a few different trials to make an xy plot. If anyone can be of help I would be very thankful.
    -Jon
    Attachments:
    Curve_trace_w_relays_while.vi ‏122 KB

    If it works in a FOR loop, but nor in a while loop, most likely your output tunnels are not autoindexing (FOR: on by default, WHILE: off by default). Right-click on the output tunnels and select "enable indexing".
    If you want to watch your graph update during the while loop, you could accumulate your x and y data in a shift register and graph it. (See attached modification).
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    Curve_trace_w_relays_whileMOD.vi ‏74 KB

  • 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

  • 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

  • Iteration non sequencial with While Loop

    I've a SubVi in while Loop. Iteration n+1 will execute when Iteration n finish.
    Can I execute this SubVi in paralel (no sequencial)?
    In Spanish:
    Tengo una SubVi dentro de un bucle while. Pero este bucle actúa de forma secuencial. No se cargará la iteración n+1 hasta que la n acabe.
    ¿Cómo puedo hacer para que se ejecuten las iteraciones de forma no secuencial? Es decir, que no haya que espera a que acabe una para que se ejecute la siguiente.

    Hello,
    it is not possible. The while loop works as follows: 1) execute the code inside 2) check the ternimation condition 3) depending on that, continues with the following iteration or exit from the while loop. So, it is not possible what you are asking for.
    Maybe you have to use two while loops.
    Regards
    rusC

Maybe you are looking for

  • Doubt on servlet architecture, URGENT

    Hello Java experts!! Please claurify my small doubt In servlet architecture, if i write one servlet, multi threading concept of servlets will be implemented in Servlet level or doPost(doGet) level. Because I wrote all functions out side the dopost me

  • How to move all contacts TO the SIM card on an N97

    I have searched and while some topics exist on taking from the sim card using Nokia Suite, none address my issue of moving contacts from phone memory to the SIM Card. I have the latest N97 and Nokia Suite updates, but I can find no way to write to th

  • Drop-down list database question

    Hey there. So this is what I want to do. I want a drop-down list that would have hundreds of possible choices. The user could pick one and several text fields throughout the document would populate accordingly. I'm assuming there would have to be a d

  • Blazeds messaging header problem

    I have been using blazeds messaging for several weeks now it thought it was working fine. But somehow it's losing information now. Here is some of the code I've been using to create the message: var message:IMessage = new AsyncMessage(); var arc:Arra

  • I want to know if my charger port is dirty or my charger dosent work

    i want to know if my charger port is dirty or my charger dosent work