Skip to content Skip to navigation

Connexions

You are here: Home » Content » LabVIEW Programming Environment

Navigation

Recently Viewed

This feature requires Javascript to be enabled.
 

LabVIEW Programming Environment

Module by: Nasser Kehtarnavaz, Philipos Loizou, Mohammad Rahman. E-mail the authors

Summary: This chapter provides an introduction to LabVIEW graphical programming.

The LabVIEW graphical programming environment can be used to design and analyze a signal processing system in a more time-efficient manner than with text-based programming environments. This chapter provides an introduction to LabVIEW graphical programming. Also see (Reference), (Reference), and (Reference) to learn more about LabVIEW graphical programming.

LabVIEW graphical programs are called virtual instruments (VIs). VIs run based on the concept of dataflow programming. This means that execution of a block or a graphical component is dependent on the flow of data, or, more specifically, a block executes after data is made available at all of its inputs. Block output data are then sent to all other connected blocks. With dataflow programming, one can perform multiple operations in parallel because the execution of blocks is done by the flow of data and not by sequential lines of code.

Virtual Instruments (VIs)

A VI consists of two major components: a front panel and block diagram. A front panel provides the user interface of a program while a block diagram incorporates its graphical code. When a VI is located within the block diagram of another VI, it is called a subVI. LabVIEW VIs are modular, meaning that one can run any VI or subVI by itself.

Front Panel and Block Diagram

A front panel contains the user interfaces of a VI shown in a block diagram. VI inputs are represented by controls such as knobs, pushbuttons and dials. VI outputs are represented by indicators such as graphs, LEDs (light indicators) and meters. As a VI runs, its front panel provides a display or user interface of controls (inputs) and indicators (outputs).

A block diagram contains terminal icons, nodes, wires and structures. Terminal icons, or interfaces through which data are exchanged between a front panel and a block diagram, correspond to controls or indicators that appear on a front panel. Whenever a control or indicator is placed on a front panel, a terminal icon gets added to the corresponding block diagram. A node represents an object or block that has input and/or output connectors and performs a certain function. SubVIs and functions are examples of nodes. Wires establish the flow of data in a block diagram, and structures control the flow of data such as repetitions or conditional executions. Figure 1 shows front panel and block diagram windows.

Figure 1: LabVIEW Windows: Front Panel and Block Diagram
Figure 1 (figure 1-1.png)

Icon and Connector Pane

A VI icon is a graphical representation of a VI. It appears in the top right corner of a block diagram or a front panel window. When a VI is inserted into a block diagram as a subVI, its icon is displayed.

A connector pane defines VI inputs (controls) and outputs (indicators). One can change the number of inputs and outputs by using different connector pane patterns. In Figure 1, a VI icon is shown at the top right corner of the block diagram, and its corresponding connector pane, with two inputs and one output, is shown at the top right corner of the front panel.

Graphical Environment

Functions Palette

The Functions palette (see Figure 2) provides various function VIs or blocks to build a system. View this palette by right-clicking on an open area of a block diagram. Note that this palette can be displayed only in a block diagram.

Figure 2: Functions Palette
Figure 2 (figrue 1-2.png)

Controls Palette

The Controls palette (see Figure 3) features front panel controls and indicators. View this palette by right-clicking on an open area of a front panel. Note that this palette can be displayed only in a front panel.

Figure 3: Controls Palette
Figure 3 (figrue 1-3.png)

Tools Palette

The Tools palette offers various mouse cursor operation modes for building or debugging a VI. The Tools palette and the frequently used tools are shown in Figure 4.

Figure 4: Tools Palette
Figure 4 (graphics1.jpg)

Each tool is used for a specific task. For example, use the wiring tool to wire objects in a block diagram. If one enables the automatic tool selection mode by clicking on the Automatic Tool Selection button, LabVIEW selects the best matching tool based on a current cursor position.

Building a Front Panel

In general, one constructs a VI by going back and forth between a front panel and block diagram, placing inputs/outputs on the front panel and building blocks on the block diagram.

Controls

Controls make up the inputs to a VI. Controls grouped in the Numeric Controls palette(Controls Express Num Ctrls) are used for numerical inputs, controls grouped in the Buttons & Switches palette(Controls Express Buttons) are used for Boolean inputs, and controls grouped in the Text Controls palette(Controls Express Text Ctrls) are used for text and enumeration inputs. These control options are displayed in Figure 5.

Figure 5: Control Palettes
Figure 5 (graphics8.jpg)

Indicators

Indicators make up the outputs of a VI. Indicators grouped in the Numeric Indicators palette(Controls Express Numeric Inds) are used for numerical outputs, indicators grouped in the LEDs palette(Controls Express LEDs) are used for Boolean outputs, indicators grouped in the Text Indicators palette(Controls Express Text Inds) are used for text outputs, and indicators grouped in the Graph Indicators palette(Controls Express Graph Indicators) are used for graphical outputs. These indicator options are displayed in Figure 6.

Figure 6: Indicator Palettes
Figure 6 (graphics17.jpg)

Align, Distribute and Resize Objects

The menu items on the front panel toolbar (see Figure 7) provide options to align and orderly distribute objects on the front panel. Normally, after one places controls and indicators on a front panel, these options can be used to tidy up their appearance.

Figure 7: Menu to Align, Distribute, Resize and Reorder Objects
Figure 7 (graphics18.png)

Building a Block Diagram

Express VI and Function

Express VIs denote higher-level VIs configured to incorporate lower-level VIs or functions. These VIs are displayed as expandable nodes with a blue background. Placing an Express VI in a block diagram opens a configuration dialog window to adjust the Express VI parameters. As a result, Express VIs demand less wiring. The configuration window can be opened by double-clicking on its Express VI.

Basic operations such as addition or subtraction are represented by functions. Figure 8 shows three examples corresponding to three block diagram objects (VI, Express VI and function).

Figure 8: Block Diagram Objects: (a) VI, (b) Express VI, (c) Function
Figure 8 (graphics19.jpg)

One can display subVIs or Express VIs as icons or expandable nodes. If a subVI is displayed as an expandable node, the background appears yellow. Icons can be used to save space in a block diagram and expandable nodes can be used to achieve easier wiring or better readability. One can resize expandable nodes to show their connection nodes more clearly. Three appearances of a VI/Express VI are shown in Figure 9.

Figure 9: Icon versus Expandable Node
Figure 9 (graphics20.jpg)

Terminal Icons

Front panel objects are displayed as terminal icons in a block diagram. A terminal icon exhibits an input or output as well as its data type. Figure 10 shows two terminal icon examples consisting of a double precision numerical control and indicator. As shown in this figure, one can display terminal icons as data type terminal icons to conserve space in a block diagram.

Figure 10: Terminal Icon Examples Displayed in a Block Diagram
Figure 10 (graphics21.png)

Wires

Wires transfer data from one node to another in a block diagram. Based on the data type of a data source, the color and thickness of its connecting wires change.

Wires for the basic data types used in LabVIEW are shown in Figure 11. In addition to the data types shown in this figure, there are some other specific data types. For example, the dynamic data type is always used for Express VIs, and the waveform data type, which corresponds to the output from a waveform generation VI, is a special cluster of waveform components incorporating trigger time, time interval and data value.

Figure 11: Basic Wire Types
Figure 11 (graphics22.jpg)

Structures

A structure is represented by a graphical enclosure. The graphical code enclosed in the structure gets repeated or executed conditionally. A loop structure is equivalent to a for loop or a while loop statement in text-based programming languages, while a case structure is equivalent to an if-else statement.

For Loop

A for loop structure is used to perform repetitions. As illustrated in Figure 12, the displayed border indicates a for loop structure, where the count terminal Fig_index_N.png represents the number of times the loop is to be repeated. It is set by wiring a value from outside of the loop to it. The iteration terminal Fig_index_i.png denotes the number of completed iterations, which always starts at zero.

Figure 12: For Loop
Figure 12 (Fig02-18.png)

While Loop

A while loop structure allows repetitions depending on a condition (see Figure 13). The conditional terminal Fig02-17.png initiates a stop if the condition is true. Similar to a for loop, the iteration terminal Fig_index_i.pngprovides the number of completed iterations, always starting at zero.

Figure 13: While Loop
Figure 13 (Fig02-16.png)

Case Structure

A case structure (see Figure 14) allows the running of different sets of operations depending on the value it receives through its selector terminal, which is indicated by Fig02-20.png. In addition to Boolean type, the input to a selector terminal can be of integer, string, or enumerated type. This input determines which case to execute. The case selector Fig02-21.png shows the status being executed. Cases can be added or deleted as needed.

Figure 14: Case Structure
Figure 14 (Fig02-19.png)

Grouping Data: Array and Cluster

An array represents a group of elements having the same data type. An array consists of data elements having a dimension up to 23112311 size 12{2 rSup { size 8{"31"} } - 1} {}. For example, if a random number is generated in a loop, it is appropriate to build the output as an array because the length of the data element is fixed at 1 and the data type is not changed during iterations.

Similar to the structure data type in text-based programming languages, a cluster consists of a collection of different data type elements. With clusters, one can reduce the number of wires on a block diagram by bundling different data type elements together and passing them to only one terminal. One can add or extract an individual element to or from a cluster by using the cluster functions such as Bundle by Name and Unbundle by Name.

Debugging and Profiling VIs

Probe Tool

VIs can be debugged as they run by checking values on wires with the Probe tool. Note that the Probe tool can be accessed only in a block diagram window.

With the Probe tool, breakpoints and execution highlighting, one can identify the source of an incorrect or an unexpected outcome. To visualize the flow of data during program execution, a breakpoint can be used to pause the execution of a VI at a specific location.

Profile Tool

Timing and memory usage information – in other words, how long a VI takes to run and how much memory it consumes – can be gathered with the Profile tool. It is required to make sure that a VI is stopped before setting up a Profile window.

An effective way to become familiar with LabVIEW programming is to review examples. In the lab that follows, we explore most of the key LabVIEW programming features by building simple VIs.

Containers and Decoration Tools

Containers and Decoration tools can be used to organize front panel controls and indicators. Container tools are grouped in the Containers pallete(Controls Modern Containers Classic Classic Containers) and Decoration tools are grouped in the Decorations pallete(Controls Modern Decorations).

One can use Tab Control(Controls Modern Containers Tab Control Classic Classic Containers Tab Control) to display various controls and indicators within a limited screen area. This feature helps one to organize controls and indicators under different tabs as illustrated in Figure 15. To add more tabs or delete tabs, right-click the border area and choose one of the following options: Add Page After, Add Page Before, Duplicate Page or Remove Page.

Figure 15: Tab Control
Figure 15 (graphics35.png)

Content actions

Download module as:

PDF | EPUB (?)

What is an EPUB file?

EPUB is an electronic book format that can be read on a variety of mobile devices.

Downloading to a reading device

For detailed instructions on how to download this content's EPUB to your specific device, click the "(?)" link.

| More downloads ...

Add module to:

My Favorites (?)

'My Favorites' is a special kind of lens which you can use to bookmark modules and collections. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need an account to use 'My Favorites'.

| A lens I own (?)

Definition of a lens

Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual member, a community, or a respected organization.

What are tags? tag icon

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

| External bookmarks