Upload
gabrieljimenez
View
215
Download
0
Embed Size (px)
Citation preview
8/11/2019 Lesson_1-4
1/92
National Instruments Confidential
1
LabVIEW Introduction Course
Semester
National Instruments11500 N. Mopac Expressway
Austin, Texas 78759(512) 683-0100
8/11/2019 Lesson_1-4
2/92
2
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 fromReal-Time to FPGA to PDA
Localized in French, German, and
Japanese (Korean documentation)
8/11/2019 Lesson_1-4
3/92
3
Readers of Electronic Design name invention of LabVIEW as one
of the Top 50 Milestones for the Electronics Industry
LabVIEW 6.1 receives IAN Automation Excellence Award of
2002
Design News awards LabVIEW 6i Best Computer Productivity
Tool of 2000
LabVIEW 6i chosen the Best of the Bestin the software
category by readers of Evaluation Engineering
LabVIEW Awards
8/11/2019 Lesson_1-4
4/92
4
May 2003
January 2002
August 2000
March 1998
February 1996
August 1993
September 1992
January 1990
October 1986
April 1983
LabVIEW 7 Express VIs, I/O Assistants, FPGA/PDA targets
LabVIEW 6.1 Enhanced networking capabilities, analysis
LabVIEW 6iInternet-ready measurement intelligence
LabVIEW 5.0 ActiveX, Multithreading
LabVIEW 4.0 Added professional tools, improved debugging
LabVIEW 3.0 Multiplatform version of LabVIEW
LabVIEW for Windows
LabVIEW 2.0 for Macintosh
LabVIEW 1.0 for Macintosh
LabVIEW project begins
NI LabVIEW: A History of Innovation
8/11/2019 Lesson_1-4
5/92
5
Third-Party Software
Wolfram Research Mathematica Microsoft Excel The MathWorks MATLABand Simulink MathSoftMathCAD Electronic Workbench MultiSim
Texas Instruments Code Composer Studio
Ansoft RF circuit design software Microsoft Access Microsoft SQL Server Oracle
Leveraging Commercial Technologies
Communication Protocols
Ethernet CAN DeviceNet USB IEEE 1394 RS-232
GPIB RS-485
8/11/2019 Lesson_1-4
6/92
6
PC, Mac, Linux, Sun
LabVIEW Everywhere
Networked I/O
PC Boards
Workstation
Handheld
Embedded(FPGA)
Industrial Computer (PXI)
Wireless
Sensor
Tektronix Open Windows
Oscilloscopes
8/11/2019 Lesson_1-4
7/927
The LabVIEW Family
NI LabVIEWGraphical Programming Software for Measurement and Automation
LabVIEW Real-Time Module LabVIEW FPGA Module LabVIEW PDA Module LabVIEW Datalogging andSupervisory Control Module
8/11/2019 Lesson_1-4
8/928
Acquire, Analyze, and Present
Nearly all test, measurement, and control applications can be
divided into 3 main components: the ability to acquire, analyze, and
presentdata. LabVIEW is the easiest, most powerful tool foracquiring, analyzing, and presenting real-world data.
8/11/2019 Lesson_1-4
9/92
8/11/2019 Lesson_1-4
10/9210
Analyzewith LabVIEWLabVIEW 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, Transforms, Peak Detection,
Harmonic Analysis, Spectrum Analysis, etc.
Powerful measurement
analysis is built in to the
LabVIEW development
environment.
8/11/2019 Lesson_1-4
11/9211
Presentwith LabVIEW
LabVIEW includes the following
tools to help you present your data: On your machine Graphs, Charts,
Tables, Gauges, Meters, Tanks, 3DControls, Picture Control, 3D Graphs
(Windows Only), Report Generation(Windows Only)
Over the Internet Web PublishingTools, Datasocket (Windows Only),TCP/IP, VI Server, Remote Panels, Email
Enterprise Connectivity Toolset SQLTools (Databases), Internet Tools (FTP,Telnet, HTML)
Presentation withLabVIEW can be done
on your PC or over a
network, or you can take
advantage of additionalapplications such as
DIAdem.
8/11/2019 Lesson_1-4
12/9212
Course Map
Introduction toLabVIEW
Repetition &Loops
Modular
Programming
VICustomization
Data Acquisition& Waveforms
InstrumentControl
Arrays
Plotting Data
Clusters
Decision Makingin a VI
Strings andFile I/O
8/11/2019 Lesson_1-4
13/9213
Course Goals
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
This course prepares you to:
8/11/2019 Lesson_1-4
14/9214
Course Non-Goals
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
It is notthe purpose of this course to discuss the
following:
8/11/2019 Lesson_1-4
15/9215
Lesson 1
Introduction to LabVIEW
TOPICS
LabVIEW EnvironmentFront Panel
Block Diagram
Dataflow Programming
LabVIEW Help and Manuals
Debugging a VI
8/11/2019 Lesson_1-4
16/9216
Virtual Instruments (VIs)
Front Panel Controls = Inputs
Indicators = Outputs
Block Diagram Accompanying program
for front panel
Components wired
together
8/11/2019 Lesson_1-4
17/9217
LabVIEW Dialog Box
8/11/2019 Lesson_1-4
18/9218
Creating a new VI
FileNew VIto open a blank VI
FileNewto open the New dialog box and configure a VI template,global variable, control, etc
8/11/2019 Lesson_1-4
19/9219
Template Browser
8/11/2019 Lesson_1-4
20/9220
Menu
File Edit Operate Tools Browse Window Help
8/11/2019 Lesson_1-4
21/9221
Front Panel Window
Front Panel
Toolbar
Graph
Legend
BooleanControl
WaveformGraph
Icon
Plot
Legend
ScaleLegend
Waveform
GraphOwnedLabel
8/11/2019 Lesson_1-4
22/9222
Block Diagram Window
WireData
GraphTerminal
SubVI
While LoopStructure
Block
DiagramToolbar DivideFunction
NumericConstant
TimingFunction
Boolean ControlTerminal
8/11/2019 Lesson_1-4
23/9223
Front Panel and Block Diagram Toolbars
Run button
Continuous Run button
Abort button
Pause/Continue button
Execution Highlighting button
Step Into button Step Over button
Step Out button
Warning indicator
Enter button
Broken Run button
Font ring
Alignment ring
Distribution ring
Resize ring
Reorder ring
Context Help ButtonAdditional Buttons on theBlock Diagram Toolbar
8/11/2019 Lesson_1-4
24/92
24
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 andblock diagram objects
To show the tools palette, select
WindowShow Tools Palette
8/11/2019 Lesson_1-4
25/92
25
Front Panel Controls Palette
Controls PaletteContains the most commonly used controls
All Controls PaletteShows all controls
8/11/2019 Lesson_1-4
26/92
26
Block Diagram Functions Palette
Functions PaletteContains the Express VIs (interactive VIs with
configurable dialog page) and the most commonly
used functions
All Functions PaletteShows all functions
8/11/2019 Lesson_1-4
27/92
27
Palette Tools
Graphical, floating palettes
Subpalettes can be converted to floating palettes Use Palette Options to change palette view from
Express to Advanced
Search Palette Options
Click pushpin to tack down palette
Up to OwningPalette
8/11/2019 Lesson_1-4
28/92
28
Searching for Controls, VIs, and Functions
Press the search button toperform text searches of
the palettes
Click and drag an item
from the search window tothe block diagram or
double-click an item to
open the owning palette
8/11/2019 Lesson_1-4
29/92
8/11/2019 Lesson_1-4
30/92
30
Build the front panel with controls (inputs)and indicators (outputs)
NumericControl
NumericIndicatorOwned
Labels
IncrementButtons
BooleanControl
BooleanIndicator
Creating a VI Front Panel
8/11/2019 Lesson_1-4
31/92
8/11/2019 Lesson_1-4
32/92
32
Property Page
Right-click a control orindicator on the front
panel and select
Properties from the
shortcut menu to accessthe property dialog box
for that object
8/11/2019 Lesson_1-4
33/92
33
NodesWires
ControlTerminals
Block DiagramFront Panel
IndicatorTerminals
Creating a VI Block Diagram
8/11/2019 Lesson_1-4
34/92
34
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
8/11/2019 Lesson_1-4
35/92
35
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
8/11/2019 Lesson_1-4
36/92
36
Block Diagram Terminals
Terminals are entry and exit ports
that exchange information betweenthe 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
8/11/2019 Lesson_1-4
37/92
37
Wiring the Block Diagram
Scalar
Numeric
Boolean
String
2D Array1D Array
Dynamic
8/11/2019 Lesson_1-4
38/92
38
Wiring TechniquesHot Spot
Automatic Wiring
Use Context Help Window when wiring
Right-click wire and selectClean Up Wire
Tip Strips
Automatic wire routing
Right-click terminals
and select Visible
ItemsTerminals
View the terminal connections to a function
8/11/2019 Lesson_1-4
39/92
39
Block diagram executes
dependent on the flow of data;block diagram does NOT
execute left to right
Node executes when data is
available to ALL input terminals
Nodes supply data to all outputterminals when done
Dataflow Programming
8/11/2019 Lesson_1-4
40/92
40
Context Help
To display the Context Help window, select
HelpShow Context Help, press the keys, or pressthe Show Context Help Windowbutton in the toolbar
Move cursor over object
to display help
Connections:
Requiredbold
Recommendednormal
Optional - dimmed
Simple/Detailed Context Help Lock Help More Help
8/11/2019 Lesson_1-4
41/92
41
LabVIEW Help
Click the More Help button in the Context Help window
Select HelpVI, Function, & How-To Help
Click the sentence Click here for more helpin the ContextHelp window.
Contains detailed descriptions of most palettes, menus,tools, VIs, and functions, step-by-step instructions for usingLabVIEW features, links to the LabVIEW Tutorial, PDF
versions of all the LabVIEW manuals and Application Notes,and technical support resources.
8/11/2019 Lesson_1-4
42/92
42
NI Example Finder
To find an example, selectHelpFind Examples
Web-integrated
Search by keyword,
example type, hardwaretype, etc.
8/11/2019 Lesson_1-4
43/92
43
Debugging Techniques
Finding Errors
Click on broken Run button. A window showing the
error appears
Execution Highlighting
Click on Execution Highlighting button; data flow isanimated using bubbles. Values are displayed on
wires.
8/11/2019 Lesson_1-4
44/92
44
Debugging Techniques
Probe
Right-click on wire and select probe and it showsdata as it flows through the wire segment
Breakpoints
Right-click on wire and select Set Breakpoint; pauseexecution at the breakpoint.
Conditional Probe
Combination of a breakpoint and a probe. Right-click on
wire and select custom probe.
8/11/2019 Lesson_1-4
45/92
45
Debugging Techniques
Step Into, Over, and Out buttons for Single Stepping
Click on Step Into button to enable single steppingOnce Single Stepping has begun, the button stepsinto nodes
Click on Step Over button to enable single steppingor to step over nodes
Click on Step Out button to step out of nodes
8/11/2019 Lesson_1-4
46/92
46
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 blockdiagram 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 createyour measurement code. For the most common requirements, use ExpressVIs with interactive configuration dialogs to define your application.
Floating Palettes: Tools Palette, Controls Palette (only when Front PanelWindow is active), and Functions Palette (only when Block Diagram Window isactive)
There are help utilities including the Context Help Window and LabVIEW Help
8/11/2019 Lesson_1-4
47/92
47
Summary Place controls (inputs) and indicators (outputs) in the front panel window
Use the Operating tool to manipulate panel objects. Use the Positioning tool toselect, 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
Ti
8/11/2019 Lesson_1-4
48/92
48
Tips Common keyboard shortcuts
Access Tools Palette with -right-click
Increment/Decrement faster using key
ToolsOptions selection set preferences in LabVIEW VI Properties (File menu)
Window s Sun Linux MacOS
Run a VI
Find object
Activate Context Help window
Remove all broken wires
Close the active window
Toggle btwn Diagram/Panel Window
8/11/2019 Lesson_1-4
49/92
49
Lesson 2
Modular Programming
TOPICS
SubVIs
Icon and Connector Pane
Using SubVIs
Creating a SubVI from sections of a VI
8/11/2019 Lesson_1-4
50/92
50
LabVIEW Hierarchy
SubVI
8/11/2019 Lesson_1-4
51/92
51
SubVIs
Function Pseudo Codefunction average (in1,in2, out)
{
out = (in1 + in2)/2.0;
}
SubVI Block Diagram
Calling Program Pseudo Codemain{
average (point1, point2,
pointavg)
}
Calling VI Block Diagram
8/11/2019 Lesson_1-4
52/92
52
Icon/Connector
An icon represents a VI in other block
diagrams
A connector passes data to and receives
data from a subVI through terminals
Icon
Connector
terminals
terminals
8/11/2019 Lesson_1-4
53/92
53
SubVI ExampleCalculating 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
8/11/2019 Lesson_1-4
54/92
54
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
Default Icon Create a custom icon
8/11/2019 Lesson_1-4
55/92
55
Creating the Connector
Right-click the icon(Front Panel only)
C ti th C t ti d
8/11/2019 Lesson_1-4
56/92
56
Creating the Connector- continuedClick withwiring tool
Th C t P
8/11/2019 Lesson_1-4
57/92
57
The Connector Pane
Terminal colors match the data types to which they are connected
Click the terminal to see its associated front panel object
8/11/2019 Lesson_1-4
58/92
58
Using a VI as a SubVI
All Functions Select a VI
Drag icon onto target diagram
8/11/2019 Lesson_1-4
59/92
59
Help and Classifying Terminals
Classify inputs and outputs:
Required Error if no connection Recommended Warning if no connection
Optional No effect if no connection
C t S bVI O ti
8/11/2019 Lesson_1-4
60/92
60
Create SubVI Option
Enclose area to be converted into a subVI
Select Create SubVI from the Edit Menu
S
8/11/2019 Lesson_1-4
61/92
61
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
L 3
8/11/2019 Lesson_1-4
62/92
62
Lesson 3
Repetition and Loops
TOPICS
While Loops
For Loops
Accessing Previous Loop Data
Whil L
8/11/2019 Lesson_1-4
63/92
63
While Loops
LabVIEW While Loop Flow Chart Pseudo Code
Repeat (code);
Until Condition met;
End;
Whil L
8/11/2019 Lesson_1-4
64/92
64
While Loops1. Select While Loop 2. Enclose code to be repeated
3. Drop or drag additional nodes and then wire
Select the Loop Condition
8/11/2019 Lesson_1-4
65/92
65
Select the Loop Condition
Click the Conditional Terminal with the Operating tool to
define when the loop stopsDefault: Stop if True
Iteration Terminal Conditional Terminal
St t T l
8/11/2019 Lesson_1-4
66/92
66
Structure Tunnels
Tunnels feed data into and out of structures.
The tunnel is a block that appears on the border; the color ofthe 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 thetunnel.
Data pass out of a loop after
the loop terminates.
For Loops
8/11/2019 Lesson_1-4
67/92
67
For Loops
LabVIEW For Loop Flow Chart Pseudo Code
N=100;
i=0;
Until i=N:
Repeat (code; i=i+1);
End;
F L
8/11/2019 Lesson_1-4
68/92
68
For Loops In Structures subpalette of Functions palette
Enclose code to be repeated and/or resize and add nodesinside boundary
Executes diagram inside of loop a predetermined numberof times
Count terminal(Numerical input)
Wait Until Nextms Multiplefunction
W it F ti
8/11/2019 Lesson_1-4
69/92
69
Wait Functions
Wait Until Next
ms Multiple
FunctionsTime
& Dialogpalette
W it F ti
8/11/2019 Lesson_1-4
70/92
70
Wait Functions
Wait (ms)
FunctionsTime& Dialogpalette
Time Delay
FunctionsTime& Dialogpalette
Numeric Conversion
8/11/2019 Lesson_1-4
71/92
71
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 coerciondot on terminal indicates conversion
Numeric Conversion
8/11/2019 Lesson_1-4
72/92
72
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.
When LabVIEW converts floating-point numerics to integers, it
rounds to the nearest integer. LabVIEW rounds x.5 to the
nearest even integer.For example, LabVIEW rounds 2.5 to 2 and 3.5 to 4.
8/11/2019 Lesson_1-4
73/92
Additional Shift Register Elements
8/11/2019 Lesson_1-4
74/92
74
Additional Shift Register Elements
Latest value
is passed toright terminal
Right-click theleft terminal toadd newelements
Previous values are available atthe left terminals
Right-click theborder for a
new shiftregister
1 loop ago
2 loops ago
3 loops ago
Feedback Nodes
8/11/2019 Lesson_1-4
75/92
75
Feedback Nodes
Appears automatically in a For Loop or While Loop ifyou wire the output of a subVI, function, or group of
subVIs and functions to the input of that same VI,
function, or group.
Stores data when the loop completes an iteration,
sends that value to the next iteration of the loop, and
transfers any data type
8/11/2019 Lesson_1-4
76/92
Initialized Shift Registers & Feedback Nodes
8/11/2019 Lesson_1-4
77/92
77
Initialized Shift Registers & Feedback Nodes
Run Once VI stops execution Run Again
Output = 5Output = 5
Output = 5 Output = 5
8/11/2019 Lesson_1-4
78/92
Summary
8/11/2019 Lesson_1-4
79/92
79
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
8/11/2019 Lesson_1-4
80/92
80
Lesson 4
Arrays
TOPICS
Introduction to Arrays
Auto Indexing Arrays
Array Functions
Polymorphism
Arrays
8/11/2019 Lesson_1-4
81/92
81
Collection of data elements that are of same type
One or more dimensions, up to 2 elements per dimension Elements accessed by their index; first element is index 0
31
index
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 7 8 9
2D array
Five row by seven column array of 35 elements
0 1 2 3 4 5 601234
Arrays
8/11/2019 Lesson_1-4
82/92
Creating Array Constants
8/11/2019 Lesson_1-4
83/92
83
1. Select Array
Constantshell fromthe Arraysubpalette
2. Place the data object in the array shell
Creating Array Constants
Auto-Indexing
8/11/2019 Lesson_1-4
84/92
84
Loops can
accumulate arrays attheir boundaries with
auto-indexing
For Loops auto-index
by default
While Loops output the
final value by default
Right-click on tunnel
and enable/disable
auto-indexing
Auto-Indexing
Wire becomes thicker
Wire remains the same size
Auto-Indexing Disabled
Auto-Indexing Enabled
Only one value (last iteration)
is passed out of the loop
1D Array
0 1 2 3 4 5
Creating 2D Arrays
8/11/2019 Lesson_1-4
85/92
85
Inner loop creates column elements
Outer loop stacks them into rows
Creating 2D Arrays
1D Array
0 1 2 3 4 5
2D Array
Auto-Index Input
8/11/2019 Lesson_1-4
86/92
86
Auto-Index Input
An array input can be
used to set the For
Loop count terminal
Number of elements
in the array equals
the count terminalinput
Run arrow not
broken
Common Array Functions
8/11/2019 Lesson_1-4
87/92
87
Array Size
Initialize Array
Common Array Functions
Common Array Functions
8/11/2019 Lesson_1-4
88/92
88
Array Subset
Common Array Functions
The Build Array Function
8/11/2019 Lesson_1-4
89/92
89
The Build Array Function
Building a higher dimension array
Concatenate Inputs
Appending an element
default
The Index Array Function
8/11/2019 Lesson_1-4
90/92
90
The Index Array Function
Extracting an Element
Extracting an Element of a Row
Extracting a Row
8/11/2019 Lesson_1-4
91/92
8/11/2019 Lesson_1-4
92/92