You are on page 1of 24

LabVIEW Basics I CBT Exercises

Lesson 1: Introduction to LabVIEW

Exercise 1-1: Acquiring a Signal VI


Objective:

Explore the LabVIEW environment by creating a VI that generates a signal and


displays it on the front panel.
In the following exercise, you will build a VI that generates a signal and
displays that signal in a graph. LabVIEW provides templates containing
information from which you can build a VI. These templates help you get
started with LabVIEW.
Complete the following steps to create a VI that generates a signal and
displays it on the front panel.
1. Launch LabVIEW.
2. In the LabVIEW dialog box that appears, shown in the following figure,
click the New button to display the New dialog box.

3. Select VI from TemplateTutorial (Getting Started)Generate and


Display in the Create new list. This template VI generates and displays
a signal.
Notice that previews of the template VI appear in the Front panel
preview and the Block diagram preview sections. The following figure
shows the New dialog box and the Generate and Display template VI.

LabVIEW Basics I CD-Based Training

ni.com

Lesson 1: Introduction to LabVIEW

LabVIEW Basics I CBT Exercises

4. Click the OK button to open the template. You also can double-click the
name of the template VI in the Create new list to open the template.
5. Examine the front panel of the VI.
The user interface, or front panel, appears with a gray background and
includes controls and indicators. The title bar of the front panel indicates
that this window is the front panel for the Generate and Display VI.
If the front panel is not visible, you can display the front panel by selecting
WindowShow Front Panel.

Note

6. Examine the block diagram of the VI.


The block diagram appears with a white background and includes VIs
and structures that control the front panel objects. The title bar of the
block diagram indicates that this window is the block diagram for the
Generate and Display VI.
If the block diagram is not visible, you can display the block diagram by selecting
WindowShow Block Diagram.

Note

National Instruments Corporation

LabVIEW Basics I CD-Based Training

LabVIEW Basics I CBT Exercises

Lesson 1: Introduction to LabVIEW

7. On the front panel toolbar, click the Run button, shown at left.
Notice that a sine wave appears on the graph.
8. Stop the VI by clicking the STOP button, shown at left, on the front
panel.

Adding a Control to the Front Panel


Controls on the front panel simulate the input devices on a physical
instrument and supply data to the block diagram of the VI. Many physical
instruments have knobs you can turn to change an input value. Complete the
following steps to add a knob control to the front panel.
Throughout these exercises, you can undo recent edits by selecting EditUndo or
pressing the <Ctrl-Z> keys.
Tip

1. If the Controls palette is not visible on the front panel, select Window
Show Controls Palette to display it.
2. Move the cursor over the icons on the Controls palette to locate the
Numeric Controls palette.
Notice that when you move the cursor over icons on the Controls
palette, the name of that subpalette appears in the gray space above all
the icons on the palette. When you idle the cursor over any icon on any
palette, the full name of the subpalette, control, or indicator appears.
3. Click the Numeric Controls icon to access the Numeric Controls
palette.
4. Select the knob control on the Numeric Controls palette and place it on
the front panel to the left of the waveform graph.
You will use this knob in a later exercise to control the amplitude of a
signal.
5. Select FileSave As and save this VI as Acquiring a Signal.vi in
the C:\Exercises\LV Basics I directory.
Note Save all the VIs you edit or create in this course in the C:\Exercises\
LV Basics I directory.

LabVIEW Basics I CD-Based Training

ni.com

Lesson 1: Introduction to LabVIEW

LabVIEW Basics I CBT Exercises

Changing the Signal Type


The block diagram has a blue icon labeled Simulate Signal. This icon
represents the Simulate Signal Express VI. The Simulate Signal Express VI
simulates a sine wave by default. Complete the following steps to change
this signal to a sawtooth wave.
1. Display the block diagram by selecting WindowShow Block
Diagram or by clicking the block diagram.
Notice the Simulate Signal Express VI, shown at left. An Express VI is
a component of the block diagram that you can configure to perform
common measurement tasks. The Simulate Signal Express VI simulates
a signal based on the configuration that you specify.
2. Right-click the Simulate Signal Express VI and select Properties from
the shortcut menu to display the Configure Simulate Signal dialog box.
3. Select Sawtooth from the Signal type pull-down menu.
Notice that the waveform on the graph in the Result Preview section
changes to a sawtooth wave. The Configure Simulate Signal dialog
box should appear similar to the following figure.

4. Click the OK button to apply the current configuration and close the
Configure Simulate Signal dialog box.

National Instruments Corporation

LabVIEW Basics I CD-Based Training

LabVIEW Basics I CBT Exercises

Lesson 1: Introduction to LabVIEW

5. Move the cursor over the down arrows at the bottom of the Simulate
Signal Express VI.
6. When a double-headed arrow appears, shown at left, click and drag the
border of the Express VI until the Amplitude input appears.
Notice how you expanded the Simulate Signal Express VI to display a
new input. Because the Amplitude input appears on the block diagram,
you can configure the amplitude of the sawtooth wave on the block
diagram.
In the previous figure, notice how Amplitude is an option in the
Configure Simulate Signal dialog box. When inputs, such as
Amplitude, appear on the block diagram and in the configuration dialog
box, you can configure the inputs in either location.

Wiring Objects on the Block Diagram


To use the knob control to change the amplitude of the signal, you must
connect the two objects on the block diagram. Complete the following steps
to wire the knob to the Amplitude input on the Simulate Signal Express VI.
1. Move the cursor over the Knob terminal, shown at left, until the
Positioning tool appears.
Notice how the cursor becomes an arrow, or the Positioning tool, shown
at left. Use the Positioning tool to select, position, and resize objects.
2. Click the Knob terminal to select it, then drag the terminal to the left of
the Simulate Signal Express VI. Make sure the Knob terminal is inside
the loop, shown at left.
The terminals are representations of front panel controls and indicators.
Terminals are entry and exit ports that exchange information between
the front panel and block diagram.
3. Deselect the Knob terminal by clicking a blank space on the block
diagram.
4. Move the cursor over the arrow of the Knob terminal, shown at left.
Notice how the cursor becomes a wire spool, or the Wiring tool, shown
at left. Use the Wiring tool to wire objects together on the block diagram.
Note

The cursor does not switch to another tool while an object is selected.
5. When the Wiring tool appears, click the arrow and then click the
Amplitude input of the Simulate Signal Express VI, shown at left, to
wire the two objects together.
Notice that a wire appears and connects the two objects. Data flows
along this wire from the terminal to the Express VI.
6. Select FileSave to save this VI.

LabVIEW Basics I CD-Based Training

ni.com

Lesson 1: Introduction to LabVIEW

LabVIEW Basics I CBT Exercises

Running the VI
Running a VI executes your solution. Complete the following steps to run
the Acquiring a Signal VI.
1. Display the front panel by selecting WindowShow Front Panel or by
clicking the front panel.
Press the <Ctrl-E> keys to switch from the front panel to the block diagram or from
the block diagram to the front panel.

Tip

2. Click the Run button.


3. Move the cursor over the knob control.
Notice how the cursor becomes a hand, or the Operating tool, shown at
left. Use the Operating tool to change the value of a control or select the
text within a control.
4. Using the Operating tool, turn the knob to adjust the amplitude of the
sawtooth wave.
Notice how the amplitude of the sawtooth wave changes as you turn the
knob. Also notice that the y-axis on the graph autoscales to account for
the change in amplitude.
To indicate that the VI is running, the Run button changes to a darkened
arrow, shown at left. You cannot edit the front panel or block diagram
while the VI runs.
5. Click the STOP button, shown at left, to stop the VI.
Although the Abort Execution button
looks like a stop button, the Abort
Execution button does not always properly close the VI. National Instruments
recommends stopping your VIs using the STOP button on the front panel. Use the Abort
Execution button only when errors prevent you from terminating the application using
the STOP button.

Note

National Instruments Corporation

LabVIEW Basics I CD-Based Training

LabVIEW Basics I CBT Exercises

Lesson 1: Introduction to LabVIEW

Modifying the Signal


Complete the following steps to add scaling to the signal and display the
results in the graph on the front panel.
1. On the block diagram, use the Positioning tool to double-click the wire
that connects the Simulate Signal Express VI to the Waveform Graph
terminal, shown at left.
2. Press the <Delete> key to delete this wire.
3. If the Functions palette is not visible on the block diagram, select
WindowShow Functions Palette to display it.
4. Select the Scaling and Mapping Express VI, shown at left, on the
Arithmetic & Comparison palette and place it on the block diagram
inside the loop between the Simulate Signal Express VI and the
Waveform Graph terminal. If there is no room between the Express VI
and the terminal, move the Waveform Graph terminal to the right.
Notice that the Configure Scaling and Mapping dialog box
automatically opens when you place the Express VI on the block
diagram.
5. Define the value of the scaling factor by entering 10 in the Slope (m)
text box.
The Configure Scaling and Mapping dialog box should appear similar
to the following figure.

6. Click the OK button to apply the current configuration and close the
Configure Scaling and Mapping dialog box.

LabVIEW Basics I CD-Based Training

ni.com

Lesson 1: Introduction to LabVIEW

LabVIEW Basics I CBT Exercises

7. Move the cursor over the arrow on the Sawtooth output of the Simulate
Signal Express VI.
8. When the Wiring tool appears, click the arrow and then click the arrow
on the Signals input of the Scaling and Mapping Express VI, shown at
left, to wire the two objects together.
9. Using the Wiring tool, wire the Scaled Signals output of the Scaling and
Mapping Express VI to the Waveform Graph terminal.
Notice the wires connecting the Express VIs and terminals. The arrows
on the Express VIs and terminals indicate the direction that the data
flows along these wires. The block diagram should appear similar to the
following figure.

10. Select FileSave to save this VI.

Displaying Two Signals on the Graph


To compare the signal generated by the Simulate Signal Express VI and the
signal modified by the Scaling and Mapping Express VI on the same graph,
use the Merge Signals function. Complete the following steps to display two
signals on the same graph.
1. Move the cursor over the arrow on the Sawtooth output of the Simulate
Signal Express VI.
2. Using the Wiring tool, wire the Sawtooth output to the Waveform
Graph terminal.
The Merge Signals function, shown at left, appears where the two wires
connect. This function takes the two separate signals and combines them
so that both can be displayed on the same graph. The block diagram
should appear similar to the following figure.

National Instruments Corporation

LabVIEW Basics I CD-Based Training

LabVIEW Basics I CBT Exercises

Lesson 1: Introduction to LabVIEW

3. Select FileSave to save this VI. You also can press the <Ctrl-S> keys
to save a VI.
4. Return to the front panel, run the VI, and turn the knob control.
Notice that the graph plots the sawtooth wave and the scaled signal. Also
notice that the maximum value on the y-axis automatically changes to
be 10 times the knob value. This scaling occurs because you set the slope
to 10 in the Scaling and Mapping Express VI.
5. Click the STOP button.

Customizing the Knob


The knob control changes the amplitude of the sawtooth wave so labeling it
Amplitude accurately describes the function of the knob. Complete the
following steps to customize the appearance of a control on the front panel.
1. Right-click the knob and select Properties from the shortcut menu to
display the Knob Properties dialog box.
2. In the Label section on the Appearance tab, delete the label Knob, and
type Amplitude in the text box.
The Knob Properties dialog box should appear similar to the following
figure.

LabVIEW Basics I CD-Based Training

10

ni.com

Lesson 1: Introduction to LabVIEW

LabVIEW Basics I CBT Exercises

3. Click the Scale tab and in the Scale Range section, change the
maximum value to 5.0.
Notice how the knob on the front panel instantly updates to reflect these
changes.
4. Click the OK button to apply the current configuration and close the
Knob Properties dialog box.
5. Save this VI.
As you build VIs, you can experiment with different properties and configurations.
You also can add and delete objects. Remember you can undo recent edits by selecting
EditUndo or pressing the <Ctrl-Z> keys.

Tip

6. Experiment with other properties of the knob by using the Knob


Properties dialog box. For example, try changing the colors for the
Marker Text Color by clicking the color box located on the Scale tab.
7. Click the Cancel button to avoid applying the changes you made while
experimenting. If you want to keep the changes you made, click the OK
button.

National Instruments Corporation

11

LabVIEW Basics I CD-Based Training

LabVIEW Basics I CBT Exercises

Lesson 1: Introduction to LabVIEW

Customizing the Waveform Graph


The waveform graph indicator displays the two signals. To indicate which
plot is the scaled signal and which is the simulated signal, you customize the
plots. Complete the following steps to customize the appearance of an
indicator on the front panel.
1. Move the cursor over the top of the plot legend on the waveform graph.
Notice that while there are two plots on the graph, the plot legend
displays only one plot.
2. When a double-headed arrow appears, shown in the following figure,
click and drag the border of the plot legend until the second plot name
appears.

3. Right-click the waveform graph and select Properties from the shortcut
menu to display the Graph Properties dialog box.
4. On the Plots tab, select Sawtooth from the pull-down menu. Click the
Line Color color box to display the color picker. Select a new line color.
5. Select Sawtooth (Scaled) from the pull-down menu.
6. Place a checkmark in the Dont use waveform names for plot names
checkbox.
7. In the Name text box, delete the current label and change the name of
this plot to Scaled Sawtooth.
8. Click the OK button to apply the current configuration and close the
Graph Properties dialog box.
Notice how the plot color on the front panel changes.
9. Experiment with other properties of the graph by using the Graph
Properties dialog box. For example, try disabling the autoscale feature
located on the Scales tab.

LabVIEW Basics I CD-Based Training

12

ni.com

Lesson 1: Introduction to LabVIEW

LabVIEW Basics I CBT Exercises

10. Click the Cancel button to avoid applying the changes you made while
experimenting. If you want to keep the changes you made, click the OK
button.
11. Save and close the VI.

End of Exercise 1-1

National Instruments Corporation

13

LabVIEW Basics I CD-Based Training

LabVIEW Basics I CBT Exercises

Lesson 1: Introduction to LabVIEW

Exercise 1-2: Express Filter VI


Objective:

Explore the data flow of an example VI.


Complete the following steps to use the NI Example Finder to search for an
example VI that generates a sine wave with a frequency of 10 Hz and an
amplitude of 10 volts with white noise of 1 volts of amplitude and applies a
filter.
1. Select HelpFind Examples to open the NI Example Finder.
2. Click the Search tab and type filter in the Type in the word(s) to
search for text box.
Notice that this word choice reflects what you want this Express VI
to dofilter a signal.
3. Select filter to display the example VIs that include filter in the title.
4. Find the example VI called Express Filter.vi and double-click to
open it.
5. Open the block diagram of the VI, shown in the following figure.

LabVIEW Basics I CD-Based Training

14

ni.com

Lesson 1: Introduction to LabVIEW

LabVIEW Basics I CBT Exercises

6. Click the Highlight Execution button, shown at left, on the toolbar


to slow down the execution of the program so you can observe the
execution order on the block diagram.
7. Click the Run button.
8. Observe the block diagram. Notice the flow of data on the block
diagram. For example, notice that the Tone Measurements2 Express VI
cannot output data until it receives data from Filter.
9. Close the VI. Do not save changes.

End of Exercise 1-2

National Instruments Corporation

15

LabVIEW Basics I CD-Based Training

LabVIEW Basics I CBT Exercises

Lesson 1: Introduction to LabVIEW

Exercise 1-3: Reduce Samples VI


Objective:

Use the LabVIEW documentation resources to build a VI that generates a signal,


reduces the number of samples in the signal, and displays the resulting data in a
table on the front panel.
In the following exercises, you will open a blank VI and add Express VIs
and structures to the block diagram to build a new VI. When you complete
the exercise, the front panel of the VI will appear similar to the following
figure.

Opening a Blank VI
If no template is available for the task you want to create, you can start with
a blank VI and add Express VIs to accomplish the specific task. Complete
the following steps to open a blank VI.
1. In the LabVIEW dialog box, click the arrow on the New button and
select Blank VI from the shortcut menu or press the <Ctrl-N> keys to
open a blank VI.
Notice that a blank front panel and block diagram appear.
2. If the Functions palette is not visible, right-click any blank space on the
block diagram to display the Functions palette. Click the thumbtack,
shown at left, in the upper left corner of the Functions palette to place
the palette on the screen.
You can right-click a blank space on the block diagram or the front panel to display
the Functions or Controls palettes.

Note

LabVIEW Basics I CD-Based Training

16

ni.com

Lesson 1: Introduction to LabVIEW

LabVIEW Basics I CBT Exercises

Adding an Express VI that Simulates a Signal


Complete the following steps to find the Express VI you want to use and
then add it to the block diagram.
1. If the Context Help window is not visible, press the <Ctrl-H> keys to
open the Context Help window. You also can press the Show Context
Help Window button, shown at left, to open the Context Help window.
2. Select the Input palette on the Functions palette and move the cursor
over the Express VIs on the Input palette.
Notice that the Context Help window displays information about the
function of each Express VI.
3. From the information provided in the Context Help window, find the
Express VI that can simulate a sine wave signal.
4. Select the Express VI and place it on the block diagram. The Configure
Simulate Signal dialog box appears.
5. Idle the cursor over the various options in the Configure Simulate
Signal dialog box, such as Frequency (Hz), Amplitude, and Samples
per second (Hz). Read the information that appears in the Context
Help window.
6. Configure the Simulate Signal Express VI to generate a sine wave with
a frequency of 10.7 and amplitude of 2.
7. Notice how the signal displayed in the Result Preview window changes
to reflect the configured sine wave.
8. Close the Configure Simulate Signal dialog box by clicking the OK
button.
9. Move the cursor over the Simulate Signal Express VI and read the
information that appears in the Context Help window.
Notice that the Context Help window now displays the configuration of
the Simulate Signal Express VI.
10. Save this VI as Reduce Samples.vi in the C:\Exercises\
LV Basics I directory.

Modifying the Signal


Complete the following steps to use the LabVIEW Help to search for the
Express VI that reduces the number of samples in a signal.
1. Select HelpVI, Function, & How-To Help to open the LabVIEW
Help.
2. Click the Search tab and type sample compression in the Type in
the word(s) to search for text box.
Notice that this word choice reflects what you want this Express VI to
docompress, or reduce, the number of samples in a signal.

National Instruments Corporation

17

LabVIEW Basics I CD-Based Training

LabVIEW Basics I CBT Exercises

Lesson 1: Introduction to LabVIEW

3. To begin the search, press the <Enter> key or click the List Topics
button.
4. Double-click the Sample Compression topic to display the topic that
describes the Sample Compression Express VI.
5. After you read the description of the Express VI, click the Place on the
block diagram button to select the Express VI.
6. Move the cursor to the block diagram.
Notice how LabVIEW attaches the Sample Compression Express VI to
the cursor.
7. Place the Sample Compression Express VI on the block diagram to the
right of the Simulate Signal Express VI.
8. Configure the Sample Compression Express VI to reduce the signal by
a factor of 25 using the mean of these values.
9. Close the Configure Sample Compression dialog box.
10. Using the Wiring tool, wire the Sine output in the Simulate Signal
Express VI to the Signals input in the Sample Compression Express VI.

Customizing the Front Panel


In a previous exercise, you added controls and indicators to the front panel
using the Controls palette. You also can add controls and indicators from
the block diagram. Complete the following steps to create controls and
indicators.
1. Right-click the Mean output in the Sample Compression Express VI
and select CreateNumeric Indicator from the shortcut menu to create
a numeric indicator.
2. Right-click the Mean output of the Sample Compression Express VI
and select Insert Input/Output from the shortcut menu to insert the
Enable input.
3. Right-click the Enable input and select CreateControl from the
shortcut menu to create the Enable switch.
4. Right-click the wire linking the Sine output in the Simulate Signal
Express VI to the Signals input in the Signal Compression Express VI
and select CreateGraph Indicator from the shortcut menu.
Notice that you can create controls and indicators from the block
diagram. When you create controls and indicators using this method,
LabVIEW automatically creates terminals that are labeled and
formatted correctly.
5. Using the Wiring tool, wire the Mean output in the Sample
Compression Express VI to the Sine terminal.
Notice that the Merge Signals function appears.

LabVIEW Basics I CD-Based Training

18

ni.com

Lesson 1: Introduction to LabVIEW

LabVIEW Basics I CBT Exercises

6. Arrange the objects on the block diagram so that they appear similar to
the following figure.
You can right-click any wire and select Clean Up Wire from the shortcut menu to
automatically route an existing wire.

Tip

7. Display the front panel.


Notice that the controls and indicators you added automatically appear
on the front panel with labels that correspond to their function.
8. Save this VI.

Configuring the VI to Run Continuously Until the User Stops It


In the current state, the VI runs once, generates one signal, then stops
executing. To run the VI until a condition is met, you can add a While Loop
to the block diagram. Complete the following steps to add a While Loop.
1. Display the front panel and run the VI.
Notice how the VI runs once and then stops. Also notice how there is no
STOP button.
2. Display the block diagram and select the While Loop on the Functions
Execution Control palette.
3. Move the cursor to the upper left corner of the block diagram. Place the
top left corner of the While Loop here.

National Instruments Corporation

19

LabVIEW Basics I CD-Based Training

LabVIEW Basics I CBT Exercises

Lesson 1: Introduction to LabVIEW

4. Click and drag the cursor diagonally to enclose all the Express VIs and
wires, as shown the following figure.

Notice that the While Loop, shown at left, appears with a STOP button
wired to the condition terminal. This While Loop is configured to stop
when the user clicks the STOP button.
5. Display the front panel and run the VI.
Notice that the VI now runs until you click the STOP button. A While
Loop executes the functions inside the loop until the user presses the
STOP button. Refer to Lesson 3, Loops and Charts for more
information about While Loops.

Controlling the Speed of Execution


To plot the points on the waveform graph more slowly, you can add a time
delay to the block diagram. Complete the following steps to control the
speed at which the VI executes.
1. On the block diagram, select the Time Delay Express VI on the
FunctionsExecution Control palette and place it inside the loop.
2. Type .250 in the Time delay (seconds) text box.
This time delay specifies how fast the loop runs. With a .250 second time
delay, the loop iterates once every quarter of a second.
3. Close the Configure Time Delay dialog box.
4. Save this VI.
5. Display the front panel and run the VI.

LabVIEW Basics I CD-Based Training

20

ni.com

Lesson 1: Introduction to LabVIEW

LabVIEW Basics I CBT Exercises

6. Click the Enable switch and notice the change on the graph.
Notice how if the Enable switch is on, the graph displays the reduced
signal. If the Enable switch is off, the graph does not display the
reduced signal.
7. Click the STOP button to stop the VI.

Using a Table to Display Data


Complete the following steps to display a collection of mean values in a
table on the front panel.
1. On the front panel, select the Express Table indicator on the Controls
Text Indicators palette and place it on the front panel to the right of the
waveform graph.
2. Display the block diagram.
Notice that the Table terminal appears wired to the Build Table
Express VI automatically.
3. If the Build Table Express VI and the Table terminal are not selected
already, click an open space on the block diagram to the left of the Build
Table Express VI and the Table terminal. Drag the cursor diagonally
until the selection rectangle encloses the Build Table Express VI and the
Table terminal, shown at left.
A moving dashed outline called a marquee highlights the Build Table
Express VI, the Table terminal, and the wire joining the two.
4. Drag the objects into the While Loop to the right of the Mean terminal.
Notice that the While Loop automatically resizes to enclose the Build
Table Express VI and the Table terminal.
5. Using the Wiring tool, wire the Mean terminal of the Sample
Compression Express VI to the Signals input of the Build Table
Express VI.

National Instruments Corporation

21

LabVIEW Basics I CD-Based Training

LabVIEW Basics I CBT Exercises

Lesson 1: Introduction to LabVIEW

The block diagram should appear similar to the following figure.

6. Display the front panel and run the VI.


7. Click the Enable switch.
The table displays the mean values of every 25 samples of the sine wave.
Notice if the Enable switch is off, the table does not record the mean
values.
8. Stop the VI.
9. Experiment with properties of the table by using the Table Properties
dialog box. For example, try changing the number of columns to one.
10. Save and close the VI.

End of Exercise 1-3

LabVIEW Basics I CD-Based Training

22

ni.com

Lesson 1: Introduction to LabVIEW

LabVIEW Basics I CBT Exercises

Exercise 1-4: Debug Exercise (Main) VI


Objective:

To practice debugging techniques.


Complete the following steps to load a broken VI and correct the error. Use
single-stepping and execution highlighting to step through the VI.

Front Panel
1. Select FileOpen and navigate to C:\Exercises\LV Basics I to
open the Debug Exercise (Main) VI.
The following front panel appears.

Notice the Run button on the toolbar appears broken, shown at left,
indicating that the VI is broken and cannot run.

Block Diagram
2. Select WindowShow Block Diagram to display the following block
diagram.

The Random Number (0-1) function, located on the Functions


Arithmetic & ComparisonExpress Numeric palette, produces a
random number between 0 and 1.
The Multiply function, located on the FunctionsArithmetic &
ComparisonExpress Numeric palette, multiplies the random number
by 10.0.
The numeric constant, located on the FunctionsArithmetic &
ComparisonExpress Numeric palette, is the number to multiply by
the random number.
The Debug Exercise (Sub) VI, located in the C:\Exercises\
LV Basics I directory, adds 100.0 and calculates the square root of
the value.

National Instruments Corporation

23

LabVIEW Basics I CD-Based Training

LabVIEW Basics I CBT Exercises

Lesson 1: Introduction to LabVIEW

3. Find and fix each error.


a. Click the broken Run button to display the Error list window,
which lists all the errors.
b. Select an error description in the Error list window. The Details
section describes the error and in some cases recommends how to
correct the error.
c. Click the Help button to display a topic in the LabVIEW Help that
describes the error in detail and includes step-by-step instructions
for correcting the error.
d. Click the Show Error button or double-click the error description to
highlight the area on the block diagram that contains the error.
e. Use the Error list window to fix each error.
4. Select FileSave to save the VI.
5. Display the front panel by clicking it or by selecting WindowShow
Front Panel.

Run the VI
6. Click the Run button to run the VI several times.
7. Select WindowShow Block Diagram to display the block diagram.
8. Animate the flow of data through the block diagram.
a. Click the Highlight Execution button, shown at left, on the toolbar
to enable execution highlighting.
b. Click the Step Into button, shown at left, to start single-stepping.
Execution highlighting shows the movement of data on the block
diagram from one node to another using bubbles that move along the
wires. Nodes blink to indicate they are ready to execute.
c. Click the Step Over button, shown at left, after each node to step
through the entire block diagram. Each time you click the Step Over
button, the current node executes and pauses at the next node.
Data appear on the front panel as you step through the VI. The VI
generates a random number and multiplies it by 10.0. The subVI
adds 100.0 and takes the square root of the result.
d. When a blinking border surrounds the entire block diagram, click the
Step Out button, shown at left, to stop single-stepping through the
Debug Exercise (Main) VI.
9. Single-step through the VI and its subVI.
a. Click the Step Into button to start single-stepping.
b. When the Debug Exercise (Sub) VI blinks, click the Step Into
button. Notice the run button on the subVI.

LabVIEW Basics I CD-Based Training

24

ni.com

Lesson 1: Introduction to LabVIEW

LabVIEW Basics I CBT Exercises

c. Display the Debug Exercise (Main) VI block diagram by clicking it.


A green glyph, shown at left, appears on the subVI icon on the
Debug Exercise (Main) VI block diagram, indicating that the subVI
is running.
d. Display the Debug Exercise (Sub) VI block diagram by clicking it.
e. Click the Step Out button twice to finish single-stepping through the
subVI block diagram. The Debug Exercise (Main) VI block diagram
is active.
f. Click the Step Out button to stop single-stepping.
10. Use a probe to check intermediate values on a wire as a VI runs.
a. Use the Probe tool, shown at left, to click any wire. A window
similar to the following window appears.

LabVIEW numbers the Probe window automatically and displays


the same number in a glyph on the wire you clicked.
b. Single-step through the VI again. The Probe window displays data
passed along the wire.
11. Place breakpoints on the block diagram to pause execution at that
location.
a. Use the Breakpoint tool, shown at left, to click nodes or wires. Place
a breakpoint on the block diagram to pause execution after all nodes
on the block diagram execute.
b. Click the Run button to run the VI. When you reach a breakpoint
during execution, the VI pauses and the Pause button on the toolbar
appears red.
c. Click the Continue button, shown at left, to continue running to the
next breakpoint or until the VI finishes running.
d. Use the Breakpoint tool to click the breakpoints you set and
remove them.
12. Click the Highlight Execution button to disable execution highlighting.
13. Select FileClose to close the VI and all open windows.

End of Exercise 1-4

National Instruments Corporation

25

LabVIEW Basics I CD-Based Training

You might also like