LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

stopping nested while loops

Hello All

 

My problem is as followos:

 

I have and outer loop in which my entire program runs continuesly until the STOP button is pressed.

in the outer loop I have encoder readings and speed calculations.

 

Also in the program regulator controller i have a flat sequence which is made of two two frames.

 

in the first frame I have an inner while loop that checks a device angle, when I get a true value I want the frame should end and continue to the next frame which is the controller.

 

My problem is that when I exit the first frame the encoder stop responding.

 

It would seem that they are working - when I stop the loop I see a new position but I can only use the abort button since clicking on the stop button does not do anything.

 

I've attached the VI.

 

Are there better solutions for my design?

 

How can I fix this?

 

Thanks

 

Gil

0 Kudos
Message 1 of 4
(3,455 Views)

You need to take the tutorials and learn about data flow.

LabVIEW Introduction Course - Three Hours
LabVIEW Introduction Course - Six Hours

 

 

In your inner while loop, you take a value that comes in at the tunnel and use an Express VI to do some comparison on it.  The problem is that once that while loop starts, the value will never change.  It will always be whatever value it was when the While loop started.  So your inner while loop will either run 1 time, or run forever.

Message 2 of 4
(3,437 Views)

Hi Gil,

 

The problem is indeed with the while loop containing "In Range2." I would suggest not having that second while loop since the larger loop has to wait for the smaller loop to finish. I understand your thought process and what you would like to happen, but the small loop will not have its input updated in the current setup; like Ravens Fan stated, the smaller while loop will either run once (if the result is true) or forever (if the result is false).

 

I would guess there are several ways to accomplish what you are trying to do, but I would suggest that you get rid of the small while loop and even the flat sequence structure. Use a case structure, like you did in the second frame of the sequence structure, to have your program decide if it needs to just keep measuring the angle or if it actually needs to do something with the motor, etc.

 

Let me know if there is any more clarification needed.

 

Kind Regards,

 

Nathan B

Applications Engineer

National Instruments

Message 3 of 4
(3,414 Views)

Thanks very much for your suggestion.

 

Gil

0 Kudos
Message 4 of 4
(3,386 Views)