LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

SubVI In Infinite Loop

I have a subVI in an infinite loop that I want to run until I feed in a STOP or TRUE to the loop. However, I am noticing that my stop never reaches the subVI and it gets stuck looping within the subVI. Any idea how to execute this properly?

0 Kudos
Message 1 of 8
(4,421 Views)

Please post your code (LV 2012 for me). If your SubVI really is inside the loop, then all you have to do is wire a True to the stop condition of the loop. If your loop is inside your SubVI, that's a whole different thing entirely, and you must rethink how you've written your code.

0 Kudos
Message 2 of 8
(4,418 Views)

My loop is within my subVI, how exactly would I make it so that it would run continously until I wanted it to stop?

0 Kudos
Message 3 of 8
(4,413 Views)

Well, I cannot open your code. (As I said above, it needs to be LV 2012 for me). 

 

There are many ways to communicate between SubVIs. I'm guessing you are using this almost as part of your UI if you are expecting user interaction. In this case, go to the properties and set to "run when called" and "close if originally closed", and then the front panel will open whenever you call it. You can just make a stop button inside the SubVI.

 

You could also load it up in a subpanel on your main UI, but I'm not too familiar with this.

 

You can also use globals, queues, references, action engines...

0 Kudos
Message 4 of 8
(4,409 Views)

The problem with using a subVI is that the inputs are determined when it is called.  The exception is if you show the front panel either directly as a pop-up or in a subpanel.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 5 of 8
(4,375 Views)

Your "stop" bolean is only availible in your second loop. My guess is that the conditions of your first loop are not being met, and so the VI never makes it to the second loop. You may want to try to condense your logic to a single loop structure.

0 Kudos
Message 6 of 8
(4,250 Views)

Allen,

 

Just to make sure i understand you here.  The VI you posted is acutally a sub VI and you want to stop it with the stop button on your main VI? If that is the case then you will need to pass a reference to the stop button on your main vi into that sub vi. If im mistaken and the vi posted is the what your referring to then try stopping it like the one attached.



-Matt
0 Kudos
Message 7 of 8
(4,237 Views)

Or you could use a global variable or have the front panel for that vi visable with a stop button as crossrulz stated.  There are several ways to handle this problem, but you do need to pass a value from the main vi to the sub vi to stop it.

 

Heres a link that should help:

 

http://www.ni.com/example/28769/en/



-Matt
0 Kudos
Message 8 of 8
(4,232 Views)