The LabVIEW Environment and Virtual Instruments
Virtual Instrument Architecture
A LabVIEW program can look like a laboratory instrument while implementing its calculations graphically. Virtual Instrument Architecture separates what you operate, how results are computed, and how another program accesses those results. Understanding these roles helps you build a small engineering calculator that works both on its own and inside a larger application.
Front panel and block diagram
A virtual instrument (VI) is a LabVIEW program, commonly saved as a .vi file. Its front panel provides the user interface, and its block diagram contains the graphical source code. These are linked views of the same program.
On the front panel, a control supplies an input, such as an entered voltage. An indicator displays an output, such as a calculated voltage. Creating a front-panel control or indicator also creates its corresponding terminal on the block diagram. Moving an object on the front panel changes the layout; it does not change the arithmetic connected to its terminal.
Component | Main purpose | Typical objects |
|---|---|---|
Front panel | Accept inputs and display outputs | Numeric controls, switches, numeric indicators |
Block diagram | Implement the calculation | Control and indicator terminals, functions, constants, wires |
Icon and connector pane | Identify the VI and expose callable connections | An identifying image and assigned input/output terminals |
The Controls palette supplies front-panel controls and indicators. The Functions palette supplies functions, constants, and VIs for the block diagram. Context Help helps you identify an object's purpose and terminals without guessing from its appearance.
Representing an engineering calculation
Consider a voltage-correction VI governed by
Here, x is the input voltage, g is a dimensionless gain, b is an offset voltage, and y is the corrected voltage. If the operator chooses all three inputs, use three numeric controls and one numeric indicator. The block diagram connects the input terminals to multiplication and addition functions, then connects the result to the output indicator terminal.
Use a floating-point numeric representation, such as double precision (DBL), when fractional values are needed. A Boolean represents a true/false condition rather than a continuously varying voltage. Choose objects by their data role and type, then give them clear labels.
A diagram constant supplies a fixed value without requiring an operator entry. Decide which quantities should be adjustable before choosing between controls and constants.
Making the VI reusable and checking it
A VI used within another VI is called a subVI. Its icon identifies it on the calling block diagram. Its connector pane defines the terminals through which the caller supplies inputs and receives outputs. Assign each exposed input terminal to the appropriate front-panel control and each exposed output terminal to the appropriate indicator.
A common convention places inputs on the left and outputs on the right. Assignment determines which object a terminal represents; screen position and matching names do not establish that connection. A front-panel object can exist without being exposed on the connector pane.
Test the VI alone with known inputs, then test it through its connector pane. Inspect both the assigned objects and the values received by the caller.
What to remember
- Controls supply inputs; indicators display outputs.
- The block diagram implements the calculation through connected objects.
- The icon identifies a subVI; connector assignments define its callable interface.
- Successful execution and correct engineering results require separate checks.
Example: Building a reusable force converter
You are building a LabVIEW VI called Force conversion for a benchtop load-cell calculation. For this exercise, the operator enters the signal voltage manually; no acquisition hardware is involved. The specified conversion is
where V is signal voltage, V0 is zero-load voltage, and s is sensitivity in volts per newton. Treat the supplied values as exact for this calculation. Use DBL numeric objects and report force to one decimal place.
For the initial test, V=1.840 V, V0=0.100 V, and s=0.0240 V/N.
a) Identify the required front-panel controls and indicator. Describe the block-diagram connections.
The operator supplies three quantities, so create three numeric controls: Signal voltage (V), Zero-load voltage (V), and Sensitivity (V/N). The VI computes force, so create one numeric indicator labeled Force (N). Place these objects using the Controls palette.
On the block diagram, use subtraction and division functions from the Functions palette. Wire Signal voltage to the first subtraction input and Zero-load voltage to the second. Wire the subtraction output to the division numerator and Sensitivity to the denominator. Finally, wire the division output to the Force indicator terminal.
This arrangement implements the specified equation. Clear labels document the units; enter every voltage in volts so that the calculation uses a consistent scale.
b) Calculate the initial Force indicator value and check its units.
Subtract the zero-load voltage before applying the sensitivity. This removes the voltage present at zero force rather than treating it as part of the load signal.
Dividing volts by volts per newton leaves newtons. The Force indicator should display 72.5 N. Multiplying that force by the sensitivity and adding the zero-load voltage recovers 1.840 V, which checks the calculation.
c) Configure the VI for reuse. A calling VI supplies V=0.940 V and the same V0 and s. State the connector assignments and calculate the expected returned force.
Choose a connector pattern with at least ________ available terminals. Assign ________ input terminals to Signal voltage, Zero-load voltage, and Sensitivity, and assign one output terminal to Force. Conventionally, place inputs on the left and the output on the right. Give the icon a recognizable identity, but use the connector assignments to establish the actual connections.
In the caller, wire the three specified numeric values to their matching inputs and wire the force output to a numeric indicator. The expected return value is
Run the caller and compare its indicator with 35.0 N. This checks the externally supplied values and returned output, in addition to the earlier stand-alone calculation. Merely placing the VI's icon in the caller does not establish these individual input assignments.
An engineer builds a VI that converts a pressure reading from kilopascals to pounds per square inch. They lay out the user interface before writing any graphical code, and they want to test the VI before relying on it. Put the steps in the order the engineer should carry them out.
1.
Create a new blank VI, which opens an empty front panel window and an empty block diagram window.
2.
Wire the kPa terminal and the constant to the Multiply inputs, and wire the Multiply output to the psi terminal.
3.
Switch to the block diagram and place a Multiply function and a numeric constant from the Functions palette.
4.
Type a known pressure into the kPa control on the front panel and click the Run button.
5.
Place a numeric control for kPa and a numeric indicator for psi on the front panel from the Controls palette.
6.
Read the psi indicator and compare its value with a conversion worked out by hand.
An operator must enter a text run label and a voltage in volts into a LabVIEW VI. The VI calculates a current and displays it in amperes. Which selection correctly creates these front-panel objects?