Professional Documents
Culture Documents
6- Hou r Hands -O n
Co ur se Goals
• Become comfortable with the LabVIEW environment
and data flow execution
• Ability to use LabVIEW to solve problems
• LabVIEW Concepts
– Acquiring, saving and loading data
– Find and use math and complex analysis functions
– Work with data types, such as arrays and clusters
– Displaying and printing results
Th e Vir tual I nstru menta tion Ap pro ach
La bVI EW Grap hical De velop ment S yst em
• Graphical Programming Environment
• Compile code for multiple OS and devices
• Useful in a broad range of applications
Virtua l Inst rumen tat ion App li ca tio ns
• Des ign
– Signal and Image Processing
– Embedded System Programming A single graphical development platf orm
• (PC, DSP, FPGA, Microcontroller)
– Simulation and Prototyping Design Prototype Deploy
– And more…
• Control
– Automatic Controls and Dynamic Systems
– Mechatronics and Robotics
– And more…
• Meas urem ents
– Circuits and Electronics
– Measurements and Instrumentation
– And more…
The NI Approach – Integrated Hardware Platforms
Hig h-S pe edHig h -R eso lu tio n Mu lti functio n Dyn a mic In stru me n t Dig ita l I/ O Cou nter/ M ach in e Mo tio n Distr ib u te d I/O a nd
Dig itiz ers Dig itiz e rs a nd DMM sDa ta Acq u isi tio nS ig nal A cq uis itio n Co ntro l T ime rs V isio n Con tro l E mb e dd ed Con tro l
Un it Und er T est
Sect io n I – La bVI EW En vir onme nt
A. Getting Data into your Computer
• Data Acquisition Devices
– NI-DAQ
– Simulated Data Acquisition
– Sound Card
B. LabVIEW Environment
• Front Panel / Block Diagram
• Toolbar /Tools Palette
C. Components of a LabVIEW Application
• Creating a VI
• Data Flow Execution
D. Additional Help
• Finding Functions
• Tips for Working in LabVIEW
A. Sett in g Up Yo ur Ha rd wa re
abo ve tab le may no t be rep resen tative of all de vice varia tions that exist i n ea ch c ategory
What is MA X?
• MAX stands for Measurement & Automation Explorer.
• MAX configures and organizes all your National Instruments DAQ,
PCI/PXI instruments, GPIB, IMAQ, IVI, Motion, VISA, and VXI devices.
• Used for configuring and testing devices.
Icon Found on
Windows Desktop
Track A
Ex ercis e 1 – Se tting Up Your Device
• Use Measurement and Automation Explorer (MAX) to:
– Configure and test your Data Acquisition (DAQ) device
Do No t De lete
Ex ercis e Inst ruct ions
Track B
Ex ercis e 1 – Se tting Up Your Device
• Use Measurement and Automation Explorer (MAX) to:
– Configure and test your Simulated Data Acquisition (DAQ) device
Do No t De lete
Ex ercis e Inst ruct ions
Track C
Ex ercis e 1 – Se tting Up Your Device
• Use Windows to:
– Verify your Sound Card
Un-Mute Microphone
Open and Run LabVIEW
Sta rt »Al l P ro grams »N ation al In st ruments LabVIE W
»
Sta rtu p
Scr een:
Start from a Blank VI :
New» Blan k VI
or
Start from an
Example:
Ex am ples»F ind
Ex amples …
LabVIEW Programs Are Called Virtual Instruments (VIs)
Each VI has 2 Windows
Fr ont P anel
• User Interface (UI)
– Controls = Inputs
– Indicators = Outputs
Block D iagram
• Graphical Code
– Data travels on wires from
controls through functions to
indicators
– Blocks execute by Dataflow
Con trols Pale tte (Place items on the Front Panel Window)
(Con trols & Indicator s)
Control: Cu sto miz
Numeric e Pa lett e
Vi ew
Indicator:
Numeric Slide
Fun ction s (a nd Structure s) Pa lett e
Structure:
While Loop
Tools Palette
• Recommended: Automatic Selection Tool
• Tools to operate and modify both front panel and
block diagram objects
Operating Tool
Positioning/Resizing Tool
Labeling Tool
Wiring Tool
Status Toolbar
Run Button
Abort Execution
Additional Buttons on
the Diagram Toolbar
Graph
Indicator
Output
Terminal
Boolean
Control
Input
Terminals
Da taf low Pro gr amming
• Block diagram execution
– 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 output
terminals when done
Debugging Techniques
• Finding Errors
Click on broken Run button.
Window showing error appears.
• Execution Highlighting
Click on Execution Highlighting button; data
flow is animated using bubbles. Values are
displayed on wires.
• Probes
Right-click on wire to display probe and it shows
data as it flows through wire segment.
• While Loops
– i terminal counts iteration
– Always runs at least once
– Runs until stop condition is
met
For Loop
• For Loops
– i terminal counts iterations
– Run according to input N of
count terminal
Drawing a Loop
2. Enclose code to be repeated
(a) (b)
7. Select
(c )
File I /O
• File I/O – Allows recording or reading data in a file.
• LabVIEW creates or uses the following file formats:
– Binary: underlying file format of all other file formats
– ASCII: regular text files
– LVM: LabVIEW measurement data file
– TDM: created for National Instruments products
Hi gh Le vel File I/O Fu nct io ns
• Easy to use
• High Level of abstraction
Functions»Express»Graph Indicators»Chart
Graph s – Dis play ma ny data poin ts at
onc e
Waveform graph – special numeric indicator that
displays an array of data
• Graph updates after all points have been collected
• May be used in a loop if VI collects buffers of data
Functions»Express»Graph Indicators»Graph
Build ing Arr ay s with Lo op s (Auto-
Inde xin g) Auto-I ndexing Enabl ed
• Loops can accumulate
Wire becomes thicker
arrays at their boundaries
with auto-indexing
• For Loops auto-index by
1D Array
default
• While Loops output only 012345
the final value by default
Aut o-Indexing Dis abl ed
• Right-click tunnel and
Wire remains the same size
enable/disable auto-
indexing
(Terminal labels
reflect data type)
Bundle
Bundle By Name
Using A rra ys and Clust ers wit h G ra phs
The Waveform Datatype contains 3 pieces of data:
• t0 = Start Time
• dt = Time between Samples
• Y = Array of Y magnitudes
Initial
Va lu e Val ue 3
Before
Loop First Second Last
Begins Iteration Iteration Iteration
Mod ula rity in La bVI EW – Sub VI s
• Top terminals are usually reserved for references, such as a file reference
• Bottom terminals are
usually reserved for
error clusters
Ic on and Con nector Pan e – Cr ea te Ic on
• Create custom icons by right-clicking the icon in the upper right corner of
the front panel or block diagram and selecting Ed it Ic on or by double-
clicking the icon
• You also can drag a graphic from anywhere in your file system and drop it
on the icon
• Refer to the
Icon Art Glossary at
ni.com for standard
graphics to use in
a VI icon
Do No t De lete
Ex ercis e Inst ruct ions
Do No t De lete
Ex ercis e Inst ruct ions
St ate Ma chine s
• While Loop
• Case Structure
• Shift Register
St ate Ma chine s Tra nsit io ns
• Several programming
techniques exist for transitioning
from state to state in LabVIEW
using State Machines
• Default transition implies that
after one state, another state
always follows
• Transitions between two
potential states can be handled
by a Select Function
Co mmun ic atin g betw ee n l oop s
•Communicating between loops using data
flow is not possible
•The left loop will execute completely
before the right loop
•Variables are needed when communication
with wires does not give the desired behavior
Local Variables
• Local Variables allow data to be passed between parallel loops.
• A single control or indicator can be read or written to from more than one
location in the program
– Local Variables break the dataflow paradigm and should be used sparingly
Crea ting a Local Variable - Walk Throu gh
In this example we will see
how Local Variables allow us
to share data between
parallel loops. We will
create a program that
toggles two separate LEDs
using one switch. It also
stops two loops with one
button.
• LabVIEW Certification
– LabVIEW Fundamentals Exam (free on www.ni.com/academic)
– Certified LabVIEW Associate Developer Exam (industry recognized certification )
Associate Developer
• Proficiency in navigating
Certifie d L abVIEW Asso ciat e
LabVIEW environment De velo pe r
• Some application
development experience
Fundam ental s Ex am
• Pre-Certification Skills Test Fr ee O n-L ine Fu ndamen tals
Exa m
Elect roni cs Wor kbench an d Multis im