Lesson 07 - Modularity (SubVIs)
Lesson 07 - Modularity (SubVIs)
Modularity
Recognize the benefits of reusing code and create a subVI
with a properly configured connector pane, meaningful icon,
documentation, and error handling.
A. Understanding Modularity
B. Icon
C. Connector Pane
D. Documentation
E. Using SubVIs
1
LESSON 7 Modularity
A. Understanding
Modularity
Recognize the benefit of using modular code and identify
sections of code that could be reused.
• Modularity
• SubVIs
2
A. Understanding Modularity
3
B. Understanding Modularity
SubVIs—Reusing Code
4
B. Understanding Modularity
SubVIs
Function Code Calling Program Code
function average (in1, in2, out) main
{ {
out = (in1 + in2)/2.0; average (point1, point2, pointavg)
} }
5
LESSON 7 Modularity
B. Icon
Recognize characteristics of a good icon and use the
LabVIEW Icon Editor to create a custom icon.
6
B. Icon
Purpose of Icon
• Graphical representation of a VI
• Identifies the subVI on the block diagram of the VI
7
B. Icon
8
B. Icons
9
LESSON 7 Modularity
Demonstration
Creating an Icon
10
LESSON 7 Modularity
C. Connector Pane
Select and configure a connector pane for a subVI.
• Patterns
• Standards
11
C. Connector Pane
Patterns
12
C. Connector Pane
Assigning Terminals
Min.Temperature
Error In Error Out
13
C. Connector Pane
Standards
14
LESSON 7 Modularity
D. Documentation
Explain how to document code in LabVIEW using
descriptions and tip strips, and describe four methods for
documenting code on the block diagram.
• VI Descriptions and Tip Strips
• Labels
15
D. Documentation
16
D. Documentation
Free
label
Owned label
17
LESSON 7 Modularity
E. Using SubVIs
Demonstrate how to place subVIs on the block diagram,
explain terminal settings and error handling, and create
subVIs from a section of existing code.
• Placing SubVIs on the Block Diagram
• Terminal Settings
• Handling Errors
• Creating from a Section of Block Diagram
18
E. Using SubVIs
19
E. Using SubVIs
Terminal Settings
• Bold
– Required terminal
• Plain
– Recommended terminal
• Dimmed
– Optional terminal
20
E. Using SubVIs
Handling Errors
Use a Case Structure to handle errors passed into the
subVI.
21
E. Using SubVIs
Handling Errors
Avoid using LabVIEW error handler VIs inside subVIs.
22
E. Using SubVIs
23
LESSON 7 Modularity
Exercise 7-1
Temperature Warnings VI – As SubVI
Create the icon and connector pane for a VI so you can use the VI as a
subVI. Call the subVI from a test VI.
24
LESSON 7 Modularity
Exercise 7-1
Temperature Warnings VI – As SubVI
• Do the terminal names in the calling VI need to match the subVI terminal
names?
• Do the data types in the calling VI need to match the subVI terminal data
types?
25
LESSON 7 Modularity
Activity 7-1
Lesson Review
Refer to the participant guide to answer questions about what you have learned
in this lesson and then discuss the answers as a group.
26
Lesson Review
a) Required
b) Recommended
c) Optional
27
Lesson Review
a) Required
b) Recommended
c) Optional
28
Lesson Review
29
Lesson Review
30