Vous êtes sur la page 1sur 9

Signals, Spectra and Signal Processing

Name:__________________________________ Rating:__________________________
Date Performed: _________________________ Date Submitted: __________________

Signals, Spectra and Signal Processing

GETTING FAMILIAR WITH LABVIEW (PART II)


Activity No. 2

I. INTENDED LEARNING OUTCOMES

1. Use the debugging tools of LabVIEW.


2. Build a VI that demonstrates the generation of sine wave and its amplitude-scaled version using
Express VIs and regular VIs and compare the advantages and disadvantages of each.
3. Use the graphing tool of LabVIEW to display graphs and charts.

II. BACKGROUND INFORMATION

In the first activity, the basic environment of LabVIEW has been explored. In this activity, other features
of LabVIEW such as the debugging tools and Express VIs are used.

If a VI does not run, it is either broken or non-executable. In the first activity, recall that there is an error
in the program when the Run arrow is broken. Warnings do not prevent you from running a VI as they are
designed to help you avoid potential problems in VIs. Errors, however, can break a VI. You must resolve
any errors before you can run the VI. Some common causes of broken VIs are:
the block diagram contains a broken wire because of a mismatch of data types or a loose
unconnected end;
a required block diagram terminal is unwired; or
a subVI is broken or you edited its connector pane after you placed its icon on the block diagram of
VI.
In some cases, a VI is not broken but you get an unexpected data. You can use various techniques to
identify and correct problems with VI or the block diagram data flow. You can wire the error-in and error-out
parameters at the bottom of most built-in VIs and functions. These parameters detect errors encountered in
each node on the block diagram and indicate if and where an error occurred.

Express VIs denote higher-level VIs that have been configured to incorporate lower-level VIs or
functions. These VIs are displayed as expandable nodes with a blue background. Placing an Express VI in
a BD brings up a configuration dialog window allowing adjustments of its parameters. As a result, Express
VIs demand less wiring. A configuration window can be brought up by double-clicking on its Express VI.

Activity No. 2 Getting Familiar with LabVIEW (Part II) Page 1


Signals, Spectra and Signal Processing

III. LEARNING ACTIVITIES

Activity 2.1 Debugging Tools


1. Obtain the folder act02-01_error. This folder contains the VIs for this part of the activity. Inside this
folder, open act02-01_main.vi by double-clicking on the file. The FP appears. Notice that this VI is non-
executable because the Run button is broken.

2. Press Ctrl+E to make the BD of the VI appear. Notice that there is a subVI called act02-01_sub.vi.
Double-click the subVI and the FP of this subVI appears.

Question: What are the terminal icons and nodes that can be seen in act02-01_main.vi? Discuss the
function of each.
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________

Question: What are the terminal icons and nodes that can be seen in act02-01_sub.vi? Discuss the
function of each.
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________

Question: Based on the BDs of the VIs, describe the functionality of this program.
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________

Activity No. 2 Getting Familiar with LabVIEW (Part II) Page 2


Signals, Spectra and Signal Processing

3. Press the broken Run button in the act02-01_main.vi FP or BD. The Error List window appears.

Question: List all the errors as seen on the Error List window. Discuss the details of each.
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________

4. Perform the necessary steps to correct the errors and make the VI executable.

Question: What should be done to correct the errors? Detail your step-by-step solution in
correcting the errors of the VI.
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________

5. When the VI is executable, click the Highlight Execution button in the toolbar of BD ( ) to start
animating the flow of data in the VI. The Start Single Stepping button ( ) causes the execution of the
VI step-by-step. Continue pressing this icon until the data enters the subVI, in which the same button in that
subVIs window can be pressed. The execution is finished when a blinking border covers the entire BD, in
which the Finish the button ( ) must be pressed to end the execution of VI.

Note: When the data enters a node, it is automatically reflected in the FP. To make the VI run in its normal
speed, click on Do not Highlight Execution button after using this tool.

Question: How can the Highlight Execution feature help in debugging VIs?
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________

Activity No. 2 Getting Familiar with LabVIEW (Part II) Page 3


Signals, Spectra and Signal Processing

6. Click on View > Tools Palette and the Tools Palette window appears. Here, various tools in debugging
and interpreting the BD can be seen. Click on the Probe Data icon ( ) to place probes on wires. The
Probe Watch Window appears. When the VI is run, data that passes through this probe is displayed in this
window. You can add text in the BD by using the Edit text tool ( ) to add comments and describe the
functionalities of certain parts of the BD. The Breakpoint tool ( ) can be placed on wires to pause the
execution of VI when it encounters the breakpoint. Click the Continue button to resume the operation of VI.
Click the Breakpoint icon again to remove the placed breakpoints and to stop placing breakpoints.

Question: What is the difference between the Probe Data and the Breakpoint tools of LabVIEW?
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________

Activity 2.2 Building a System VI with Express VIs


1. Create the VI act02-02.vi. Build the following BD and FP.

In the BD, insert Simulate Signal Express VI (Functions Palette > Express > Signal Analysis >
Simulate Signal). The Configure Simulate Signal window appears.
In this window, set the Frequency (Hz) to 200, Amplitude to 100, Samples per second (Hz) to
8000, uncheck the Automatic checkbox under the Number of Samples category and set it to 128.
This generates a signal whose amplitude is between 100 to -100, frequency of 200 Hz. The timing

Activity No. 2 Getting Familiar with LabVIEW (Part II) Page 4


Signals, Spectra and Signal Processing

information enables one to see clearly the signal by setting the sampling rate (Samples per
second) and the number of samples correctly. Click OK.
Place a Scaling and Mapping Express VI (Functions Palette > Express > Arithmetic &
Comparison > Scale and Map). The Configure Scaling and Mapping window appears.
In this configuration window, choose Linear and set the Slope (m) to 5. This will scale the
amplitude (or amplify) the input 5 times. Click OK.
Wire the Sine output of the Simulate Signal Express VI to the Signal input of the Scaling and
Mapping Express VI. Note: The wire used for connecting the Express VI together is for a dynamic
data type, that is, it carries dynamic data or data that change over time.
Switch to FP. Insert a Waveform Graph (Controls Palette > Express > Graph Indicator >
Waveform Graph). Right-click on the Waveform Graph, choose X Scale and uncheck the Loose
Fit option and Ignore Time Stamp.
Right-click on the Waveform Graph then choose Properties. On the Display Format tab, under
the Default Editing Mode, set the Time (X-Axis) axis data Type to Floating point. Then choose
Digits of Precision as the Precision Type. Set the Digits to 2.
Switch back to BD. The terminal icon for the Waveform Graph should have appeared. Connect
the outputs of the Scaling and Mapping and Simulate Signal Express VIs to the Waveform
Graph. On the process, the Merge Signals node appears automatically.
Enclose the diagram with a While-Loop structure to make the program run continuously.

2. Save and run the VI.

Question: Describe the functionality of the VI.


_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________

Question: If the Loose Fit option of the X-Scale of the Waveform Graph is enabled, what happens to
the plot?
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________

Activity No. 2 Getting Familiar with LabVIEW (Part II) Page 5


Signals, Spectra and Signal Processing

Question: The reading in the Waveform Graph runs too fast. What can be done about this?
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________

Question: How does the Sampling Frequency and the Number of Samples parameters of the
Express VI affect the VI? Adjust the values and observe.
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________

Activity 2.3 Building a System with Regular VIs


1. Create a blank VI named act02-03.vi. Build the BD and FP as shown.

Note: To aid in configuring this VI, open the Context Help for this VI. Click Help and select Show Context
Help (or press Ctrl+H). The Context Help window appears. The terminals for selected VIs will be shown

Activity No. 2 Getting Familiar with LabVIEW (Part II) Page 6


Signals, Spectra and Signal Processing

here. Click on the Basic Function Generator VI to show context help for that VI. A more detailed help is
provided when the Detailed Help link at the bottom is clicked.

Insert a Basic Function Generator VI (Functions Palette > Programming > Waveform >
Analog Waveform > Waveform Generation > Basic FuncGen). The parameters of this function
generator will be configured using constants and controls.
Right-click on the Signal Type terminal and choose Create > Constant. An Enum (enumerated)
type constant appears, the default being Sine Wave. Note: An Enum data type is one in which a
string value is associated with a numeric value, from zero to n 1, n being the number of
choices.The Enum constant for the Signal Type input includes Sine Wave (value is 0, the default
value), Triangle Wave (value is 1), Square Wave (value is 2) and Sawtooth Wave (value is 3).
Right-click on the Frequency terminal and create a constant whose value is 200 (the default unit of
this terminal is hertz). Right-click on the Amplitude terminal and create a constant whose value is
100. Right-click on the Sampling Info terminal and create a constant in this terminal. There are
two constants to be defined. Put 8000 in the Sampling Rate (Fs) and 128 in the Number of
Samples (#s). Note: These are the values we have set in the previous activity.
Insert a Multiply function. Wire the Signal Out of the Basic Function Generator VI to one of the
inputs of the Multiply function, while on the other one, create a constant with a value of 5.
Insert a Build Array (Functions Palette > Programming > Array > Build Array) node. Drag
down another element of the node so that two arrays can be appended. Wire the output of the
Basic Function Generator VI on the first input terminal and the output of the Multiply node on the
second input terminal.
Switch to FP. Insert a Waveform Graph. Right-click on the graph and disable the Loose Fit option
in the X Scale and the Autoscale Y in the Y Scale options of the graph. Change the limits of the y-
axis of the graph by clicking on the maximum and minimum values and changing it to 600 and -600
respectively.
Right-click on the Waveform Graph then choose Properties. On the Display Format tab, under
the Default Editing Mode, set the Time (X-Axis) axis data Type to Floating point. Then choose
Digits of Precision as the Precision Type. Set the Digits to 2.
Switch back to BD. Enclose the entire VI inside a While-Loop structure. Insert a Wait (ms)
(Functions Palette > Programming > Timing > Wait (ms)). Right-click on the milliseconds to
wait terminal of the Wait (ms) node and enter 200. This will delay the execution of the While-Loop
by 200 ms per iteration.

Activity No. 2 Getting Familiar with LabVIEW (Part II) Page 7


Signals, Spectra and Signal Processing

2. Save and run the VI.

Question: Describe the functionality of the VI. Compare it with the VI in the previous activity.
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________

Question: Which one (act02-02.vi or act02-03.vi) is easier to build? Why?


_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________

Question: What does the Build Array function do?


_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________

IV. CONCLUSIONS
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________

Activity No. 2 Getting Familiar with LabVIEW (Part II) Page 8


Signals, Spectra and Signal Processing

V. MACHINE PROBLEM

1. Modify act02-02.vi to make it interactive, that is, the frequency of the input signal, and the gain of the
amplifier can be changed by the user. Refer to the FP below as an example. Design a more appealing and
functional FP. Name the VI as macpro02-01.vi.

2. Modify act02-03.vi to make it interactive. The frequency, gain and the signal type of the input signal
must be user-defined. Refer to the FP below as an example. Design a more appealing and functional FP.
Name the VI for this case study as macpro02-02.vi.

VI. REFERENCE
Kehtarnavaz, N. & Kim, N. (2005). Digital Signal Processing System-Level Design Using LabVIEW. Oxford,
United Kingdom: Elsevier, Inc.

Activity No. 2 Getting Familiar with LabVIEW (Part II) Page 9

Vous aimerez peut-être aussi