Read and Write Main VI Control/Indicator Value from a SubVI

Updated Aug 7, 2023



  • LabVIEW

Programming Language

  • LabVIEW G

In this article, we will guide you on how to update, or read and write the controller and indicator status in the SubVI via your MainVI. This means that you could update your top-level VI controls and indicators with the "live" status of the subVI control and indicators values while the subVI is executing.

In LabVIEW, each control or indicator on the front panel has its own reference that can be passed to any part of the project and be used to access any property, including the value. The following steps explain how to create a reference node of a control or indicator, pass it to a sub-VI, and read/write the control/indicator in the sub-VI.

In the Main VI,

  1. Open the block diagram and right-click the control/indicator that you want to update via the sub-VI.
  2. Click Create >> Reference to create the reference node of this control/indicator, then drop it on the block diagram.

In the Sub-VI,

  1. Open the front panel and add a Control Refnum. There are several ways to do that:
    1. Copy a constant of this control type from the main VI and paste it onto the sub-VI's front panel:
      1. Right-click the reference node you created in main VI, and select Create >> Constant.
      2. Select the constant node and press <Ctrl+X> to cut it.
      3. Open the subVI front panel and press <Ctrl+V>. The constant node will be pasted and automatically changed to a control of the same type.
    2. Create a Control Refnum directly to the Sub-VI's front panel:
      1. Right-click the subVI's front panel, and select Controls Palette >> Modern >> Refnum >> Control Refnum.
      2. Select the appropriate VI Server Class based on the type of control in the main VI. Right-click the Control Refnum and select Select VI Server Class >> Generic >> GObject >> Control.
  2. In the sub-VI's block diagram (see Figure 1), create an implicit Property Node for the refnum. It can be found at Functions Palette >> Programming >> Application Control >> Property Node.
  3. Wire the Control Refnum to the reference input of the implicit Property Node.
  4. Click Property in the Property Node to open a drop-down list and select Value as the input parameter.
  5. Right-click the parameter and select Change to Write to allow for inputs into the parameter.
  6. Wire the varying data to the Value input of the implicit Property Node (see Figure 1 where the varying data is Number of Iterations for the While Loop.)

Figure 1: Sub-VI DigNum Refnum Passed to a Property Node 
  1. Link the Control Refnum to a terminal on the connector pane of the sub-VI, so that the reference can be passed from the main VI to the sub-VI. You should have one input terminal for the Control Refnum and one output terminal for the control/indicator you want to monitor in the connector pane.

In the Main VI,

  1. Open the block diagram (see Figure 2) and wire the reference node to the newly created terminal of the sub-VI.

Figure 2: Numeric Control Reference Passed to the Sub-VI

Additional Information

When running the main VI, any changes made to the control in sub-VI will be updated in the main VI as well because they are linked through the control reference. 

The property node used can be utilized to access not only the value, but also a variety of other control/indicator properties. Refer to LabVIEW Help for more information.