08-08-2016 12:05 PM
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?
08-08-2016 12:09 PM
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.
08-08-2016 12:15 PM
My loop is within my subVI, how exactly would I make it so that it would run continously until I wanted it to stop?
08-08-2016 12:19 PM
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...
08-08-2016 02:00 PM
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.
08-26-2016 02:42 PM
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.
08-26-2016 03:35 PM
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.
08-26-2016 03:59 PM
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/