Professional Documents
Culture Documents
Topics
Topics
ni.com/training
0
National Instruments
Corporate headquarters
in Austin, TX
Leader in data acquisition technology with
Offices in nearly 50
innovative modular instruments and countries
LabVIEW graphical programming
35,000+ companies
software
served annually
Approx. 7,100 employees
More than 1,000 products
600 Alliance Partners
ni.com/training
Navigating LabVIEW
TOPICS
A. What Is LabVIEW? F. Searching for Controls,
B. Project Explorer VIs and Functions
C. Parts of a VI G. Selecting a Tool
D. Front Panel H. Dataflow
E. Block Diagram I. Building a Simple VI
8
ni.com/training
A. What Is LabVIEW?
ni.com/training
Laboratory Virtual
Instrumentation Engineering
Workbench
10 ni.com/training
What Is LabVIEW?
—A graphical programming environment used to
develop sophisticated measurement, test and
control systems.
LabVIEW:
• Interfaces with
wide variety of
hardware
• Scales across
different targets
and OSs
• Provides built-in
analysis libraries
11 ni.com/training
B. Project Explorer
Project Explorer Window
Files Types
Project Folders
8 ni.com/training
Project Explorer
• Find, access, and
organize project files
• Prevent, detect, and
resolve incorrect links
• Deploy or download files
to targets
• Manage code for build
options
- Executables, installers,
and zip files
• Integrate with source
code
9 control providers ni.com/training
LabVIEW Files
10 ni.com/training
Adding Folders to a Project
• Virtual folder
- Organizes project items
and does not represent
files on disk
• Auto-populating folder
- Adds a directory on disk
to the project
- LabVIEW continuously
monitors and updates
the folder according to
changes made in the
project and on disk
11 ni.com/training
C. Parts of a VI
Front Panel
Block Diagram
Icon
Connector
Pane
12 ni.com/training
Parts of a VI
VIs have 3 main components:
Icon/Connector pane
Front panel
Block diagram
18 ni.com/training
Parts of a VI – Front Panel
Front Panel – User interface for
the VI
You
build the front
panel with
contro
ls (inputs) and
indicators ni.com/training
14
(outputs).
Parts of a VI – Block Diagram
Block Diagram – Contains the
graphical source code
Front
panel objects
appear as
terminals on the
block diagram.
ni.com/training
15
Parts of a VI – Icon/Connector Pane
Icon – Graphical representation
of a VI
24 ni.com/training
Controls and Indicators
Controls Indicators
- Input devices - Output devices
- Knobs, buttons, slides - Graphs, LEDs
- Supply data to the block - Display data the block
diagram diagram acquires or generates
ni.com/training
25
Numeric Controls and Indicators
Numeric
Increment/Decrement control
buttons
Numeric
indicator
20 ni.com/training
Boolean Controls and Indicators
• The Boolean data type represents data that has
only two options, such as True/False or On/Off.
• Use Boolean controls and indicators to enter
and
display Boolean (TRUE/FALSE) values.
• Boolean objects simulate switches, push buttons
and LEDs.
Boolean Boolean
control indicator
21 ni.com/training
Strings
• The string data type is a sequence of ASCII
characters .
• Use string controls to receive text from the
user.
• Use string indicators to display text to the user.
22 ni.com/training
E. Block Diagram
Terminal
s Nodes
Wires
Help
30 ni.com/training
Block Diagram
24 ni.com/training
Block Diagram
Block diagram items:
• Terminals
• Constants
• Nodes
- Functions
- SubVIs
- Structures
• Wires
• Free labels
25 ni.com/training
Terminal
s
26 ni.com/training
Terminals for Front Panel Objects
• Terminals are:
– Entry and exit ports that exchange
information between the front panel and block
diagram.
– Analogous to parameters in text-based
programming languages.
• Double-click a terminal to locate the
corresponding front panel object.
27 ni.com/training
View Terminals as Icons
28 ni.com/training
Nodes
Nodes are objects on the block diagram that have
inputs and/or outputs and perform operations
when a VI runs.
Nodes
29 ni.com/training
Function Nodes
• Functions are:
- Fundamental operating elements of LabVIEW.
- Do not have front panels or block diagrams, but
do have connector panes.
- Has a pale yellow background on its icon.
• Double-clicking a function only selects the
function.
• Functions do not open like VIs and
subVIs.
30 ni.com/training
SubVI Nodes
• SubVIs :
- Are VIs that you use on the block diagram
of another VI.
- Have front panels and block diagrams.
- Use the icon from the upper-right corner of the
front panel as the icon that appears when you
place the subVI on a block diagram.
• When you double-click a subVI, the front panel
and block diagram open.
• Any VI has the potential to be used as a
31
subVI. ni.com/training
Express VIs
• Express VIs:
- Are a special type of subVI.
- Require minimal wiring because
you configure them with dialog
boxes.
- Save each configuration as a subVI.
• Icons for Express VIs appear on the block
diagram as icons surrounded by a blue
field.
32 ni.com/training
Structures
33 ni.com/training
Wires
• Wires transfer data between block diagram objects.
• Wires are different colors, styles, and
thicknesses, depending on their data types.
Floating-point Integer String
Boolean
Scalar
1-D
Array 2-
D Array
•A
34 broken ni.com/training
Constants
35 ni.com/training
Free labels
• A free label is a label (a text box) not attached to
any object.
• Free labels can be put on the front panel or
block diagram. They are created by double-
clicking on empty space in the window.
• They can serve as comments or
instructions to
the user of the application.
36 ni.com/training
Context Help
• Displays basic
information about wires
and nodes when you
move the cursor over an
object.
• Can be shown or hidden
in the following ways:
- Select Help»Show
Context Help from the
LabVIEW menu.
- Press <Ctrl-H>.
- Click the following
45 button ni.com/training
LabVIEW Help
• Contains detailed descriptions and instructions for
most palettes, menus, tools, VIs, and functions.
• Can be accessed by:
- Selecting Help»
LabVIEW Help from the
menu.
- Clicking the Detailed
help
link in the
Context Help window.
- Right-clicking an object
and selecting Help from
the shortcut menu.
46 ni.com/training
Examples
• LabVIEW includes
hundreds of example VIs.
• Use NI Example Finder
to browse and search
installed examples.
- Select Help»Find
Examples in the
menu.
• Click the example
buttons in LabVIEW
Help
47
topics. ni.com/training
F. Searching for Controls,
VIs
and Functions
Palettes
Quick Drop
NI Global Search
40 ni.com/training
Searching for Controls,
VIs and
Functions
Ways to find controls, VIs, and functions:
• Search or navigate the palettes.
- Controls palette
- Functions palette
• Search by name of object.
- Quick Drop dialog box
• Search palettes, LabVIEW Help, and ni.com.
- Search text box in toolbar
41 ni.com/training
Controls Palette
42 ni.com/training
Functions Palette
43 ni.com/training
Searching with Quick Drop
44 ni.com/training
Global Search
45 ni.com/training
G. Selecting a
Tool a Tool
Selecting
Block Diagram Clean-Up
46 ni.com/training
Selecting a
Tool
• A tool is a special operating mode of
the mouse cursor.
• Create, modify, and debug VIs
using the tools provided by
LabVIEW.
• By default, LabVIEW automatically
selects tools based on the context
of the cursor.
• If you need more control, use the
Tools palette to select a specific
tool.
- Select View»Tools Palette
to open the Tools palette.
47 ni.com/training
Wiring
Tips
• Press <Ctrl-B> to delete broken wires.
• Right-click and select Clean Up Wire to reroute
the wire.
48 ni.com/training
TOPICS
ni.com/training
0
Implementing a VI
TOPICS
A. Designing Controls and E. Timing a VI
Indicators F. Data Feedback in Loops
B. LabVIEW Data Types G. Case Structure
C. While Loop
D. For Loop
1 ni.com/training
A. Designing Controls
and Indicators
2 ni.com/training
Labels & Options
Make sure to label controls and indicators clearly
and set a default value if necessary.
ni.com/training
B. LabVIEW Data Types
Shortcut Menu and Properties Dialog Box
Numeric
Types Boolean
Types String
Types
Enums and
Other Types
4
ni.com/training
LabVIEW Data
Types
Terminals visually communicate information
about the data type represented.
5
ni.com/training
Iteration
C. Whileand Conditional
Loop Terminals
Tunnels
Error Checking
17 ni.com/training
While Loop
Repeat (code);
Until Condition met;
End;
18 ni.com/training
While Loop
Iteration terminal Conditional terminal
• Defines when the loop stops.
• Returns number of times
• Has two options:
loop has executed.
- Stop if True
• Is zero-indexed.
- Continue if True.
19 ni.com/training
While Loop –
Tunnels
• Tunnels transfer data into and out of structures.
• When a tunnel passes data into a loop, the
loop executes only after data arrive at the
tunnel
(at all tunnels,
if there is more
than one).
• Data pass out of
a loop after the
loop terminates.
20 ni.com/training
While Loop – Error Checking and Error
Handling
Use an error cluster in a While Loop to stop the
While Loop if an error occurs.
21 ni.com/training
Conditional
D. For LoopTerminal
Comparison with While Loop
Numeric Conversion for Count Terminal
24
ni.com/training
For Loop
N=100;
i=0;
Until
i=N:
Repeat (code;i=i+1);
End;
25
ni.com/training
For Loop
• Create a For Loop the same way you create
a While Loop.
• You can replace a While Loop with a For Loop
by right-clicking 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.
26
ni.com/training
For Loop – Conditional
Terminal
You can add a conditional terminal to configure a
For Loop to stop when a Boolean condition is true or
an error occurs.
This is similar
to a ‘break’
statement in
text-based
programming
languages.
27
ni.com/training
For Loop – Conditional
Terminal
For Loops configured with a conditional terminal
have:
• A red glyph next to the count terminal
• A conditional terminal in the lower right corner.
28
ni.com/training
For Loop / While Loop Comparison
For Loop While Loop
• Executes a set number of • Stops executing only if the
times unless a conditional value at the conditional
terminal is added. terminal meets the condition.
• Can execute zero times. • Must execute at least once.
• Tunnels automatically • Tunnels automatically
output an array of data. output the last value.
29
ni.com/training
For Loop – Numeric Conversion
• The number of iterations a For Loop executes must be
specified in non-negative integers.
• If you wire a double-precision, floating-point numeric
value to the count terminal, LabVIEW converts the
numeric value to a 32-bit signed integer.
30
ni.com/training
E. Timing a VI
Reasons To Use Timing
Wait Functions and Express
VIs
32
ni.com/training
Timing a VI
33
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.
34
ni.com/training
Elapsed Time Express
VI
• Determines how much time elapses after some
point in your VI.
35
ni.com/training
F. Data Feedback in Loops
Shift Registers
Initializing Shift Registers
Default for Unwired
Values Compound Shift
Registers
37 ni.com/training
Data Feedback in Loops
• When programming with loops, you often need to
know the values of data from previous iterations
of the loop.
• Shift registers transfer values from one loop
iteration
to the next.
38 ni.com/training
Shift
Registers
• Right-click the border and select Add Shift
Register from the shortcut menu.
• Right part of shift register stores data on
completion of an iteration.
• Left part of shift
register provides
stored data at
the beginning
of the next
iteration.
39 ni.com/training
Initializing Shift
Registers
Run once VI Run again
finishes
Block Diagram 1st run 2nd run
Initialized Output = 5 Output = 5
Shift
Register
40 ni.com/training
Default Value if Unwired
Default values vary by data type:
Data Type Default Value
Numeric 0
Boolean FALSE
String Empty
41 ni.com/training
G. Case Structures
Parts of a Case Structure
Enum Case Structures
Error Case Structures
Input and Output
Tunnels
43 ni.com/training
Case Structures
• Have two or more subdiagrams (cases).
• Use an input value to determine which case
to execute.
• Execute and display only one case at a time.
• Are similar to case statements or
if...then...else
statements in text-based programming
languages.
44 ni.com/training
Case Structures
• Case Selector Label
- Contains the name of the current case.
- Has decrement and increment arrows.
• Selector Terminal Case Selector Label
- Lets you wire an input
value, or selector, to
determine which case
executes.
Selector
Terminal
45 ni.com/training
Case Structures
Selector terminal data
types:
• Boolean
- True case and False
Case
• Error Cluster
- Error Case and No Error
Case
• Integer, string or
enum
- Structure can have any
number of cases
ni.com/training
-46 Include a Default diagram
to avoid listing every
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.
47 - Specify the Default ni.com/training
Enum Case Structure
• Gives users a list of items from which to select.
• The case selector displays a case for each item
in the enumerated type control.
48 ni.com/training
Error Case Structure
Use Case structures inside VIs to execute the
code if there is no error and skip the code if there
is an error.
49 ni.com/training