<< Chapter < Page | Chapter >> Page > |
In the following exercise, you will build a VI that generates a signal and displays that signal in a graph. LabVIEW providestemplates 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.
LabVIEW
dialog box that appears, shown in
, click the
New
button to
display the
New
dialog box.
VI from Template>>Tutorial (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
shows the
New
dialog box and the
Generate and Display
template
VI.
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.Generate and Display
VI.
Window>>Show Front Panel
.Generate and Display
VI.
Window>>Show Block Diagram
.Run
button,
shown at left.Notice that a sine wave appears on the graph.Stop
button, shown at left, on
the front panel.Controls on the front panel simulate the input devices on a physical instrument and supply data to the block diagram ofthe VI. Many physical instruments have knobs you can turn to change an input value. Complete the following steps to add aknob control to the front panel.
Edit>>Undo
or pressing the
Ctrl-Z
keys.Controls
palette is not visible on the
front panel, select
Window>>Show Controls
Palette
to display it.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 thepalette. When you idle the cursor over any icon on any
palette, the full name of the subpalette, control, orindicator appears.Numeric Controls
icon to access the
Numeric Controls
palette.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.File>>Save As
and save this VI as
Acquiring a Signal.vi
in the
C:\Exercises\LabVIEW Basics I
directory.
C:\Exercises\LabVIEW Basics I
directory.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.
Window>>Show
Block Diagram
or by clicking the block diagram.Notice the
Simulate
Signal
Express VI, shown in
. An
Express VI is a component of the block diagram that you canconfigure to perform common measurement tasks. The
Simulate Signal
Express VI simulates a signal
based on the configuration that you specify.Simulate Signal
Express VI and
select
Properties
from the shortcut menu to
display the
Configure Simulate Signal
dialog
box.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
.
OK
button to apply the current
configuration and close the
Configure Simulate
Signal
dialog box.Simulate Signal
Express VI.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 theblock diagram.In
, 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 dialogbox, you can configure the inputs in either location.To use the knob control to change the amplitude of the signal,
you must connect the two objects on the blockdiagram. Complete the following steps to wire the knob to the
Amplitude
input on the
Simulate
Signal
Express VI.
Knob
terminal, shown
at left, until the
Positioning
tool appears.Notice
how the cursor becomes an arrow, or the
Positioning
tool, shown in
. Use the
Positioning
tool to
select, position, and resize objects.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 in
.The terminals are representations of front panel controls
and indicators. Terminals are entry and exit ports thatexchange information between the front panel and block
diagram.Knob
terminal by clicking a blank
space on the block diagram.Knob
terminal, shown in
.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.
Wiring
tool appears, click the arrow
and then click the
Amplitude
input of the
Simulate Signal
Express VI, shown in
, to wire the two objects together.Notice that a wire appears and connects the twoobjects. Data flows along this wire from the terminal to the
Express VI.File>>Save
to save this VI.Running a VI executes your solution. Complete the following
steps to run the
Acquiring a Signal
VI.
Window>>Show
Front Panel
or by clicking the front panel.
Ctrl-E
keys to switch from the
front panel to the block diagram or from the block diagramto the front panel.Run
button.Operating
tool, shown at left. Use the
Operating
tool to change the value of a control
or select the text within a control.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 graphautoscales 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 VIruns.Stop
button, shown at left, to stop
the VI.Abort Execution
button looks like a stop
button, the
Abort Execution
button does not
always properly close the VI. National Instruments recommendsstopping your VIs using the
Stop
button on the
front panel. Use the
Abort Execution
button only
when errors prevent you from terminating the application usingthe
Stop
button.Complete the following steps to add scaling to the signal and display the results in the graph on the front panel.
Positioning
tool
to double-click the wire that connects the
Simulate
Signal
Express VI to the
Waveform Graph
terminal shown in
.Delete
key to delete this wire.Functions
palette is not visible on the
block diagram, select
Window>>Show Functions
Palette
to display it.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.Slope (m)
text box.The
Configure Scaling and Mapping
dialog box
should appear similar to
.
OK
button to apply the current
configuration and close the
Configure Scaling and
Mapping
dialog box.Sawtooth
output of the
Simulate Signal
Express VI.Signals
input of the
Scaling and Mapping
Express VI, shown in
, to wire the two objects together.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 directionthat the data flows along these wires. The block diagram
should appear similar to
.
View As
Icon
from the shortcut menu to remove the
checkmark.File>>Save
to save this VI.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.
Sawtooth
output of the
Simulate Signal
Express VI.Wiring
tool, wire the
Sawtooth
output to the
Waveform
Graph
terminal.The
Merge Signals
function, shown in
, appears where the two wires connect. This
function takes the two separate signals and combines them sothat both can be displayed on the same graph. The block
diagram should appear similar to
.
File>>Save
to save this VI. You also can
press the
Ctrl-S
keys to save a VI.Stop
button.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 tocustomize the appearance of a control on the front panel.
Properties
from
the shortcut menu to display the
Knob
Properties
dialog box.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
.
Scale
tab and, in the
Scale Range
section, change the
maximum value to
.Notice how the knob on the front panel instantly updates to reflect
these changes.OK
button to apply the current configuration and close the
Knob Properties
dialog box.Edit>>Undo
or pressing the
Ctrl-Z
keys.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.Cancel
button to avoid applying the
changes you made while experimenting. If you want to keepthe changes you made, click the
OK
button.The
waveform graph
indicator displays the twosignals. To indicate which plot is the scaled signal and which
is the simulated signal, you customize the plots. Complete thefollowing steps to customize the appearance of an indicator on
the front panel.
plot legend
on the
waveform graph
.Notice that while there are two plots on the graph, the
plot legend
displays only one plot.plot
legend
until the second plot name appears.
waveform graph
and select
Properties
from the shortcut menu to display
the
Graph Properties
dialog box.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.Sawtooth (Scaled)
from the pull-down
menu.Don't use waveform names for
plot names
checkbox.Name
text box, delete the current label
and change the name of this plot to
Scaled
Sawtooth
.OK
button to apply the current
configuration and close the
Graph Properties
dialog box.Notice how the plot color on the front panel changes.Graph Properties
dialog box. For example, try
disabling the autoscale feature located on the
Scales
tab.Cancel
button to avoid applying the
changes you made while experimenting. If you want to keepthe changes you made, click the
OK
button.Notification Switch
Would you like to follow the 'Pdf generation problem modules' conversation and receive update notifications?