LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

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!
0 Kudos
Message 1 of 6
(3,376 Views)
You could do as shown in attached vi

Message Edited by devchander on 01-04-2007 04:00 AM

Download All
Message 2 of 6
(3,374 Views)

Thanks I guess it should work

However, I not too sure whether it would make the movement of the piezostage to be a bit strange. My outer loop code is used to return the piezo stage back to its original position and then move in the another axis. Subsequently the inner code(moving in another axis) is then.executed. Perhaps I can adopt another moving method. Is there any other way? The code will still have a problem if I move the inner code to the first frame. Right?

Another off-topic question. Does the setting of the wait timer for the while loop important in this case. In my case, I did not set any. I know this will give total control to the inner loop for my case. What about your code in your case? Does the program return control to the external while loop as it is waiting?

Thanks a lot!

0 Kudos
Message 3 of 6
(3,362 Views)
The Wait function in the while loop ensures that the loop does not take all the CPU time. It is real beneficial to use, when you are running some other programs at the same time in your system. You can notice the difference when you open up the Windows Task Manager.
Adnan Zafar
Certified LabVIEW Architect
Coleman Technologies
0 Kudos
Message 4 of 6
(3,333 Views)

HI,

I am referring to his double wait vi for both the inner and outer loop. SO I am assuming that the wait in the inner while loop does not transfer the control out to the external while loop. Is it correct for me to say this?

Thanks

0 Kudos
Message 5 of 6
(3,317 Views)
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

0 Kudos
Message 6 of 6
(3,306 Views)