week 3 - labview student ambassadors_v1
TRANSCRIPT
-
8/19/2019 Week 3 - LabVIEW Student Ambassadors_v1
1/49
ni.com/training
Course Learning Map
Lesson 3
Implementing a VI
Lesson 2
Troubleshooting &Debugging VIs
Lesson 1
Naigating LabVI!"
Lesson #
Managing $ile an% ar%'are(esources
Lesson )
Creating an% LeeragingData *tructures
Lesson +
Deeloping Mo%ular,pplications
Lesson -
*oling Datalo' Challenges 'ith Variables
Lesson
0sing *euential an% *tateMachine ,lgorithms
1
-
8/19/2019 Week 3 - LabVIEW Student Ambassadors_v1
2/49
TIC*
ni.com/training
Lesson 3
Implementing a VI
A. Front Panel Basics
B. LabVIEW Data Types
C. Documenting Code
D. Wile Loops
E. For Loops
F. Timing a VI
!. Data Feedbac" in Loops
#. Plotting Data $ Wa%e&orm Cart
I. Case 'tructures
2
-
8/19/2019 Week 3 - LabVIEW Student Ambassadors_v1
3/49
ni.com/training
!. $or Loops
Conditional TerminalComparison (it Wile Loops
)umeric Con%ersion &or Count Terminal
3
-
8/19/2019 Week 3 - LabVIEW Student Ambassadors_v1
4/49
ni.com/training
$or Loops
LabVIEW For Loop Flo(cart Pseudo Code
N41556
i456
0ntil i4N7
(epeat 8co%e6i4i91:6
!n%6
+
-
8/19/2019 Week 3 - LabVIEW Student Ambassadors_v1
5/49
ni.com/training
$or Loops
• Create a For Loop te same (ay you create a Wile Loop.
• *ou can replace a Wile Loop (it a For Loop by rigt+
clic"ing te border o& te Wile Loop and selecting
(eplace 'ith $or Loop &rom te sortcut menu.• Te %alue in te count terminal ,an input terminal-
indicates o( many times to repeat te subdiagram
in te For Loop.
)
-
8/19/2019 Week 3 - LabVIEW Student Ambassadors_v1
6/49
ni.com/training
$or Loops ; Con%itional Terminal
*ou can add a conditional terminal to con&igure a For Loop tostop (en a Boolean condition is true or an error occurs.
#
-
8/19/2019 Week 3 - LabVIEW Student Ambassadors_v1
7/49
ni.com/training
$or Loops ; Con%itional Terminal
For Loops con&igured (it a conditional terminal a%e• A red glyp ne/t to te count terminal.
• A conditional terminal in te lo(er rigt corner
-
8/19/2019 Week 3 - LabVIEW Student Ambassadors_v1
8/49
ni.com/training
$or Loop/"hile Loop Comparison
$or Loop• E/ecutes a set number o& times
unless a conditional terminal is
added.
•
Can e/ecute 0ero times.• Tunnels automatically output an
array o& data.
"hile Loop• 'tops e/ecuting only i& te %alue
at te conditional terminal meets
te condition.
•
1ust e/ecute at least once.• Tunnels automatically output te
last %alue.
-
-
8/19/2019 Week 3 - LabVIEW Student Ambassadors_v1
9/49
ni.com/training
$or Loops ; Numeric Conersion• Te number o& iterations a For Loop e/ecutes must be speci&ied in
non+negati%e integers.
• I& you (ire a double+precision2 &loating+point numeric %alue to te
count terminal2 LabVIEW con%erts te numeric %alue to a 34+bit signed
integer.
<
-
8/19/2019 Week 3 - LabVIEW Student Ambassadors_v1
10/49
ni.com/training
$or loop an% 'hile loop in%e=ing
comparison 8N!" *LID!:
15
-
8/19/2019 Week 3 - LabVIEW Student Ambassadors_v1
11/49>,L
>roup !=ercise 3?3
Concept7 "hile Loops ersus $or Loops
5nderstand (en to use a Wile Loop and (en to use a For
Loop.
-
8/19/2019 Week 3 - LabVIEW Student Ambassadors_v1
12/49
ni.com/training
$. Timing a VI
6easons To 5se TimingWait Functions and E/press VIs
12
-
8/19/2019 Week 3 - LabVIEW Student Ambassadors_v1
13/49
ni.com/training
Timing a VI
Wy do you need timing in a VI7
• To control te &re8uency at (ic a loop e/ecutes.
• To pro%ide te processor (it time to complete oter tas"s2
suc as processing te user inter&ace.
13
-
8/19/2019 Week 3 - LabVIEW Student Ambassadors_v1
14/49
ni.com/training
"ait $unctions
A (ait &unction inside a loop• Allo(s te VI to sleep &or a set amount o& time.
• Allo(s te processor to address oter tas"s during te (ait
time.
• 5ses te operating system millisecond cloc".
1+
-
8/19/2019 Week 3 - LabVIEW Student Ambassadors_v1
15/49
ni.com/training
!lapse% Time !=press VI
•
Determines o( muc time elapses a&ter some point inyour VI.
• 9eeps trac" o& time (ile te VI continues to e/ecute.
• Does not pro%ide te processor (it
time to complete oter tas"s.
1)
-
8/19/2019 Week 3 - LabVIEW Student Ambassadors_v1
16/49
D!MN*T(,TIN
"ait Chart VI
Compare and contrast using a Wait &unction and te Elapsed
Time E/press VI &or so&t(are timing.
-
8/19/2019 Week 3 - LabVIEW Student Ambassadors_v1
17/49
ni.com/training
>. Data $ee%bac@ in Loops
'i&t 6egistersInitiali0ing 'i&t 6egisters
De&ault &or 5n(ired Values
Compound 'i&t 6egisters
1
-
8/19/2019 Week 3 - LabVIEW Student Ambassadors_v1
18/49
ni.com/training
Data $ee%bac@ in Loops
•
Wen programming (it loops2 you o&ten need to "no( te%alues o& data &rom pre%ious iterations o& te loop.
• 'i&t registers trans&er %alues &rom one loop iteration to te
ne/t.
1-
-
8/19/2019 Week 3 - LabVIEW Student Ambassadors_v1
19/49
ni.com/training
*hit (egisters
•
6igt+clic" te border and select ,%% *hit (egister &romte sortcut menu.
• 6igt si&t register stores data on completion o& an iteration.
• Le&t si&t register pro%ides stored data at beginning o& te
ne/t iteration.
1<
-
8/19/2019 Week 3 - LabVIEW Student Ambassadors_v1
20/49
ni.com/training
Bloc" Diagram :st run 4nd run
Initiali0ed'i&t
6egister
;utput < = ;utput < =
)ot
Initiali0ed'i&t6egister
;utput < > ;utput < ?
InitialiAing *hit (egistersVI inishes (un again(un once
25
-
8/19/2019 Week 3 - LabVIEW Student Ambassadors_v1
21/49
ni.com/training
0se Deault i 0n'ire%
De&ault %alues %ary by data type
5ninitiali0ed si&t registers use de&ault %alues &or &irst run.
Data TBpe Deault Value
)umeric @
Boolean FAL'E
'tring Empty
21
-
8/19/2019 Week 3 - LabVIEW Student Ambassadors_v1
22/49
-
8/19/2019 Week 3 - LabVIEW Student Ambassadors_v1
23/49
>,L
!=ercise 3?+
,erage Temperature VI
M!"(
5se a Wile Loop and si&t registers to a%erage data.
-
8/19/2019 Week 3 - LabVIEW Student Ambassadors_v1
24/49
DI*C0**IN
!=ercise 3?+
,erage Temperature VI
*ou calculated te a%erage o& te last = temperature readings.#o( (ould you modi&y te VI to calculate te a%erage o& te
last :@ temperature readings7
-
8/19/2019 Week 3 - LabVIEW Student Ambassadors_v1
25/49
ni.com/training
. lotting Data ; "aeorm Chart
2)
-
8/19/2019 Week 3 - LabVIEW Student Ambassadors_v1
26/49
ni.com/training
lotting Data ; "aeorm Chart
•
Wa%e&orm cartis a special type
o& numeric
indicator.
• Wa%e&orm carts
display single or
multiple plots.
2#
-
8/19/2019 Week 3 - LabVIEW Student Ambassadors_v1
27/49
ni.com/training
"aeorm Chart roperties
E/tensi%e plotcustomi0ation lets you
• 'o( or ide legends.
• Cange color and line
styles.• Cange interpolation
styles.
2
-
8/19/2019 Week 3 - LabVIEW Student Ambassadors_v1
28/49
>,L
!=ercise 3?)
Temperature Monitor VI ; lot Multiple Temperatures
M!"(
Plot multiple data sets on a single (a%e&orm cart and
customi0e te cart %ie(.
-
8/19/2019 Week 3 - LabVIEW Student Ambassadors_v1
29/49
DI*C0**IN
!=ercise 3?)
Temperature Monitor VI ; lot Multiple Temperatures
In (at (ays do te &ollo(ing tools allo( te user to interact (it te plot7
• Plot Legend
• !rap Palette
• 'cale Legend
-
8/19/2019 Week 3 - LabVIEW Student Ambassadors_v1
30/49
ni.com/training
I. Case *tructures
Parts o& a Case 'tructureEnum Case 'tructures
Error Case 'tructures
Input and ;utput Tunnels
35
-
8/19/2019 Week 3 - LabVIEW Student Ambassadors_v1
31/49
ni.com/training
Case *tructures
•
#a%e t(o or more subdiagrams or cases.• 5se an input %alue to determine (ic case to e/ecute.
• E/ecute and display only one case at a time.
• Are similar to case statements or i...then...else statements
in te/t+based programming languages.
31
-
8/19/2019 Week 3 - LabVIEW Student Ambassadors_v1
32/49
ni.com/training
Case *tructures
Case *elector Label
*elector Terminal
• Case 'elector Label
Contains te name o& te current
case.
#as decrement and increment
arro(s.
• 'elector Terminal
Lets you (ire an input %alue2 or
selector2 to determine (ic case
e/ecutes.
32
-
8/19/2019 Week 3 - LabVIEW Student Ambassadors_v1
33/49
ni.com/training
Case *tructures
'elector terminal data types
• Boolean
True case and False Case
• Error Cluster
Error Case and )o Error Case
• Integer2 string2 or enum
'tructure can a%e any
number o& cases.
Include a De&ault diagram to
a%oid listing e%ery possible
input %alue.
33
-
8/19/2019 Week 3 - LabVIEW Student Ambassadors_v1
34/49
ni.com/training
!num Case *tructure
• !i%es users a list o& items &rom (ic to select
• Te case selector displays a case &or eac item in te
enumerated type control
3+
-
8/19/2019 Week 3 - LabVIEW Student Ambassadors_v1
35/49
ni.com/training
*hortcut Menu
5se te sortcut menu o& aCase structure to Customi0e te structure and
diagrams.
6emo%e or replace testructure.
Add2 duplicate2 remo%e2 or
rearrange cases.
'peci&y te De&ault case.
'(itc cases.
3)
-
8/19/2019 Week 3 - LabVIEW Student Ambassadors_v1
36/49
ni.com/training
!rror Case *tructure
5se Case structures inside VIs to e/ecute te code i& tere is
no error and s"ip te code i& tere is an error.
3#
-
8/19/2019 Week 3 - LabVIEW Student Ambassadors_v1
37/49
ni.com/training
Input an% utput Tunnels
*ou can create multiple input and output tunnels.
• Inputs tunnels are a%ailable to all cases i& needed.
• *ou must de&ine eac output tunnel &or eac case.
3
-
8/19/2019 Week 3 - LabVIEW Student Ambassadors_v1
38/49
D!MN*T(,TIN
Case *tructures
• Create case structures using di&&erent data type selectors.
• Add2 remo%e2 and duplicate cases.
• Create di&&erent type o& output tunnels.
-
8/19/2019 Week 3 - LabVIEW Student Ambassadors_v1
39/49
>,L
!=ercise 3?#
Temperature "arnings VI
M!"(
1odi&y a VI to use Case structures to ma"e a so&t(are
decision.
-
8/19/2019 Week 3 - LabVIEW Student Ambassadors_v1
40/49
DI*C0**IN
!=ercise 3?#
Temperature "arnings VI
• Wat appens i& all te %alues are :@7 #o( could you &i/
tis7• Are all output tunnels de&ined7 Wat appens i& an output
is not de&ined7
-
8/19/2019 Week 3 - LabVIEW Student Ambassadors_v1
41/49
ni.com/training
*ummarBEuiA
:. I& an input to a &unction is mar"ed (it a red dot ,"no(n as
a coercion dot-2 (at does te dot indicate7
a- Data (as trans&erred into a structure.
b- A For Loop (as con&igured (it a conditional terminal.
c- A For Loop iteration terminal is un(ired.
d- Te %alue passed into a node (as con%erted to a
di&&erent representation.
+1
-
8/19/2019 Week 3 - LabVIEW Student Ambassadors_v1
42/49
ni.com/training
*ummarBEuiA ,ns'er
:. I& an input to a &unction is mar"ed (it a red dot ,"no(n as
a coercion dot-2 (at does te dot indicate7
a- Data (as trans&erred into a structure.
b- A For Loop (as con&igured (it a conditional terminal.
c- A For Loop iteration terminal is un(ired.
%: The alue passe% into a no%e 'as conerte% to a
%ierent representation.
+2
-
8/19/2019 Week 3 - LabVIEW Student Ambassadors_v1
43/49
ni.com/training
*ummarBEuiA
4. Wic structure must run at least one time7
a- Wile Loop
b- For Loop
+3
-
8/19/2019 Week 3 - LabVIEW Student Ambassadors_v1
44/49
ni.com/training
*ummarBEuiA ,ns'er
4. Wic structure must run at least one time7
a: "hile Loop
b- For Loop
++
-
8/19/2019 Week 3 - LabVIEW Student Ambassadors_v1
45/49
ni.com/training
*ummarBEuiA
3. Wic is only a%ailable on te bloc" diagram7
a- Control
b- Constant
c- Indicatord- Connector Pane
+)
-
8/19/2019 Week 3 - LabVIEW Student Ambassadors_v1
46/49
ni.com/training
*ummarBEuiA ,ns'er
3. Wic is only a%ailable on te bloc" diagram7
a- Control
b: Constant
c- Indicatord- Connector Pane
+#
-
8/19/2019 Week 3 - LabVIEW Student Ambassadors_v1
47/49
ni.com/training
*ummarBEuiA
>. Wic mecanical action causes a Boolean control in te
FAL'E state to cange to T65E (en you clic" it and stay
T65E until LabVIEW as read te %alue7
a- '(itc 5ntil 6eleasedb- '(itc Wen 6eleased
c- Latc 5ntil 6eleased
d- Latc Wen 6eleased
+
-
8/19/2019 Week 3 - LabVIEW Student Ambassadors_v1
48/49
ni.com/training
*ummarBEuiA ,ns'er
>. Wic mecanical action causes a Boolean control in te
FAL'E state to cange to T65E (en you clic" it and stay
T65E until LabVIEW as read te %alue7
a- '(itc 5ntil 6eleasedb- '(itc Wen 6eleased
c- Latc 5ntil 6eleased
%: Latch "hen (elease%
+-
-
8/19/2019 Week 3 - LabVIEW Student Ambassadors_v1
49/49
!n% o "ee@ 3