Académique Documents
Professionnel Documents
Culture Documents
Implementing a VI
TOPICS
A. Front Panel Design G. Iterative Data Transfer
B. LabVIEW Data Types H. Plotting Data
C. Documenting Code I. Case Structures
D. While Loops
E. For Loops
F. Timing a VI
ni.com/training
A. Front Panel Design
ni.com/training
A. Front Panel Design – Labels/Captions
ni.com/training
A. Front Panel Design – Color Tips
ni.com/training
A. Front Panel Design – Spacing
ni.com/training
A. Front Panel Design – Text & Fonts
Bad Example
ni.com/training
A. Front Panel Design – Tab Controls
Use tab controls to
overlap front panel
controls and indicators
in a smaller area
ni.com/training
A. Front Panel Design – Decorations
• Use decorations to visually
group or separate objects on
a front panel with boxes, lines,
or arrows
• These objects are for
decoration only
ni.com/training
B. LabVIEW Data Types – Terminals
ni.com/training
B. LabVIEW Data Types – Numerics
ni.com/training
B. LabVIEW Data Types – Boolean
ni.com/training
Mechanical Action of Booleans
DEMONSTRATION
B. Data Types – String
ni.com/training
B. Data Types – Enum
An enum
represents a
pair of values,
a string and a
numeric, where the
enum can be one
of a defined list of
values
ni.com/training
B. Data Types – Enum
• Enum: enumerated
control, constant, or
indicator
• Enums are useful because it is easier
to manipulate numbers than strings
on the block diagram
ni.com/training
B. Data Types – Dynamic
ni.com/training
C. Documenting Code – Front Panels
• Tip Strips
• Descriptions
• VI Properties
• Good Design
ni.com/training
C. Documenting Code – Naming
ni.com/training
C. Documenting Code – Block Diagram
ni.com/training
Configuring Your LabVIEW Environment
ni.com/training
Configuring Your LabVIEW Environment
• Functions Palette
− Tack the Functions palette and select View»Change Visible
Categories then click Select All
• Controls Palette
− Tack the Controls palette and select View»Change Visible
Categories then click Select All
ni.com/training
Exercise 4-1
Determine Warnings VI
• What happens if the Max. Temp value is lower than the Min.
Temp value?
DISCUSSION
D. While Loops
Repeat (code);
Until Condition met;
End;
ni.com/training
D. While Loops
ni.com/training
D. While Loops – Tunnels
ni.com/training
D. While Loops - Error Checking and Error
Handling
Use an error cluster in a While Loop to stop the While Loop if
an error occurs
ni.com/training
Exercise 4-2
Auto Match VI
DISCUSSION
E. For Loops
N=100;
i=0;
Until i=N:
Repeat (code;i=i+1);
End;
ni.com/training
E. For Loops
• Create a For Loop the same way you create a While Loop
• If you need to replace an existing While Loop with a For
Loop, right-click the border of the While Loop, and select
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
ni.com/training
E. For Loops – Conditional Terminal
ni.com/training
E. For Loops – Conditional Terminal
ni.com/training
E. For Loop/While Loop Comparison
• Executes a set number of times unless • Stops executing only if the value at the
a conditional terminal is added conditional terminal meets the
• Can execute zero times condition
• Tunnels automatically output an array • Must execute at least once
of data • Tunnels automatically output the last
value
ni.com/training
E. For Loops – Numeric Conversion
ni.com/training
E. For Loops – Numeric Conversion
ni.com/training
E. For Loops – Numeric Conversion
ni.com/training
Exercise 4-3
Concept: While Loops versus For Loops
ni.com/training
F. Timing a VI – Wait Functions
ni.com/training
F. Timing a VI – Elapsed Time Express VI
ni.com/training
Wait Chart VI
DEMONSTRATION
G. Iterative Data Transfer
ni.com/training
G. Iterative Data Transfer – Shift Registers
ni.com/training
G. Iterative Data Transfer – Initializing
Run once VI finishes Run again
Not
Initialized Output = 4 Output = 8
Shift
Register
ni.com/training
G. Iterative Data Transfer –
Stacked Shift Registers
• Stacked shift registers remember values from multiple
previous iterations and carry those values to the next
iterations
• Right-click the left shift register and select Add Element
from the shortcut menu
ni.com/training
Exercise 4-4
Average Temperature VI
DISCUSSION
H. Plotting Data – Waveform Chart
ni.com/training
H. Plotting Data – Chart Update Modes
ni.com/training
H. Plotting Data
ni.com/training
H. Plotting Data – Waveform Graphs
ni.com/training
Exercise 4-5
Temperature Multiplot VI
DISCUSSION
I. Case Structures
• Have two or more subdiagrams or cases
• Execute and displays only one case at a time
• An input value determines which subdiagram to execute
• Similar to case statements or if...then...else
statements in text-based programming languages
ni.com/training
I. Case Structures
ni.com/training
I. Case Structures – Default Case
• You can specify a default case
for the Case structure
− If you specified cases for 1, 2,
and 3, but you get an input of
4, the Case structure executes
the default case
• Right-click the Case structure
border to add, duplicate,
remove, or rearrange cases
and to select a default case
ni.com/training
I. Case Structures – Input & Output Tunnels
ni.com/training
I. Case Structures – Use Default if Unwired
Numeric 0
Boolean FALSE
String Empty
ni.com/training
I. Case Structures – Boolean
ni.com/training
I. Case Structures – Integer
ni.com/training
I. Case Structures – String
ni.com/training
I. Case Structures – Enum
• Gives users a list of items from which to select
• The case selector displays a case for each item in the
enumerated type control
ni.com/training
I. Case Structures - Error Checking and Error
Handling
Use Case Structures inside VIs to execute the code if there
is no error and skip the code if there is an error
ni.com/training
Exercise 4-6
Determine Warnings VI
• What happens if all the values are 10? How could you fix
this?
DISCUSSION
Summary—Quiz
ni.com/training
Summary—Quiz Answer
ni.com/training
Summary—Quiz
ni.com/training
Summary—Quiz Answer
ni.com/training
Summary—Quiz
ni.com/training
Summary—Quiz Answer
ni.com/training
Summary—Quiz
ni.com/training
Summary—Quiz Answer
ni.com/training