From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I access front panel controls and indicators from sub VI's ?

Hi,

I want to be able to access the front panel controls and indicators of my main VI from sub VI's that are called from the main.

For examples sake I might want to call a sub vi that will initialise the values of all the controls and indicators on the main front panel.

Or when a button is pressed it goes into another sub.vi that requires all the settings of the controls on the main front panel to do something with. Ok, so they could be wired as parameters which is fine if there's one or two but what if there's 10 or more - it gets a bit messy!?

How can I do this, should I be using global variables?

If you were writing a program in C for a microcontroller for example and you had various i/o devices, switches, ADCs, DACs, LCDs, etc... connected to the ports the sub-routines themselves could read and write to the i/o devices directly. Unless I'm missing something why is there no simple way of doing this with controls and indicators in LabView?

Thanks,
Dave.
0 Kudos
Message 1 of 4
(2,608 Views)
If you want to change the value of a front panel control / indicator from a sub vi, you have to pass the reference of the control / indicator to the sub vi. So you do a call by reference.

If you have lots of controls and indicators you could group the items with the same datatype or you could do it dynamically, by passing the vi reference to the sub vi and extract all control / indicator references there.

Hope it helps.

Thomas
Using LV8.0
--------------------------------------------------------------------
Don't be afraid to rate a good answer... 😉
--------------------------------------------------------------------
0 Kudos
Message 2 of 4
(2,605 Views)
You don't actually need to pass anything to the Sub-VI.

Within the Sub-VI you can call up the chain of "higher" VIs, i.e. the VI call chain leading to the sub-VI in question being called. From here you can wire simply the text of the VI you require to an "Open VI reference" function, get a list of the controls or indicators and initialise them as you wish. I used this a few times for a custom "Print Parent Panel" VI.

Here's a pic of an example (LV 6.1)

Hope this helps

Shane.
Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
0 Kudos
Message 3 of 4
(2,595 Views)
In addition, a disclaimer.

This is quite an inefficient way of doing things. All of the calls to the front panel are carried out in the UI Thread.

Otherwise it's OK. I have to admit I abuse this ability a bit for some of my own Initialisation routines (which are all absolutely time-uncritical).

Shane.
Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
0 Kudos
Message 4 of 4
(2,593 Views)