Вы находитесь на странице: 1из 78

Introduction to NI LabVIEW

Payman Tehrani
Academic Field Sales Engineer - National Instruments
Our Mission
We equip engineers and scientists with tools that accelerate
productivity, innovation, and discovery.

ni.com 2
Who Chooses NIs Virtual Instrumentation Platform

Eighty-five percent of Fortune 500 manufacturing


companies have adopted NI virtual instrumentation.
ni.com 3
Empowering Users Through Software
Providing Unique Differentiation and Preserving Investments

LEGO MINDSTORMS CERN Large Hadron Collider


NXT the most powerful instrument on
the smartest, coolest toy Earth
of the year

ni.com 4
ni.com
Large Channel Case Studies
Boeing: 448-channel Microphone Array
200 Hz

Airframe Noise

400 Hz

Inlet Noise

ni.com 6
LabVIEW: Graphical System Design

Timing Textual Math

I/O integration Data Flow

Parallel C and HDL Code

Statecharts Simulation

ni.com 7
The Foundation of LabVIEW: Virtual Instrumentation
By leveraging COTS PC components, the software becomes the instrument

LabVIEW unlocks the power of instrument and data acquisition hardware


by capitalizing on the PC industry and abstracting redundant circuitry.

ni.com 8
National Instruments Strategy: Graphical System Design

Test Monitor Embedded Control Cyber Physical

Industries and Applications

Hardware and I/O Devices

Desktops and PXI and Modular Open Connectivity


NI CompactRIO
PC-Based DAQ Instruments With Third-Party I/O

ni.com 9
Therefore, LabVIEW Building Blocks Are Called
Virtual Instruments (*.VI)

LabVIEW Front Panel


The user interface of a VI

LabVIEW Block Diagram


The source code of a VI

ni.com Note: A *.vi file encapsulates


10
all three elements
Front Panel Object Styles

ni.com 11
Instructor Demo: Using Help Tools
Use Highlight Execution, Context Help and Block
Diagram Cleanup

ni.com 12
Front Panel

ni.com 13
Block Diagram

ni.com 14
Block Diagram
Block diagram items:
Terminals
Constants
Nodes
o Functions
o SubVIs
o Structures
Wires
Free labels

ni.com 15
Context Help
Displays basic
information about
wires and nodes when
you move the cursor
over an object.
Can be shown or
hidden in the following
ways.
o Select HelpShow
Context Help from the
LabVIEW menu.
o Press <Ctrl-H>.
o Click the following
button on the toolbar:
ni.com 16
16
LabVIEW Help

Contains detailed descriptions and instructions for most palettes,


menus, tools, VIs, and functions.

Can be accessed by:


Selecting Help
LabVIEW Help from the
menu.
Clicking the Detailed help
link in the
Context Help window.
Right-clicking an object
and selecting Help from
the shortcut menu.
ni.com 17
17
Examples

LabVIEW
includes
hundreds of
example VIs.
Use NI Example
Finder to browse
and search
installed
examples.

ni.com 18
18
Examples

Click the example


buttons in
LabVIEW Help
topics.
Select HelpFind
Examples in the
menu.

ni.com 19
19
Controls Palette

Contains the
controls and
indicators you use to
create the front
panel.
Navigate the
subpalettes or use
the Search button to
search the Controls
palette.
ni.com 20
Functions Palette

Contains the VIs,


functions, and
constants you use to
create the block
diagram.
Navigate the
subpalettes or use the
Search button to
search the Functions
palette.
ni.com 21
Searching with Quick Drop

Lets you quickly find


controls, functions,
VIs, and other items
by name.
Press the <Ctrl-
Space> keys to
display the Quick
Drop dialog box.

ni.com 22
Selecting a Tool

A tool is a special operating mode of


the mouse cursor.
Create, modify, and debug VIs using the
tools provided by LabVIEW.
By default, LabVIEW automatically
selects tools based on the context of
the cursor.
If you need more control, use the Tools
palette to select a specific tool.
o Select
ViewTools Palette to
open the Tools palette.

ni.com 23
23
Correcting Broken VIs

Broken Run arrow VI cannot be compiled VI cannot be executed

ni.com 24
Single-Stepping

Single-step through the VI to view each action of the VI on the


block diagram.
Suspend the execution of a subVI to edit values of controls and
indicators, to control the number of times it runs, or to go back to
the beginning of the execution of the subVI.
o Open subVI and select OperateSuspend When Called from the
shortcut menu.

ni.com 25
25
Execution Highlighting

Use execution highlighting to watch the data flow through the


block diagram.
If the VI runs more slowly than expected, confirm that you turned
off execution highlighting in subVIs.

ni.com 26
26
With LabVIEW, You Can Program the Way You Think

ni.com 27
With LabVIEW, You Can Program the Way You Think

The graphical, dataflow-based G programming language


is ideal for programming parallel data acquisition
hardware.
ni.com 28
Execution Control Structures: Loops
For Loop
Count Terminal
The code contained within this For
Loop will execute N times.

While Loop
Loop Iteration Terminals
This provides the current loop
iteration count, which ranges from
0 to N-1.

Conditional Terminal
The code within this While Loop will
ni.com
run until a True value is evaluated. 29
The Color, Style, and Thickness of Common Wires

Wire Type Scalar 1D Array 2D Array Color

Floating Point Orange

Integer Blue

Boolean Green

String Pink

Error Yellow

A broken wire represents a data type conflict that LabVIEW


cannot automatically resolve. Fix it, or your code wont run!
ni.com 30
Terminals

Same label name

ni.com 31
View Terminals as Icons

By default, View as Icon


option enabled.
Deselect View as Icon for a
more compact view.

ni.com 32
Nodes
Nodes are objects on the block diagram that have inputs and/or outputs
and perform operations when a VI runs.

Nodes

ni.com 33
SubVI Nodes
SubVIs :
o Are VIs that you use on the block diagram of another VI.
o Have front panels and block diagrams.
o Use the icon from the upper-right corner of the front panel as the
icon that appears when you place the subVI on a block diagram.
When you double-click a subVI, the front panel and block
diagram open.
Any VI has the potential to be used as a subVI.

ni.com 34
As Complex as You Need

Express Quick, easy

VIs Limited

Hides
unnecessary
Regular details
VIs Retains power
and flexibility
Powerful,
Low-level flexible,

VIs Difficult, time-


consuming

ni.com 35
Building a Simple VI

ni.com 36
While Loops

Repeat (code);
Until Condition met;
End;

LabVIEW While Loop Flowchart Pseudo Code

ni.com 37
For Loop/While Loop Comparison

For Loop While Loop


Executes a set number of Stops executing only if the
times unless a conditional value at the conditional
terminal is added. terminal meets the
Can execute zero times. condition.
Tunnels automatically Must execute at least once.
output an array of data. Tunnels automatically
output the last value.

ni.com 38
Wait Functions
A wait function inside a loop:
Allows the VI to sleep for a set amount of time.

Allows the processor to address other tasks during the wait


time.
Uses the operating system millisecond clock.

ni.com 39
Case Structures
Case Selector Label
o Contains the name of
the current case.
Case Selector Label
o Has decrement and
increment arrows.
Selector Terminal
o Letsyou wire an input
value, or selector, to
determine which case
executes.

Selector Terminal
ni.com 40
What Is Data Flow?
Each block diagram node executes only when it receives all inputs
Each node produces output data after execution
Data flows along a path defined by wires
The movement of data determines execution order

Formula: Result = (A+B*C) / (D-E)

ni.com 41
What Is Data Flow?
Each block diagram node executes only when it receives all inputs
Each node produces output data after execution
Data flows along a path defined by wires
The movement of data determines execution order

The [Multiply] and [Subtract] operations can execute at the same time since they
dont have any data dependencies.
ni.com 42
Dataflow Languages Naturally Express Parallelism
The LabVIEW compiler will automatically multithread code expressed in parallel

Task Parallelism

Data Parallelism

ni.com 43
What are Resources?

Resources An addressable file, hardware


device, object, or network connection available
on your system

LabVIEW includes VIs and functions to allow you to


access your resources.
Resources are known to the system by a path, name,
port, or other identifier.

ni.com 44
Accessing Resources in LabVIEW

A typical resource operation involves the following process:

Open, Read
Check for
Initialize or and/or Close
Errors
Create Write

Specify the path or device name. The refnum becomes obsolete.


LabVIEW creates a refnum as a unique
identifier to the resource.
A refnum is a temporary pointer to the
resource.
ni.com 45
Accessing Resources in LabVIEW

Sample refnum wires:

ni.com 46
File I/O
Understanding File I/O
File Formats
High-Level File I/O VIs
Low-Level File I/O VIs

ni.com 47
Understanding File I/O
File I/O writes to or reads from a file.
A typical file I/O operation involves the following process:

Open/ Read
Close Check for
Create/ and/or
File Errors
Replace File Write to File

ni.com 48
Understanding Low-Level File I/O VIs

ni.com 49
DAQ Programming Basic Flow
A basic DAQmx application involves the following
process:
Acquire or Check
Create Configure Start Clear
Generate for
Task Task Task Task
Data Errors

ni.com 50
Understanding Modularity SubVIs

Repeated code can become subVIs.

ni.com 51
Understanding Modularity SubVIs

ni.com 52
Understanding Modularity SubVIs

Function Code Calling Program Code


function average (in1, in2, main
out) {
{ average (point1, point2,
out = (in1 + in2)/2.0; pointavg)
} }

SubVI Block Diagram Calling VI Block Diagram

ni.com 53
Creating Icons - Icon Editor
Open the Icon Editor using one of these methods:
o Right-click the icon in the upper-right corner of the front panel or
block diagram and select Edit Icon.
o Double-click the icon.

ni.com 54
Parallelism
Execute multiple tasks at the same time

ni.com 55
Variables

Variables - Block diagram elements that allow


you to access or store data in another location

Variables can be of the following types:


LocalStores data in front panel controls and indicators
Global Stores data in special repositories that can be accessed from multiple
VIs
Functional GlobalStores data in While Loop shift registers
SharedTransfers data between various distributed targets connected
together over a network

ni.com 56
How do the loops stop in this example?

Passing data among parallel loops is a challenge.

ni.com 57
57
Local Variables

Use local variables to pass data within a single VI.

ni.com 58
58
Race Conditions Sequencing
What is the final value?
Four possible outcomes:
Value = (Value * 5) +2
Value = (Value + 2) * 5
Value = Value * 5
Value = Value +2

ni.com 59
Arrays

An array:
Is a collection of data
elements that are of
same type.
Has one or more
dimensions.
Contains up to (231)1
elements per dimension,
memory permitting.
Accesses elements by
its index.
Note: The first element
is index 0.

ni.com 60
Arrays 1D and 2D Examples

ID array
One row of 10-elements
0 1 2 3 4 5 6 7 8 9
1.2 3.2 8.2 8.0 4.8 5.1 6.0 1.0 2.5 1.7

Index
2D array numbers
Five-row by seven-column table of 35
elements
0 1 2 3 4 5 6
0
1
2
3
4

ni.com 61
Common Array Functions
Array Size
Initialize Array
Array Subset
Build Array
Index Array

ni.com 62
Auto-Indexing Input
If the iteration count terminal is wired and arrays of
different sizes are wired to auto-indexed tunnels, the
actual number of iterations becomes the smallest of the
choices.

ni.com 63
63
Charts vs. Graphs Single-Plot

ni.com 64
Why Use Build Specifications?
Use build specifications to build the following:
Stand-alone applications
Installers
Source distributions
Zip files
Shared libraries
Packed Project libraries
.NET Interop Assemblies
Web services

65 ni.com 65
LabVIEW Real-Time Module
LabVIEW FPGA Module

Leveraging the LabVIEW Ecosystem LabVIEW Embedded Module for ARM


LabVIEW Touch Panel Module
LabVIEW Wireless Sensor Network Module
LabVIEW C Code Generator
NI Real-Time Hypervisor
LabVIEW Tools Network Vision Development Module for LabVIEW
Sound and Vibration Measurement Suite
1,000,000+ Add-Ons Downloaded Sound and Vibration Toolkit
26+ Certified Add-Ons LabVIEW Advanced Signal Processing Toolkit
LabVIEW Adaptive Filter Toolkit
100+ Available Add-Ons LabVIEW Digital Filter Design Toolkit
LabVIEW MathScript RT Module
Spectral Measurements Toolkit
Modulation Toolkit for LabVIEW
LabVIEW Robotics Module
LabVIEW Biomedical Toolkit
ECU Measurement and Calibration Toolkit
GPS Simulation Toolkit for LabVIEW
Measurement Suite for Fixed WiMAX
WLAN Measurement Suite
Automotive Diagnostic Command Set
LabVIEW GPU Analysis Toolkit
Multicore Analysis and Sparse Matrix Toolkit
LabVIEW PID and Fuzzy Logic Toolkit
LabVIEW Control Design and Simulation Module
LabVIEW System Identification Toolkit
User Community LabVIEW Simulation Interface Toolkit
LabVIEW SoftMotion Module
9,000+ Certified Users LabVIEW Datalogging and Supervisory Control Module
700+ Alliance Partners LabVIEW Report Generation Toolkit for Microsoft Office
LabVIEW Database Connectivity Toolkit
60+ Registered User Groups LabVIEW DataFinder Toolkit
LabVIEW SignalExpress
LabVIEW VI Analyzer Toolkit
LabVIEW Statechart Module
Modules and Toolkits LabVIEW Desktop Execution Trace Toolkit
40+ Toolkits and Modules Including: NI Requirements Gateway
NI Real-Time Execution Trace Toolkit
LabVIEW Unit Test Framework Toolkit
ni.com 66 LabVIEW Application Builder for Windows
Stratos II+ The Space Rocket
Designed, Built & Launched
Entirely by Students
The Challenge The Solution

Developing a robust and flexible remote ground CompactRIO used to provide time-critical,
control system to control and monitor the remote-control of rocket fuelling and
Stratos II+ rocket filling and firing procedures launching, and aided the development of one
during both the engine test and the launch of the most powerful hybrid rocket engines
campaigns. ever built by students.

ni.com 67
IMPACT: Stratos II+
The rocket launched to an altitude of
21.5km, setting a new European record
for amateur rocketry

ni.com 68
Colorophone Enabling Visually
Impaired Users to Listen to Light Norwegian Association of the
Blind and Partially Sighted

The Challenge The Solution

Developing a novel, low-cost visual sensory Using an NI myRIO to transform light and
substitution device, which transforms visual color into sound. The soundwaves, which mix
information into soundwaves, to help blind values for RGB in the same way the human
people in orientation and identification tasks eye does, are communicated to the wearer
in everyday life. using bone-conduction headphones.

ni.com 69
IMPACT: Colorophone
Having received overwhelmingly positive feedback
from potential users, the students have formed a
startup company to commercialise the colorophone.

ni.com 70
DeepFreezeROV Underwater
Robot for Arctic Research
The Challenge The Solution

Ice algae represents the main food source for Developing a unique, low-cost aquatic robot,
all life beneath the 5 million square km of ice called the DeepFreezeROV. NI myRIO controls
covered Arctic ocean, and significantly the entire robot, from propulsion to bio-
contributes to global CO2 adsorption. sensing. myRIO also processors web-cam
Surprisingly then, this vital organism has rarely images, as part of their unique vision-based
been studied within its own environment. navigation & positioning system.

ni.com 71
Impact: DeepFreezeROV
The data collected on its Artic mission, is
now being used to generate sustainable
fishing quotas and global CO2 models

ni.com 72
Roadrunners Rising from the Ashes
to Set World Record in Fuel Efficiency
The Challenge The Solution

To compete in the Shell Ecomarathon, the Fortunately, the rugged, cRIO-based electronic
students designed and build a urban-concept systems survived the blaze, allowing the team
car, and used NI cRIO as a high-perform ECU to concentrate on rebuilding the vehicle
that controlled all engine and in-vehicle sub- chassis and mechanical components. Within
systems. 48hrs before the race, the car 48hrs, the car was fully restored, and the
caught fire in the Paddock, and was team were able to successfully compete in
destroyed in the blaze. the Ecomarathon.

ni.com 73
IMPACT: DTU Roadrunners
Not onlyImpact: DTUthey won and set
did they compete,
a world-record for fuel-efficiency
ROADRUNNERS
Not only were they able to compete,
they won the Ecomarathon and set a
new world record for fuel-efficiency

ni.com 74
Breath-to-Speech Giving a Voice
Back to Paralysed People

The Challenge The Solution

Augmented communication systems help Using myDAQ to monitor user breath-patterns,


disabled people to speak again. However, which are interpreted in LabVIEW, matched
existing technologies are both expensive and against a specific phrase, and spoken aloud
rely on muscle movements (eg. facial using voice synthesis. The student also
twitches, fingers taps, hand gestures) implemented machine-learning alogirthms, to
therefore, they can not be used by people allow the device to continuously adjust and
suffering with acute paralysis. improve for a particular user.

ni.com 75
IMPACT: Breath-to-Speech
This device received ethical approval and
funding from the NHS, and is undergoing
patient-trials in hospital intensive care units

ni.com 76
Project ALAN Remote, Robotic
Rehabilitation for Stroke Survivors
The Challenge The Solution

Leeds researchers used cRIO to develop iPAM, Using the myRIO to control a 3D printed
a robotic rehabilitation system, which can be humanoid arm, capable of operating iPAM for
installed at the homes of stroke survivors. iPAM extended periods of time, in a highly accurate,
improves the convenience and intensity of repeatable and life-like manner. As both the
physio-exercise, and transforms it into highly rehabilitation system and the verification
motivating games. Now, a robust, mechatronic system were developed with a common
verification system is required to accelerate the platform, control, kinematic and processing
time-to-market for this life-changing device. algorithms could be reused throughout.

ni.com 77
IMPACT: Project ALAN
The robotic test arm is so life-like that, when
connected to the web, can enable remote
consultations with live physiotherapists.

ni.com 78

Вам также может понравиться