Using Control References to Pass Access of Front Panel Controls to SubVIs

Publish Date: Oct 27, 2009 | 33 Ratings | 3.67 out of 5 | Print | 4 Customer Reviews | Submit your review

You can pass access to front panel object values, properties, and methods to subVIs by using explicitly linked control references. Explicitly linked control references consist of a general property or invoke node with an explicit control reference wire to its input. 

In this example program's main VI, there is a Control Reference constant for the Waveform Chart Indicator and the Boolean Stop Control. The explicit references to these front panel objects are wired to the subVI input terminals.

The subVI has two Control Refnum controls, one corresponding to the Waveform Chart and one to the Stop boolean control. Looking at the subVI block diagram, we can see what is being done with the control and indicator from the main VI. The Waveform Chart Refnum is fed to a Property Node that turns on autoscaling for the chart. This refnum is then passed inside the while loop where it is used to write a value to the chart in the front panel of the main VI. Meanwhile, the Boolean refnum is being used to read the current value of the Boolean control in the main VI's front panel to determine when the user selected the stop button.

This example illustrates how to read and write values from a subVI to controls and indicators in a main VI. A similar example that would be useful involves doing data acquistion in a subVI, displaying the data in the main VI, and terminating the data acquisition being done in the subVI from the main VI.

More more information on creating Control References, see the Concept Document on NI Developer Zone titiled "Control References: Overview".

How to Create This Setup from Scratch

Modifications to the SubVI:

  1. On the front panel place down a Control Refnum from the Controls » Refnum sub-palette
  2. Drop a Push Button from the Controls » Boolean sub-palette into the Control Refnum (similar to the two step process involved in creating an array)
  3. Modify the Connector Pane for the sub VI to include the Control Refnum as an input to the sub VI. Right-click on the icon in the top, right corner of the front panel and select Show Connector (choose an alternate pattern if necessary)
  4. In the block diagram, place the Control Refnum terminal outside of the while loop and wire it up to the left side of loop boundary
  5. Place down a Property Node inside your while loop on your block diagram, from the Functions » Application Control sub-palette
  6. Wire up the Control Refnum to the Reference input of the Property Node
  7. Right-click on the Property and select Properties » Value
  8. Wire the output of the Property to the Conditional Terminal of your while loop

Modifications to the Main Program:

  1. Create a reference from your boolean control that you want to use to control the sub VI (turn it on and off) by right-clicking on the boolean control and selecting Create » Reference
  2. Wire the reference terminal in your block diagram into the corresponding control reference input of the sub VI
  3. If you are using a Stop button, set the mechanical action of the button to Switch Until Released by right-clicking on the button on the front panel and selecting Mechanical Action » Switch Until Released


Back to Top

Customer Reviews
4 Reviews | Submit your review

Data type of property node in sub vi doesnt chane  - Apr 20, 2016

I did exactly as described above. But changing the buttons mechanical behaviour from latch to switch has no effect on the sub vi's property node. If i create a similar one in the main vi it's data type changes from Variant to Boolean just as it should.

  - Jul 4, 2013

Please include the information about creating the control reference in the front panel and what is difference when we include the data type of the control.

Solution to problem  - Jun 4, 2011

In regards to the previous comments that I posted. I found that I had to get rid of the strict status. And that did the trick.

works but is missing data  - Jun 4, 2011

I used what was done in the example to show the waveform chart on my main vi from a subvi that is doing data acquisition. I found that I was missing some of the data. I setup a waveform chart in the subvi so that I could watch both charts. And its obvious that some of the data is missing.

View more reviews

Bookmark & Share


Downloads

Attachments:

Main (control and indicator).v
i

Requirements


Ratings

Rate this document

Answered Your Question?
Yes No

Submit