LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to close a subVI's while loop from Main.vi

Solved!
Go to solution

I have a running subVI (as a popup windows). Inside this subVI, I have a while loop that is going to exit once I read a string via serial COM port.

I was wondering if it is posible to change the value of the while's loop exit button from

out side this subVI. Until now I can stop this subVI, with a local variable, but this happens in the same subVI. What I want to know is if it can be done from outside the while loop/from another VI.

I've read control references, global variables but still haven't figure this out.

 

Could someone help me with this issue, please!!

 

 

Many thanks in advance!

 

 

 

0 Kudos
Message 1 of 7
(3,197 Views)

If you want to use the global variable, then you have to write the True value to the global variable in the main VI.

0 Kudos
Message 2 of 7
(3,184 Views)

What do you mean? I don't get it....

0 Kudos
Message 3 of 7
(3,182 Views)

How is the subVI configured? (e.g. modal, etc.)

 

From the picture, you are stalling the main VI while the subVI is running, so clearly we need more information on your code architecture. Pictures are not sufficient.

0 Kudos
Message 4 of 7
(3,160 Views)

You need to spend some time thinking this through.

 

You're waiting for this to happen because the next bit of your main VI needs this input, most likely.  This means you want the main VI to stall and wait for this string.  If you don't, you want to move the logic for this to your main VI so you can more easily handle the exit.

 

If it's in a subVI, you're likely going to want to just include a timeout and let that be the determining factor.  Otherwise, are you really gaining anything by allowing the main VI to iterate and check/change values while this VI is running in the background? 

 

Look at a simple state machine.  In the acquire string state (or whatever you call it), you'll either acquire a string or you won't.  If you do, you go on to the process string state.  If not, you go back to the acquire string state.  If you want to be fancy, make it event driven.  Go back to the event structure before the second acquire string state.  If anything is changed, you can process that event.

 

Any of these are cleaner ways to solve the same problem you're running into.

0 Kudos
Message 5 of 7
(3,145 Views)

@JLuna wrote:

What do you mean? I don't get it....


You don't show anywhere in your code where you are writing to the global variable.

0 Kudos
Message 6 of 7
(3,124 Views)
Solution
Accepted by topic author JLuna

Hi, thanks to all for you replies. I have manage to exit the subVI using "Strict Refnum boleean control". This example saved my day:

 

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

 

Thanks alot, and have a nice day! Later on I'll try to exit subVI using global variables and event driven case.

Message 7 of 7
(3,092 Views)