Lesson 5
Introduction to Clusters
Cluster Functions
Error Clusters
• Data structure that groups data together
• Data may be of different types
• Analogous to struct in C or a record in Pascal
• Elements must be either all controls or all indicators
• Thought of as wires bundled into a cable
Cluster Controls and Indicators
1. Select a Cluster shell
from the Array &
Cluster subpalette
2. Place objects inside the shell
Creating Cluster Constants
1. Select Cluster
Constant shell from
the Cluster
2. Place objects in the Cluster shell
Cluster Order
• Elements have a logical order (start with 0)
• To change order, right-click the border and select Reorder Controls
in Cluster...
Using Clusters to Pass Data to SubVIs
Use clusters to pass several
values to one terminal
Overcomes 28-terminal limit
Simplifies wiring
Cluster Functions - Bundle
By Name
Create new cluster
Must have an existing
cluster to use this function.
Modify existing cluster
Cluster Functions - Unbundle
Unbundle By Name
Error Cluster
Use the error in and error out clusters in each VI you use or build
to handle errors in the VI.
The error clusters located on the Controls»Array & Cluster
palette include the components of information shown
Error Cluster Details
• Status is a Boolean value that reports TRUE
if an error occurred. Most VIs, functions, and
structures that accept Boolean data also
recognize this parameter.
• Code is a signed 32-bit integer that
identifies the error numerically. A non-zero
error code coupled with a status of FALSE
signals a warning rather than a fatal error.
• Source is a string that identifies where the
error occurred.
Error Handling with Clusters
• LabVIEW does not handle errors automatically. In LabVIEW, you
can make these error handling decisions on the block diagram of
the VI.
• Error handling in LabVIEW follows the dataflow model. Just as data
flow through a VI, so can error information.
• Wire the error information from the beginning of the VI to the end.
Error Cluster
Simple Error Handler
Use the Simple Error Handler to handle the error at the end of the
execution flow.
The Simple Error Handler is located on the Functions»All
Functions»Time and Dialog palette. Wire the error cluster to the
Error In (no error) input.
Using While Loops for Error Handling
You can wire an error cluster to the conditional terminal of a While
Loop to stop the iteration of the While Loop.
Only the TRUE or FALSE value of the status parameter of the error
cluster is passed to the terminal.
When an error occurs, the
While Loop stops.
• Clusters group data elements of mixed types. A cluster cannot contain
a mixture of controls and indicators.
• To create a cluster control or indicator, select a cluster on the
Controls»Array & Cluster palette, place it on the front panel, and drag
controls or indicators into the cluster shell.
• Use the Cluster functions located on the Functions»All
Functions»Cluster palette to create and manipulate clusters.
• Error checking tells you why and where errors occur.
• The error cluster reports the status, code and source of the error.
• Use the error cluster controls and indicators to create error inputs and
outputs in subVIs.
Lesson 6
Plotting Data
Waveform Charts
Waveform and XY Graphs
Intensity Graphs
Waveform Charts
Selected from the Controls»Graphs and Charts palette
Wiring to Charts
Single-Plot Chart
Multiple-Plot Chart
Modifying Chart Properties
• Change the
• Set the format and
precision of the axis
• Choose the plot type
• Edit the scales
• Document the chart
Customizing Charts and Graphs
Right-click and select Visible Items to view the following items:
• Plot Legend
• Digital Display
Graph Palette
• Scrollbar
Zoom Subpalette
• X and Y Scale
• Graph Palette
• Scale Legend
Scale Legend
• Selected from the Graph subpalette
• Waveform Graph – Plot an array of numbers against their indices
• XY Graph – Plot one array against another
Plot Legend
(point and line
Scale Legend
Graph Palette
Single-Plot Waveform Graphs
Uniform X axis
Initial X = 0.0
Delta X = 1.0
Uniform X axis
you specify point
Multiple-Plot Waveform Graphs
Each row is a
separate plot:
Initial X = 0
Delta X = 1
Each row is a
separate plot:
Bundle specifies
point spacing of
the X axis
XY Graphs
• Non-uniform X axis
• Separate X and Y arrays
define data points
Chart and Graph Use Summary
Use the Context Help window with charts and graphs
Intensity Plots and Graphs
• Useful in displaying terrain, temperature patterns, spectrum analysis, and
image processing
• Data type is a 2D array of numbers; each number represents a color
• Use these options to set and display color mapping scheme
• Cursor also adds a third dimension
• The waveform chart is a special numeric indicator that displays one
or more plots. The waveform chart has the following three update
–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 right.
–A sweep works similarly to a scope except it shows the old data on
the right and the new data on the left separated by a vertical line.
• Waveform graphs and XY graphs display data from arrays.
• Right-click a waveform chart or graph or its components to set
attributes of the chart and its plots.
Summary, cont.
• You can display more than one plot on a graph using the Build
Array function and the Bundle function for charts and XY graphs.
The graph becomes a multiplot graph when you wire the array of
outputs to the terminal.
• When you wire data to charts and graphs, use the Context Help
window to determine how to wire them.
• You can use intensity charts and graphs to plot three-dimensional
data. The third dimension is represented by different colors
corresponding to a color mapping that you define. Intensity charts
and graphs are commonly used in conjunction with spectrum
analysis, temperature display, and image processing.
Lesson 7
Making Decisions in a VI
Decision making with the Select function
Case Structures
Formula Nodes
Simple Decision: Select Function
• If Temp Scale is TRUE, pass top input;
if temp scale is FALSE, pass bottom input.
• If the decision to be made is more complex than a Select function
can execute, a Case Structure may be what is required.
Case Structures
Boolean Case Structure Example:
If Temp Scale is TRUE, execute True case;
if temp scale is FALSE, execute False case.
Case Structures
• In the Structures
subpalette of
Functions palette
• Enclose nodes or drag
them inside the
• Stacked like a deck of
cards, only one case
visible at a time
Boolean and Numeric Cases
Wire all possible outputs of the case structure
String, Enum, and Error Cases
String Case
Enum Case
Error Case
Formula Node
In the Structures subpalette
Implement complicated equations
Variables created at border
Variable names are case sensitive
Each statement must terminate with a semicolon (;)
Context Help Window shows available functions
Note semicolon
Decision Making with Formula Nodes
Two different ways of using an if-then statement in a Formula Node
Both structures produce the same result
• The Select function is used to choose between two inputs dependant
on a boolean input.
• A Case structure has two or more cases. Only one case is visible at a
time, and the structure executes only one case at a time.
• If the case selector terminal is Boolean, the structure has a TRUE
case and a FALSE case. If the selector terminal is an integer, string,
or enumerated type value, the structure can have up to 231–1 cases.
• Inputs are available to all cases, but cases do not need to use each
input. If at least one output tunnel is not defined, all output tunnels on
the structure appear as white squares.
• Formula Nodes are useful for complicated equations and for using
existing text-based code. A semicolon (;) must terminate each statement.
Lesson 8
Strings and File I/O
How to create string controls and indicators
How to use several String functions
About file I/O operations
How to use the high-level File I/O VIs
How to use the low-level File I/O VIs
How to format text files for use in spreadsheets
• A string is a sequence of displayable or - characters (ASCII)
• Many uses — displaying messages, instrument control, file I/O
• String control/indicator is in the Controls»String subpalette
String Display Modes
Normal display
\ code display
Password display
Hex display
String Functions
String Length
Concatenate Strings
(spaces here)
String Functions
String Subset
Match Pattern
Converting Numerics to Strings: Build String
Converting Strings to Numerics:
Scan From String
Edit Format String
Scan From String Function
File Input and Output
Four Hierarchy Levels:
High-level File VIs
Intermediate File VIs and Functions
Advanced File Functions subpalette
Express VIs
High-level File I/O VIs
• Write to Spreadsheet File
• Read from Spreadsheet File
• Write Characters to File
• Read Characters from File
• Read Lines from File
File I/O Programming Model - Intermediate
Replace File
Write to File
Check for
Write to File Example
• Open/Create/Replace opens the existing file TEST1.DAT and
generates refnum and error cluster
• Write File writes the data
• Close File closes the file
• Simple Error Handler checks for errors
Reading Data from a File
• Open/Create/Replace opens the file
• Read File reads the specified number of bytes from the file
• Close File closes the file
• Simple Error Handler checks for errors
Formatting a Spreadsheet String
• Spreadsheets are popular tools for data handling and analysis
• There are many formats for spreadsheet data. One of the most
popular is tab-delimited:
– Columns are separated by a tab character
– Rows are separated by an end-of-line
A spreadsheet yields:
Tab End of Line
Creating a Spreadsheet File
Can replace Format Into String and
Write File with Format Into File
in above example
Write LabVIEW Measurement File
• Includes the open, write, close and error handling functions
• Handles formatting the string with either a tab or comma
• Merge Signals function is used to combine data into the
dynamic data type
• Strings group sequences of ASCII characters. Use the string control
and indicator located on the Controls»String & Path palette to
simulate text entry boxes and labels.
• Use the String functions located on the Functions»String palette to
edit and manipulate strings on the block diagram.
• Use the Format Into String function and the Build String Express VI to
convert a numeric to a string.
• Use the Scan From String function to convert a string to a numeric.
• Right-click the Format Into String or Scan From String function and
select Edit Format String or Edit Scan String from the shortcut menu
to create or edit a format string.
Summary, cont.
• Use the File I/O VIs and functions located on the Functions»File I/O
palette to handle all aspects of file I/O.
• When writing to a file, you open, create, or replace a file, write the
data, and close the file. Similarly, when you read from a file, you open
an existing file, read the data, and close the file.
• To access a file through a dialog box, do not wire file path in the
Open/Create/Replace File VI.
• To write data to a spreadsheet file, you must format the string as a
spreadsheet string, which is a string that includes delimiters, such as
tabs. Use the Format Into File function to format string, numeric, path,
and Boolean data as text and write the text to a file

No Slide Title