Creating a SubVI in LabVIEW: A Step-by-Step Guide

SubVIs are incredibly useful in LabVIEW, offering a way to manage changes, debug your block diagrams more efficiently, and easily reuse code. Think of SubVIs as functions in text-based programming languages.

Requirements:

  • LabVIEW (any version later than 2009)

Task:

Create a SubVI that performs linear scaling. Given inputs, calculate an output using a linear equation.

Procedure

Step 1: Create a New VI

Start by creating a new, blank VI in LabVIEW by navigating to File -> New VI.

Step 2: Give the VI a Name

Save the VI with a descriptive name, such as “Linear Scaling.vi”.

Step 3: Create Your Front Panel

Design your front panel with the necessary controls (inputs) and indicators (output). For the linear scaling SubVI, you’ll need controls for the input value and any scaling parameters.

subVI labview fig1 Image alt: subVI labview fig1

Step 4: Create Your Block Diagram

This is where you implement the logic of your SubVI. Your block diagram should perform the linear scaling calculation.

subVI labview fig2 Image alt: subVI labview fig2

Step 5: Create the Input and Output Connectors

This step defines how the SubVI interacts with other VIs.

  1. Right-click on the small icon in the upper-right corner of your VI and select “Show Connector”. This displays the connector pane.

  2. Select the “Wire” tool (usually the default). Click on a connector in the connector pane and then click on the corresponding Control or Indicator on your front panel that you want to connect to that connector.

subVI labview fig3 Image alt: subVI labview fig3

Step 6: Create an Icon using the Icon Editor

Give your SubVI a recognizable icon.

  1. Right-click on the same icon in the upper-right corner (where you revealed the connector pane) and select “Edit Icon”.

  2. The Icon Editor allows you to draw a custom icon for your SubVI.

subVI labview fig4 Image alt: subVI labview fig4

Step 7: Create a New VI to Test Your SubVI

Create a separate VI to test the functionality of your newly created SubVI. Place the SubVI on the block diagram of this new VI and connect inputs and outputs to test different scenarios.

subVI labview fig5 Image alt: subVI labview fig5