Introduction To LabVIEW 8 in 6 Hours-1
Introduction To LabVIEW 8 in 6 Hours-1
6-Hour Hands-On
The Virtual Instrumentation Approach
LabVIEW Graphical Development System
• Graphical Programming Environment
• Compile code for multiple OS and devices
• Useful in a broad range of applications
Virtual Instrumentation Applications
• Design
– Signal and Image Processing
– Embedded System Programming A single graphical development platform
• (PC, DSP, FPGA, Microcontroller)
– Simulation and Prototyping Design Prototype Deploy
– And more…
• Control
– Automatic Controls and Dynamic Systems
– Mechatronics and Robotics
– And more…
• Measurements
– Circuits and Electronics
– Measurements and Instrumentation
– And more…
The NI Approach – Integrated Hardware Platforms
High-Speed High-Resolution Multifunction Dynamic Instrument Digital I/O Counter/ Machine Motion Distributed I/O and
Digitizers Digitizers and DMMs Data Acquisition Signal Acquisition Control Timers Vision Control Embedded Control
Signal Conditioning
and Switching
* The above table may not be representative of all device variations that exist in each category
What is MAX?
• 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
Exercise 1 – Setting Up Your Device
• Use Measurement and Automation Explorer (MAX) to:
– Configure and test your Data Acquisition (DAQ) device
Track B
Exercise 1 – Setting Up Your Device
• Use Measurement and Automation Explorer (MAX) to:
– Configure and test your Simulated Data Acquisition (DAQ) device
Track C
Exercise 1 – Setting Up Your Device
• Use Windows to:
–Verify your Sound Card
Un-Mute Microphone
Open and Run LabVIEW
Start»All Programs»National Instruments LabVIEW
»
Startup Screen:
Start from a Blank VI:
New»Blank VI
or
Start from an Example:
Examples»Find
Examples…
LabVIEW Programs Are Called Virtual Instruments (VIs)
Each VI has 2 Windows
Front Panel
• User Interface (UI)
– Controls = Inputs
– Indicators = Outputs
Block Diagram
• Graphical Code
– Data travels on wires from
controls through functions to
indicators
– Blocks execute by Dataflow
Controls Palette (Place items on the Front Panel Window)
(Controls & Indicators)
Control: Customize
Numeric Palette
View
Indicator:
Numeric Slide
Functions (and Structures) Palette
Structure:
While Loop
Status Toolbar
Run Button
Abort Execution
Additional Buttons on
the Diagram Toolbar
Graph
Indicator
Output
Terminal
Boolean
Control
Input
Terminals
Dataflow Programming
• 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.
Additional Help
– Right-Click on the VI icon and
choose Help, or
– Choose “Detailed Help.” on
the context help window
Tips for Working in LabVIEW
• Keystroke Shortcuts
– <Ctrl+H> – Activate/Deactivate Context Help Window
– <Ctrl+B> – Remove Broken Wires From Block Diagram
– <Ctrl+E> – Toggle Between Front Panel and Block
Diagram
– <Ctrl+Z> – Undo (Also in Edit Menu)
• Tools»Options… – Set Preferences in LabVIEW
• VI Properties–Configure VI Appearance,
Documentation, etc.
Section II – Elements of Typical Programs
A. Loops
• While Loop
• For Loop
B. Functions and SubVIs
• Types of Functions
• Creating Custom Functions (SubVI)
• Functions Palette & Searching
C. Decision Making and File IO
• Case Structure
• Select (simple If statement)
• File I/O
Loops While Loop
•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)
2. 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
High Level File I/O Functions
• Easy to use
• High Level of abstraction
(Functions»Programming»
Structures»MathScript)
View/Modify
Variable Contents
User Commands
m-file Script
(LabVIEW»Tools»MathScript Window)
Exercise 3.2 – Using MathScript Track A,B,&C
Use the MathScript Node and Interactive Window to process the
acquired signal (logarithmic decay) in the MathScript and save
the script.
(Terminal labels
reflect data type)
Bundle
Bundle By Name
Using Arrays and Clusters with Graphs
The Waveform Datatype contains 3 pieces of data:
• t0 = Start Time
• dt = Time between Samples
• Y = Array of Y magnitudes
Initial
Value Value 3
Before
Loop First Second Last
Begins Iteration Iteration Iteration
Modularity in LabVIEW – SubVIs
• Top terminals are usually reserved for references, such as a file reference
• Bottom terminals are
usually reserved for
error clusters
Icon and Connector Pane – Create Icon
• Create custom icons by right-clicking the icon in the upper right corner of
the front panel or block diagram and selecting Edit Icon 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 Not Delete
Exercise Instructions
Do Not Delete
Exercise Instructions
State Machines
• While Loop
• Case Structure
• Shift Register
State Machines Transitions
• 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
Communicating between loops
•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
Creating a Local Variable - Walk Through
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»Project»New)
Shared Variables
• Shared Variables are used to send data between VIs.
• Variable Types:
– Single Process: share the data among VIs on the local computer.
– Network-published: communicate between VIs, remote
computers, and hardware through the Shared Variable Engine.
• LabVIEW Certification
– LabVIEW Fundamentals Exam (free on www.ni.com/academic)
– Certified LabVIEW Associate Developer Exam (industry recognized certification )
Associate Developer
• Proficiency in navigating
Certified LabVIEW Associate
LabVIEW environment
Developer
• Some application
development experience
Fundamentals Exam
• Pre-Certification Skills Test Free On-Line Fundamentals Exam
Electronics Workbench and Multisim