Labview Introduction Course Semester
Labview Introduction Course Semester
Semester
1
Graphical Programming for
Test, Measurement, and
Control
• Rapid application development
with Express VIs and easy-to-use
graphical environment
• Interactive measurement
assistants and powerful
redesigned DAQ interface for
connecting to all types of I/O
• Expanded targeting options from
Real-Time to FPGA to PDA
• Localized in French, German, and
Japanese (Korean
documentation)
2
LabVIEW Everywhere
Sensor
Embedded
(FPGA)
Handheld
Wireless
Networked I/O
PC Boards
Workstation
3
The LabVIEW Family
NI LabVIEW
Graphical Programming Software for Measurement and Automation
LabVIEW Real-Time Module LabVIEW FPGA Module LabVIEW PDA Module LabVIEW Datalogging and
Supervisory Control Module
4
Acquire, Analyze, and Present
5
Acquire with LabVIEW
LabVIEW can acquire data using the following
devices and more:
• GPIB, Serial, Ethernet, VXI, PXI Instruments
• Data Acquisition (DAQ)
• PCI eXtensions for Instrumentation (PXI)
• Image Acquisition (IMAQ)
• Motion Control
LabVIEW is tightly • Real-Time (RT) PXI
integrated with all NI • PLC (through OPC Server)
hardware, in addition to • PDA
connecting to • Modular Instruments
thousands of I/O
devices from hundreds
of different vendors.
6
Analyze with LabVIEW
LabVIEW includes the following tools to help you
analyze your data:
• More than 400 measurement analysis functions for
Differential Equations, Optimization, Curve Fitting,
Calculus, Linear Algebra, Statistics, etc.
• 12 new Express VIs specifically designed for
measurement analysis, including filtering and
spectral analysis
• Signal Processing VIs for Filtering, Windowing,
Powerful measurement Transforms, Peak Detection, Harmonic Analysis,
analysis is built in to the Spectrum Analysis, etc.
LabVIEW development
environment.
7
Present with LabVIEW
LabVIEW includes the following tools to help
you present your data:
• On your machine — Graphs, Charts, Tables,
Gauges, Meters, Tanks, 3D Controls, Picture
Control, 3D Graphs (Windows Only), Report
Generation (Windows Only)
• Over the Internet — Web Publishing Tools,
Datasocket (Windows Only), TCP/IP, VI Server,
Presentation with Remote Panels, Email
LabVIEW can be done • Enterprise Connectivity Toolset — SQL Tools
(Databases), Internet Tools (FTP, Telnet, HTML)
on your PC or over a
network, or you can take
advantage of additional
applications such as
DIAdem.
8
Course Map
Strings and VI
Arrays File I/O Customization
9
Course Goals
This course prepares you to:
• Understand front panels, block diagrams, and connectors/icons
• Use the programming structures and data types that exist in
LabVIEW
• Use various editing and debugging techniques
• Create and save your own VIs so you can use them as subVIs
• Display and log your data
• Create applications that use plug-in data acquisition (DAQ)
boards
• Create applications that use GPIB and serial port instruments
10
Lesson 1
Introduction to LabVIEW
TOPICS
LabVIEW Environment
Front Panel
Block Diagram
Dataflow Programming
LabVIEW Help and Manuals
Debugging a VI
11
Virtual Instruments (VIs)
Front Panel
• Controls = Inputs
• Indicators = Outputs
Block Diagram
• Accompanying “program”
for front panel
• Components wired
together
12
LabVIEW Dialog Box
13
Creating a new VI
• File»New VI to open a blank VI
14
Template Browser
15
Menu
16
Front Panel Window
Front Panel Icon
Toolbar
Boolean
Control Graph
Waveform Legend
Graph
Owned
Label
Waveform
Graph
Plot Scale
Legend Legend
17
Block Diagram Window
Block
Diagram
Toolbar Divide
Function
SubVI
Graph
Terminal
Wire
Data
18
Front Panel and Block Diagram Toolbars
19
Tools Palette
• LabVIEW automatically selects the tool needed
• Available on the front panel and the block diagram
• A tool is a special operating mode of the mouse cursor
• Use the tools to operate and modify front panel and
block diagram objects
• To show the tools palette, select
Window»Show Tools Palette
20
Front Panel − Controls Palette
Controls Palette
Contains the most commonly used controls
21
Block Diagram − Functions Palette
Functions Palette
Contains the Express VIs (interactive VIs with
configurable dialog page) and the most commonly
used functions
22
Palette Tools
Click pushpin to tack down palette
23
Searching for Controls, VIs, and Functions
24
Customize Control & Function Palette
Programs» National Instruments»LabVIEW 7.0
25
Creating a VI Front Panel
Build the front panel with controls (inputs)
and indicators (outputs)
Numeric
Owned Indicator
Labels
Increment
Buttons Numeric
Boolean Boolean Control
Control Indicator
26
Shortcut Menus for Front Panel Objects
Right-click the digital display
to access its shortcut menu
27
Property Page
Right-click a control or
indicator on the front
panel and select
Properties from the
shortcut menu to
access the property
dialog box for that
object
28
Creating a VI Block Diagram
Wires Nodes
29
Express VIs, VIs and Functions
• Express VIs: interactive VIs with configurable dialog page
• Standard VIs: modularized VIs customized by wiring
• Functions: fundamental operating elements of
LabVIEW; no front panel or block diagram
30
Block Diagram Nodes
• Function Generator VI
• Same VI, viewed three different ways
• Yellow field designates a standard VI
• Blue field designates an Express VI
31
Block Diagram Terminals
• Terminals are entry and exit ports
that exchange information between
the panel and diagram
• Terminals are analogous to
parameters and constants in text-
based programming languages
• Right-click and toggle View As Icon
to change the icon view
32
Wiring the Block Diagram
Numeric
Boolean
String
Dynamic
33
Wiring Techniques
Hot Spot
• Automatic Wiring
• Use Context Help Window when wiring
• Right-click wire and select Clean Up Wire
• Tip Strips
• Automatic wire routing
• Right-click terminals
and select Visible
Items»Terminals
View the terminal connections to a function
34
Dataflow Programming
• Block diagram executes
dependent on the flow of data;
block diagram does NOT
execute left to right
35
Context Help
• To display the Context Help window, select
Help»Show Context Help, press the <Ctrl-H> keys, or press the Show
Context Help Window button in the toolbar
• Move cursor over object
to display help
• Connections:
Required – bold
Recommended – normal
Optional - dimmed
36
LabVIEW Help
• Click the More Help button in the Context Help window
• Select Help»VI, Function, & How-To Help
• Click the sentence Click here for more help in the Context Help window.
37
NI Example Finder
38
Debugging Techniques
Finding Errors
Click on broken Run button. A window showing the
error appears
Execution Highlighting
Click on Execution Highlighting button; data flow is
animated using bubbles. Values are displayed on
wires.
39
Debugging Techniques
Probe
Right-click on wire and select probe and it shows
data as it flows through the wire segment
Breakpoints
Right-click on wire and select Set Breakpoint; pause
execution at the breakpoint.
Conditional Probe
Combination of a breakpoint and a probe. Right-click on
wire and select custom probe.
40
Debugging Techniques
Step Into, Over, and Out buttons for Single Stepping
41
Summary
• Virtual instruments (VIs) have three main parts — the front panel, the
block diagram, and the icon and connector pane
• The front panel is the user interface of a LabVIEW program and the
block diagram is the executable code
• The block diagram contains the graphical source code composed of
nodes, terminals, and wires
• Use Express VIs, standard VIs and functions on the block diagram to
create your measurement code. For the most common requirements,
use Express VIs with interactive configuration dialogs to define your
application.
• Floating Palettes: Tools Palette, Controls Palette (only when Front
Panel Window is active), and Functions Palette (only when Block
Diagram Window is active)
• There are help utilities including the Context Help Window and
LabVIEW Help
42
Summary
• Place controls (inputs) and indicators (outputs) in the front panel window
• Use the Operating tool to manipulate panel objects. Use the Positioning tool to
select, move, and resize panel objects. Use the Wiring tool to connect diagram
objects
• Control terminals have thicker borders than indicator terminals
• All front panel objects have property pages and shortcut menus
• Wiring is the mechanism to control dataflow and produce LabVIEW programs
• Broken Run arrow means a nonexecutable VI
• Various debugging tools and options available such as setting probes and
breakpoints, execution highlighting, and single stepping
43
Tips
• Common keyboard shortcuts
Windows Sun Linux MacOS
<Ctrl-R> <-R> <M-R> <z-R> Run a VI
<Ctrl-F> <-F> <M-F> <z-F> Find object
<Ctrl-H> <-H> <M-H> <z-H> Activate Context Help window
<Ctrl-B> <-B> <M-B> <z-B> Remove all broken wires
<Ctrl-W> <-W> <M-W> <z-W> Close the active window
<Ctrl-E> <-E> <M-E> <z-E> Toggle btwn Diagram/Panel Window
44
Lesson 2
Modular Programming
TOPICS
SubVIs
Icon and Connector Pane
Using SubVIs
Creating a SubVI from sections of a VI
45
LabVIEW Hierarchy
SubVI
46
SubVIs
Function Pseudo Code Calling Program Pseudo Code
function average (in1, main
in2, out) {
{ average (point1, point2,
out = (in1 + in2)/2.0; pointavg)
} }
47
Icon/Connector
terminals
Icon
Connector
A connector passes data to and receives
data from a subVI through terminals
terminals
48
SubVI Example – Calculating Slope
• A VI within another VI is called a subVI
• To use a VI as a subVI, create an icon and a connector pane after
building the front panel and block diagram
49
Creating the Icon
• Icon: graphical representation of a VI
• Right-click in the icon pane (Panel or Diagram)
• Always create a black and white icon
50
Creating the Connector
51
Creating the Connector - continued
Click with
wiring tool
52
The Connector Pane
Terminal colors match the data types to which they are connected
Click the terminal to see its associated front panel object
53
Using a VI as a SubVI
54
Help and Classifying Terminals
55
Create SubVI Option
• Enclose area to be converted into a subVI
• Select Create SubVI from the Edit Menu
56
Summary
• VIs can be used as subVIs after you make the icon and connector
• Icon created using Icon Editor
• Connector defined by choosing number of terminals
• Load subVIs using the Select a VI option in the All Functions palette
or dragging the icon onto a new diagram
• Online help for subVIs using the Show Context Help option
• Descriptions document functionality
• Use Create SubVI feature to easily modularize the block diagram
57
Lesson 3
Repetition and Loops
TOPICS
While Loops
For Loops
Accessing Previous Loop Data
58
While Loops
Repeat (code);
Until Condition met;
End;
59
While Loops
1. Select While Loop 2. Enclose code to be repeated
60
Select the Loop Condition
Click the Conditional Terminal with the Operating tool to define when the
loop stops
Default: Stop if True
61
Structure Tunnels
• Tunnels feed data into and out of structures.
• The tunnel is a block that appears on the border; the color of the block
is related to the data type wired to the tunnel.
• When a tunnel passes data into a loop, the loop executes
only after data arrive at the
tunnel.
• Data pass out of a loop after
the loop terminates.
62
For Loops
N=100;
i=0;
Until i=N:
Repeat (code; i=i+1);
End;
63
For Loops
• In Structures subpalette of Functions palette
• Enclose code to be repeated and/or resize and add nodes
inside boundary
• Executes diagram inside of loop a predetermined number
of times
Count terminal
(Numerical input)
64
Wait Functions
Wait Until Next
ms Multiple
Functions»Time
& Dialog palette
65
Wait Functions
Wait (ms)
Functions»Time
& Dialog palette
Time Delay
Functions»Time
& Dialog palette
66
Numeric Conversion
• Numerics default to double-precision (8 bytes) or long integer
(4 bytes)
• LabVIEW automatically converts to different representations
• For Loop count terminal always converts to a long integer
• Gray coercion dot on terminal indicates conversion
67
Numeric Conversion
• LabVIEW chooses the representation that uses more bits.
• If the number of bits is the same,
LabVIEW chooses unsigned over signed.
• To choose the representation,
right-click on the terminal and
select Representation.
68
Accessing Previous Loop Data – Shift Register
• Available at left or right border of loop structures
• Right-click the border and select Add Shift Register
• Right terminal stores data on completion of iteration
• Left terminal provides stored data at beginning of next iteration
Before
Loop First Second Last
Begins Iteration Iteration Iteration
69
Additional Shift Register Elements
70
Feedback Nodes
71
Feedback Node
• Wire from output to input to
automatically create a
feedback node
<OR>
• Place a feedback node from
the Functions»Structures
palette
72
Arrays
TOPICS
Introduction to Arrays
Auto Indexing Arrays
Array Functions
Polymorphism
73
Arrays
• Collection of data elements that are of same type
31
• One or more dimensions, up to 2 elements per dimension
• Elements accessed by their index; first element is index 0
index 0 1 2 3 4 5 6 7 8 9
10-element array 1.2 3.2 8.2 8.0 4.8 5.1 6.0 1.0 2.5 1.7
0 1 2 3 4 5 6
2D array 0
1
2
3
4
Five row by seven column array of 35 elements
74
Array Controls and Indicators
1. Select the Array shell from the 2. Place data object inside
Controls palette shell
Add Dimension
for 2D arrays
75
Creating Array Constants
1. Select Array
Constant shell from
the Array subpalette
76
Auto-Indexing
Auto-Indexing Enabled
• Loops can Wire becomes thicker
accumulate arrays at
their boundaries with
auto-indexing 1D Array
• For Loops auto-index
by default 0 1 2 3 4 5
77
Creating 2D Arrays
1D Array 2D Array
0 1 2 3 4 5
78
Common Array Functions
Array Size
Initialize Array
79
Common Array Functions
Array Subset
80
The Build Array Function
Appending an element
Concatenate Inputs
81
The Index Array Function
Extracting an Element
Extracting a Row
82
Polymorphism
Function inputs can be of different types
All LabVIEW arithmetic functions are polymorphic
Combination Result
83
Summary
• Arrays group data elements of the same type. You can build arrays of
numeric, Boolean, path, string, waveform, and cluster data types.
• The array index is zero-based, which means it is in the range 0 to n – 1,
where n is the number of elements in the array.
• To create an array control or indicator, select an Array on the
Controls»Array & Cluster palette, place it on the front panel, and drag
a control or indicator into the array shell.
• By default, LabVIEW enables auto-indexing in For Loops and disables
auto-indexing in While Loops.
• Polymorphism is the ability of a function to adjust to input data of
different data structures.
84