Professional Documents
Culture Documents
Labview Introduction Course Semester: National Instruments 11500 N. Mopac Expressway Austin, Texas 78759 (512) 683-0100
Labview Introduction Course Semester: National Instruments 11500 N. Mopac Expressway Austin, Texas 78759 (512) 683-0100
Semester
National Instruments
11500 N. Mopac Expressway
Austin, Texas 78759
(512) 683-0100
Networked I/O
PC Boards
Workstation
The LabVIEW Family
NI LabVIEW
Graphical Programming Software for Measurement and Automation
LabVIEW Real-Time LabVIEW FPGA Module LabVIEW PDA Module LabVIEW Datalogging and
Module Supervisory Control Module
Acquire, Analyze, and Present
Strings and VI
Arrays File I/O Customization
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
Course Non-Goals
It is not the purpose of this course to discuss the
following:
• Every built-in LabVIEW object, function, or library VI
• Analog-to-digital (A/D) theory
• The detailed operation of the serial port or GPIB bus
• How to develop an instrument driver
Lesson 1
Introduction to LabVIEW
TOPICS
LabVIEW Environment
Front Panel
Block Diagram
Dataflow Programming
LabVIEW Help and Manuals
Debugging a VI
Virtual Instruments (VIs)
Front Panel
• Controls = Inputs
• Indicators = Outputs
Block Diagram
• Accompanying “program”
for front panel
• Components wired
together
LabVIEW Dialog Box
Creating a new VI
•File»New VI to open a blank VI
Boolean
Control Graph
Waveform Legend
Graph
Owned
Label
Waveform
Graph
Plot Scale
Legend Legend
Block Diagram Window
Block
Diagram
Toolbar Divide
Function
SubVI
Graph
Terminal
Wire
Data
Controls Palette
Contains the most commonly used controls
Functions Palette
Contains the Express VIs (interactive VIs with
configurable dialog page) and the most commonly
used functions
Numeric
Owned Indicator
Labels
Increment
Buttons Numeric
Boolean Boolean Control
Control Indicator
Shortcut Menus for Front Panel Objects
Right-click the digital display
to access its shortcut menu
Wires Nodes
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
Block Diagram Nodes
Icon Expandable Node Expanded Node
• Function Generator VI
• Same VI, viewed three different ways
• Yellow field designates a standard VI
• Blue field designates an Express VI
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
Wiring the Block Diagram
Scalar 1D 2D Array
Array
Numeric
Boolean
String
Dynamic
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
Dataflow Programming
• Block diagram executes
dependent on the flow of data;
block diagram does NOT
execute left to right
TOPICS
SubVIs
Icon and Connector Pane
Using SubVIs
Creating a SubVI from sections of a VI
LabVIEW Hierarchy
SubVI
SubVIs
Function Pseudo Code Calling Program Pseudo Code
function average (in1, main
in2, out) {
{ average (point1, point2,
out = (in1 + in2)/2.0; pointavg)
} }
terminals
Icon
An icon represents a VI in other block
diagrams
Connector
A connector passes data to and receives
data from a subVI through terminals
terminals
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
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
TOPICS
While Loops
For Loops
Accessing Previous Loop Data
While Loops
Repeat (code);
Until Condition met;
End;
N=100;
i=0;
Until i=N:
Repeat (code; i=i+1);
End;
Functions»Time
& Dialog palette
Wait Functions
Wait (ms)
Functions»Time
& Dialog palette
Time Delay
Functions»Time
& Dialog palette
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
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.
Before
Loop First Second Last
Begins Iteration Iteration Iteration
Additional Shift Register Elements
Output = 5 Output = 5
Output = 5 Output = 5
Uninitialized Shift Registers & Feedback
Nodes
Output = 4 Output = 8
Output = 4 Output = 8
Summary
• Two structures to repeat execution: While Loop and For Loop
• Loop timing controlled using Wait Until Next ms Multiple function,
the Wait (ms) function, or the Time Delay Express VI.
• Coercion dots appear where LabVIEW coerces a numeric
representation of one terminal to match the numeric representation
of another terminal
• Feedback nodes and shift registers transfer data values from one
iteration to the next
• Use shift registers only when more than one past iteration is
needed
Lesson 4
Arrays
TOPICS
Introduction to Arrays
Auto Indexing Arrays
Array Functions
Polymorphism
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
Array Controls and Indicators
1. Select the Array shell from the 2. Place data object inside
Controls palette shell
Add Dimension
for 2D arrays
Creating Array Constants
1. Select Array
Constant shell from
the Array subpalette
1D Array 2D Array
0 1 2 3 4 5
Array Size
Initialize Array
Common Array Functions
Array Subset
The Build Array Function
Appending an element
Concatenate Inputs
Extracting an Element
Extracting a Row