Lesson 1
Navigating LabVIEW
Lesson 2
Lesson 4
Developing Modular
Applications
Lesson 5
Troubleshooting &
Debugging VIs
Lesson 3
Lesson 6
Implementing a VI
Lesson 7
Lesson 8
Solving Dataflow Challenges
with Variables
ni.com/training
Lesson 3
Implementing a VI
TOPICS
A.
B.
C.
D.
E.
F.
G.
H.
I.
Timing a VI
Data Feedback in Loops
Plotting Data Waveform Chart
Case Structures
ni.com/training
E. For Loops
Conditional Terminal
Comparison with While Loops
Numeric Conversion for Count Terminal
ni.com/training
For Loops
N=100;
i=0;
Until i=N:
Repeat (code;i=i+1);
End;
Flowchart
Pseudo Code
ni.com/training
For Loops
Create a For Loop the same way you create a While Loop.
You can replace a While Loop with a For Loop by rightclicking the border of the While Loop and selecting
Replace with For Loop from the shortcut menu.
The value in the count terminal (an input terminal)
indicates how many times to repeat the subdiagram
in the For Loop.
ni.com/training
ni.com/training
ni.com/training
While Loop
Stops executing only if the value
at the conditional terminal meets
the condition.
Must execute at least once.
Tunnels automatically output the
last value.
ni.com/training
ni.com/training
10
ni.com/training
F. Timing a VI
Reasons To Use Timing
Wait Functions and Express VIs
12
ni.com/training
Timing a VI
Why do you need timing in a VI?
To control the frequency at which a loop executes.
To provide the processor with time to complete other tasks,
such as processing the user interface.
13
ni.com/training
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.
14
ni.com/training
15
ni.com/training
Wait Chart VI
17
ni.com/training
18
ni.com/training
Shift Registers
Right-click the border and select Add Shift Register from
the shortcut menu.
Right shift register stores data on completion of an iteration.
Left shift register provides stored data at beginning of the
next iteration.
19
ni.com/training
VI finishes
Block Diagram
Run again
1st run
2nd run
Initialized
Shift
Register
Output = 5
Output = 5
Not
Initialized
Shift
Register
Output = 4
Output = 8
20
ni.com/training
Default Value
Numeric
Boolean
FALSE
String
Empty
21
ni.com/training
22
ni.com/training
Exercise 3-4
Average Temperature VI
HOMEWORK
Use a While Loop and shift registers to average data.
GOAL
Exercise 3-4
Average Temperature VI
25
ni.com/training
26
ni.com/training
27
ni.com/training
Exercise 3-5
Temperature Monitor VI Plot Multiple Temperatures
HOMEWORK
Plot multiple data sets on a single waveform chart and
customize the chart view.
GOAL
Exercise 3-5
Temperature Monitor VI Plot Multiple Temperatures
In what ways do the following tools allow the user to interact with the plot?
Plot Legend
Graph Palette
Scale Legend
DISCUSSION
I. Case Structures
Parts of a Case Structure
Enum Case Structures
Error Case Structures
Input and Output Tunnels
30
ni.com/training
Case Structures
31
ni.com/training
Case Structures
Case Selector Label
Contains the name of the current
case.
Has decrement and increment
arrows.
Selector Terminal
Lets you wire an input value, or
selector, to determine which case
executes.
Selector Terminal
32
ni.com/training
Case Structures
Selector terminal data types:
Boolean
True case and False Case
Error Cluster
Error Case and No Error Case
ni.com/training
34
ni.com/training
Shortcut Menu
Use the shortcut menu of a
Case structure to:
Customize the structure and
diagrams.
Remove or replace the
structure.
Add, duplicate, remove, or
rearrange cases.
Specify the Default case.
Switch cases.
35
ni.com/training
36
ni.com/training
37
ni.com/training
Case Structures
Exercise 3-6
Temperature Warnings VI
HOMEWORK
Modify a VI to use Case structures to make a software
decision.
GOAL
Exercise 3-6
Temperature Warnings VI
What happens if all the values are 10? How could you fix
this?
Are all output tunnels defined? What happens if an output
is not defined?
DISCUSSION
SummaryQuiz
1. If an input to a function is marked with a red dot (known as
a coercion dot), what does the dot indicate?
a) Data was transferred into a structure.
b) A For Loop was configured with a conditional terminal.
c) A For Loop iteration terminal is unwired.
d) The value passed into a node was converted to a
different representation.
41
ni.com/training
SummaryQuiz Answer
1. If an input to a function is marked with a red dot (known as
a coercion dot), what does the dot indicate?
a) Data was transferred into a structure.
b) A For Loop was configured with a conditional terminal.
c) A For Loop iteration terminal is unwired.
d) The value passed into a node was converted to a
different representation.
42
ni.com/training
SummaryQuiz
2. Which structure must run at least one time?
a) While Loop
b) For Loop
43
ni.com/training
SummaryQuiz Answer
2. Which structure must run at least one time?
a) While Loop
b) For Loop
44
ni.com/training
SummaryQuiz
3. Which is only available on the block diagram?
a)
b)
c)
d)
45
Control
Constant
Indicator
Connector Pane
ni.com/training
SummaryQuiz Answer
3. Which is only available on the block diagram?
a)
b)
c)
d)
46
Control
Constant
Indicator
Connector Pane
ni.com/training
SummaryQuiz
4. Which mechanical action causes a Boolean control in the
FALSE state to change to TRUE when you click it and stay
TRUE until LabVIEW has read the value?
a)
b)
c)
d)
47
ni.com/training
SummaryQuiz Answer
4. Which mechanical action causes a Boolean control in the
FALSE state to change to TRUE when you click it and stay
TRUE until LabVIEW has read the value?
a)
b)
c)
d)
48
ni.com/training
End of Week 3
49
ni.com/training