Lesson 1
Navigating LabVIEW
TOPICS
A. What Is LabVIEW?
B. Project Explorer
C. Parts of a VI
D. Front Panel
E. Block Diagram
F. Searching for Controls, VIs
and Functions
0
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
LabVIEW Core 1 Topics
• Graphical
• Dataflow-oriented
• Compiled
• Multi-platform
• Synchronous
1
ni.com/training
C. Parts of a VI
VIs have 3 main components:
Icon/Connector pane
Block diagram
Front panel
2
ni.com/training
Parts of a VI – Front Panel
Front Panel – User interface for the VI
You build the front
panel with
controls (inputs) and
indicators (outputs).
3
ni.com/training
Parts of a VI – Block Diagram
Block Diagram – Contains the
graphical source code
Front panel objects
appear as terminals
on the block diagram.
4
ni.com/training
Parts of a VI – Icon/Connector Pane
Icon – Graphical representation of a VI
Connector Pane – Map of the inputs
and outputs of a VI
Icons and connector panes are necessary to use a VI as a
subVI.
− A subVI is a VI that appears on the block diagram of another VI.
− A subVI is similar to a subroutine or function in a text-based
programming language.
5
ni.com/training
D. Front Panel
6
ni.com/training
Controls and Indicators
Controls
Indicators
− Input devices
− Knobs, buttons, slides
− Supply data to the block
diagram
− Output devices
− Graphs, LEDs
− Display data the block diagram
acquires or generates
7
ni.com/training
Front Panel Object Styles
8
ni.com/training
E. Block Diagram
9
ni.com/training
Block Diagram
Block diagram items:
• Terminals
• Constants
• Nodes
− Functions
− SubVIs
− Structures
• Wires
• Free labels
10
ni.com/training
View Terminals as Icons
• By default, View as Icon option enabled.
• Double-click a terminal to locate the corresponding front panel
object.
• Analogous to parameters in text-based programming
languages
• Deselect View as Icon for a more compact view.
Terminals are:
• Entry and exit ports that exchange information between the
front panel and block diagram.
11
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
12
ni.com/training
Advertisement
Wires
• Wires transfer data between block diagram objects.
• Wires are different colors, styles, and thicknesses,
depending on their data types.
• A broken wire appears as a dashed
black line with a red X in the middle.
Floating-point
Integer
String
Boolean
Scalar
1-D Array
2-D Array
13
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 button on the
toolbar:
14
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.
15
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 topics.
16
ni.com/training
Controls Palette
• Contains the controls and
indicators you use to create
the front panel.
• Navigate the subpalettes or
use the Search button to
search the Controls palette.
17
ni.com/training
Functions Palette
• Contains the VIs, functions,
and constants you use to
create the block diagram.
• Navigate the subpalettes or
use the Search button to
search the Functions palette.
18
ni.com/training
F. Searching for Controls, VIs, and
Functions
Palettes
Quick Drop
NI Global Search
19
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
20
ni.com/training
Searching with Quick Drop
• Lets you quickly find controls,
functions, VIs, and other
items by name.
• Press the <Ctrl-Space> keys
to display the Quick Drop
dialog box.
21
ni.com/training
Lesson 2
Creating your First Application
TOPICS
A. Dataflow
B. Labview Data Types
C. Tools for Programming, Cleaning and Organizing Your VI
D. Building a Basic VI
22
ni.com/training
A. Dataflow
LabVIEW follows a dataflow model for running VIs
Advertisement
– A node executes only when data are available at all of
its input terminals
– A node supplies data to the output terminals only when
the node finishes execution
DISCUSSION
23
B. LabVIEW Data Types
Shortcut Menu and Properties Dialog Box
Numeric Types
Boolean Types
String Types
Enums and Other Types
24
DISCUSSION
LabVIEW Data Types
Terminals visually communicate information about the data
type represented
25
DISCUSSION
Shortcut Menus
– All LabVIEW objects
have associated
shortcut menus.
– Use shortcut menu
items to change the
look or behavior of
objects.
– To access the shortcut
menu, right-click the
object.
26
DISCUSSION
26
Properties Dialog Box
– All LabVIEW objects have
properties.
– To access properties, right-
click the object and select
Properties.
– Property options are similar
to shortcut menu options.
– Select multiple objects to
simultaneously configure
shared properties.
27
DISCUSSION
27
Numerics
Various data type
representations:
– Floating-point
– Unsigned integers
– Signed integers
28
DISCUSSION
Numeric Conversion
Coercion Dot
– Coercion dots indicate that LabVIEW
converted the value passed into a
node to a different representation.
• Occurs when a node expects an input
with a different representation.
– LabVIEW chooses the representation
that uses more bits.
– Avoid coercion by programmatically
converting to a matching data type.
29
DISCUSSION
Exercice 1:
1: le type de données est réel
2: changer le type des entrées à entier sur 32bit
3: Changer les contrôles à des constantes de type entier
DISCUSSION
Booleans
– Behavior of Boolean
controls is specified by
the mechanical action.
– Boolean have only
TRUE/FALSE values.
31
DISCUSSION
Exercice 2:
1: créer un nouveau VI
2: Editer les équations suivantes:
A and B
A or B
A nand B
A and B and C
3: Ajouter un voyant LED à chaque entrée
DISCUSSION
Strings
– A string is a sequence of ASCII
characters.
– Strings have various display
styles.
• Backslash codes
• Password
• Hex
33
DISCUSSION
Enums//Ring
– Enums give users a
list of items from
which to select.
– Each item represents
a pair of values.
• String
• 16-bit Integer
34
DISCUSSION
Other Data Types
– Dynamic
Advertisement
• Stores the information generated or acquired by an Express VI.
– Path
• Stores the location of a file or directory using the standard
syntax for the platform you are using.
– Waveform
• Carries the data, start time, and dt of a waveform.
35
DISCUSSION
C. Tools for Programming, Cleaning and
Organizing Your VI
– Create, modify, and debug VIs
using the tools provided by LabVIEW
– A tool is a special operating mode of the
mouse cursor
– The operating mode of the cursor corresponds to the
icon of the tool selected
– When using the Automatic Tool Selection, LabVIEW
chooses which tool to select based on the current
location of the mouse
DISCUSSION
36
DISCUSSION
D. Building a Basic VI
3
8
DISCUSSION
Acquire Express VIs
– DAQ Assistant Express VI
– Instrument I/O Assistant Express VI
– Simulate Signal Express VI
– Read from Measurement File Express VI
3
9
DISCUSSION
Analyze Express VIs
– Amplitude and Level Measurements Express VI
– Statistics Express VI
– Spectral Measurements Express VI
– Tone Measurements Express VI
– Filter Express VI
4
0
DISCUSSION
Present Express VIs and Indicators
– Display Message Express VI
– Play Waveform Express VI
– Report Express VI
– Write Measurement File
Express VI
4
1
DISCUSSION
Building and Running a VI
Place Express VI on the block diagram.
1.
2. Configure the dialog box that opens.
3. Wire Express VIs together.
Save and run the VI.
4.
The Run button appears broken when the VI you
are creating or editing contains errors.
4
2
DISCUSSION
DISCUSSION
Lesson 3
Troubleshooting and Debugging VIs
TOPICS
A. Correcting Broken VIs
B. Debugging Techniques
C. Undefined or Unexpected Data
D. Error Handling
44
ni.com/training
A. Correcting Broken VIs
Broken Run arrow VI cannot be compiled VI cannot be executed
45
DISCUSSION
Common Causes of Broken VIs
– Broken wires exist on the
block diagram.
• You wired a Boolean control to
a String indicator.
• You wired a numeric control to
a numeric control.
– A required block diagram
terminal is unwired.
– A subVI is broken.
46
DISCUSSION
B. Debugging Techniques
Execution Highlighting
Single-Stepping
Probes
Breakpoints
47
DISCUSSION
Debugging Techniques
What to look for if a VI produces unexpected data or behavior:
– Are there any unwired or hidden subVIs?
– Is the default data correct?
– Does the VI pass undefined data?
– Are numeric representations correct?
– Are node executed in the correct order?
48
DISCUSSION
Execution Highlighting
– Use execution highlighting to watch the data flow
through the block diagram.
– If the VI runs more slowly than expected, confirm that
you turned off execution highlighting in subVIs.
49
Advertisement
DISCUSSION
Single-Stepping
– Single-step through the VI to view each action of the VI
on the block diagram.
– Suspend the execution of a subVI to edit values of
controls and indicators, to control the number of times it
runs, or to go back to the beginning of the execution of
the subVI.
• Open subVI and select Operate»Suspend When Called from
the shortcut menu.
50
DISCUSSION
Probes
– Use the Probe tool to observe intermediate
data values and check the error output of VIs
and functions, especially those performing I/O.
– Specify to retain the values in the wires so
that you can probe wires for data after
execution.
51
DISCUSSION
Breakpoints
– When you reach a breakpoint during execution,
the VI pauses and the Pause button appears red.
• You can take the following actions at a breakpoint:
− Single-step through execution using the single-stepping buttons.
− Probe wires to check intermediate values.
− Change values of front panel controls.
− Click the Pause button to continue running to the next breakpoint
or until the VI finishes running.
52
DISCUSSION
52
C. Undefined or Unexpected Data
Check for unexpected Inf values or NaN values in your
mathematical operations:
– ∞ (Inf)
• Infinity
• Produced by dividing a number by zero.
– NaN
• Not a number
• Produced by invalid operations, such as taking the square
root of a negative number.
53
DISCUSSION
D. Error Handling
Automatic and Manual Error Handling
Merge Errors Function
Error Clusters
Warnings
54
DISCUSSION
Error Handling
Error Handling – Anticipation, detection,
and resolution of warnings and errors
– You cannot predict every problem a user can encounter.
– Without a mechanism to check for errors, you know only
that the VI does not work properly.
– Error handling tells you why and where errors occur.
• Automatic error handling
• Manual error handling
55
DISCUSSION
Manual Error Handling
– You control when dialog boxes appear.
– Propagate errors by wiring the error out cluster to error
in cluster of next node to execute.
– Terminate the error chain with a call to Simple Error
Handler VI.
56
DISCUSSION
Merge Errors
– Propagate errors along wires.
– Merge errors from different wire paths.
57
DISCUSSION
Merge Errors Function
– Merge Errors function returns the first error found. If no
error is found, it returns the first warning.
– The Merge Errors function does not concatenate errors.
58
DISCUSSION
Error Clusters
– Use the error cluster controls and indicators to create
error inputs and outputs in subVIs.
• The error in and error
out clusters include the
following components
of information:
− Status
− Code
− Source
59
DISCUSSION
Errors and Warnings
Status = TRUE
Status = FALSE
Code = Non-zero
Error
Warning
60
DISCUSSION
Errors and Warnings Recommendations
– Report errors and warnings with the Simple Error
Handler VI
• Modify Type of Dialog to detect warnings.
– Call the Simple Error Handler VI from the top-level VI.
– Avoid error dialogs in subVIs.
61
DISCUSSION