Documente Academic
Documente Profesional
Documente Cultură
Approximate Time
You can complete this exercise in approximately 30 minutes.
Background
You can choose one of many LabVIEW template VIs to use as a starting point when building VIs.
However, sometimes you need to build a VI for which a template is not available. This tutorial
teaches you how to build and customize a VI without using a template.
Overview
In the following exercises, you will open a blank VI and add structures and Express VIs to the
block diagram to build a new VI. You will 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.
1
Completed Exercise
2
Step-by-Step Instructions
1. Opening a Blank VI
If no template is available for the VI you want to build, you can start with a blank VI and add
Express VIs to accomplish a specific task. Complete the following steps to open a blank VI:
a. In the Getting Started window, click the Blank VI link in the New section or press the
<Ctrl-N> keys to open a blank VI. A blank front panel and block diagram appear.
You also can open a blank VI by selecting File » New VI or by selecting File » New
and selecting Blank VI from the Create New list.
3
2. Adding an Express VI that Simulates a Signal
Complete the following steps to find the Express VI you will use and add it to the block diagram:
a. Click the Show Context Help Window button on the front panel or
block diagram toolbar to display the Context Help window. You also
can select Help » Show Context Help from either window to display
the Context Help window.
You also can press the <Ctrl-H> keys to display the Context Help window.
c. Use the information that appears in the Context Help window to find the Express VI
that can simulate a sine wave signal. Keep the Context Help window open.
4
f. Configure the Simulate Signal Express
VI to generate a sine wave with a
frequency of 10.7 and amplitude of 2.
The signal in the Result Preview
window changes to reflect the
configured sine wave.
g. Click the OK button to save the current configuration and close the Configure
Simulate Signal dialog box.
h. Move the cursor over the Simulate Signal Express VI and read the information that
appears in the Context Help window. The Context Help window displays
configuration information about the Simulate Signal Express VI.
5
3. Searching the Help and Modifying a 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:
You also can access the LabVIEW Help by right-clicking a VI or function on the block
diagram or on a pinned palette and selecting Help from the shortcut menu or by
selecting Help » Search the LabVIEW Help.
6
d. After you read the
description of the
Express VI, click the
Place on the block
diagram button to
place the Express VI
on the cursor.
7
4. Customizing a User Interface from the Block Diagram
In the previous exercises, you added controls and indicators to the front panel using the
Controls palette. You also can create controls and indicators from the block diagram. Complete
the following steps to create controls and indicators from the block diagram:
In a previous exercise you learned to add inputs and outputs by expanding the
Express VI using the down arrows. Using the shortcut menu is a different way of
displaying and selecting the inputs and outputs of an Express VI.
c. Right-click the Enable input and select Create » Control from the
shortcut menu to create a switch. A Boolean control appears on the
block diagram.
Control terminals have a thicker border than indicator terminals. Also, an arrow
appears on the right of the terminal if the terminal is a control, and an arrow
appears on the left of the terminal if the terminal is an indicator.
8
d. Right-click the wire that connects
the Sine output of the Simulate
Signal Express VI to the Signals input
of the Sample Compression Express
VI and select Create » Graph
Indicator from the shortcut menu.
g. Display the front panel. The controls and indicators you added appear on the front
panel with labels that correspond to the inputs and outputs from which you created.
You might need to scroll or resize the front panel to see all controls and indicators.
9
5. Configuring a VI to Run Continuously until the User Stops It
In the current state, the VI runs once, generates one signal, then stops running. To run the VI
until a condition occurs, you can use a While Loop. Complete the following steps to add a While
Loop to the block diagram:
a. Display the front panel and run the VI. The VI runs once and then stops.
b. Display the block diagram.
LabVIEW searches as you type and displays any matches in the search results text
box. LabVIEW displays a folder glyph to the left of subpalettes in the search results
and displays a light blue glyph to the left of Express VIs in the search results.
g. Move the cursor to the upper left corner of the block diagram. Click to place the top
left corner of the While Loop. Drag the cursor diagonally to enclose all the Express
VIs and wires.
10
h. Click to create the While
Loop around the Express
VIs and wires. The While
Loop appears with a
STOP button wired to
the conditional
terminal. This While
Loop is configured to
stop when the user
clicks the STOP button.
If all of the block diagram objects are not enclosed in the while loop, you can select
the objects and move them into the while loop.
i. Display the front panel and run the VI. The VI now runs until you click the STOP
button. A While Loop executes the VIs and functions inside the loop until the user
clicks the STOP button.
j. Click the STOP button and save the VI.
a. On the front panel, move the cursor over the Mean indicator until the
Positioning tool appears.
b. Click the Mean indicator to select it and press the <Delete> key.
c. Display the block diagram.
d. A wire appears as a dashed black line with a red X in the middle. The
dashed black line is a broken wire. The Run button appears broken to
indicate the VI cannot run.
11
e. Click the broken Run button to
display the Error list window.
The Error list window lists all
errors in the VI and provides
details about each error.
f. In the errors and warnings list,
select the Wire: has loose ends
error and click the Help button
to display more information.
You also can move the Wiring tool over a broken wire to display a tip strip that
describes why the wire is broken. This information also appears in the Context Help
window when you move the Wiring tool over a broken wire.
g. In the errors and warnings list, double-click the Wire: has loose ends error to
highlight the broken wire.
h. Press the <Ctrl-B> keys to delete the broken wire. Pressing the <CTRL-B> keys
deletes all broken wires on the block diagram.
You can press the <Delete> key to delete only the selected wire.
i. Select View » Error List to display the Error list window. No errors appear in the
errors and warnings field.
You also can press the <Ctrl-L> keys to display the Error list window.
j. Click the Close button to close the Error list window. The Run
button no longer appears broken.
12
7. 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 runs:
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.
13
8. Using a Table to Display Data
Complete the following steps to display a collection of mean values in front panel table:
c. If the Build Table Express VI and the Table terminal are not selected already, click an
open area on the block diagram to the left of the Build Table Express VI.
d. Drag the cursor diagonally until the selection rectangle
encloses the Build Table Express VI and the Table terminal. A
moving dashed outline highlights the Build Table Express VI,
the Table terminal, and the wire joining the two.
e. Drag the objects into the While Loop to the right of the
Sample Compression Express VI.
When you place an object in a While Loop near the border, the loop resizes to add
space for that object.
f. Wire the Mean output of the Sample Compression Express VI to the Signals input of
the Build Table Express VI.
g. Display the front panel and run the VI.
h. If the Enable switch is on, the table displays the mean values of every 25 samples of
the sine wave. If the Enable switch is off, the table does not record the mean values.
i. Stop the VI.
j. Experiment with properties of the table by using the Table Properties dialog box.
The Table Properties dialog box can be accessed if you right-click the table and
select Properties from the drop-down menu.