LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How Can I Stop multiple while loops using subVI

I wanted to stop multiple while loops by using subVI. I am attaching one example.could anybody send me the soultion for my problem.

thanks
Download All
0 Kudos
Message 1 of 4
(3,237 Views)
Lots of ways. Here is a quick one.
Download All
0 Kudos
Message 2 of 4
(3,237 Views)
Thank you very much, it is working now. i am new to this labview and just last month only i started to learn Labview. Once again thank you for answer EH.
0 Kudos
Message 3 of 4
(3,237 Views)
eh's answer (using control references) is good. As he says, there are a lot of ways to do this. There has also been a lot of discussion on this. If you enter "stop mulitple while loops subvi" in the ask box, you'll get thousands of answers.
You need to understand a couple of things about reading controls and passing data to subVIs.
1. A front panel control gets read only once, unless the control is in a loop, or you use local variables or property nodes or control references. So in your calling VI, the Stop button was read only once: when the program first starts and passes its value to the subVI. You can operate the control multiple times while the program is running, but nothing on the diagram sees the new value. eh creates a reference to the control so you ca
n read the control multiple times in the subVI.
2. A VI passes parameters to a subVI only once per call. Changing the source of the parameter (the control) in the main VI doesn't send an update to a running subVI. When the subVI starts, it reads the passed parameters (controls wired in the calling VI), and then it basically disconnects its inputs from the calling VI. Even if you read the controls in a loop in the subVI, the subVI never gets any updates from the calling VI through its front panel controls. Two ways to get updates are by using control references (like in eh's example) or globals.
P.S. Your subVI had a very tight loop just waiting for the user to press a button. This type of loop can slow the whole system down. Anytime you're in a tight loop waiting for operator input or for a global, etc., to change, it's a good idea to include a delay. I typically use the wait mS function from the Time&Dialog palette to generate a 100 ms delay. While wait mS is running, it fre
es up your system to do other things. Even if you don't think you're doing other things while your program is running, Windows is.
Message 4 of 4
(3,237 Views)