How to use LabVIEW

advertisement
How to use LabVIEW
February 2011
Contents
 What is LabVIEW?
 How does LabVIEW work?
Block diagram
Front panel
Palettes
 Data flow programming. Functions.
 LabVIEW Programming Structures (Formula, Case structure …)
 What is a subVI? Using a VI as a subVI.
 How to use LabVIEW with data acquisition (DAQ) software
Measurements and automation explorer (MAX)
I. Korolov: How to use LabVIEW
What is LabVIEW?
LabVIEW – Laboratory Virtual Instrument Engineering Workbench
is a graphical (visual) programming from National istruments (NI).
The purpose is automating the usage of processing and measuring equipment in any laboratory setup.
Originally released for the Apple Macintosh in 1986, the graphical language at the heart of LabVIEW is called "G".
C language
Dataflow programming language
uses icons instead of lines of text to create programs
The graphical approach of LabVIEW allows non-programmers to build
programs by dragging and dropping virtual representations of lab
equipment with which they are already familiar.
Cross-platform
I. Korolov: How to use LabVIEW
Price
Desktop PC
LabVIEW Professional Development System
http://www.ni.com/labview/buy/
I. Korolov: How to use LabVIEW
Laptop
PDA
LabVIEW
PXI Modular Instrumentation
High-Speed High-Resolution
Multifunction
Dynamic
Digitizers and DMMs Data Acquisition Signal Acquisition
Digitizers
Instrument
Control
Laptop PC
Desktop PC
Digital I/O
Counter/
Timers
Machine
Vision
Motion
Control
Distributed I/O and
Embedded Control
Signal Conditioning
and Switching
Unit Under Test
www.ni.com
I. Korolov: How to use LabVIEW
PDA
How does LabVIEW work?
I. Korolov: How to use LabVIEW
How does LabVIEW work?
I. Korolov: How to use LabVIEW
How does LabVIEW work?
Front panel
Block Diagram
Ctrl+E
Block diagram toolbar
Continuous run
Clean Up diagram
Pause
Run
Stop
Reorder objects
Debugging features
I. Korolov: How to use LabVIEW
How does LabVIEW work?
LabVIEW Front panel
Used to display Controls or Indicators
I. Korolov: How to use LabVIEW
How does LabVIEW work?
LabVIEW Block Diagram
- Actual program
- Invisible to user
- Read left to right
I. Korolov: How to use LabVIEW
Example LP
How does LabVIEW work? Palettes
Front panel
Block Diagram
Controls palette
Tools palette
I. Korolov: How to use LabVIEW
How does LabVIEW work? Tools palette
• Floating Palette
• Used to operate and modify front
panel and block diagram objects.
Automatic Selection Tool
Operating Tool
Scrolling Tool
Positioning/Resizing Tool
Breakpoint Tool
Labeling Tool
Probe Tool
Wiring Tool
Color Copy Tool
Shortcut Menu Tool
Coloring Tool
I. Korolov: How to use LabVIEW
Example
Data flow programming
I. Korolov: How to use LabVIEW
Data flow programming
If you put a control (or
indicator) on the front panel
I. Korolov: How to use LabVIEW
LabVIEW automatically creates a corresponding
control (or indicator) terminal on theBlock
Diagram
Example FP TB
Data flow programming. Functions.
View as icon
“Add” function
Click and Ctrl+H
wire
I. Korolov: How to use LabVIEW
Example2,3
Data flow programming. Functions.
I. Korolov: How to use LabVIEW
Example
Data flow programming. Wires
Some of basic wires used in block diagrams
Data type
Color
Floating-point
orange
Integer
blue
Boolean
green
String
Pink/purple
Dynamic
Dark blue
Broken wires
The wire connects more than one data source
You have connected two terminals of different types
I. Korolov: How to use LabVIEW
Data flow programming. Functions
I. Korolov: How to use LabVIEW
Example
Data flow programming. Functions
Polymorphism
Array Arithmetic Operations
I. Korolov: How to use LabVIEW
Programming structures
I. Korolov: How to use LabVIEW
LabVIEW Programming Structures
For loop
From 0 to N-1
I. Korolov: How to use LabVIEW
Example For Loop
LabVIEW Programming Structures
While loop
Auto-indexed tunnel
Loop tunnel
Shift register
Timed While loop
Repeats the sub diagram inside the loop until the conditional terminal
receives a particular Boolean value
I. Korolov: How to use LabVIEW
Example WhileL
LabVIEW Programming Structures
Case structure
I. Korolov: How to use LabVIEW
Example
LabVIEW Programming Structures
Flat sequence structure
1
2
3
Stacked sequence structure
4
Sequence structures are
used
to
ensure
a
subdiagram
executes
after or before another
subdiagram
I. Korolov: How to use LabVIEW
3
2
1
LabVIEW Programming Structures
Local variables
Use local variables to read or write to one
of the controls or indicators on the front
panel of a VI.
I. Korolov: How to use LabVIEW
Global variables
Use global variables to access
and pass data among several
VIs
Example
LabVIEW: Wait statements
Wait (ms) function
Pre-loop
code
I. Korolov: How to use LabVIEW
Wait Until Next ms Multiple function
Loop code
LabVIEW: Graphs
Waveform Graph – Plot an array of numbers against their indices
XY Graph – Plot one array against another
Digital Waveform Graph – Plot bits from binary data
Graph properties
I. Korolov: How to use LabVIEW
Example Graph
LabVIEW: File I/O
Write to a File
Read from a File
Write/Read LabVIEW Measurements file
Writing to LVM file
I. Korolov: How to use LabVIEW
Reading from LVM file
Example File I/O
SubVI
I. Korolov: How to use LabVIEW
What is a subVI? Using a VI as a subVI.
What is a subVI?
A SubVi is a stand VI that can be called by other VI and it is similar to an individual function.
Advantages
Modular
Easier to debug
Don’t have to recreate code
Require less memory
I. Korolov: How to use LabVIEW
What is a subVI? Using a VI as a subVI.
How to create a subVI?
A SubVi is a stand VI that can be called by other VI and it is similar to an individual function.
 Create/Edit the Icon
 Create the Connector
 Assign Terminals to controls and indicators
 Add description (optional)
 Save the VI
 Insert the VI into a Top Level VI
1 Create/Edit the Icon
Right-click on the icon in
the block diagram or front
panel
I. Korolov: How to use LabVIEW
What is a subVI? Using a VI as a subVI.
2 Create the Connector
3 Assign Terminals to controls and indicators
Right click on the icon pane (front panel only)
r
4 Documentation (VI properties)
5. Save the VI
6. Insert the VI into a Top Level VI
I. Korolov: How to use LabVIEW
Example
Data acquisition
I. Korolov: How to use LabVIEW
How to use LabVIEW with DAQ software
Fundamental task of a DAQ system is to measure or generate real-world physical signals
• Data acquisition (DAQ)
• Connecting Signals
• Simple DAQ application
DAQ device
Sensors
Terminal Block
I. Korolov: How to use LabVIEW
Measurements and automation explorer (MAX)
MAX is the primary configuration and testing utility that is available for the DAQ device
Measurement & Automation Explorer (MAX) provides access to all your NI DAQ,
GPIB, IMAQ, IVI, Motion, VISA, and VXI devices. Here can configure your NI
hardware and software, add new channels, interfaces, and virtual instruments, execute
system diagnostics, and view the devices and instruments connected to your system.
Configuration tree
Configuration View
I. Korolov: How to use LabVIEW
Task list
MAX
How to use LabVIEW with DAQ software
Traditional NI-DAQ
Specific VIs for
performing:
• Analog Input
• Analog Output
• Digital I/O
• Counter operations
DAQ assistant
I. Korolov: How to use LabVIEW
NI-DAQmx
Next generation driver:
• VIs for performing a
task
• One set of VIs for all
measurement types
Measurement type can be:
• Analog Input
• Analog Output
• Counter Input
• Counter Output
• Digital I/O
How to use LabVIEW with DAQ software
Ni USB 6501
DAQ assistant
Quickly and easily program the DAQ device
Creates a local task
Most applications can use the DAQ Assistant
I. Korolov: How to use LabVIEW
Example DAQ
How to use LabVIEW ? Tips and tricks
Tips and tricks
 GPIB Communication and Configuration
 Virtual Instrument Software Architecture (VISA)
Serial Port Communication
 Instrument Drivers (How to create and use *.dll in LabVIEW)
 Application control (property node and invoke node)
 How to execute a system command
 Remote panel connection manager and Web publishing tool
 …
I. Korolov: How to use LabVIEW
Download