LabVIEW Graphical Programming
LabVIEW Graphical Programming
Collection Editor:
Serhat Beyenir
Collection Editor:
Serhat Beyenir
Authors:
National Instruments
Malan Shiralkar
Online:
< http://cnx.org/content/col11408/1.1/ >
CONNEXIONS
Rice University, Houston, Texas
This selection and arrangement of content as a collection is copyrighted by Serhat Beyenir. It is licensed under the
Creative Commons Attribution 3.0 license (http://creativecommons.org/licenses/by/3.0/).
Collection structure revised: February 6, 2012
PDF generated: October 29, 2012
For copyright and attribution information for the modules contained in this collection, see p. 114.
Table of Contents
1 Introduction
1.1 LabVIEW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.2 LabVIEW Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.3 Front Panel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
1.4 Block Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
1.5 Acquiring a Signal VI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
1.6 LabVIEW Documentation Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
1.7 Reduce Samples VI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
1.8 Debugging Techniques . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
1.9 Debug Exercise (Main) VI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
1.10 Summary, Tips, and Tricks on Introduction to LabVIEW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
2 Modular Programming
2.1
2.2
2.3
2.4
2.5
2.6
2.7
Modular Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
Icons and Connector Panes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
Convert C to F VI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
Using SubVIs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
Thermometer VI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
Creating a SubVI from Sections of a VI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
Summary, Tips, and Tricks on Modular Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
While Loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
For Loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
Timed Temperature VI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
Summary, Tips, and Tricks on Repetition and Loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
4 Customizing VIs
4.1
4.2
4.3
4.4
4.5
4.6
4.7
4.8
4.9
5 Plotting Data
5.1 Waveform Charts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
5.2 Temperature Monitor VI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
5.3 Temperature Running Average VI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
5.4 Waveform and XY Graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
5.5 Graph Waveform Array VI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
5.6 Temperature Analysis VI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
5.7 Graph Circle VI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
5.8 Intensity Plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . 108
5.9 Intensity Graph Example VI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
5.10 Summary, Tips, and Tricks on Plotting Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
5.11 Additional Exercises for Plotting Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
iv
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
Attributions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
Chapter 1
Introduction
CHAPTER 1. INTRODUCTION
1.1 LabVIEW1
LabVIEW programs are called virtual instruments, or VIs, because their appearance and operation imitate
physical instruments, such as oscilloscopes and multimeters. LabVIEW contains a comprehensive set of
tools for acquiring analyzing, displaying, and storing data, as well as tools to help you troubleshoot your
code.
LabVIEW VIs contain three components-the front panel, the block diagram, and the icon and connector pane. This lesson describes the front panel and the block diagram; refer to Modular Programming
(Section 2.1) for more information about the icon and the connector pane.
In LabVIEW, you build a user interface, or front panel, with controls and indicators. Controls are knobs,
push buttons, dials, and other input devices. Indicators are graphs, LEDs, and other displays. After you
build the user interface, you add code using VIs and structures to control the front panel objects. The block
diagram contains this code. In some ways, the block diagram resembles a flowchart.
Use LabVIEW to communicate with hardware such as data acquisition, vision, and motion control devices, and GPIB, PXI, VXI, RS-232, and RS-484 devices. LabVIEW also has built-in features for connecting
your application to the Web using the LabVIEW Web Server and software standards such as TCP/IP networking and ActiveX.
Using LabVIEW, you can create test and measurement, data acquisitions, instrument control, datalogging, measurement analysis, and report generation applications. You also can create stand-alone executables and shared libraries, like DLLs, because LabVIEW is a true 32-bit compiler.
1 This
CHAPTER 1. INTRODUCTION
VI appear in the Front panel preview and the Block diagram preview sections, and a description of the
template appears in the Description section. Figure 1.2 shows the New dialog box and the SubVI with
Error Handling VI template.
Click the OK button to open the template. You also can double-click the name of the template VI in the
Create new list to open the template. If no template is available for the task you want to create, you can
start with a blank VI and create a VI to accomplish the specific task. In the LabVIEW dialog box, click the
arrow on the New button and select Blank VI from the shortcut menu or press the Ctrl-N keys to open a
blank VI.
NOTE : You also can open a blank VI by selecting Blank VI from the Create new list in the New
dialog box or by selecting FileNew VI.
1.2.1.1 Open/Templates
Use the New dialog box to create different components in LabVIEW to help you build an application. You
can start with a blank VI to write a VI from scratch, or start with a template to simplify the programming.
Available for free at Connexions <http://cnx.org/content/col11408/1.1>
5
The New dialog box includes the following components:
Create new - Displays templates you can use to start building VIs and other LabVIEW documents.
Select from the following templates and click the OK button to start building a VI or other LabVIEW document.
Blank VI - Opens a blank front panel and blank block diagram.
VI from Template - Opens a front panel and block diagram with components you need to build
different types of VIs.
Other Document Types - Opens the tools you use to build other LabVIEW objects.
Browse for Template - Displays the Browse dialog box so you can navigate to a VI, control, or template. If you previously have browsed for and selected a template from this dialog box, use the
pull-down menu of the Browse button to select a template to reopen it.
Front panel preview - Displays the front panel for the VI template you selected in the Create new
list.
Block diagram preview - Displays the block diagram for the VI template you selected in the Create
new list.
Description - Displays a description of the template you selected in the Create new list if the template includes a description.
Figure 1.3
The Loading section lists the subVIs of the VI as they are loaded into memory. Number Loaded is the
number of subVIs loaded into memory so far. You can cancel the load at any time by clicking the Stop
button.
If LabVIEW cannot immediately locate a subVI, it begins searching through all directories specified by
the VI Search Path. You can edit the VI Search Path by selecting ToolsOptions and selecting Paths
from the top pull-down menu. The Searching section lists directories or VIs as LabVIEW searches through
Available for free at Connexions <http://cnx.org/content/col11408/1.1>
CHAPTER 1. INTRODUCTION
them. You can have LabVIEW ignore a subVI by clicking the Ignore SubVI button, or you can click the
Browse button to search for the missing subVI.
1.2.1.3 Saving VIs
Select Save, Save As, Save All, or Save with Options from the File menu to save VIs as individual files
or group several VIs together and save them in a VI library. VI library files end with the extension .llb.
National Instruments recommends that you save VIs as individual files, organized in directories, especially
if multiple developers are working on the same project.
LabVIEW uses the native file dialog boxes so they act similar to other applications on the computer. You
can disable this feature by selecting ToolsOptions and selecting Miscellaneous from the top pull-down
menu. If you disable native file dialogs, LabVIEW uses its own platform-independent file dialog boxes with
some convenient features, such as providing a list of recent paths and reducing the steps necessary to save
VIs in VI libraries.
1.2.1.4 Moving VIs Across Platforms
You can transfer VIs from one platform to another, such as from Mac OS to Windows. LabVIEW automatically translates and recompiles the VIs on the new platform.
Because VIs are files, you can use any file transfer method or utility to move VIs between platforms. You
can port VIs over networks using FTP, Z or XModem protocols, or similar utilities. Such network transfers
eliminate the need for additional file translation software. If you port VIs using magnetic media, such as
floppy disks or a moveable external hard drive, you need a generic file transfer utility program, such as the
following:
(Windows) MacDisk and TransferPro transfer Mac OS files to the PC format and vice versa.
(Mac OS) DOS Mounter, MacLink, and Apple File Exchange convert PC files to the Mac OS format
and vice versa.
(Sun) PC File System (PCFS) converts PC files to the Sun format and vice versa.
NOTE : Certain operating system-specific VIs are not portable between platforms, such as DDE
(Dynamic Data Exchange) VIs, ActiveX VIs, and AppleEvents.
Refer to the Porting and Localizing LabVIEW VIs Application Note, available by selecting HelpSearch
the LabVIEW Bookshelf, for more information about porting VIs.
1.2.2 Menus
The menus at the top of a VI window contain items common to other applications, such as Open, Save, Copy,
and Paste, and other items specific to LabVIEW. Some menu items also list shortcut key combinations.
(Mac OS) The menus appear at the top of the screen.
(Windows and UNIX) The menus display only the most recently used items by default. Click the arrows at the bottom of a menu to display all items. You can display all menu items by default by selecting
ToolsOptions and selecting Miscellaneous from the top pull-down menu.
NOTE :
The File menu contains items used for basic file operations, such as opening, closing, saving, and
printing files.
The Edit menu contains items that allow you to search for and modify LabVIEW files and their
components.
The Operate menu contains items you use to control the operation of VIs.
Available for free at Connexions <http://cnx.org/content/col11408/1.1>
The Tools menu contains items for configuring LabVIEW, your projects, and your VIs.
The Browse menu contains items that allow you to view aspects of the current VI and its hierarchy.
The Window menu contains items that allow you to configure the appearance of the current windows
and palettes. You also can access the Error List window and view the contents of the clipboard.
The Help menu contains items to explain and define LabVIEW features and other components, provide full LabVIEW documentation, and access National Instruments technical support.
Figure 1.4: 1. Toolbar, 2. Owned Label, 3. Numeric Control, 4. Free Label, 5. Numeric Control Terminal,
6. Knob Terminal, 7. Numeric Constant, 8. Multiply Function, 9. Icon, 10. Knob Control, 11. Plot Legend,
12. XY Graph, 13. Wire Data Path, 14. XY Graph Terminal, 15. Bundle Function, 16. SubVI, 17. For Loop
Structure
Figure 1.5
Click the Run button to run a VI. LabVIEW compiles the VI, if necessary. You can run a VI if the
Run button appears as a solid white arrow. The solid white arrow, shown above, also indicates you can use
the VI as a subVI if you create a connector pane for the VI.
Available for free at Connexions <http://cnx.org/content/col11408/1.1>
CHAPTER 1. INTRODUCTION
While the VI runs, the Run button appears as shown at left if the VI is a top-level VI, meaning it
has no callers and therefore is not a subVI.
If the VI that is running is a subVI, the Run button appears as shown at left.
The Run button appears broken, shown at left, when the VI you are creating or editing contains
errors. If the Run button still appears broken after you finish wiring the block diagram, the VI is broken and
cannot run. Click this button to display the Error list window, which lists all errors and warnings.
Click the Run Continuously button, shown at left, to run the VI until you abort or pause execution.
You also can click the button again to disable continuous running.
While the VI runs, the Abort Execution button, shown at left, appears. Click this button to stop
the VI immediately if there is no other way to stop the VI. If more than one running top-level VI uses the
VI, the button is dimmed.
NOTE : Avoid using the Abort Execution button to stop a VI. Either let the VI complete its data
flow or design a method to stop the VI programmatically. By doing so, the VI is at a known state.
For example, place a button on the front panel that stops the VI when you click it.
Click the Pause button, shown at left, to pause a running VI. When you click the Pause button, LabVIEW highlights on the block diagram the location where you paused execution, and the Pause button
appears red. Click the button again to continue running the VI.
Select the Text Settings pull-down menu, shown at left, to change the font
settings for the selected portions of the VI, including size, style, and color.
Select the Align Objects pull-down menu, shown at left, to align objects along axes, including
vertical, top edge, left, and so on.
Select the Distribute Objects pull-down menu, shown at left, to space objects evenly, including gaps, compression, and so on.
Select the Resize Objects pull-down menu, shown at left, to resize multiple front panel objects
to the same size.
Select the Reorder pull-down menu, shown at left, when you have objects that overlap each
other and you want to define which one is in front or back of another. Select one of the objects with the
Positioning tool and then select from Move Forward, Move Backward, Move To Front, and Move To Back.
Select the Show Context Help Window button, shown at left, to toggle the display of the Context
Help window.
Type appears to remind you that a new value is available to replace an old value. The Enter button
disappears when you click it, press the Enter key, or click the front panel or block diagram workspace.
Figure 1.6
Click the Highlight Execution button, shown at left, to display an animation of the block diagram execution when you click the Run button. see the flow of data through the block diagram. Click the
button again to disable execution highlighting.
Click the Step Into button, shown at left, to open a node and pause. When you click the Step
Into button again, it executes the first action and pauses at the next action of the subVI or structure. You
also can press the Ctrl and down arrow keys. Single-stepping through a VI steps through the VI node by
node. Each node blinks to denote when it is ready to execute. By stepping into the node, you are ready to
single-step inside the node.
Click the Step Over button, shown at left, to execute a node and pause at the next node. You
also can press the Ctrl and right arrow keys. By stepping over the node, you execute the node without
single-stepping through the node.
Click the Step Out button, shown at left, to finish executing the current node and pause. When
the VI finishes executing, the Step Out button becomes dimmed. You also can press the Ctrl and up arrow
keys. By stepping out of a node, you complete single-stepping through the node and go to the next node.
The Warning button, shown at left, appears if a VI includes a warning and you placed a checkmark in the Show Warnings checkbox in the Error List window. A warning indicates there is a potential
problem with the block diagram, but it does not stop the VI from running.
1.2.6 Palettes
LabVIEW has graphical, floating palettes to help you create and run VIs. The three palettes include the
Tools, Controls, and Functions palettes. You can place these palettes anywhere on the screen.
1.2.6.1 Tools Palette
You can create, modify, and debug VIs using the tools located on the floating Tools (Figure 1.7) palette. The
Tools palette is available on both the front panel and the block diagram. A tool is a special operating mode
of the mouse cursor. The cursor corresponds to the icon of the tool selected in the Tools palette. Use the
tools to operate and modify front panel and block diagram objects.
Select WindowShow Tools Palette to display the Tools palette.
NOTE : Press the Shift key and right-click to display a temporary version of the Tools palette at
the location of the cursor.
10
CHAPTER 1. INTRODUCTION
If automatic tool selection is enabled and you move the cursor over objects on the front panel or block
diagram, LabVIEW automatically selects the corresponding tool from the Tools palette. You can disable
automatic tool selection and select a tool manually by clicking the tool you want on the Tools palette.
If you want to use the Tab key to cycle through the four most common tools on the Tools
palette, click the Automatic Tool Selection button, shown at left, on the Tools palette to disable automatic tool selection. Press the Shift-Tab keys or click the Automatic Tool Selection button to enable
automatic tool selection again. You also can manually select a tool on the Tools palette to disable automatic
tool selection. Press the Tab or Shift-Tab keys or click the Automatic Tool Selection button on the Tools
palette to enable automatic tool selection again. If automatic tool selection is disabled, you can press the
spacebar to switch to the next most useful tool.
Use the Operating tool, shown at left, to change the values of a control or select the text
within a control. The Operating tool changes to the icon shown at left when it moves over a text control,
such as a numeric or string control.
Use the Positioning tool, shown at left, to select, move, or resize objects. The Positioning tool
changes to resizing handles when it moves over the edge of a resizable object.
Use the Labeling tool, shown at left, to edit text and create free labels. The Labeling tool
changes to the following icon when you create free labels.
Use the Wiring tool, shown at left, to wire objects together on the block diagram.
Use the Object Shortcut Menu, shown at left, tool to access an object shortcut menu with the left
mouse button.
Use the Scrolling tool, shown at left, to scroll through windows without using scrollbars.
Use the Breakpoint tool, shown at left, to set breakpoints on VIs, functions, nodes, wires, and
structures to pause execution at that location.
Use the Probe tool, shown at left, to create probes on wires on the block diagram. Use the Probe
tool to check intermediate values in a VI that produces questionable or unexpected results.
Available for free at Connexions <http://cnx.org/content/col11408/1.1>
11
Use the Color Copy tool, shown at left, to copy colors for pasting with the Coloring tool.
Use the Coloring tool, shown at left, to color an object. It also displays the current
foreground and background color settings.
1.2.6.2 Controls and Functions Palettes
The Controls and Functions palettes contain subpalettes of objects you can use to create a VI. When you
click a subpalette icon, the entire palette changes to the subpalette you selected. To use an object on the
palettes, click the object and place it on the front panel or block diagram.
The Controls palette, shown in Figure 1.8, is available only on the front panel. The Controls palette
contains the controls and indicators you use to build the front panel. Refer to the Front Panel (Section 1.3)
section for more information about the using the Controls palette on the front panel. The controls and
indicators located on the Controls palette depend on the palette view currently selected.
The Functions palette, shown in the Figure 1.9, is available only on the block diagram. The Functions
palette contains the VIs and functions you use to build the block diagram. Refer to the Block Diagram
(Section 1.4) section of this lesson for more information about using the Functions palette on the block
diagram. The VIs and functions located on the Functions palette depend on the palette view currently
selected. The VIs and functions are located on subpalettes based on the types of VIs and functions.
12
CHAPTER 1. INTRODUCTION
Search Changes the palette to search mode. In search mode, you can perform text-based
searches to locate controls, VIs, or functions on the palettes. For example, if you want to find
the Random Number function, click the Search button on the Functions palette toolbar and start
typing Random Number in the text box at the top of the palette. LabVIEW lists all matching items
that either start with or contain the text you typed. You can click one of the search results and
drag it to the block diagram, as shown in Figure 1.10.
13
Figure 1.10
Double-click the search result to highlight its location on the palette. You then can click the Up to Owning
Palette button to view the hierarchy of where the object resides.
14
CHAPTER 1. INTRODUCTION
figure. The options available on the property dialog box for an object are similar to the options available on
the shortcut menu for that object.
15
16
CHAPTER 1. INTRODUCTION
NOTE : In the Express palette view, toolsets and modules do not install subpalettes on the top
level of the Controls and Functions palettes. Instead, toolsets and modules install on the All
Controls and All Functions subpalettes. In the Advanced palette view, toolsets and modules
install subpalettes on the top level.
Click the Options button on the Controls or Functions palette to change to another palette view or format.
1.3.1.1.1 Numeric Controls and Indicators
The two most commonly used numeric objects are the numeric control and the numeric indicator, as shown
in Figure 1.14.
Figure 1.14: 1. Increment and Decrement Buttons, 2. Numeric Control, 3. Numeric Indicator
To enter or change values in a numeric control, click the increment and decrement buttons with the
Operating tool or double-click the number with either the Labeling tool or the Operating tool, type a new
number, and press the Enter key.
1.3.1.1.2 Boolean Controls and Indicators
Use Boolean controls and indicators to enter and display Boolean (True or False) values. Boolean objects
simulate switches, push buttons, and LEDs. The most common Boolean objects are the vertical toggle
switch and the round LED, as shown in Figure 1.15.
Figure 1.15
17
18
CHAPTER 1. INTRODUCTION
1.4.3 Nodes
Nodes are objects on the block diagram that have inputs and/or outputs and perform operations when a VI
runs. They are analogous to statements, operators, functions, and subroutines in text-based programming
languages. Nodes can be functions, subVIs, or structures. Structures are process control elements, such as
Case structures, For Loops, or While Loops. The Add and Subtract functions in Figure 1.16 are function
nodes.
1.4.3.1 Expandable Nodes versus Icons
You can display VIs and Express VIs as icons or as expandable nodes. Expandable nodes appear as icons
surrounded by a colored field. SubVIs appear with a yellow field, and Express VIs appear with a blue
field. Use icons, such as the Basic Function Generator VI icon if you want to conserve space on the block
diagram. Use expandable nodes, such as the Basic Function Generator VI expandable node to make
wiring easier and to aid in documenting block diagrams. By default, subVIs appear as icons on the block
diagram, and Express VIs appear as expandable nodes.
To display a subVI or Express VI as an expandable node, right-click the subVI or Express VI and select
View As Icon from the shortcut menu to remove the checkmark.
You can resize the expandable node to make wiring even easier, but it also takes a large amount of space
on the block diagram. Complete the following steps to resize a node on the block diagram.
1.
2.
3.
4.
Move the Positioning tool over the node. Resizing handles appear at the top and bottom of the node.
Move the cursor over a resizing handle to change the cursor to the resizing cursor.
Use the resizing cursor to drag the border of the node down to display additional terminals.
Release the mouse button.
To cancel a resizing operation, drag the node border past the block diagram window before you release the
mouse button.
Figure 1.17 shows the Basic Function Generator VI as a resized expandable node.
19
Figure 1.17
NOTE : If you display a subVI or Express VI as an expandable node, you cannot display the terminals for that node and you cannot enable database access for that node.
1.4.3.2 Terminals
Front panel objects appear as terminals on the block diagram. The terminals represent the
data type of the control or indicator. You can configure front panel controls or indicators to appear as icon
or data type terminals on the block diagram. By default, front panel objects appear as icon terminals. For
example, a knob icon terminal, shown at left, represents a knob on the front panel. The DBL at the bottom
of the terminal represents a data type of double-precision, floating-point numeric. To display a terminal as
a data type on the block diagram, right-click the terminal and select View As Icon from the shortcut menu
to remove the checkmark. A DBL data type terminal, shown above at left, represents a double-precision,
floating-point numeric control or indicator.
Terminals are entry and exit ports that exchange information between the front panel and block diagram. Terminals are analogous to parameters and constants in text-based programming languages. Types
of terminals include control or indicator terminals and node terminals. Control and indicator terminals
belong to front panel controls and indicators. Data you enter into the front panel controls (a and b in Figure 1.16) enter the block diagram through the control terminals. The data then enter the Add and Subtract
functions. When the Add and Subtract functions complete their internal calculations, they produce new
Available for free at Connexions <http://cnx.org/content/col11408/1.1>
20
CHAPTER 1. INTRODUCTION
data values. The data flow to the indicator terminals, where they exit the block diagram, reenter the front
panel, and appear in front panel indicators ( a + b and a b in Figure 1.16). The terminals in Figure 1.16
belong to four front panel controls and indicators. The connector panes of the Add and Subtract functions,
shown in this media, have three node terminals. To display the terminals of the function on the block
diagram, right-click the function node and select Visible ItemsTerminals from the shortcut menu.
1.4.3.3 Wires
You transfer data among block diagram objects through wires. Wires are analogous to variables in textbased programming languages. In Figure 1.16, wires connect the control and indicator terminals to the Add
and Subtract functions. Each wire has a single data source, but you can wire it to many VIs and functions
that read the data. Wires are different colors, styles, and thicknesses, depending on their data types. A
broken wire appears as a dashed black line with a red X in the middle. The examples in Table 1.1 are the
most common wire types.
Wire Type
Scalar
1D Array
2D Array
Color
Numeric
Orange
(floating-point),
Blue (integer)
Boolean
Green
String
Pink
Table 1.1
In LabVIEW, you use wires to connect multiple terminals together to pass data in a VI. The wires must
be connected to inputs and outputs that are compatible with the data that is transferred with the wire. For
example, you cannot wire an array output to a numeric input. In addition the direction of the wires must
be correct. The wires must be connected to only one input and at least one output. For example, you cannot
wire two indicators together. The components that determine wiring compatibility include the data type of
the control and/or indicator and the data type of the terminal.
1.4.3.3.1 Data Types
Data types indicate what objects, inputs, and outputs you can wire together. For example, a switch has a
green border so you can wire a switch to any input with a green label on an Express VI. A knob has an
orange border so you can wire a knob to any input with an orange label. However, you cannot wire an
orange knob to an input with a green label. Notice the wires are the same color as the terminal.
The dynamic data type stores the information generated or acquired by an Express VI. The
dynamic data type appears as a dark blue terminal, shown at left. Most Express VIs accept and/or return
the dynamic data type. You can wire the dynamic data type to any indicator or input that accepts numeric,
waveform, or Boolean data. Wire the dynamic data type to an indicator that can best present the data.
Indicators include a graph, chart, or numeric indicator.
Most other VIs and functions in LabVIEW do not accept the dynamic data type. To use a built-in VI or
function to analyze or process the data the dynamic data type includes, you must convert the dynamic data
type.
Use the Convert from Dynamic Data Express VI, shown at left, to convert the dynamic data
type to numeric, Boolean, waveform, and array data types for use with other VIs and functions. When you
place the Convert from Dynamic Data Express VI on the block diagram, the Configure Convert from
Available for free at Connexions <http://cnx.org/content/col11408/1.1>
21
Dynamic Data dialog box appears. The Configure Convert from Dynamic Data dialog box displays options that let you specify how you want to format the data that the Convert from Dynamic Data Express
VI returns.
When you wire a dynamic data type to an array indicator, LabVIEW automatically places the Convert
from Dynamic Data Express VI on the block diagram. Double-click the Convert from Dynamic Data Express VI to open the Configure Convert from Dynamic Data dialog box to control how the data appears
in the array.
Use the Convert to Dynamic Data Express VI to convert numeric, Boolean, waveform, and array data
types to the dynamic data type for use with Express VIs. When you place the Convert to Dynamic Data
Express VI on the block diagram, the Configure Convert to Dynamic Data dialog box appears. Use this
dialog box to select the kind of data to convert to the dynamic data type.
1.4.3.3.2 Automatically Wiring Objects
LabVIEW automatically wires objects as you place them on the block diagram. You also can automatically
wire objects already on the block diagram. LabVIEW connects the terminals that best match and leaves
terminals that do not match unconnected.
As you move a selected object close to other objects on the block diagram, LabVIEW draws temporary
wires to show you valid connections. When you release the mouse button to place the object on the block
diagram, LabVIEW automatically connects the wires.
Toggle automatic wiring by pressing the spacebar while you move an object using the Positioning tool.
You can adjust the automatic wiring settings by selecting ToolsOptions and selecting Block Diagram
from the top pull-down menu.
1.4.3.3.3 Manually Wiring Objects
When you pass the Wiring tool over a terminal, a tip strip appears with the name of the terminal. In
addition, the terminal blinks in the Context Help window and on the icon to help you verify that you are
wiring to the correct terminal.
22
CHAPTER 1. INTRODUCTION
Figure 1.18
23
Figure 1.19
4. Click the OK button to open the template. You also can double-click the name of the template
VI in the Create new list to open the template.
5. Examine the front panel of the VI. The user interface, or front panel, appears with a gray
background and includes controls and indicators. The title bar of the front panel indicates
that this window is the front panel for the Generate and Display VI.
NOTE :
If the front panel is not visible, you can display the front panel by selecting
WindowShow Front Panel.
6. Examine the block diagram of the VI. The block diagram appears with a white background
and includes VIs and structures that control the front panel objects. The title bar of the block
diagram indicates that this window is the block diagram for the Generate and Display VI.
NOTE : If the block diagram is not visible, you can display the block diagram by selecting
WindowShow Block Diagram.
7.
8.
On the front panel toolbar, click the Run button, shown at left. Notice that a sine wave
appears on the graph.
Stop the VI by clicking the Stop button, shown at left, on the front panel.
Available for free at Connexions <http://cnx.org/content/col11408/1.1>
24
CHAPTER 1. INTRODUCTION
1. If the Controls palette is not visible on the front panel, select WindowShow Controls
Palette to display it.
2. Move the cursor over the icons on the Controls palette to locate the Numeric Controls
palette. Notice that when you move the cursor over icons on the Controls palette, the name
of that subpalette appears in the gray space above all the icons on the palette. When you idle
the cursor over any icon on any palette, the full name of the subpalette, control, or indicator
appears.
3. Click the Numeric Controls icon to access the Numeric Controls palette.
4. Select the knob control on the Numeric Controls palette and place it on the front panel to the
left of the waveform graph. You will use this knob in a later exercise to control the amplitude
of a signal.
5. Select FileSave As and save this VI as Acquiring a Signal.vi in the
C:\Exercises\LabVIEW Basics I directory.
NOTE :
Save all the VIs you edit or create in this course in the C:\Exercises\LabVIEW
Basics I directory.
25
Figure 1.20
4. Click the OK button to apply the current configuration and close the Configure Simulate
Signal dialog box.
5. Move the cursor over the down arrows at the bottom of the Simulate Signal Express VI.
6.
When a double-headed arrow appears, shown at left, click and drag the border of
the Express VI until the Amplitude input appears. Notice how you expanded the Simulate
Signal Express VI to display a new input. Because the Amplitude input appears on the block
diagram, you can configure the amplitude of the sawtooth wave on the block diagram. In
Figure 1.20, notice how Amplitude is an option in the Configure Simulate Signal dialog
box. When inputs, such as Amplitude, appear on the block diagram and in the configuration
dialog box, you can configure the inputs in either location.
26
CHAPTER 1. INTRODUCTION
Move the cursor over the Knob terminal, shown at left, until the Positioning tool
1.
appears.
Notice how the cursor becomes an arrow, or the Positioning tool, shown in
this media. Use the Positioning tool to select, position, and resize objects.
Click the Knob terminal to select it, then drag the terminal to the left of the
Simulate Signal Express VI. Make sure the Knob terminal is inside the loop, shown in this
media. The terminals are representations of front panel controls and indicators. Terminals
are entry and exit ports that exchange information between the front panel and block diagram.
3. Deselect the Knob terminal by clicking a blank space on the block diagram.
2.
4.
Move the cursor over the arrow of the Knob terminal, shown in this media.
Notice how the cursor becomes a wire spool, or the Wiring tool, shown at left. Use the
Wiring tool to wire objects together on the block diagram.
NOTE :
The cursor does not switch to another tool while an object is selected.
When the Wiring tool appears, click the arrow and then click the
Amplitude input of the Simulate Signal Express VI, shown in this media, to wire the two
objects together. Notice that a wire appears and connects the two objects. Data flows along
this wire from the terminal to the Express VI.
6. Select FileSave to save this VI.
5.
To indicate
27
that the VI is running, the Run button changes to a darkened arrow, shown at left. You cannot
edit the front panel or block diagram while the VI runs.
5.
NOTE : Although Abort Execution button looks like a stop button, the Abort Execution button
does not always properly close the VI. National Instruments recommends stopping your VIs using
the Stop button on the front panel. Use the Abort Execution button only when errors prevent you
from terminating the application using the Stop button.
On the block diagram, use the Positioning tool to double-click the wire
that connects the Simulate Signal Express VI to the Waveform Graph terminal shown in
this media.
2. Press the Delete key to delete this wire.
3. If the Functions palette is not visible on the block diagram, select WindowShow Functions
Palette to display it.
1.
Select the Scaling and Mapping Express VI, shown at left, on the Arithmetic
& Comparison palette and place it on the block diagram inside the loop between the
Simulate Signal Express VI and the Waveform Graph terminal. If there is no room between
the Express VI and the terminal, move the Waveform Graph terminal to the right. Notice that
the Configure Scaling and Mapping dialog box automatically opens when you place the
Express VI on the block diagram.
5. Define the value of the scaling factor by entering 10 in the Slope (m) text box. The Configure
Scaling and Mapping dialog box should appear similar to Figure 1.21.
4.
28
CHAPTER 1. INTRODUCTION
Figure 1.21
6. Click the OK button to apply the current configuration and close the Configure Scaling and
Mapping dialog box.
7. Move the cursor over the arrow on the Sawtooth output of the Simulate Signal Express VI.
8.
When the Wiring tool appears, click the arrow and then click the
arrow on the Signals input of the Scaling and Mapping Express VI, shown in this media,
to wire the two objects together.
9. Using the Wiring tool, wire the Scaled Signals output of the Scaling and Mapping Express VI to the Waveform Graph terminal. Notice the wires connecting the Express VIs and
terminals. The arrows on the Express VIs and terminals indicate the direction that the data
flows along these wires. The block diagram should appear similar to Figure 1.22.
29
Figure 1.22
NOTE : The terminals in the block diagram are set to display as icons. To display a terminal
as a data type on the block diagram, right-click the terminal and select View As Icon from
the shortcut menu to remove the checkmark.
30
CHAPTER 1. INTRODUCTION
Figure 1.23
3. Select FileSave to save this VI. You also can press the Ctrl-S keys to save a VI.
4. Return to the front panel, run the VI, and turn the knob control. Notice that the graph plots
the sawtooth wave and the scaled signal. Also notice that the maximum value on the y-axis
automatically changes to be 10 times the knob value. This scaling occurs because you set the
slope to 10 in the Scaling and Mapping Express VI.
5. Click the Stop button.
31
Figure 1.24
3. Click the Scale tab and, in the Scale Range section, change the maximum value to 5.0.
Notice how the knob on the front panel instantly updates to reflect these changes.
4. Click the OK button to apply the current configuration and close the Knob Properties dialog
box.
5. Save this VI.
TIP : As you build VIs, you can experiment with different properties and configurations.
You also can add and delete objects. Remember, you can undo recent edits by selecting
EditUndo or pressing the Ctrl-Z keys.
6. Experiment with other properties of the knob by using the Knob Properties dialog box.
For example, try changing the colors for the Marker Text Color by clicking the color box
located on the Scale tab.
7. Click the Cancel button to avoid applying the changes you made while experimenting. If
you want to keep the changes you made, click the OK button.
32
CHAPTER 1. INTRODUCTION
2. When a double-headed arrow appears, shown in Figure 1.25, click and drag the border of
the plot legend until the second plot name appears.
Figure 1.25
3. Right-click the waveform graph and select Properties from the shortcut menu to display
the Graph Properties dialog box.
4. On the Plots tab, select Sawtooth from the pull-down menu. Click the Line Color color
box to display the color picker. Select a new line color.
5. Select Sawtooth (Scaled) from the pull-down menu.
6. Place a checkmark in the Don't use waveform names for plot names checkbox.
7. In the Name text box, delete the current label and change the name of this plot to Scaled
Sawtooth.
8. Click the OK button to apply the current configuration and close the Graph Properties dialog box. Notice how the plot color on the front panel changes.
9. Experiment with other properties of the graph by using the Graph Properties dialog box.
For example, try disabling the autoscale feature located on the Scales tab.
10. Click the Cancel button to avoid applying the changes you made while experimenting. If
you want to keep the changes you made, click the OK button.
11. Save and close this VI.
33
6 This
34
CHAPTER 1. INTRODUCTION
Click the Hide Optional Terminals and Full Path button located on the lower left corner of the
Context Help window to display the optional terminals of a connector pane and to display the full path to
a VI. Optional terminals are shown by wire stubs, informing you that other connections exist. The detailed
mode displays all terminals, as shown in Figure 1.27.
35
Click the Lock Context Help button to lock the current contents of the Context Help window.
When the contents are locked, moving the cursor over another object does not change the contents of the
window. To unlock the window, click the button again. You also can access this option from the Help menu.
If a corresponding LabVIEW Help topic exists for an object the Context Help window describes, a
blue Click here for more help. link appears in the Context Help window. Also, the More Help button,
shown at left, is enabled. Click the link or the button to display the LabVIEW Help for more information
about the object.
36
CHAPTER 1. INTRODUCTION
LabVIEW Bookshelf, which includes PDF versions of all the LabVIEW manuals and Application
Notes.
Technical support resources on the National Instruments Web site7 , such as the NI Developer Zone8
, the Knowledge Base9 , and the Product Manuals Library10 .
37
Figure 1.28
If the Functions palette is not visible, right-click any blank space on the block diagram to display the Functions palette. Click the thumbtack, shown in this media, in the
upper left corner of the Functions palette to place the palette on the screen.
NOTE : You can right-click a blank space on the block diagram or the front panel to display the
Functions or Controls palettes.
If the Context Help window is not visible, press the Ctrl-H keys to open the Context
Help window. You also can press the Show Context Help Window button, shown in this
media, to open the Context Help window.
38
CHAPTER 1. INTRODUCTION
2. Select the Input palette on the Functions palette and move the cursor over the Express VIs
on the Input palette. Notice that the Context Help window displays information about the
function of each Express VI.
3. From the information provided in the Context Help window, find the Express VI that can
simulate a sine wave signal.
4. Select the Express VI and place it on the block diagram. The Configure Simulate Signal
dialog box appears.
5. Idle the cursor over the various options in the Configure Simulate Signal dialog box, such
as Frequency (Hz), Amplitude, and Samples per second (Hz). Read the information that
appears in the Context Help window.
6. Configure the Simulate Signal Express VI to generate a sine wave with a frequency of 10.7
and amplitude of 2.
7. Notice how the signal displayed in the Result Preview window changes to reflect the configured sine wave.
8. Close the Configure Simulate Signal dialog box by clicking the OK button.
9. Move the cursor over the Simulate Signal Express VI and read the information that appears in the Context Help window. Notice that the Context Help window now displays
the configuration of the Simulate Signal Express VI.
10. Save this VI as Reduce Samples.vi in the C:\Exercises\LabVIEW Basics I directory.
39
Figure 1.29
1. Right-click the Mean output in the Sample Compression Express VI and select
CreateNumeric Indicator from the shortcut menu to create a numeric indicator.
2. Right-click the Mean output of the Sample Compression Express VI and select Insert
Input/Output from the shortcut menu to insert the Enable input.
3. Right-click the Enable input and select CreateControl from the shortcut menu to create
the Enableswitch.
4. Right-click the wire linking the Sine output in the Simulate Signal Express VI to the
Signals input in the Signal Compression Express VI and select CreateGraph Indicator
from the shortcut menu. Notice that you can create controls and indicators from the block diagram. When you create controls and indicators using this method, LabVIEW automatically
creates terminals that are labeled and formatted correctly.
5. Using the Wiring tool, wire the Mean output in the Sample Compression Express VI to the
Sine graph indicator terminal created in the previous step. Notice that the Merge Signals
function appears.
6. Arrange the objects on the block diagram so that they appear similar to Figure 1.29.
TIP :
You can right-click any wire and select Clean Up Wire from the shortcut menu to
automatically route an existing wire.
7. Display the front panel. Notice that the controls and indicators you added automatically
appear on the front panel with labels that correspond to their function.
8. Save this VI.
40
CHAPTER 1. INTRODUCTION
2. Display the block diagram and select the While Loop on the FunctionsExecution
Control palette.
3. Move the cursor to the upper left corner of the block diagram. Place the top left corner of the
While Loop here.
4. Click and drag the cursor diagonally to enclose all the Express VIs and wires, as shown in
Figure 1.30.
Figure 1.30
Notice that the While Loop, shown in this media, appears with a Stop button wired to the condition terminal. This While Loop is configured to stop when the user
clicks the Stop button.
5. Display the front panel and run the VI. Notice that the VI now runs until you click the Stop
button. A While Loop executes the functions inside the loop until the user presses the Stop
button. Refer to Repetition and Loops (Section 3.1) for more information about While Loops.
41
6. Click the Enable switch and notice the change on the graph. Notice how if the Enable switch
is on, the graph displays the reduced signal. If the Enable switch is off, the graph does not
display the reduced signal.
7. Click the Stop button to stop the VI.
If the Build Table Express VI and the Table terminal are not selected
already, click an open space on the block diagram to the left of the Build Table Express VI
and the Table terminal. Drag the cursor diagonally until the selection rectangle encloses the
Build Table Express VI and the Table terminal, shown in this media. A moving dashed
outline called a marquee highlights the Build Table Express VI, the Table terminal, and the
wire joining the two.
4. Drag the objects into the While Loop to the right of the Mean terminal. Notice that the While
Loop automatically resizes to enclose the Build Table Express VI and the Table terminal.
5. Using the Wiring tool, wire the Mean terminal of the Sample Compression Express VI to the
Signals input of the Build Table Express VI. The block diagram should appear similar to
Figure 1.31.
3.
42
CHAPTER 1. INTRODUCTION
Figure 1.31
43
1.8.3 Single-Stepping
Single-step through a VI to view each action of the VI on the block diagram as the VI runs. The singlestepping buttons affect execution only in a VI or subVI in single-step mode. Enter single-step mode by
clicking the Step Over or Step Into button. Move the cursor over the Step Over, Step Into, or Step Out
button to view a tip strip that describes the next step if you click that button. You can single-step through
subVIs or run them normally.
If you single-step through a VI with execution highlighting on, an execution glyph, shown in this
media, appears on the icons of the subVIs that are currently running.
1.8.4 Probes
Use the Probe tool, shown in this media, to check intermediate values on a wire as a VFI runs. When
execution pauses at a node because of single-stepping or a breakpoint, you also can probe the wire that just
executed to see the value that flowed through that wire.
You also can create a custom probe to specify which indicator you use to view the probed data. For
example, if you are viewing numeric data, you can choose to see that data in a chart within the probe. To
create a custom probe, right-click a wire and select Custom ProbeNew from the shortcut menu.
1.8.5 Breakpoints
Use the Breakpoint tool, shown in this media, to place a breakpoint on a VI, node, or wire on the block
diagram and pause execution at that locatiFon. When you set a breakpoint on a wire, execution pauses after
data pass through the wire. Place a breakpoint on the block diagram workspace to pause execution after all
nodes on the block diagram execute. When a VI pauses at a breakpoint, LabVIEW brings the block diagram
to the front and uses a marquee to highlight the node or wire that contains the breakpoint. LabVIEW
highlights breakpoints with red borders for nodes and block diagrams and red bullets for wires. When you
move the cursor over an existing breakpoint, the black area of the Breakpoint tool cursor appears white.
Use the Breakpoint tool to click an existing breakpoint to remove it.
44
CHAPTER 1. INTRODUCTION
Figure 1.32
Notice the Run button on the toolbar appears broken, shown in this media, indicating
that the VI is broken and cannot run.
Figure 1.33
45
b. Select an error description in the Error list window. The Details section describes
the error and in some cases recommends how to correct the error.
c. Click the Help button to display a topic in the LabVIEW Help that describes the error
in detail and includes step-by-step instructions for correcting the error.
d. Click the Show Error button or double-click the error description to highlight the area
on the block diagram that contains the error.
e. Use the Error list window to fix each error.
3. Select FileSave to save the VI.
4. Display the front panel by clicking it or by selecting WindowShow Front Panel.
Click the Highlight Execution button, shown in this media, on the toolbar to
enable execution highlighting.
b.
Click the Step Into button, shown in this media, to start single-stepping. Execution highlighting shows the movement of data on the block diagram from one node
to another using bubbles that move along the wires. Nodes blink to indicate they are
ready to execute.
c.
Click the Step Over button, shown in this media, after each node to step through
the entire block diagram. Each time you click the Step Over button, the current node
executes and pauses at the next node. Data appear on the front panel as you step
through the VI. The VI generates a random number and multiplies it by 10.0. The subVI
adds 100.0 and takes the square root of the result.
d.
When a blinking border surrounds the entire block diagram, click the Step Out
button, shown in this media, to stop single-stepping through the Debug Exercise
(Main) VI.
When the Debug Exercise (Sub) VI blinks, click the Step Into button. Notice
the run button on the subVI.
Display the Debug Exercise (Main) VI block diagram by clicking it. A green
glyph, shown in this media, appears on the subVI icon on the Debug Exercise (Main)
VI block diagram, indicating that the subVI is running.
d. Display the Debug Exercise (Sub) VI block diagram by clicking it.
e. Click the Step Out button twice to finish single-stepping through the subVI block diagram. The Debug Exercise (Main) VI block diagram is active.
f. Click the Step Out button to stop single-stepping.
c.
46
CHAPTER 1. INTRODUCTION
a.
Use the Probe tool, shown this media, to click any wire. A window similar to
Figure 1.34 appears.
Figure 1.34
LabVIEW numbers the Probe window automatically and displays the same number in
a glyph on the wire you clicked.
b. Single-step through the VI again. The Probe window displays data passed along the
wire.
6. Place breakpoints on the block diagram to pause execution at that location.
Use the Breakpoint tool, shown in this media, to click nodes or wires. Place a
breakpoint on the block diagram to pause execution after all nodes on the block diagram
execute.
b. Click the Run button to run the VI. When you reach a breakpoint during execution, the
VI pauses and the Pause button on the toolbar appears red.
a.
Click the Continue button, shown this media, to continue running to the next
breakpoint or until the VI finishes running.
d. Use the Breakpoint tool to click the breakpoints you set and remove them.
c.
47
15 This
48
CHAPTER 1. INTRODUCTION
1.10.1 Summary
Virtual instruments (VIs) contain three main components-the front panel, the block diagram, and the
icon and connector pane.
The front panel is the user interface of a VI and specifies the inputs and displays the outputs of the VI.
The block diagram contains the graphical source code composed of nodes, terminals, and wires.
Use the Tools palette to create, modify, and debug VIs. Press the Shift key and right-click to display
a temporary version of the Tools palette at the location of the cursor.
Use the Controls palette to place controls and indicators on the front panel. Right-click an open space
on the front panel to display the Controls palette.
Use the Functions palette to place VIs and functions on the block diagram. Right-click an open space
on the block diagram to display the Functions palette.
Use the Search button on the Controls and Functions palettes to search for controls, VIs, and functions.
All LabVIEW objects and empty space on the front panel and block diagram have associated shortcut
menus, which you access by right-clicking an object, the front panel, or the block diagram.
Use the Help menu to display the Context Help window and the LabVIEW Help, which describes
most palettes, menus, tools, VIs, functions, and features.
Select HelpSearch the LabVIEW Bookshelf to display the LabVIEW Bookshelf, which you can use
to search PDF versions of all the LabVIEW manuals and Application Notes.
You build the front panel with controls and indicators, which are the interactive input and output
terminals of the VI, respectively.
Control terminals have a thicker border than indicator terminals. To change a control to an indicator
or to change an indicator to a control, right-click the object and select Change to Indicator or Change
to Control from the shortcut menu.
The block diagram is composed of nodes, terminals, and wires.
The broken Run button appears on the toolbar to indicate the VI is broken. Click the broken Run button
to display the Error list window, which lists all the errors.
Use execution highlighting, single-stepping, probes, and breakpoints to debug VIs by animating the
flow of data through the block diagram.
Frequently used menu options have equivalent keyboard shortcuts. For example, to save a VI, you
can select FileSave or press the Ctrl-S keys. Common keyboard shortcuts include the following:
Ctrl-R - Runs a VI.
Ctrl-E - Toggles between the front panel and block diagram.
Ctrl-H - Toggles display of the Context Help window.
Ctrl-B - Removes all broken wires.
Ctrl-F - Finds VIs, globals, functions, text, or other objects loaded in memory or in a specified list of
VIs.
To increment or decrement numeric controls faster, use the Operating or Labeling tools to place the
cursor in the control and press the Shift key while pressing the up or down arrow keys.
You can disable the debugging tools to reduce memory requirements and to increase performance
slightly. Select FileVI Properties, select Execution from the top pull-down menu, and remove
the checkmark from the Allow Debugging checkbox.
49
1.10.2.2 Wiring
Click the Show Context Help Window button on the toolbar to display the Context Help window.
Use the Context Help window to determine which terminals are required. Required terminals are
bold, recommended connections are plain text, and optional connections are dimmed.
Press the spacebar to toggle the wire direction.
To move objects one pixel, press the arrow keys. To move objects several pixels, press the Shift key
while you press the arrow keys.
To cancel a wire you started, press the Esc key, right-click, or click the terminal where you started the
wire.
Use the tip strips that appear as you move the Wiring tool over terminals.
Display the connector pane by right-clicking the node and selecting Visible ItemsTerminals from
the shortcut menu.
You can bend a wire by clicking to tack the wire down and moving the cursor in a perpendicular
direction. To tack down a wire and break it, double-click.
Figure 1.35: 1. Tack Down a Wire by Clicking, 2. Tack and Break the Wire by Double-clicking
1.10.2.3 Editing
To duplicate an object, press the Ctrl key while using the Positioning tool to click and drag a selection.
To restrict an objects direction of movement horizontally or vertically, use the Positioning tool to
select the object and press the Shift key while you move the object.
To keep an object proportional to its original size as you resize it, press the Shift key while you drag
the resizing handles or circles.
To resize an object as you place it on the front panel, press the Ctrl key while you click to place the
object and drag the resizing handles or circles.
To replace nodes, right-click the node and select Replace from the shortcut menu.
To display the block diagram of a subVI from the calling VI, press the Ctrl key and use the Operating
or Positioning tool to double-click the subVI on the block diagram.
To display the front panel of a subVI from the calling VI, use the Operating or Positioning tool to
double-click the subVI on the block diagram. You also can select BrowseThis VI's SubVIs.
After you type a label, press the Enter key to end text entry.
To add items quickly to ring controls and Case structures, press the Shift-Enter keys after each item.
Pressing Shift-Enter accepts the item and positions the cursor to add the next item. Refer to Making
Decisions in a VI16 for more information about Case structures.
16 "Case
Structures" <http://cnx.org/content/m12245/latest/>
50
CHAPTER 1. INTRODUCTION
To copy the color of one object and transfer it to a second object without using a color picker, use the
Color Copy tool to click the object whose color you want to copy. Use the Coloring tool to click the
object to which you want to apply the color. You also can copy the color of one object by using the
Coloring tool and pressing the Ctrl key.
Select EditUndo if you make a mistake.
To create more blank space on the block diagram, press the Ctrl key while you use the Positioning
tool to draw a rectangle on the block diagram.
1.10.2.4 Debugging
Chapter 2
Modular Programming
2.1 Modular Programming1
The power of LabVIEW lies in the hierarchical nature of the VI. After you create a VI, you can use it on
the block diagram of another VI. There is no limit on the number of layers in the hierarchy. Using modular
programming helps you manage changes and debug the block diagram quickly.
A VI within another VI is called a subVI. A subVI corresponds to a subroutine in text-based programming languages. When you double-click a subVI, a front panel and block diagram appear, rather than a
dialog box in which you can configure options. The front panel includes controls and indicators that might
look familiar. The block diagram includes wires, front panel icons, functions, possibly subVIs, and other
LabVIEW objects that also might look familiar.
The upper right corner of the front panel and block diagram displays the icon for the VI. This icon is the
same as the icon that appears when you place the VI on the block diagram.
51
52
Figure 2.1
You can create a subVI that performs that operation and call the subVI twice. The example in Figure 2.2
calls the Temperature VI as a subVI twice on its block diagram and functions the same as the previous
block diagram.You also can reuse the subVI in other VIs. Refer to Repetition and Loops (Section 3.1) for
more information about using loops to combine common operations.
Figure 2.2
Refer to the LabVIEW Basics II: Development Course Manual for more information about application
development. The following pseudo-code and block diagrams demonstrate the analogy between subVIs
and subroutines.
Function Code
53
Table 2.1
54
Figure 2.3
Depending on the type of monitor you use, you can design a separate icon for monochrome, 16-color,
and 256-color mode. LabVIEW uses the monochrome icon for printing unless you have a color printer.
Use the Edit menu to cut, copy, and paste images from and to the icon. When you select a portion of
the icon and paste an image, LabVIEW resizes the image to fit into the selection area. You also can drag a
graphic from anywhere in your file system and drop it in the upper right corner of the front panel or block
diagram. LabVIEW converts the graphic to a 32 32 pixel icon.
Use the Copy from option on the right side of the Icon Editor dialog box to copy from a color icon
to a black-and-white icon and vice versa. After you select a Copy from option, click the OK button to
complete the change.
NOTE : If you do not draw a complete border around a VI icon, the icon background appears
transparent. When you select the icon on the block diagram, a selection marquee appears around
each individual graphic element in the icon.
Use the tools on the left side of the Icon Editor dialog box to create the icon design in the editing
area. The normal size image of the icon appears in the appropriate box to the right of the editing area. The
following tasks can be performed with these tools:
Use the Rectangle tool to draw a rectangular border in the foreground color. Double-click this
tool to frame the icon in the foreground color.
Use the Filled Rectangle tool to draw a rectangle with a foreground color frame and filled
with the background color. Double-click this tool to frame the icon in the foreground color and fill it
with the background color.
Available for free at Connexions <http://cnx.org/content/col11408/1.1>
55
Use the Select tool to select an area of the icon to cut, copy, move, or make other changes.
Double-click this tool and press the <Delete> key to delete the entire icon.
Use the Text tool to enter text into the icon. Double-click this tool to select a different font.
(Windows) The Small Fonts option works well in icons.
Use the Foreground/Background tool to display the current foreground and background
colors. Click each rectangle to display a color palette from which you can select new colors.
Use the options on the right side of the editing area to perform the following tasks:
The menu bar in the Icon Editor dialog box contains more editing options such as Undo, Redo,
Cut, Copy, Paste , and Clear .
Figure 2.4
56
To change the spatial arrangement of the connector pane patterns, right-click the connector pane and
select Flip Horizontal, Flip Vertical, or Rotate 90 Degrees from the shortcut menu.
Clusters" <http://cnx.org/content/m12231/latest/>
content is available online at <http://cnx.org/content/m12207/1.2/>.
57
Figure 2.5
2. (Optional) Select WindowTile Left and Right to display the front panel and block diagram side by side or WindowTile Up and Down to display the front panel and block
diagram stacked.
3. Create a numeric control. You will use this control to enter the value for degrees Celsius.
a. Select ControlsNumeric Controls to display the Numeric Controls palette. If
the Controls palette is not visible, right-click an open space on the front panel
workspace to display it.
b.
Select the Numeric Control. Move the control to the front panel and click to
place the control.
c.
Type deg C in the label of the control and press the <Enter> key or click the Enter
button, shown in this media, on the toolbar. If you do not type the name immediately,
LabVIEW uses a default label.
NOTE : You can edit a label at any time by double-clicking the label, using the Labeling tool,
or right-clicking and selecting Properties from the shortcut menu to display the property
dialog box.
4. Create a numeric indicator. You will use this indicator to display the value for degrees
Fahrenheit.
Select the Numeric Indicator located on the ControlsNumeric Indicators
palette.
b. Move the indicator to the front panel and click to place the indicator.
c. Type deg F in the label and press the <Enter> key or click the Enter button.
a.
2.
58
3.
6.
Use the Wiring tool, shown in this media, to wire the icons as shown in Figure 2.6.
Figure 2.6
To wire from one terminal to another, use the Wiring tool to click the first terminal,
move the tool to the second terminal, and click the second terminal. You can start
wiring at either terminal.
You can bend a wire by clicking to tack down the wire and moving the cursor in a
perpendicular direction. Press the spacebar to toggle the wire direction.
To identify terminals on the nodes, right-click the Multiply and Add functions and
select Visible ItemsTerminals from the shortcut menu to display the connector
pane on the block diagram. Return to the icons after wiring by right-clicking the functions and selecting Visible ItemsTerminals from the shortcut menu to remove
the checkmark.
When you move the Wiring tool over a terminal, the terminal area blinks, indicating
that clicking will connect the wire to that terminal and a tip strip appears, displaying
the name of the terminal. If the Context Help window is open, the terminal area also
blinks in the Context Help window.
To cancel a wire you started, press the <Esc> key, right-click, or click the terminal
where you started the wire.
7. Display the front panel by clicking it or by selecting WindowShow Front Panel.
8. Save the VI as Convert C to F.vi in the C:\Exercises\LabVIEW Basics I directory.
59
a.
Use the Operating tool, shown in this media, or the Labeling tool to double-click
the numeric control and type a new number.
2.
Double-click the Rectangle tool, shown in this media, to redraw the border.
4.
5. Create the icon in Figure 2.7.
Figure 2.7
Double-click the Text tool, shown in this media, and change the font to Small
Fonts .
b. Use the Text tool to click the editing area where you will begin typing.
c. Type C and F. While the text is active, you can move the text by pressing the arrow keys.
a.
Use the Pencil tool, shown in this media, to create the arrow.
To draw horizontal or vertical straight lines, press the <Shift> key while you
use the Pencil tool to drag the cursor.
e. Use the Select tool and the arrow keys to move the text and arrow you created.
f. Select the B & W icon and click the 256 Colors button in the Copy from section
to create a black and white icon, which LabVIEW uses for printing unless you have a
color printer.
d.
NOTE :
60
61
dimmed. The labels of optional terminals do not appear if you click the Hide Optional Terminals and
Full Path button in the Context Help window.
You can designate which inputs and outputs are required, recommended, and optional to prevent users
from forgetting to wire subVI terminals.
Right-click a terminal in the connector pane and select This Connection Is from the shortcut menu.
A checkmark indicates the terminal setting. Select Required, Recommended, or Optional .
For terminal inputs, required means that the block diagram on which you placed the subVI will be
broken if you do not wire the required inputs. Required is not available for terminal outputs. For terminal
inputs and outputs, recommended or optional means that the block diagram on which you placed the subVI
can execute if you do not wire the recommended or optional terminals. If you do not wire the terminals,
the VI does not generate any warnings.
LabVIEW sets inputs and outputs of VIs you create to Recommended by default. Set a terminal setting
to required only if the VI must have the input or output to run properly. Refer to the Read File function
located on the FunctionsAll FunctionsFile I/O palette for examples of required, recommended,
and optional inputs and outputs.
Figure 2.8
Type Temperature in the label and press the <Enter> key or click the Enter
button on the toolbar, shown at left.
62
63
Figure 2.9
2.
Place the DAQ Assistant Express VI, located on the FunctionsInput palette, on
the block diagram. When you place this Express VI on the block diagram the DAQ Assistant
configuration dialog box appears.
a. Select Analog InputVoltage for the type of measurement to make.
b. Select Dev1ai0 (or Dev2ai0) for the physical channel and click the Finish button.
c. You must multiply the temperature by 100 to convert it from voltage to Celsius. On the
Settings tab, select Custom ScalingCreate New. Select a Linear scale. Name the
scale Temperature. Enter a slope scale of 100. Click the OK button.
d. Set min = 0. Set max = 100
e. Select the Acquire 1 Sample option on the Task Timing tab. Click the OK button.
NOTE : If you do not have a DAQ device with a temperature sensor connected to your
computer, use the (Demo) Read Voltage VI, located in the C:\Exercises LabVIEW
Basics I directory.
3.
Place the Convert from Dynamic Data Express VI, located on the
FunctionsSignal Manipulation palette, on the block diagram. This VI converts
the dynamic data type. In the configuration dialog box, select Single scalar in the
Resulting data type listbox.
4.
5.
64
Figure 2.10
a. Right-click the icon in the upper right corner of the front panel and select Edit Icon
from the shortcut menu. The Icon Editor dialog box appears.
Double-click the Select tool, shown at left, on the left side of the Icon Editor
dialog box to select the default icon.
c. Press the <Delete> key to remove the default icon.
b.
d.
Double-click the Rectangle tool, shown at this media, to redraw the border.
Use the Pencil tool, shown in this media, to draw an icon that represents the
thermometer.
f. Use the Foreground and Fill tools to color the thermometer red.
NOTE : To draw horizontal or vertical straight lines, press the <Shift> key while you
use the Pencil tool to drag the cursor.
e.
Double-click the Text tool, shown in this media, and change the font to Small
Fonts.
h. Type Temp. Reposition the text if necessary.
g.
65
i. Select the B & W icon and select 256 Colors in the Copy from section to create a
black and white icon, which LabVIEW uses for printing unless you have a color printer.
j. When the icon is complete, click the OK button. The icon appears in the upper right
corner of the front panel.
2. Right-click the icon and select Show Connector from the shortcut menu and assign terminals
to the switch and the thermometer.
a.
b.
c.
d.
e.
Figure 2.11
The new subVI uses a default pattern for the connector pane and a default icon. Double-click the subVI
to edit the connector pane and icon, and to save the subVI.
NOTE : Do not select more than 28 objects to create a subVI because 28 is the maximum number of
connections on a connector pane.
7 This
66
8 This
Chapter 3
Figure 3.1
The While Loop is located on the FunctionsExecution Control palette. Select the While Loop from
the palette then use the cursor to drag a selection rectangle around the section of the block diagram you
want to repeat. When you release the mouse button, a While Loop boundary encloses the section you
selected.
Add block diagram objects to the While Loop by dragging and dropping them inside the While Loop.
NOTE :
The While Loop executes the subdiagram until the conditional terminal, an input terminal, receives
a specific Boolean value. The default behavior and appearance of the conditional terminal is Stop If True,
shown in this media. When a conditional terminal is Stop If True, the While Loop executes its subdiagram until the conditional terminal receives a True value.
The iteration terminal, an output terminal, shown in this media, contains the number of completed iterations. The iteration count always starts at zero. During the first iteration, the iteration terminal
returns 0.
In the block diagram in Figure 3.2, the While Loop executes until the subVI output is greater than or
equal to 10.00 and the Enable control is True. The And function returns True only if both inputs are True.
Otherwise, it returns False.
1 This
67
68
Figure 3.2
In the previous example (Figure 3.2), there is an increased probability of an infinite loop. Generally, the
desired behavior is to have one condition met to stop the loop, rather than requiring both conditions to be
met.
You can change the behavior and appearance of the conditional terminal by right-clicking the terminal or the border of the While Loop and selecting Continue if True, shown at left. You also can use the
Operating tool to click the conditional terminal to change the condition. When a conditional terminal is
Continue if True, the While Loop executes its subdiagram until the conditional terminal receives a False
value, as shown in Figure 3.3.
Figure 3.3
The While Loop executes until the subVI output is less than 10.00 or the Enable control is False.
69
Figure 3.4
Only the last value of the iteration terminal displays in the Iteration Number indicator.
Figure 3.5
The For Loop is located on the FunctionsAll FunctionsStructures palette. You also can
place a While Loop on the block diagram, right-click the border of the While Loop, and select Replace
with For Loop from the shortcut menu to change a While Loop to a For Loop. The value in the count
terminal (an input terminal), shown in this media, indicates how many times to repeat the subdiagram.
The iteration terminal (an output terminal), shown in this media, contains the number of completed iterations. The iteration count always starts at zero. During the first iteration, the iteration terminal
returns 0.
The For Loop differs from the While Loop in that the For Loop executes a set number of times. A While
Loop stops executing the subdiagram only if the value at the conditional terminal exists.
The For Loop in Figure 3.6 generates a random number every second for 100 seconds and displays the
random numbers in a numeric indicator.
2 This
70
Figure 3.6
Figure 3.7
3 "Error
Clusters" <http://cnx.org/content/m12231/latest/>
71
If you wire two different numeric data types to a numeric function that expects the inputs to be the
same data type, LabVIEW converts one of the terminals to the same representation as the other terminal.
LabVIEW chooses the representation that uses more bits. If the number of bits is the same, LabVIEW
chooses unsigned over signed.
In the example in Figure 3.8, a 32-bit signed integer (I32) and a double-precision, floating-point numeric
value (DBL) are wired to the Divide function. The 32-bit signed integer is coerced since it uses fewer bits
than the double-precision, floating-point numeric value.
Figure 3.8
To change the representation of a numeric object, right-click the object and select Representation from
the shortcut menu. Select the data type that best represents the data.ut data types.
When LabVIEW converts double-precision, floating-point numeric values to integers, it rounds to the
nearest integer. LabVIEW rounds x.5 to the nearest even integer. For example, LabVIEW rounds 2.5 to 2
and 3.5 to 4.
Refer to the Data Types section of Introduction to LabVIEW, of this manual or to the LabVIEW Help for
more information about data types.
Figure 3.9
4 This
72
Figure 3.10
73
2. Save this VI as Timed Temperature.vi in the C:\Exercises\LabVIEW Basics I directory.
3. Run the VI. The first reading might take longer than one second to retrieve if the computer
needs to configure the DAQ device.
4. If time permits, complete the following optional and challenge steps, otherwise close the VI.
3.3.3 Optional
1. Build a VI that generates random numbers in a While Loop and stops when you click a stop
button on the front panel.
2. Save the VI as General While Loop.vi in the C:\Exercises\LabVIEW Basics I directory.
3.3.4 Challenge
1. Modify the General While Loop VI to stop when the stop button is clicked or when the
While Loop reaches a number of iterations specified by a front panel control.
2. Select FileSave As to save the VI as Combo While-For Loop.vi in the
C:\Exercises\LabVIEW Basics I directory.
74
5 This
Chapter 4
Customizing VIs
4.1 Configuring the Appearance of Front Panels1
After you build a VI, you can configure the appearance of the front panel so users can more easily operate
the VI. For example, you can hide the menu bar and scrollbars to create VIs that look and behave like
standard dialog boxes for each platform.
Select FileVI Properties to configure the appearance and behavior of a VI. You also can right-click
the VI icon on the front panel or block diagram and select VI Properties from the shortcut menu. You
cannot access the VI Properties dialog box while a VI is running. Refer to the LabVIEW Basics II: Development Course Manual for more information about configuring the behavior of VIs.
Use the Category pull-down menu at the top of the VI Properties dialog box to select from several
different option categories, including the following:
General - Displays the current path where a VI is saved, its revision number, revision history, and
any changes made since the VI was last saved. You also can use this page to edit the icon or the
size of the alignment grid for the VI.
Documentation - Use this page to add a description of the VI and link to a help file topic. Refer to
the original Thermometer VI (Section 2.5) for more information about documenting VIs.
Security - Use this page to lock or password-protect a VI.
Window Appearance - Use this page to configure various window settings.
Window Size - Use this page to set the size of the window.
Execution - Use this page to configure how a VI runs. For example, you can configure a VI to run
immediately when it opens or to pause when called as a subVI.
Editor Options - Use this page to set the size of the alignment grid for the current VI and to change
the style of control or indicator LabVIEW creates when you right-click a terminal and select
CreateControl or CreateIndicator from the shortcut menu.
75
76
By default, the VI window title is the same as the VI name. You can customize the VI window title to
make it more descriptive than the VI filename. This is useful for localized VIs so the VI window title can
be translated to the local language. Remove the checkmark from the Same as VI Name checkbox to edit
Window title.
To configure the window appearance, select one of the following window styles. A graphical representation of each style displays on the right when you select the style.
Top-level Application Window - Shows the title bar and menu bar, hides the scrollbars and toolbar,
allows the user to close the window, allows run-time shortcut menus, does not allow resizing,
and shows the front panel when called.
Dialog - The VI functions as a dialog box in the operating system, so the user cannot interact with
other LabVIEW windows while this VI window is open. This option does not prevent you from
bringing windows of other applications to the front. (UNIX) You cannot make a window stay in
front of all other windows. Dialog style windows stay on top, have no menu bar, scrollbars, or
toolbar, allow the user to close the window but not resize it, allow run-time shortcut menus, and
show the front panel when called. Also, if a Boolean parameter on the front panel is associated
with the <Enter> or <Return> key, LabVIEW highlights the parameter with a dark border.
Default - Same window style used in the LabVIEW development environment.
Custom - Custom window style.
Customize - Displays the Customize Window Appearance dialog box.
You also can use tab controls to make the front panel more usable.
77
When LabVIEW calls a subVI, ordinarily the subVI runs without opening its front panel. If you want a
single instance of the subVI to open its front panel when called, use the SubVI Node Setup dialog box. If
you want every instance of the subVI to open its front panel when called, use the VI Properties dialog
box.
Figure 4.1
3 This
78
The indicator to the right of the thermometer is a digital display belonging to the thermometer. Right-click the thermometer and select Visible ItemsDigital Display from
the shortcut menu to display the digital value.
Change # of data values to signed 32-bit integer (I32) representation.
Figure 4.2
a.
Place the Thermometer VI from a previous exercise (Section 2.5) on the block
diagram. This VI acquires the current temperature value.
b.
c.
d.
79
b. Select FileVI Properties.
c. Select Window Appearance from the Category pull-down menu.
d. Click the Customize button. Configure the window appearance as shown in the dialog
box (Figure 4.3).
Figure 4.3
e. Click the OK button twice and save and close the subVI. If the front panel is not closed,
it will not close after the subVI runs.
4. Run the Use Pop-up Graph VI. After the VI acquires 10 seconds of temperature data, the
front panel of the Pop-up Graph VI displays and plots the temperature data. Click the DONE
button to return to the calling VI.
5. Change the window appearance settings for the Pop-up Graph subVI to the Dialog window
style.
6. Save and close the subVI.
7. Run the Use Pop-up Graph VI again. The Pop-up Graph subVI front panel window behaves
as a dialog box. For example, the window stays on top of all other windows and uses the
system colors.
8. Close all open VIs.
80
Select the shortcut key you want to assign to the control in the Key Assignment section. The front panel
control names that appear in the Current Assignments listbox correspond to the owned labels of those
controls.
To prevent users from accessing a control by pressing the <Tab> key while the VI runs, place a checkmark in the Skip this control when tabbing checkbox.
Figure 4.4
The front panel contains four Boolean buttons (Figure 4.4). The mechanical action of the first
three buttons is Latch When Pressed. This setting changes the control value when you click
it and retains the new value until the VI reads it once. At this point the control reverts to
its default value, even if you keep pressing the mouse button. This action is similar to a
circuit breaker and is useful for stopping While Loops or for getting the VI to perform an
action only once each time you set the control. The mechanical action of the Stop button
is Latch When Released. This setting changes the control value only after you release the
mouse button within the graphical boundary of the control. When the VI reads it once, the
control reverts to the old value. This action guarantees at least one new value. This action is
similar to dialog box buttons and system buttons.
2. Right-click a control and select AdvancedKey Navigation from the shortcut menu to display the Key Navigation dialog box.
3. In the Key Assignment section, assign the shortcut key shown in the Figure 4.4.
4. Repeat list, item 2, p. 80 and list, item 3, p. 80 for each control.
81
Figure 4.5
The Display and Log Temp VI simulates a temperature measurement every 500
ms, plots it on a strip chart, and logs it to a file.
The Display Logged Temp VI opens a file that you select, reads the logged data,
and displays them on a graph.
82
Before you change VI properties, save a backup of the VI to a new location by selecting FileSave with
Options to avoid situations like the previous examples.
Select the Development Distribution option to save the VI to a new location along with its entire
hierarchy. You also can include the vi.lib files in the save. After you save the backup VI, change the VI
properties of the original VI. If you encounter a problem, you can return to the backup VI.
NOTE : If you select the Remove diagrams option, you remove the source code of the VI. Select
this option only if you never need to edit the VI again. Before you save a VI without the block
diagrams, save a backup of the VI with the block diagrams.
If you already saved a development VI with properties that make the VI difficult to edit, refer to the Edit
Me VI (Section 4.7) exercise for more information about editing the VI.
83
Figure 4.6
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
The VI is already running when it opens. While the VI runs, you cannot use the menu bar,
toolbar, or keyboard shortcuts to edit or abort the VI.
Click the Start button. After 10 seconds, the VI stops running and quits LabVIEW.
Relaunch LabVIEW and open a blank VI.
If the VI you want to edit either does not have subVIs or you do not know what it contains,
complete list, item 5, p. 83 through list, item 13, p. 83. However, if the VI you want to edit
has subVIs, open one of the subVIs and modify the block diagram to break the subVI. For
example, place an Add function on the block diagram and do not wire the inputs. Open the VI
you want to edit. Because its subVI is nonexecutable, the VI that calls it is also nonexecutable.
It opens in edit mode and the Run button appears broken. Make sure to fix the subVI after
you edit the calling VI.
Display the block diagram of the new VI.
Place the Edit Me VI, which is already built, on the block diagram. The front panel for the
Edit Me VI displays. Although you can display the block diagram of the Edit Me VI, you
cannot edit it.
Select OperateChange to Edit Mode. A dialog box informs you that the VI is locked.
Click the Unlock button. You now can edit the VI. You also can unlock a VI by selecting
FileVI Properties and selecting Security from the Category pull-down menu.
Select and delete the Quit LabVIEW function from the block diagram.
Save and close the Edit Me VI. Close the new VI and do not save changes.
Open the Edit Me VI again.
After the VI runs, try to edit it.
Close the Edit Me VI.
4.8.1 Adding VIs and Controls to the User Library and the Instrument Library
The simplest method for adding VIs and controls to the Controls and Functions palettes is to save them in
the labview\user.lib directory. When you restart LabVIEW, the FunctionsExpress User Libraries
8 This
84
and ControlsExpress User Controls palettes contain subpalettes for each directory, VI library (.llb),
or menu (.mnu) file in the labview\user.lib directory, and icons for each file in the labview\user.lib
directory. After you add files to or remove files from specific directories, LabVIEW automatically updates
the palettes when you restart LabVIEW.
The FunctionsAll FunctionsInstrument I/O palette corresponds to the labview\instr.lib directory. Save instrument drivers in this directory to add them to the Functions palette.
When you add VIs or controls to the Controls and Functions palettes using this method, you cannot
set the name of each subpalette or the exact location of the VIs or controls on the palettes.
Refer to the LabVIEW User Manual and the LabVIEW Help for more information about palette views.
85
9 This
86
Chapter 5
Plotting Data
5.1 Waveform Charts1
The waveform chart is a numeric indicator that displays one or more plots. The waveform chart is located
on the ControlsGraph Indicators palette. Waveform charts can display single or multiple plots. Figure 5.1 shows the elements of a multiplot waveform chart. Two plots are displayed: Raw Data and Running
Avg.
Figure 5.1
Charts use three different modes to scroll data, as shown in the Figure 5.2. Right-click the chart and select
AdvancedUpdate Mode from the shortcut menu. Select Strip Chart, Scope Chart, or Sweep Chart . The
default mode is Strip Chart.
Figure 5.2
A strip chart shows running data continuously scrolling from left to right across the chart. A scope
chart shows one item of data, such as a pulse or wave, scrolling partway across the chart from left to the
1 This
87
88
right. A sweep chart is similar to an EKG display. A sweep chart works similarly to a scope except it
shows the older data on the right and the newer data on the left separated by a vertical line. The scope
chart and sweep chart have retracing displays similar to an oscilloscope. Because there is less overhead
in retracing a plot, the scope chart and the sweep chart display plots significantly faster than the strip
chart.
Figure 5.3
Waveform charts can display multiple plots. Bundle multiple plots together using the Bundle function
located on the Cluster palette. In Figure 5.4, the Bundle function bundles the outputs of the three VIs to
plot on the waveform chart.
Figure 5.4
The waveform chart terminal changes to match the output of the Bundle function. To add more plots,
use the Positioning tool to resize the Bundle function.
89
Figure 5.5
a. Place the vertical toggle switch, located on the ControlsButtons & Switches
palette, on the front panel. Label this switch Power. You use the switch to stop the
acquisition.
b. Place a waveform chart, located on the ControlsGraph Indicators palette, on the
front panel. Label the chart Temperature History. The waveform chart displays the
temperature in real time.
The waveform chart legend labels the plot Plot 0. Use the Labeling tool to
triple-click Plot 0 in the chart legend, and change the label to Temp.
d. The temperature sensor measures room temperature. Use the Labeling tool to doubleclick 10.0 in the y-axis and type 90 to rescale the chart. Leave the x-axis in its default
state.
e. Change 10.0 in the y-axis to 70.
f. Label the y-axis Temp (Deg F) and the x-axis Time (sec).
c.
90
Figure 5.6
a.
b.
c.
the
91
Figure 5.7
d. Select the Scales tab and select the Time (sec) (X-axis) in the top pull-down menu.
Set the scale options as shown in Figure 5.8. Set the Multiplier to 0.50 to account for
the 500 ms Wait function.
92
Figure 5.8
e. In the Scales tab, select the Deg F (Y-axis) in the top pull-down menu. Set the scale
options as shown in Figure 5.9.
93
Figure 5.9
When a VI is running, you can select Clear Chart from the shortcut menu.
3. Each time you run the VI, you first must turn on the vertical toggle switch and then click the
Run button due to the current mechanical action of the switch. Modify the mechanical action
of the vertical toggle switch so temperature is plotted on the graph each time you run the VI,
without having to first set the toggle switch.
a. Stop the VI if it is running.
b. Use the Operating tool to click the vertical toggle switch and turn it to the ON position.
c. Right-click the switch and select Data OperationsMake Current Value Default
from the shortcut menu. This sets the ON position as the default value.
d.
94
Figure 5.10
a.
3 This
Press the <Ctrl> key while you click the Thermometer VI and drag it outside
the While Loop to create a copy of the subVI. The Thermometer VI returns one tempera-
95
ture measurement from the temperature sensor and initializes the left shift registers
before the loop starts.
b.
Place
the
Compound Arithmetic
function,
located
on
the
FunctionsArithmetic & ComparisonExpress Numeric palette, on the block
diagram. This function returns the sum of the current temperature and the two
previous temperature readings. Use the Positioning tool to resize the function to have
three left terminals.
c.
d.
Figure 5.11
a.
96
5.3.6 Optional
Customize the waveform chart as shown in Figure 5.12. You can display a plot legend, a scale
legend, a graph palette, a digital display, and a scrollbar. By default, a waveform chart displays
the plot legend.
Figure 5.12
NOTE : The waveform chart size has a direct effect on the display of axis scales. Increase the
waveform chart size if you encounter problems while customizing the axis.
Available for free at Connexions <http://cnx.org/content/col11408/1.1>
97
2. Right-click the waveform chart and select Visible ItemsScale Legend from the shortcut
menu to display the scale legend, as shown in Figure 5.13. You can place the scale legend
anywhere on the front panel.
Figure 5.13: 1. X-axis, 2. Y-axis, 3. Scale Labels, 4. Scale Lock Button, 5. Autoscale Button, 6. Scale Format
Button
Figure 5.14: 1. Cursor Movement Tool, 2. Zoom Button, 3. Panning Tool, 4. Zoom Pull-down Menu
Use the Zoom button on the graph palette to zoom in or out of sections of the chart or the
whole chart. Use the Panning tool to pick up the plot and move it around on the display.
Use the Cursor Movement tool to move the cursor on the graph.
6. Run the VI. While the VI runs, use the buttons in the scale legend and graph palette to modify
the waveform chart.
NOTE : If you modify the axis labels, the display might become larger than the maximum
size that the VI can correctly present.
7. Use the Operating tool to click the Power switch and stop the VI.
8. Save and close the VI.
98
Figure 5.15
The graphs located on the ControlsGraph Indicators palette include the waveform graph and XY
graph. The waveform graph plots only single-valued functions, as in y = f ( x ), with points evenly distributed along the x-axis, such as acquired time-varying waveforms. XY graphs display any set of points,
evenly sampled or not.
Resize the plot legend to display multiple plots. Use multiple plots to save space on the front panel and
to make comparisons between plots. XY and waveform graphs automatically adapt to multiple plots.
99
Figure 5.16
100
Figure 5.17
a.
b.
101
Figure 5.18
Figure 5.19
102
2. If time permits, complete the optional steps. Otherwise, close the VI.
5.5.6 Optional
1. Right-click the waveform graph and select Visible ItemsGraph Palette from the shortcut menu to display the graph palette. Click the Zoom button to see the data on the graph in
more detail.
2. Right-click the graph and select Visible ItemsScale Legend from the shortcut menu
to display the scale legend.
3. Return to the block diagram. Create a multiple-plot waveform graph by building a 2D array
of the data type normally passed to a single-plot graph. Modify the block diagram as shown
in Figure 5.20.
Figure 5.20
a.
103
diagram. Use this function to build an array of points that represents one cycle of a
sine wave.
b.
Figure 5.21
c. Click and drag a selection rectangle on the graph. When you release the mouse button,
the graph display zooms in on the selected area.
d. You also can select Zoom by Y Rectangle or Zoom by Selected Area. Experiment
with these options.
e.
11.
Select Undo Zoom from the lower left corner of the pull-down menu to undo
a zoom or click the x-axis single fit button and the y-axis single fit button on the scale
legend, shown in this media and this media.
Use the Panning tool, shown in this media, to click and drag the graph display. Click
the x-axis and y-axis single fit buttons again to restore the display to its original position.
Use the Cursor Movement tool, shown in this media, to return the cursor to standard
mode.
13. Save and close the VI.
12.
104
Figure 5.22
a.
b.
c.
d.
e.
f.
g.
h.
i.
105
Figure 5.23
a.
b.
c.
Place the Array Max & Min function, located on the FunctionsAll
FunctionsArray palette, on the block diagram. This function returns the maximum
and minimum temperature.
Place
the
Mean
VI,
located
on
the
FunctionsAll
FunctionsAnalyzeMathematicsProbability and Statistics palette, on
the block diagram. This subVI returns the average of the temperature measurements.
e. Right-click the output terminals of the Array Max & Min function and Mean VI and select CreateIndicator from the shortcut menu to create the Max, Min, and Mean
indicators.
d.
f.
g.
106
h.
Figure 5.24
107
Figure 5.25
Figure 5.26
108
a.
Place the Sine & Cosine function, located on the FunctionsArithmetic &
ComparisonExpress NumericExpress Trigonometric palette, on the block diagram. This function builds an array of points that represents one cycle of a sine wave
and a cosine wave.
b.
c.
Figure 5.27
8 This
109
Figure 5.28
Use the Operating or Positioning tools to right-click the marker next to the color ramp, select Marker
Color from the shortcut menu to change the color associated with a marker, and select the color you want
from the color picker that appears. To add markers to a color ramp, right-click the color ramp and select
Add Marker from the shortcut menu. To change the value of an arbitrary marker on a color ramp, use the
Operating tool to drag the marker to the value you want or use the Labeling tool to highlight the text of
the marker and enter a new value.
110
Figure 5.29
2. Change the Plot switch on the front panel to User Data and enter values between 0.0 and
10.0 in the User Data array control. Run the VI. Notice how the magnitude of each element
is mapped to the intensity graph.
Figure 5.30
111
112
INDEX
113
D Debug, 1.9(43)
Debugging Techniques, 1.8(42), 1.8(42)
Documentation Resources, 1.6(33), 1.6(33)
E environment, 1.2(3)
exercise, 1.5(21), 1.7(36), 1.9(43), 4.3(77),
4.5(80), 4.7(82), 5.2(89), 5.3(94),
5.7(106), 5.9(109), 5.11(111)
icon, 2
Intensity Graph Example VI, 5.9(109)
P palettes, 4.8(83)
plotting data, 5.11(111)
pop-up graph, 4.3(77)
U UNIX, 76
V VI, 4.3(77), 4.5(80), 4.6(82), 4.7(82),
4.9(85)
VI properties, 4.6(82)
virtual instruments, 2
VIs, 2
W waveform chart, 87
114
ATTRIBUTIONS
Attributions
Collection: LabVIEW Graphical Programming
Edited by: Serhat Beyenir
URL: http://cnx.org/content/col11408/1.1/
License: http://creativecommons.org/licenses/by/3.0/
Module: "LabVIEW"
By: National Instruments
URL: http://cnx.org/content/m12192/1.2/
Page: 2
Copyright: National Instruments
License: http://creativecommons.org/licenses/by/1.0
Module: "LabVIEW Environment"
By: National Instruments
URL: http://cnx.org/content/m12193/1.3/
Pages: 3-14
Copyright: National Instruments
License: http://creativecommons.org/licenses/by/1.0
Module: "Front Panel"
By: National Instruments
URL: http://cnx.org/content/m12194/1.1/
Pages: 14-16
Copyright: National Instruments
License: http://creativecommons.org/licenses/by/1.0
Module: "Block Diagram"
By: National Instruments
URL: http://cnx.org/content/m12195/1.2/
Pages: 16-21
Copyright: National Instruments
License: http://creativecommons.org/licenses/by/1.0
Module: "Acquiring a Signal VI"
By: National Instruments
URL: http://cnx.org/content/m12196/1.3/
Pages: 21-32
Copyright: National Instruments
License: http://creativecommons.org/licenses/by/1.0
Module: "LabVIEW Documentation Resources"
By: National Instruments
URL: http://cnx.org/content/m12199/1.1/
Pages: 33-36
Copyright: National Instruments
License: http://creativecommons.org/licenses/by/1.0
ATTRIBUTIONS
115
116
ATTRIBUTIONS
ATTRIBUTIONS
117
118
ATTRIBUTIONS
ATTRIBUTIONS
119
About Connexions
Since 1999, Connexions has been pioneering a global system where anyone can create course materials and
make them fully accessible and easily reusable free of charge. We are a Web-based authoring, teaching and
learning environment open to anyone interested in education, including students, teachers, professors and
lifelong learners. We connect ideas and facilitate educational communities.
Connexionss modular, interactive courses are in use worldwide by universities, community colleges, K-12
schools, distance learners, and lifelong learners. Connexions materials are in many languages, including
English, Spanish, Chinese, Japanese, Italian, Vietnamese, French, Portuguese, and Thai. Connexions is part
of an exciting new information distribution system that allows for Print on Demand Books. Connexions
has partnered with innovative on-demand publisher QOOP to accelerate the delivery of printed course
materials and textbooks into classrooms worldwide at lower prices than traditional academic publishers.
For your own Unlimited Reading and FREE eBooks today, visit:
http://www.Free-eBooks.net
Share this eBook with anyone and everyone automatically by selecting any of the
options below:
COPYRIGHT INFORMATION
Free-eBooks.net respects the intellectual property of others. When a book's copyright owner submits their work to Free-eBooks.net, they are granting us permission to distribute such material. Unless
otherwise stated in this book, this permission is not passed onto others. As such, redistributing this book without the copyright owner's permission can constitute copyright infringement. If you
believe that your work has been used in a manner that constitutes copyright infringement, please follow our Notice and Procedure for Making Claims of Copyright Infringement as seen in our Terms
of Service here:
http://www.free-ebooks.net/tos.html