LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

update value in subVI from main VI

Solved!
Go to solution

I have a subVI that loops for an indeterminant amount of time (at least a few seconds) while polling a piece of hardware for data. I want to let the user stop the polling loop prematurely from the main VI.

 

I thought I would be able to create a reference to the control that stops the polling loop in the subVI and use that reference with a property node to stop the polling loop from the main VI. But that does not work because when I create a reference on the subVI and copy/paste it into the main VI, it creates a new control on the main VI and the reference no longer refers to the control in the subVI.

 

I've attached simplified examples that demonstrate the problem. Any ideas?

 

stop subVI.png

polling subVI.png

Download All
0 Kudos
Message 1 of 7
(1,284 Views)
Solution
Accepted by topic author dvonch

I would feel more inclined to use a Notifier to stop the subVIs.  You "obtain" the Notifier in the top level VI and pass the reference down to the subVIs.  The subVIs can then Wait On Notification with a timeout (this can replace your wait).  The top level VI can then send the notification to tell the subVIs to stop.


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
Message 2 of 7
(1,275 Views)

@crossrulz wrote:

I would feel more inclined to use a Notifier to stop the subVIs.  You "obtain" the Notifier in the top level VI and pass the reference down to the subVIs.  The subVIs can then Wait On Notification with a timeout (this can replace your wait).  The top level VI can then send the notification to tell the subVIs to stop.


Yes, that works perfectly. Here is the updated code (for posterity).

 

stop subVI with notifier.png

polling subVI with notifier.png

Download All
0 Kudos
Message 3 of 7
(1,263 Views)

I make it even simpler.  Set the data type of the Notifier to a boolean.  You can then wire the stop condition straight to the output of the Wait On Notification.


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 4 of 7
(1,259 Views)

Good call. Thanks for the help!

0 Kudos
Message 5 of 7
(1,255 Views)

After you created the reference, if you made a constant of the reference, you can copy that without causing a new control to be created.

0 Kudos
Message 6 of 7
(1,201 Views)

The simplest modification of your original vi would be to wire the reference to a subvi input and read its value via a property node there.

 

altenbach_0-1689324291091.png

 

 

Still, if this will be part of a large, scalable project, there are probably better ways.

0 Kudos
Message 7 of 7
(1,171 Views)