Skip to content
Tutorials Center
My learning

Topics

Lesson 6 of 36 ยท Environment and VIs

Connector Pane and SubVIs

Turn a VI into a reusable subVI: design the icon and connector pane, mark inputs required or recommended, and keep hierarchies clean and testable.

A subVI is to LabVIEW what a function is to a text language: a VI called from another VI. SubVIs let you break a large diagram into named pieces, reuse them, and test them one at a time. This lesson describes the real workflow in words; no LabVIEW output is shown. JavaScript stand-ins model parameters, return values and the "required input" rule.

Why subVIs

  • Readability. A diagram with twenty small named nodes beats one huge sprawl.
  • Reuse. Write a filter once and call it from many VIs.
  • Testing. A subVI has a clear input/output contract you can run alone.
  • Memory and speed. A rule of thumb: if a diagram does not fit on one screen without scrolling, split it.

Two things make a VI callable

Every VI has an icon and a connector pane.

  • The icon (top right of either window) is the picture shown when this VI is placed as a node. Double-click it to open the Icon Editor. Use a short text label, or a simple glyph, with a colored banner for related VIs.
  • The connector pane is a set of small rectangles, one for each input and output. Right-click the icon and choose Show Connector to see it. Choose a pattern (right-click > Patterns). Pick a pattern with a few spare terminals so you can add more later without breaking callers.

Assigning terminals

  1. Show the connector pane.
  2. Click a terminal rectangle in the pane. The cursor becomes the wiring spool.
  3. Click a control or indicator on the front panel. The rectangle changes color to match the type.
  4. Repeat for every control and indicator you want available.

Convention: inputs on the left, outputs on the right, and the error in/out clusters at the bottom-left and bottom-right. See waveforms and error clusters.

Required settings: right-click a connector terminal and choose This Connection Is > Required / Recommended / Optional. Required inputs produce a broken Run arrow in the caller when left unwired. Recommended produces a warning. Optional has no complaint and uses the control's default value.

Making a subVI

Icon Picture on the diagram
Connector pane Inputs and outputs
Description Hover help

Name controls clearly.

1 / 2

Create a subVI from a selection

If a diagram has grown, select the part you want to extract with the arrow tool and use Edit > Create SubVI. LabVIEW makes a new VI, adds controls and indicators for each wire crossing the selection, and replaces the selection with the new node. Always review the generated icon, labels and connector pane afterwards. It is a quick way to refactor, but it often produces poor names.

Calling a subVI

On the diagram right-click and use Select a VI, or drag the VI's icon from the corner of its own panel (or from the project window) onto the caller's diagram. Wire the terminals as with any function. Double-click the node to open the subVI and edit it.

Documentation of a subVI

  • VI Description (File > VI Properties > Documentation). Shows in Context Help.
  • Control Descriptions. Right-click each control and use Description and Tip.
  • Icon and name. Use a noun phrase for data VIs and a verb phrase for actions: Moving Average.vi, Open Instrument Session.vi.

Context Help shows the pane with required inputs in bold, recommended in plain text, and optional greyed. This is documentation your callers actually see.

Design rules for good subVIs

  1. One job. If you cannot name it in a few words, split it.
  2. Few terminals. More than eight or so suggests grouping inputs in a cluster; see clusters and type definitions.
  3. No hidden state. Avoid global variables inside subVIs where possible, since hidden state makes tests unreliable.
  4. Pass errors. Take error in and give error out.
  5. Re-entrancy. By default a subVI is non-reentrant: if two callers use it at the same moment they share one copy and wait. Set Reentrant execution in VI Properties > Execution for functions that should run in parallel, such as filters used in two loops. Preallocated clone reentrancy gives each caller its own data space.

Stand-in: a subVI as a function with required inputs

This is not LabVIEW. It models three terminal kinds: required (the call fails if missing), recommended (a warning), and optional (a default).

JS Stand-in: terminals that are required, recommended or optional

Press Run (or Ctrl + Enter) to see the console output here.

No output.

The second stand-in shows why reusing one named routine is better than copying the logic around.

JS Stand-in: reuse one routine from many callers

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What two things must a VI have to be used as a subVI?

    The icon is its picture on the diagram and the connector pane defines its terminals.
  2. 2. What happens when a Required input of a subVI is left unwired?

    Required terminals must be wired or the calling VI cannot run.
  3. 3. Where does convention place the error in cluster on the connector pane?

    Error in goes bottom-left and error out bottom-right.
  4. 4. Which setting lets two callers run the same subVI at the same time?

    Reentrant execution gives each caller its own data space, so they do not wait for each other.

Summary

  • A subVI is a VI with an icon and connector pane, called like a function.
  • Put inputs on the left, outputs on the right, errors at the bottom.
  • Mark terminals Required, Recommended or Optional to document the contract.
  • Edit > Create SubVI refactors a selection, but always clean up the result.
  • Make a subVI reentrant if it should run in parallel from several callers.

Next: Projects and Libraries