You are on page 1of 21

LabVIEW Programming, Part III

Array and cluster functions


Error handling
Graph and chart
Basic LabVIEW programming architecture

BME313 Virtual Bioinstrumentation

Instructor: Wei

Arrays in LabVIEW
An array has elements and
Dimensions.
Elements are the data that
make up the array.
A dimension is the length of an
array.
An array can have one or
more dimensions and as many
as 231 1 elements per
dimension, memory permitting.

BME313 Virtual Bioinstrumentation

Instructor: Wei

Limitations of Arrays
Cannot create an array of arrays.
Cannot create an array of charts.
Cannot create an array of multiplot XY graphs.

Can create a multidimensional array.


Can create an array of clusters which has
one or more arrays.

BME313 Virtual Bioinstrumentation

Instructor: Wei

Adding an Array to the Front Panel


From the Controls >> All Controls
>> Array and Cluster subpalette,
select the Array Shell

Drop it on the screen.

BME313 Virtual Bioinstrumentation

Instructor: Wei

Adding an Array (cont.)


Place data object into shell (i.e. Numeric Control)

BME313 Virtual Bioinstrumentation

Instructor: Wei

Adding an Array Constant


The procedure is the same as the adding
an array control or indicator on the front
panel.
Get the array constant shell from function
palette.
Drop the element data type into the shell.
Enter element data for each index.

BME313 Virtual Bioinstrumentation

Instructor: Wei

Creating 2D Arrays Using LabVIEW

BME313 Virtual Bioinstrumentation

Instructor: Wei

Array Functions Basics


Functions >> All functions>> Array

BME313 Virtual Bioinstrumentation

Instructor: Wei

Array Functions Build Array

BME313 Virtual Bioinstrumentation

Instructor: Wei

Clusters
Data structure that groups data together
Data may be of different types
Analogous to struct in C
Elements must be either all controls or all
indicators
Thought of as wires bundled into a cable

BME313 Virtual Bioinstrumentation

Instructor: Wei

Creating a Cluster
1.

Select a Cluster shell Controls >> All Controls


>> Array & Cluster

2. Place objects inside the shell

BME313 Virtual Bioinstrumentation

Instructor: Wei

Cluster Functions
In the Cluster subpalette of the Functions>>All
functions palette
Can also be accessed by right-clicking on the cluster
terminal

(Terminal labels
reflect data type)
Bundle

Bundle By Name
BME313 Virtual Bioinstrumentation

Instructor: Wei

Cluster Functions

Unbundle

Unbundle By Name
Unbundled cluster
in the diagram

BME313 Virtual Bioinstrumentation

Instructor: Wei

Error Clusters
Error cluster contains the following information:
Boolean to report whether error occurred
Integer to report a specific error code
String to give information about the error

BME313 Virtual Bioinstrumentation

Instructor: Wei

Error Handling Techniques


Error information is
passed from one subVI
to the next
If an error occurs in one
subVI, all subsequent
subVIs are not executed
in the usual manner
Error Clusters contain
all error conditions
Automatic Error
Handling

error clusters

BME313 Virtual Bioinstrumentation

Instructor: Wei

Charts
Waveform chart special
numeric indicator that can
display a history of values
Controls >> Graph Indicators
>> Waveform Chart

BME313 Virtual Bioinstrumentation

Instructor: Wei

Wiring Data into Charts


Single Plot Charts

Multiplot Charts

BME313 Virtual Bioinstrumentation

Instructor: Wei

Graphs

Right-Click on the Graph


and choose Properties
to Interactively Customize

BME313 Virtual Bioinstrumentation

Instructor: Wei

Simple VI Architecture
Functional VI that produces results when run
No start or stop options
Suitable for lab tests, calculations
Example: Convert C to F.vi

BME313 Virtual Bioinstrumentation

Instructor: Wei

General VI Architecture
Three Main Steps
Startup
Main Application
Shutdown

BME313 Virtual Bioinstrumentation

Instructor: Wei

State Machine Architecture


Advantages

Can go from any state


from any other
Easy to modify and debug

Disadvantages

Can lose events if two


occur at the same time
States:
0: Startup
1: Idle
2: Event 1
3: Event 2
4:
Shutdown
BME313 Virtual Bioinstrumentation

Instructor: Wei

You might also like