Phantom Lord Posted November 21, 2007 Report Share Posted November 21, 2007 Hi all, We built a labview program to control a triaxial scanner. There is a subVI that initializes an automated scan, which means it calculates steps in the X and Y direction depending on the dimensions you enter. First we used a for-loop inside a for-loop to move first a few times in the X-direction, then change Y, move in X-direction again etc... Now we have to be able to stop the scanner at anytime. As I read in this forum, a for-loop can't be stopped until it reaches the final iteration. That's why we changed this to a while-loop inside a while-loop. Unfortunately this also doesn't seem to work. Activation of the stop-button is always ignored (not seen). Probably this has to do with the fact some subVI's are executed inside the while-loop. Is there anyway of jumping unconditionally out of these while-loops (without terminating the program and labview that is)? We thought about event structures but this doesn't seem to work either... regards Filip Quote Link to comment
Eugen Graf Posted November 21, 2007 Report Share Posted November 21, 2007 If you have some while/for loops in SubVIs, you have to break them too, otherwise you have to wait to completion of execution of them and your caller VI will not break. You can use a Global Stop Flag for it. Eugen Quote Link to comment
Aitor Solar Posted November 21, 2007 Report Share Posted November 21, 2007 The stop command should be detected even if there are subVIs (but the loop won't stop till the end of the iteration). Could you post the code, in a simplified form? BTW, in LV85 you can stop a for-loop too. Saludos, Aitor Quote Link to comment
Phantom Lord Posted November 21, 2007 Author Report Share Posted November 21, 2007 Thanks for the replies. In attachment I put the code as it is. We do not have labview 8.5 (yet). We did break the while-loops in the subVIs by using references to the stop. Probably you won't be able to execute the code without the external equipment, but maybe you can have a look at it as it is. regards,Filip QUOTE(Aitor Solar @ Nov 20 2007, 10:36 AM) The stop command should be detected even if there are subVIs (but the loop won't stop till the end of the iteration). Could you post the code, in a simplified form?BTW, in LV85 you can stop a for-loop too. Saludos, Aitor Quote Link to comment
Ton Plomp Posted November 21, 2007 Report Share Posted November 21, 2007 QUOTE(Phantom Lord @ Nov 20 2007, 11:07 AM) Thanks for the replies.In attachment I put the code as it is. We do not have labview 8.5 (yet). We did break the while-loops in the subVIs by using references to the stop. Probably you won't be able to execute the code without the external equipment, but maybe you can have a look at it as it is. regards,Filip Well you have 3 while loops nested. The Exit value is tested on the start of the while loop (together with the 'T' constant) and you see the LED reacting. But the while loop has to run at least one time! You should replace the two inner while loops with a for-loop. It's also better to replace your string controls with numeric controls: no conversion needed! To see what is stalling your loop you should enable executed high-lighting (het lampie) Why do you use this code? http://lavag.org/old_files/monthly_11_2007/post-2399-1195554361.png' target="_blank"> Ton Quote Link to comment
Aitor Solar Posted November 21, 2007 Report Share Posted November 21, 2007 I addition to what Ton said, in the code you're not breaking the inner while loops. I'm not sure what's your goal, so: 1) If you want to check from an inner loop if the stop button have been pressed, you can use a local. 2) If you want to check from a running subVI if the stop button have been pressed, you can use the reference, but is probably better to implement some kind of communication as queues. Hope that helps. Saludos, Aitor Quote Link to comment
Phantom Lord Posted November 21, 2007 Author Report Share Posted November 21, 2007 We have tried using the for loops, but doesn't the problem remain the same then. The reason for using string controls is they are used as a string to send commands to our CNC controller. I can't answer you regarding the code used there, it is written by my student, i am just helping him out where he gets stuck . Seems like it has something to do with adding more controls that perform a certain action. But we are trying out some of the hints you gave us right now. Quote Link to comment
Phantom Lord Posted November 21, 2007 Author Report Share Posted November 21, 2007 The code after the button start measurement is placed because earlier I had more start buttons. But now to the point. The two while loops in the code I sent to you are loops which where originally for loops. So, I thought: I'm gone replace them by while loops so that it is possible to step out of the loops. Because, when using the for loops I had exactly the same problem. After replacing them I saw that the problem wasn't solved. This program is written for a stepper motor controller and a receiver. The program you see is made to scan every point of a given surface with an adjustable step. At each point the motors have to stop and a measaurement must be made. For the measurement another subVi is called. With the "reference" I made of the button 'stop measurement' it is possible to step out of the subVi. But then comes the big problem: There will be a motion to the next point and a measurement starts again, thats because I can't step out of the while loop. One of the other remarks of you is that i didn't use numeric values: This is a good remark, but the controller reads the code which is sent to it in string format. And so... My question to you: Do you see a solution to completely stop the masurement. With other words to step out of the while loops. regards, Sacha Quote Link to comment
Aitor Solar Posted November 21, 2007 Report Share Posted November 21, 2007 QUOTE(Phantom Lord @ Nov 20 2007, 01:35 PM) But then comes the big problem: There will be a motion to the next point and a measurement starts again, thats because I can't step out of the while loop. Create a local and test it in every iteration. See the attached VI. Saludos, Aitor Quote Link to comment
Neville D Posted November 21, 2007 Report Share Posted November 21, 2007 QUOTE(Phantom Lord @ Nov 20 2007, 04:35 AM) My question to you: Do you see a solution to completely stop the masurement. With other words to step out of the while loops.regards, Sacha I haven't looked at your code, but in theory, you could replace while loops with timed loops and use "Abort timed loop" to step out of it. Neville. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.