LabVIEW Graphs, Charts, Arrays and Clusters
LabVIEW Graphs, Charts, Arrays and Clusters
Sarah Fenney
Arizona State University
Instructor’s Portion
Summary
The students will learn about the differences and similarities between
graphs and charts and when to use each. They will also write simple VIs
to incorporate arrays and clusters in LabVIEW as a means of combining
data.
Uses
This homework applies to all general instrumentation courses.
Equipment List
Computer with LabVIEW 6.1
References
LabVIEW User’s Manual. November 2001. Part Number
320999D-01. http://www.ni.com/manuals.
1
Student’s Portion
Introduction
In this homework, you will learn about the differences and similarities
between graphs and charts and when to use each. You will also write
simple VIs to incorporate arrays and clusters in LabVIEW as a means of
combining data.
Objective
Learn the difference between a chart and a graph.
Differentiate between the three update modes of a chart.
Learn how to create an array and manipulate it.
Learn the difference between a cluster and an array.
Theory
LabVIEW Graphs, Charts, Arrays, and Clusters
Introduction
In this section you will learn about graphs and charts, their similarities and
differences, and when to use each. You will also study arrays and clusters,
two ways to group data.
Graphs and Charts
Use graphs and charts to display plots of data in a graphical form.
2
Graphs and charts differ in the way they display and update data. VIs with
graphs usually collect the data in an array and then plot the data to the
graph, which is similar to a spreadsheet that first stores the data then
generates a plot of it. In contrast, a chart appends new data points to those
already in the display. On a chart, you can see the current reading or
measurement in context with data previously acquired.
The graphs and charts located on the Controls»Graph palette include the
following types:
• Waveform Chart and Graph—Displays data acquired at a constant
rate.
• XY Graph—Displays data acquired at a nonconstant rate, such as data
acquired when a trigger occurs.
• Intensity Chart and Graph—Displays 3D data on a 2D plot by using
color to display the values of the third dimension.
• Digital Waveform Graph—Displays data as pulses or groups of digital
lines. Computers transfer digital data to other computers in pulses.
• (Windows) 3D Graphs—Displays 3D data on a 3D plot in an ActiveX
object on the front panel.
You customize the appearance of graphs and charts by showing or hiding
options. Rightclick the graph or chart and select Visible Items from the
shortcut menu to display or hide the following options:
• Plot Legend—Defines the color and style of the plot(s). Resize the
legend to display multiple plots.
• Scale Legend—Defines labels for scales and configures scale properties.
• Graph Palette—Changes scaling and formatting while a VI is running.
• X Scale and Y Scale—Formats the x and yscales.
3
• Cursor Legend (graph only)—Displays a marker at a defined point
coordinate. You can display multiple cursors on a graph.
• Scrollbar (chart only)—Scrolls through the data in the chart. Use the
scroll bar to view data that the buffer does not currently display.
4
Arrays
Indexes
To locate a particular element in an array requires one index per
dimension. In LabVIEW, indexes let you navigate through an
array and retrieve elements, rows, columns, and pages from an
array on the block diagram.
Examples of Arrays
An example of a simple array is a text array that lists the nine
planets of our solar system. LabVIEW represents this as a 1D array
of strings with nine elements.
5
Another example of an array is a waveform represented as a
numeric array in which each successive element is the voltage
value at successive time intervals.
For example, a chessboard has eight columns and eight rows for a
total of 64 positions. Each position can be empty or have one chess
piece. You can represent a chessboard as a 2D array of strings.
Each string is the name of the piece that occupies the
corresponding location on the board, or an empty string if the
location is empty.
6
To display a particular element on the front panel, either type the
index number in the index display or use the arrows on the index
display to navigate to that number.
If you try to display a column or row that is out of the range of the
array dimensions, the array control is dimmed to indicate that there
is no value defined, and LabVIEW displays the default value of the
data type. The default value of the data type depends on the data
type of the array.
Use the Positioning tool to show more than one row or column at a
time.
Array Functions
7
Use the Array functions located on the Functions»Array palette to
create and manipulate arrays, such as the following tasks:
• Split arrays.
You can access more than one element, or subarray (row, column,
or page) with these functions by using the Positioning tool to
manually resize the function. When you expand one of these
functions, the functions expand in increments determined by the
dimensions of the array wired to the function.
The index inputs you wire determine the shape of the subarray you
want to access or modify. For example, if the input to an Index
8
Array function is a 2D array and you wire only the row input, you
extract a complete 1D row of the array. If you wire only the
column input, you extract a complete 1D column of the array. If
you wire the row input and the column input, you extract a single
element of the array. Each input group is independent and can
access any portion of any dimension of the array.
9
Clusters
10
Cluster elements have a logical order unrelated to their position in the
shell. The first object you place in the cluster is element 0, the second is
element 1, and so on. If you delete an element, the order adjusts
automatically. The cluster order determines the order in which the
elements appear as terminals on the Bundle and Unbundle functions on the
block diagram. You can view and modify the cluster order by right-
clicking the cluster border and selecting Reorder Controls In Cluster
from the shortcut menu.
To wire clusters, both clusters must have the same number of elements.
Corresponding elements, determined by the cluster order, must have
compatible data types. For example, if a double-precision floating-point
numeric in one cluster corresponds in cluster order to a string in the other
cluster, the wire on the block diagram appears broken and the VI does not
run. If numerics of different representations, LabVIEW coerces them to
the same representation.
11
Homework Procedure
Part 1. Temperature Monitor VI
Complete the following steps to build a VI that uses a While Loop and a
waveform chart to acquire and display data.
12
chart legend, type Temp, and click outside the label or
click the Enter button to relabel the legend.
13
c. Use the Positioning tool to resize the loop, if
necessary.
14
b. Click the Scale Style icon and select different
styles for the y-axis. You also can select different
mapping modes, grid options, scaling factors, and
formats and precisions.
15
15. Run the VI.
16
c. On the front panel, right-click the chart and select
X Scale»Formatting from the shortcut menu.
Change the X value to 0.5 because you added a
500 ms wait between loop iterations.
19. Try different values for the numeric constant and run
the VI again.
17
Part 2. Temperature Analysis VI
1. Open a new VI and build the following front panel using the following
tips.
• Use the Positioning tool to resize the plot legend of the waveform graph.
• Use the Labeling tool to rename Plot 0 to Temp and Plot 1 to Fitted.
18
• Set the point style of the waveform graph Temp plot to a small square.
a. Select Functions»Tutorial»Digital
Thermometer.vi. This VI returns simulated
temperature measurements.
19
f. Place the General Polynomial Fit VI located on the
Functions»Mathematics»Curve Fitting palette. This VI returns
an array that is a polynomial fit to the temperature array.
The elements include the initial x value (0), the .x value (0.25), and
the y array of temperature data. The .x value of 0.25 is required so
that the VI plots the temperature array points every 0.25 s on the
waveform graph.
The graph displays both the temperature data and best fit curve of the
temperature waveform.
5. Try different values for the polynomial order constant on the block
diagram and run the VI again.
6. Change the appearance of plots by modifying the plot styles and fill
styles.
a. Right-click the Temp plot display in the plot legend and select
Common Plots»Scatter Plot from the shortcut menu, the top
middle option.
b. Right-click the Fitted plot display in the plot legend, select Bar
Plots from the shortcut menu, and select the second option in the
middle row.
20
Part 3. Find Mid Value VI
21
Homework Report
For your homework report, email the VIs and the answers to the questions
below to the instructor no later than <date>.
Data Sheet
Questions
1. How is a chart different from a graph?
2. What are the three update modes of a chart? Briefly describe each.
3. How do you create an array?
4. Below is a 2D array:
2 4 7 5 1
6 9 3 4 5
2 5 8 4 9
a. What number is at index [1,3]?
b. If you used an Array Subset function on the above array, and assigned
the following input values (in order):
index: 2
length: 3
index: 3
22
length: 2
What value(s) would be returned? Would it be a 1D or 2D array?
5. How is a cluster different than an array?
6. What is the difference between the Bundle and Bundle by Name
functions? Unbundle and Unbundle by Name?
23