Upload
bolwol
View
258
Download
0
Embed Size (px)
Citation preview
7/21/2019 LabVIEW 2011.pdf
1/24
7/21/2019 LabVIEW 2011.pdf
2/24
LabVIEW
programsarecalled
virtualinstruments(VIs).
EachVIcontainsthreemainparts:
FrontpanelHowtheuser
interactswiththeVI
BlockdiagramThecodethat
co
ntrolstheprogram
Icon/connectorThemeansof
co
nnectingaVItootherVIs
LabV
IEWw
indows
2015/3/17
BlockDiagram
FrontPanel
DAAChen
6
FrontPan
el
2015/3/17
DAAChen
7
BlockDiagram
2015/3/17
DAAChen
8
ControlsP
alette
2015/3/17
DAAChen
9
7/21/2019 LabVIEW 2011.pdf
3/24
Func
tionsPalette
2015/3/17
DAAChen
10
Programm
ingandControlPalette
2015/3/17
DAAChen
11
Tools
Palette
2015/3/17
DAAChen
12
FunctionBar
2015/3/17
File
Edit
DAAChen
13
7/21/2019 LabVIEW 2011.pdf
4/24
Func
tionBar
2015/3/17
View
Operate
DAAChen
14
StatusToolbar
2015/3/17
DAAChen
15
Diagram
Toolbar
2015/3/17
DAAChen
16
2015/3/17
DAAChen
17
7/21/2019 LabVIEW 2011.pdf
5/24
Your
FirstVI
2015/3/17
DAAChen
18
DataType
s
2015/3/17
DAAChen
19
Data
flowProgramming
2015/3/17
Blockdiagram
executiondepend
ont
heflowofdata.
Nod
eexecutes
whe
ndatais
availabletoALL
inputterminals
Nod
essupplydata
toa
lloutput
term
inalswhena
nod
ecompletes
execution
DAAChen
20
DebuggingTechniques
2015/3/17
DAAChen
21
7/21/2019 LabVIEW 2011.pdf
6/24
Debu
ggingTechniques
2015/3/17
Datastream
DAAChen
22
DebuggingTechniques
2015/3/17
DAAChen
23
Cont
extHelpwindow
2015/3/17
DAAChen
24
SectionII-
ElementsofTypicalPrograms
2015/3/17
DAAChen
25
7/21/2019 LabVIEW 2011.pdf
7/24
TypesofFunctions
2015/3/17
DAAChen
26
TypesofF
unctions
2015/3/17
DAAChen
27
LabV
IEWF
unctionsand
SubVI
2015/3/17
DAAChen
28
CreateSu
bVI
2015/3/17
DAAChen
29
7/21/2019 LabVIEW 2011.pdf
8/24
ProcedureforcreateaSu
bVI
2015/3/17
DAAChen
30
SaveaSu
bVIcallitasaFunc
tion 2
015/3/17
DoubleclickLB
DAAChen
31
Loop
s
2015/3/17
DAAChen
32
Loops
2015/3/17
DAAChen
33
7/21/2019 LabVIEW 2011.pdf
9/24
CreateaLoop
2015/3/17
When
selectedloopobject,
the
mouse
cursorbecomesaspecial
pointerthatyouusetoenclosea
spaceforthewhilelooptask.
Clickth
eleftmousebuttonto
define
acornerandthenclickthe
mouse
buttonagainforits
diagon
alcorner.
1
2
DAAChen
34
HowtoTimeaLoop
2015/3/17
DAAChen
35
Timing
2015/3/17
Functio
nsProgrammingTiming
WaitUntilNextmsMultiple
Th
isfunctionwaitsuntilthevalueofthemillisecondtimerbecomesamultiple
of
thespecifiedmillisecondmultipletohelpyousynchronizeactivities.Youcan
callthisfunctioninalooptocontroltheloope
xecutionrate.Thisfunctioncan
be
foundatFunctionsProgrammingTimingWaitUntilNextmsMultiple
DAAChen
36
TimingaLoop
2015/3/17
Timer
DAAChen
37
7/21/2019 LabVIEW 2011.pdf
10/24
Exercise
2015/3/17
Crea
teacountdowntimer
Controlvariable:t
imerunit
Indication:realtimedisplayofatim
emeter
Term
inatecondition:S
TOPbutton
orafteraspecified
perio
doftime.
DAAChen
38
2015/3/17
DAAChen
39
State
Machines
2015/3/17
Astatemachineconsistsofasetofstatesandatransition
functionthatmapstothenextstate.
e.g.x
(k+1)=f(x(k))
ShiftRegister
DAAChen
40
StateMac
hinesforLoops
2015/3/17
No.oftimesforrepeattask
initial
Inputnode
Outputnode
indexing
Outputnode
nonindexing
ShiftRegister
Loopcounter
DAAChen
41
7/21/2019 LabVIEW 2011.pdf
11/24
State
MachinesforWhile
s
2015/3/17
Terminationconditio
n
Frontpanel
ShiftRegister
DAAChen
42
Exercise
2015/3/17
CreateaVIto
Calculatetheresultofadding
fromAtoBwithanintervalC.
e.g.A=5,B=18
,C=6,Ans=33
DAAChen
43
2015/3/17
DAAChen
44
DecisionM
akinginLabVIEW
2015/3/17
FunctionsProgrammingComparisonSele
ct
FunctionsProgrammingStructuresCaseStructure
DAAChen
45
7/21/2019 LabVIEW 2011.pdf
12/24
CreateaCaseStructure
2015/3/17
1
2
DAAChen
46
TypesofC
aseStructure
2015/3/17
DAAChen
47
CreateaSelect
2015/3/17
Return
sthevaluewiredtothetinputorfinput,dependingon
theva
lueofs.IfsisTRUE,
thisfunction
returnsthevalue
wired
tot.IfsisFALSE,
thisfunctionreturnsthevaluewiredto
f.
T F
S
DAAChen
48
Multi-task
Random
Processing
2015/3/17
Processings
equence?
Howtostop
theloopby
oneaction?
Communica
tionbetween
parallelloop
s?
DAAChen
49
7/21/2019 LabVIEW 2011.pdf
13/24
Sequ
enceStructure
2015/3/17
FlatTyp
e
Stacked
Type
DAAChen
50
StateMac
hineforSequence
2015/3/17
FramNo.[listofframes]
Outputto
desc
endantframe
Inputfrom
ascendantframe
DAAChen
51
FeedbackNode
2015/3/17
Wirefr
omoutputtoinputto
automa
ticallycreateafeedbacknode
Initials
DAAChen
52
InitializedShiftRegisters&FeedbackNodes
2015/3/17
RunOnce
VIstopsexecution
RunAgain
Output=8
Output=4
Output=4
Output=8
DAAChen
53
7/21/2019 LabVIEW 2011.pdf
14/24
Mech
anicalActionforLogicSwitches
2015/3/17
DAAChen
54
Communi
cateBetweenParalle
lLoops
2015/3/17
Datacannotenterorleavea
structurewhileitsstillrunningvia
dataflow.
Localvariablescanbeusedtostoredatainfrontpanel
controlsandin
dicators.
Withvariables,youcan
circumvent
normaldataflowbypassingdatafromoneplacetoanother
withoutconne
ctingthetwoplaceswithawire.
DAAChen
55
LocalVariable
2015/3/17
Youcan
alsorightclickany
control
orindicatorandselect
CreateLocalVariable.
This
creates
adirectlylinkedlocal
variable
forthatcontrolor
indicato
ryoucreateditfrom.
Next,youmustdecideto
eitherr
eadorwritetothe
object.
Rightclickonthelocal
variable
andchooseChange
ToRead
orChangetoWrite.
DAAChen
56
ShareDataBetweenLoops
2015/3/17
Actas
anindicator:
itwritesadataforthelinkedobject
Actasacontrol:
itreadsadataforthelinkedobject
DAAChen
57
7/21/2019 LabVIEW 2011.pdf
15/24
Exercise
2015/3/17
Create
aVIwithtwoparallelwhileloop
s.
1.To
controlthelogicindicatorsbelongingtoeachloops
usingacontrol(LEDswitch).
2.To
terminatebothloopsusingonlyonestopcontrol
unit.
DAAChen
58
DisplayResults
2015/3/17
DAAChen
59
TypesofControlsandIndicators
2015/3/17
DAAChen
60
Charts_O
n-l
ineDisplayTimeHi
storyData
2015/3/17
Thewaveformchartisaspecial
numericindicatorthatdisplaysoneor
moreplots.
Itislocated
onthe
ControlsModernGra
phpalette.
DAAChen
61
7/21/2019 LabVIEW 2011.pdf
16/24
Char
tandGraphUseSu
mmary
2015/3/17
DAAChen
62
Waveform
ChartforMultipleP
lots
2015/3/17
DAAChen
63
Grap
hs_
DisplayHistory
DataOff-l
ine
2015/3/17
Youcandisplaysettingsforplottypes,
scaleandcurso
roptions,andmany
otherfeatureso
fthegraphbyright-
clickingthegraphonthefrontpanel
andchooseProperties.
DAAChen
64
Waveform
Graph
2015/3/17
BuildWaveform
Buildsawaveformw
iththestarttime
representedasanab
solutetimestamp.
Timestampsareaccu
ratetorealworld
timeanddateandareveryusefulfor
realworlddatarecording.
Bundle
Buildsawaveformw
itharelative
timestamp.
Theinpu
ttot0isaDBL.By
buildingwaveformsusingthebundle,
youcanplotdataon
thenegativexaxis
(time).
DAAChen
65
7/21/2019 LabVIEW 2011.pdf
17/24
Grap
hArraysandCluste
rs
2015/3/17
DAAChen
66
Technical
GraphsOutput
2015/3/17
Youcanalsocreatetechnical-paper-quality
graphicswiththeexportsimplifiedimage
function.Right-clickthegraphandselect
DataOperationsExportSimplified
Image
DAAChen
67
MultipleGraph
2015/3/17
DAAChen
68
X-Y
Graph
2015/3/17
DAAChen
69
7/21/2019 LabVIEW 2011.pdf
18/24
2015/3/17
DAAChen
70
Controlan
dIndicatorProperties
2015/3/17
DAAChen
71
Exercise
2015/3/17
Create
aVItogenerateasinewavesign
alofaspecific
frequency(Hz),magnitudeandoffset.
Keyun
its:whileloop,waituntil,wavefor
mchart
Reference:
DAAChen
72
Operation
sforArrays
2015/3/17
Tocreateanarraycontrolorindicator
Selectanarray
ontheControlsModernArray
,Matrix,and
Clusterpalette
,placeitonthefrontpanel,and
dragacontrolor
indicatorintothearrayshell.
DAAChen
73
7/21/2019 LabVIEW 2011.pdf
19/24
Oper
ationsforArrays
2015/3/17
Tocrea
teanarraycontrolorindicator
insertanobjectinthearrayshell
1DArrayViewingMultipleElements
1DArrayViewinga
SingleElement
Index
DAAChen
74
2-D
Array
s
2015/3/17
Toadddimensionstoanarrayoneatatime,rightclicktheindex
displayandsele
ctAddDimensionfromtheshor
tcutmenu.
2DArrayViewingMult
ipleElements
2DArrayViewingSingle
Element
DAAChen
75
Build
ingArrayswithLoops
2015/3/17
DAAChen
76
Operation
sofArrays
2015/3/17
DAAChen
77
7/21/2019 LabVIEW 2011.pdf
20/24
Exercise
2015/3/17
Create
aVIforvectorinnerproduct
DAAChen
78
Exercise
2015/3/17
CreateaVIfor
calculatingMatrixvectoroperation
y=Ax
x A
y
DAAChen
79
Exercise
2015/3/17
Create
aVIforcalculatingMatrixmultiplication
C=AB
DAAChen
80
Advanced
DataFlowTopics
2015/3/17
DAAChen
81
7/21/2019 LabVIEW 2011.pdf
21/24
Clusters
2015/3/17
DAAChen
82
Creatinga
Cluster
2015/3/17
DAAChen
83
Clusterfunctions
2015/3/17
Youuse
abundlefunctiontocreateaclu
ster.Youusean
unbund
lefunctiontoextractthepartso
facluster.
DAAChen
84
Clusterfu
nctions
2015/3/17
Youuseabundlefunctiontocreateacluster.Youusean
unbundlefunctiontoextractthepartsofacluster.
DAAChen
85
7/21/2019 LabVIEW 2011.pdf
22/24
Exam
ple
2015/3/17
DAAChen
86
Waveform
Graph
2015/3/17
BuildWaveform
Buildsawaveformw
iththestarttime
representedasanab
solutetimestamp.
Timestampsareaccu
ratetorealworld
timeanddateandareveryusefulfor
realworlddatarecording.
Bundle
Buildsawaveformw
itharelative
timestamp.
Theinpu
ttot0isaDBL.By
buildingwaveformsusingthebundle,
youcanplotdataon
thenegativexaxis
(time).
DAAChen
87
Grap
hArraysandCluste
rs
2015/3/17
DAAChen
88
TheLabVIEW
MathScriptNode
2015/3/17
Locatedinth
eProgrammingStructuressubp
alette.
Resizableboxforenteringtextualmathstatem
ent.
ItworksasascripttypeSubVI
.mf
ileScrip
DAAChen
89
7/21/2019 LabVIEW 2011.pdf
23/24
TheLabViewMathScript
Node
2015/3/17
Toad
dvariables,rightclickandchoose
AddInputorAddOutput.
Namevariablesastheyareusedinthe
formula.
Youc
anchangethedatatypeofthe
outputbyrightclickingtheinputor
outputnode.
DAAChen
90
FormulaN
ode
2015/3/17
IntheStruct
uressub-palette
Implementcomplicatedequations
Variablescre
atedatborder
Variablenam
esarecasesensitive
Eachstatementmustterminatewithasemicolon(;)
DAAChen
91
FileI/O
2015/3/17
DAAChen
92
High-levelFileI/OVIs
2015/3/17
WritetoSpreadsheetFile
ReadfromSp
readsheetFile
WriteCharacterstoFile
ReadCharactersfromFile
ReadLinesfromFile
DAAChen
93
7/21/2019 LabVIEW 2011.pdf
24/24
Write
toDataFile
2015/3/17
DAAChen
94
WritetoD
ataFile
2015/3/17
Exercise:Generatea
coordinates
datafordrawinga
circleandsa
veinadatafile.
DAAChen
95
EndoftheChapter
2015/3/17
DAAChen
109