Sei sulla pagina 1di 122

Introduction to LabVIEW

Become comfortable with the LabVIEW enironment


and data flow e!ecution

"bilit# to use LabVIEW to sole $roblems

LabVIEW Conce$ts
%
"c&uirin'( sain' and loadin' data
%
)ind and use math and com$le! anal#sis functions
%
Wor* with data t#$es( such as arra#s and clusters
%
+is$la#in' and $rintin' results

Gra$hical .ro'rammin' Enironment

Com$ile code for multi$le O- and deices

/seful in a broad ran'e of a$$lications



+es i'n
% -i'nal and Ima'e .rocessin'
% Embedded -#stem .ro'rammin'
0.C( +-.( ).G"( 1icrocontroller2
% -imulation and .rotot#$in'
% "nd more3
Control
% "utomatic Controls and +#namic -#stems
% 1echatronics and 4obotics
% "nd more3
1eas urem ents
% Circuits and Electronics
% 1easurements and Instrumentation
% "nd more3
+esi'n .rotot#$e +e$lo#
" sin'le 'ra$hical deelo$ment $latf orm

,he 5I "$$roach % Inte'rated Hardware .latforms
Hi' h-- $eed
+i' iti6 ers
Hi' h-4eso lu tio n
+i' iti6 ers a nd +11s
1u lti f unctio n
+ata "c& ui si t i on
+#n amic
-i 'nal " c&uis itio n
+i' ita l I7 O In stru me nt
Contro l
Count er7
,ime rs
1achi ne
Vi sio n
1o tio n
Contro l
+istr ib ute d I7O a nd
Emb edded Contro l
La$to $ . C .+" +es*to $ . C .8I 1o dula r In stru me nta ti on
-i 'nal C ondi tio nin '
and -w itch in '
/ni t /nder , est

"9 Gettin' +ata into #our Com$uter
+ata "c&uisition +eices
% 5I-+":
% -imulated +ata "c&uisition
% -ound Card
B9 LabVIEW Enironment
)ront .anel 7 Bloc* +ia'ram
,oolbar 7,ools .alette
C9 Com$onents of a LabVIEW "$$lication
Creatin' a VI
+ata )low E!ecution
+9 "dditional Hel$
)indin' )unctions
,i$s for Wor*in' in LabVIEW

+ata "c&uisition +eice 0+":2


%
"ctual /-B( .CI( or .8I +eice
%
Confi'ured in 1"8

-imulated +ata "c&uisition +eice 0+":2


%
-oftware simulated at the drier leel
%
Confi'ured in 1"8

-ound Card
% Built into most com$uters
Track A Track A
Track B Track B
Track C Track C

%
5otes on hardware setu$

! ! ! =
,ri'' er in'
!
"C7+C
>%?
@6%AB
=
@?%@A bit
>CB D%@9 >
1s7 s
5I .CI +":
some ! !
.or ta ble
>B*-7s%> G-7 s @B%>BB
D-7s
A%?? D-7s
"I
Band widt h
!
"C7+C
B
>
@>%>? bi t
InstrumentsE
!
"C7+C
@%>
A%@6
@>%@6 bit
5I /-B
+":
=
Ca li br ated
"C
"C or +C
>
"O
Ch annels
>
"I
Ch annels
@>%@6 bi t
"ccur ac #
-ound CardE
E , he abo e tab le ma# no t be re$ r esen t atie of al l de i ce aria t i ons that e!ist i n ea ch c at e'or#

1"8 stands for 1easurement F "utomation E!$lorer9


1"8 confi'ures and or'ani6es all #our 5ational Instruments +":(
.CI7.8I instruments( G.IB( I1":( IVI( 1otion( VI-"( and V8I deices9
/sed for confi'urin' and testin' deices9
Icon )ound on Icon )ound on
Windows +es*to$ Windows +es*to$

/se 1easurement and "utomation E!$lorer 01"82 toG


%
Confi'ure and test #our +ata "c&uisition 0+":2 deice
Track A Track A

/se 1easurement and "utomation E!$lorer 01"82 toG


% Confi'ure and test #our -imulated +ata "c&uisition 0+":2 deice
Track B Track B

/se Windows toG


%
Verif# #our -ound Card
Track C Track C
/n-1ute 1icro$hone

-ta rt H"l l .ro 'r ams H5at i on al In st r uments LabVIEW
-ta rtu $
-cr eenG
-tart from a Blan* VI G
5ewHBlan * VI
-tart from an
E!am$leG
E! am$l esH) i nd
E! am$les 3
H
or
O$en and 4un LabVIEW

Each VI has > Windows
)r ont .anel

/ser Interface 0/I2


%
Controls I In$uts
%
Indicators I Out$uts
Bl oc* + i a'r am

Gra$hical Code
% +ata traels on wires from
controls throu'h functions to
indicators
% Bloc*s e!ecute b# +ataflow
LabVIEW .ro'rams "re Called Virtual Instruments 0VIs2

(Place items on the Front Panel Window)
Indicator:
Numeric Slide
Control:
Numeric
Cu sto mi 6
e .a l ett e
Vi ew

(Place items on the
Block Diagram Window)
Structure:
While Loop

Recommended: Automatic Selection Tool

Tools to oerate and modi!" #oth !ront anel and


#lock diagram o#$ects
Operating Tool
Positioning/Resizing Tool
Labeling Tool
Wiring Tool
,ools .alette
utomatic Selection Tool
Automaticall" chooses among the !ollowing tools:

Run !utton
Continuous Run !utton
bort "#ecution
"#ecution $ighlighting !utton
dditional !uttons on
the %iagram Toolbar
-tatus ,oolbar
Retain Wire &alues !utton
Step 'unction !uttons

+o 5ot +elete
E!ercis e Instr uc t i ons

!loc( %iagram Windo)
'ront Panel Windo)
+emonstration @G Creatin' a VI
Input
Terminals
Output
Terminal
!oolean
Control
*raph
Indicator

Bloc* dia'ram e!ecution


% +e$endent on the flow of data
% Bloc* dia'ram does 5O, e!ecute
left to ri'ht
5ode e!ecutes when data is
aailable to "LL in$ut terminals

5odes su$$l# data to all out$ut


terminals when done

+ebu''in' ,echni&ues

'inding "rrors

"#ecution $ighlighting

Probes
%lick on #roken Run #utton&
Window showing error aears&
%lick on "#ecution $ighlighting #utton' data
!low is animated using #u##les& (alues are
disla"ed on wires&
Right)click on wire to disla" ro#e and it shows
data as it !lows through wire segment&
*ou can also select Pro#e tool !rom Tools
alette and click on wire&

E!ercis e > % "c&uirin' a - i 'nal wit h +" :
Track A&B Track A&B
,his e!ercise should ta*e @C minutes9

/se a LabVIEW tem$late toG


%
"c&uire a si'nal from #our +":
deice




E!ercis e > % "c&uirin' a - i 'nal wit h th e - ound
Card
Track C Track C

/se LabVIEW toG


%
"c&uire a si'nal from #our sound card
,his e!ercise should ta*e @C minutes9

Hel$H-h ow Con te!t Hel$ ( $ress the JCtrlKHL


*e#s

Hoer cursor oer obMect to u$date window


"dd i t ional He l $
%
4i'ht-Clic* on the VI icon and
choose Hel $( or
%
Choose N+e t ai le d Hel $9O on
the conte!t hel$ window

+e"stroke Shortcuts
,
-%trl./0 , Acti1ate2Deacti1ate %onte3t /el Window
,
-%trl.B0 , Remo1e Broken Wires From Block Diagram
,
-%trl.40 , Toggle Between Front Panel and Block
Diagram
,
-%trl.50 , 6ndo (Also in 4dit 7enu)

Tools+Options, , Set Pre!erences in 8a#(94W

(9 Proerties,%on!igure (9 Aearance:
Documentation: etc&


"9 Loo$s

While Loo$

)or Loo$
B9 )unctions and -ubVIs

,#$es of )unctions

Creatin' Custom )unctions 0-ubVI2

)unctions .alette F -earchin'


C9 +ecision 1a*in' and )ile IO
Case -tructure
-elect 0sim$le If statement2
)ile I7O

While 8oos
, i terminal counts iteration
, Alwa"s runs at least once
, Runs until sto condition is
met

For 8oos
, i terminal counts iterations
, Run according to inut N o!
count terminal
While Loop While Loop
For Loop For Loop

+rawin' a Loo$
@9 -elect the structure
>9 Enclose code to be re$eated
P9 +ro$ or dra' additional nodes and then wire

0 f r om t he )u nct i ons
.al ett e2
E!$ress VIsG interactie VIs with confi'urable dialo' $a'e 0b l ue b or de r2
-tandard VIsG modulari6ed VIs customi6ed b# wirin' 0cus t omi6able2
)unctionsG fundamental o$eratin' elements of LabVIEWQ no front $anel or
bloc* dia'ram 0 #e l lo w2

I n$u t and Out $u t


% -i'nal and +ata -imulation
% "c&uire and Generate 4eal -i'nals with +":
% Instrument I7O "ssistant 0-erial F G.IB2
% "ctie8 for communication with other $ro'rams

"na l #sis
% -i'nal .rocessin'
% -tatistics
% "danced 1ath and )ormulas
% Continuous ,ime -oler

-to ra 'e
% )ile I7O
E!$ress )unctions .alette

.alettes are filled with hundreds
of VIs

.ress the search button to inde! the


all VIs for te!t searchin'

Clic* and dra' an item from the


search window to the bloc* dia'ram

+ouble-clic* an item to o$en the


ownin' $alette

Track A,B,&C Track A,B,&C

/se LabVIEW E!$ress VIs toG


%
-imulate a si'nal and dis$la# its am$litude and fre&uenc#
,his e!ercise should ta*e
@C minutes9


Track A&B Track A&B

/se LabVIEW E!$ress VIs toG


%
"c&uire a si'nal and dis$la# its am$litude and fre&uenc#
,his e!ercise should ta*e @C minutes9

Track C Track C

/se LabVIEW E!$ress VIs toG


%
"c&uire a si'nal and dis$la# its am$litude and fre&uenc#
,his e!ercise should ta*e @C minutes9

;& %ase Structures
<& Select
0a2
0b2
0c 2

File 92= , Allows recording or reading data in a !ile&

8a#(94W creates or uses the !ollowing !ile !ormats:


,
Binar": underl"ing !ile !ormat o! all other !ile !ormats
,
AS%99: regular te3t !iles
,
8(7: 8a#(94W measurement data !ile
,
TD7: created !or >ational 9nstruments roducts

Eas# to use

Hi'h Leel of abstraction


Writing to LVM file Writing to LVM file Reading from LVM file Reading from LVM file

E!ercis e P9P % +eci sion 1 a* in' and - a in'
+at a

/se a case structure toG


%
1a*e a VI that saes data when a condition is met
,his e!ercise should ta*e @C
minutes9
Track A,B,C Track A,B,C

O$e n7
Cre at e7
4e $lac e ) i le
4ea d
and7 or
Wr i t e t o )ile
Cl ose
)ile
Che c* f or
Er ro rs

-$readsheet files are "-CII files with a certain


formattin'
%
/suall# tabs between columns and end of line constants
between rows
%
LabVIEW includes VIs that $erform this formattin' or a strin'
can be concatenated



"9 +is$la#in' +ata on the )ront .anel

Controls and Indicators

Gra$hs and Charts

Loo$ ,imin'
B9 -i'nal .rocessin'

1ath-cri$t

"rra#s

Clusters

Waeforms

What ,#$es of Con trols and In di cat ors are
"ailable<
5umer ic +at a
% 5umber in$ut and dis$la#
% "nalo' -liders( +ials( and Gau'es
Boolean +a ta
% Buttons and LE+s
"r r a# F 1at ri ! +a ta
% 5umeric +is$la#
% Chart
% Gra$h
% 8; Gra$h
% Intensit# Gra$h
% P+ 'ra$hG $oint( surface( and model
+ec or at ions
% ,ab Control
% "rrows
Ot her
% -trin's and te!t bo!es
% .icture7Ima'e +is$la#
% "ctie8 Controls
E!$ress Controls .alette

Cha rts % " dd @ d ata $oint at a t ime wit h
histor#
Wa-e.orm chart , secial numeric indicator that can
disla" a histor" o! 1alues
%hart udates with each indi1idual oint it recei1es
'unctions+"#press+*raph Indicators+Chart

Wa-e.orm graph , secial numeric indicator that
disla"s an arra" o! data

?rah udates a!ter all oints ha1e #een collected
7a" #e used in a loo i! (9 collects #u!!ers o! data
'unctions+"#press+*raph Indicators+*raph

Loo$s can accumulate
arra#s at their boundaries
with auto-inde!in'

)or Loo$s auto-inde! b#


default
While Loo$s out$ut onl#
the final alue b# default

4i'ht-clic* tunnel and


enable7disable auto-
inde!in'
Wire becomes thic*er
Wire remains the same si6e
"ut o-Inde!in' +is abl ed
"uto-I nde!in' Enabl ed
Onl# one alue 0last iteration2
is $assed out of the loo$
@+ "rra#
B @ > P ? C
C

From the Controls+/odern+rra01 /atri#1 and
Cluster su#alette: select the rra0 icon&
Dro it on the Front Panel&

;& Place an Arra" Shell&
@& 9nsert datat"e into the shell (i&e& >umeric %ontrol)&

;& 8oo Time Dela"

%on!igure the Time Dela" 43ress (9 !or seconds to wait


each iteration o! the loo (works on For and While loos)&
@& Timed 8oos

%on!igure secial timed While loo !or desired dt.


Timed 8oo Time Dela"

.ro$erties are characteristics or &ualities about an obMect

.ro$erties can be found b# ri'ht clic*in' on a Control or Indicator

.ro$erties IncludeG
%-i6e
%
Color
%
.lot -t#le
%
.lot color

)eatures includeG
%Cursors
%
-calin'

Track A,B,&C Track A,B,&C

/se the cursor le'end on a 'ra$h toG


%
Verif# #our fre&uenc# and am$litude measurements
,his e!ercise should ta*e @C
minutes9

Inte'rate e!istin' scri$ts with LabVIEW for faster deelo$ment

Interactie( eas#-to-use( hands-on learnin' enironment

+eelo$ al'orithms( e!$lore mathematical conce$ts( and


anal#6e results usin' a sin'le enironment

)reedom to choose the most effectie s#nta!( whether


'ra$hical or te!tual within one VI
-u $$ or t ed 1ath ,oo ls G
1ath-cri$t scri$t node 1ath-oft software
1athematica software 1",L"B
R
software
1a$le software 8math

software
1",L"B
R
is a re'istered trademar* of ,he 1athWor*s( Inc9

9mlement eAuations and algorithms te3tuall"

9nut and =utut 1aria#les created at the #order

?enerall" comati#le with oular m)!ile scrit language

Terminate statements with a semicolon to disa#le immediate


outut
.rotot#$e #our e&uations in the interactie 1at h- cri$t Wi ndo w9
0) unc t ionsH. ro'ram min' H
-tructures H1at h-c ri $t2

4a$idl# deelo$ and test al'orithms


0 LabV I EWH,ools H1ath -cr i$t
Window 2
Out $ut
Wind ow
Va ria ble
Wo r* s$ac
e
View7 1od if#
Var i able
Co nte nts
/ser
Commands
m-f il e -c ri $t

-hare -cri$ts and


Variables with the 5ode

View 71odif# Variable


content in @+( >+( and P+

/se the 1ath-cri$t 5ode and Interactie Window to $rocess the
ac&uired si'nal 0lo'arithmic deca#2 in the 1ath-cri$t and sae
the scri$t9
Track A,B,&C Track A,B,&C
,his e!ercise should ta*e >C
minutes9

E!ercise Instructions

E!ercise Instructions


E!erc is e P9P % " $$l # What ;o u Ha e Learned
Track A,B,&C Track A,B,&C
,his e!ercise should ta*e >B minutes9

"9 "dditional +ata t#$es

Cluster
B9 +ata )low Constructs
-hift 4e'ister
C9 -ubVIs
+9 -tate 1achines
E9 Local Variables
)9 .roducer7Consumer

Data structure that grous data together

Data ma" #e o! di!!erent t"es

Analogous to struct in %

4lements must #e either all controls or all indicators

Thought o! as wires #undled into a ca#le

Order is important

-elect a Cl ust er shell9


Contro ls H1oder nH"r ra #( 1atr i ! F
Cl uste r
>9 .lace obMects inside the shell9

9n the Cluster 2 &ariant su#alette o! the


Programming alette

%an also #e accessed #" right)clicking the cluster


terminal
!undle
(Terminal la#els
re!lect data t"e)
!undle !0 Name

,he Waeform +atat#$e contains P $ieces of dataG

tB I -tart ,ime

dt I ,ime between -am$les

; I "rra# of ; ma'nitudes
,wo wa#s to create a Waeform ClusterG
Build Waeform 0absolute t ime2 Cluster 0relat i e ti me2

-hift 4e'ister % "ccess .reious Loo$ +ata
"ailable at left or ri'ht border of loo$ structures
4i'ht-clic* the border and select "d d -h i f t 4e 'is t er
4i'ht terminal stores data on com$letion of iteration
Left terminal $roides stored data at be'innin' of ne!t iteration
Before
Loo$
Be'ins
)irst
Iteration
-econd
Iteration
Last
Iteration
Val ue P
I ni t i al
Va lu e

Conert re$eated functions
and VIs with a sin'le VI

Enclose area to be conerted into a subVI9

-elect Edi tH Cr eat e -ubVI from the Edit 1enu9



LabVIEW )unctions and -ubVIs o$erate li*e )unctions in
other lan'ua'es
)u nct ion .s eudo Co de
function average (in1, in2,
out)
{
out = (in1 + in2)/2.0;
}
-u bV I Bl oc* +ia 'r am
Ca l li n' .r o' ra m . se udo
Co de
main
{
average (in1, in2, pointavg)
}
Ca l li n' VI Bl oc* +ia' ra m

/se this connector $ane la#out as a standard

,o$ terminals are usuall# resered for references( such as a file reference
Bottom terminals are
usuall# resered for
error clusters

Create custom icons b# ri'ht-clic*in' the icon in the u$$er ri'ht corner of
the front $anel or bloc* dia'ram and selectin' Ed it Ic on or b# double-
clic*in' the icon

;ou also can dra' a 'ra$hic from an#where in #our file s#stem and dro$ it
on the icon

4efer to the
Icon "rt Glossar# at
ni9com for standard
'ra$hics to use in
a VI icon


While Loo$

Case -tructure

-hift 4e'ister

Se1eral rogramming
techniAues e3ist !or transitioning
!rom state to state in 8a#(94W
using State 7achines
De!ault transition imlies that
a!ter one state: another state
alwa"s !ollows
Transitions #etween two
otential states can #e handled
#" a Select Function

Communicatin' between loo$s usin' data


flow is not $ossible

,he left loo$ will e!ecute com$letel#


before the ri'ht loo$

Variables are needed when communication


with wires does not 'ie the desired behaior

Local Variables

Local Variables allow data to be $assed between $arallel loo$s9

" sin'le control or indicator can be read or written to from more than one
location in the $ro'ram
%
Local Variables brea* the dataflow $aradi'm and should be used s$arin'l#

Crea tin' a Local Variable - Wal* ,hrou 'h
9n this e3amle we will see
how 8ocal (aria#les allow us
to share data #etween
arallel loos& We will
create a rogram that
toggles two searate 84Ds
using one switch& 9t also
stos two loos with one
#utton&
%reate the #lock diagram
and !ront anel as seen to
the right&

Right)click on the Sto
Button in the Front Panel
and change the
7echanical Action to
BSwitch When ReleasedC
since 8ocal (aria#les
cannot store 8atched
data&

.roducer7Con sumer +esi'n .at tern

"9 5ai'ation Window
B9 LabVIEW .roMect
C9 -hared Variable

-hows the current re'ion of iew
com$ared to entire )ront .anel or
Bloc* +ia'ram
Great for lar'e $ro'rams
E Or'ani6e and reduce $ro'ram isual si6e with subVIs

Grou$ and or'ani6e VIs

Hardware and I7O mana'ement

1ana'e VIs for multi$le tar'ets

Build libraries and e!ecutables

1ana'e lar'e LabVIEW a$$lications

Enable ersion trac*in' and mana'ement


0Lab VI EWH .r oMec t H5e w2

-hared Variables are used to send data between VIs9

Variable ,#$esG
%
-in'le .rocessG share the data amon' VIs on the local com$uter9
%
5etwor*-$ublishedG communicate between VIs( remote
com$uters( and hardware throu'h the -hared Variable En'ine9
-hared Variable must e!ist within a $roMect librar#9

-hared Variable must be de$lo#ed to be aailable to other $roMects


and remote com$uters9



"9 Oeriew of Instrument Control
B9 G.IB
C9 -erial
+9 Instrument I7O "ssistant
E9 VI-"
)9 Instrument +riers and I+5E,

Wha t ,#$es of I ns t rum ents Can Be
Con trolled<

G.IB

-erial

1odular Instruments

.8I 1odular Instruments

Ima'e "c&uisition

1otion Control

/-B

Ethernet

.arallel .ort

C"5

General .ur$ose Interface Bus 0G.IB2

G.IB is usuall# used in stand alone bench to$


instruments to control measurements and
communicate data

+i'ital A-bit $arallel communication interface

IEEE ?AA9@ and ?AA9> define standards for G.IB


-erial communication transmits one bit at a time oer a


transmission line

/suall# does not re&uire e!ternal hardware

)our $arametersG baud rate( data bits( $arit# bit( sto$


bits

LabVIEW E!$ress VI used to communicate with


messa'e-based instruments

Communicate with an instrument that uses a serial(


Ethernet( or G.IB interface

/se the Instrument I7O "ssistant when an instrument


drier is not aailable

+o 5ot +elete
E!ercis e Instr uc t i ons

+o 5ot +elete
E!ercis e Instr uc t i ons

Virtual Instrumentation -oftware "rchitecture 0VI-"2

Hi'h-leel ".I that calls low-leel driers

Can control V8I( G.IB( serial( or com$uter-based


instruments

1a*es a$$ro$riate drier calls de$endin' on the


instrument used9

.lu' and .la# driers are a set of VIs that control a


$ro'rammable instrument

VIs corres$ond to instrument o$erationG confi'urin'(


tri''erin'( and readin' measurements

Hel$ 'ettin' started since $ro'rammin' $rotocol for each


instrument is alread# *nown

Instrument +rier 5etwor* 0I+5E,2

Instrument +rier )inder within LabVIEW


,o ol s H In str ument ation H )ind In str umen t +r i ers
He l $ H )ind I nst ru men t +ri ers

Can be found online at www9ni9com7idnet



>9 Academic We# D Student %orner
, htt:22www&ni&com2academic
%onne3ions: Full 8a#(94W Training %ourse
, www&cn3&rice&edu
, =r search !or B8a#(94W #asicsC
8a#(94W %erti!ication
, 8a#(94W Fundamentals 43am (!ree on www&ni&com2academic)
, %erti!ied 8a#(94W Associate De1eloer 43am (industr" recogniEed certi!ication )
?et "our own co" o! 8a#(94W Student 4dition
, www&ni&com2academic
B# 4obert H Bisho$9
.ublished b# .rentice Hall9
/
$
d
a
t
e
d

f
o
r
L
a
b
V
I
E
W

A

Ce rtifie d L ab VI EW
+e elo$ er
Certifie d L abVIEW "sso ciat e
+e elo $e r
Certified
LabVI EW
"r ch itec t
rchitect
7aster" o! 8a#(94W
43ert in large alication de1eloment
Skilled in leading ro$ect teams
%e-eloper
Ad1anced 8a#(94W knowledge
and alication de1eloment
e3erience
Pro$ect management skills
ssociate %e-eloper
Pro!icienc" in na1igating
8a#(94W en1ironment
Some alication
de1eloment e3erience
)undam ental s E! am
.re-Certification -*ills ,est
)r ee On-L i ne )u ndamen t al s
)r ee On-L i ne )u ndamen t al s
E!a m
E!a m

WorldFs most oular so!tware !or
learning electronics
;GH:HHH industrial and academic users
Products include:
, 7ultisim: Simulation and %ature
, 7ulti)7%6: 7icrocontroller Simulation
, 7ulti(/D8: (/D8 Simulation
, 6lti#oard: P%B 8a"out
, 4lectronics %BT: %omuter)#ased training
8ow cost student editions a1aila#le
www&electronicswork#ench&com

34 Create Schematic 54 &irtual !readboard 64 Simulate
74 PC! La0out 84 Test 94 Compare

Take the !ree 8a#(94W Fundamentals 43am at
ni&com2academic
*our !irst ste to #ecome 8a#(94W %erti!iedI

Potrebbero piacerti anche