EE

456
Lab #2
Sampling and Basic Signal Processing
General
Signal information is transferred to the computer from the analog

to

digital converter at a
certain rate called the sampling rate. Words of digital data are received by the computer
at the sam
pling rate. Each sample corresponds to a voltage value. If all of the analog
information is to be transferred to the computer (in digital form), there must be a minimum
sampling rate based upon the spectrum of the analog signal. The minimum sampling rat
e
is called the Nyquist rate. This rate is equal to twice the maximum frequency component
of the analog signal. (This maximum frequency component is called the Nyquist
frequency; the Nyquist rate is equal to twice the Nyquist frequency.) If sampling is
performed at less than the Nyquist rate, information is lost; when the sampled data from
the analog

to

digital converter is reconstructed (using a digital

to analog converter) the
signal will not be the same. This effect is called aliasing.
The effects o
f sampling and aliasing and reconstruction will be explored in this lab
exercise
This lab exercise can only be performed on a PC with both MATLAB[TM] and a digital
signal processing board. A computer such as this is so equipped in the (Junior/Senior)
el
ectronics lab labeled “Digital Signal Processing Station.”
Sampling
Enter into MATLAB and execute the following two special commands:
>> fir(1)
>> ssrat(10000)
(These commands were written as a MATLAB m

file especially for the digital signal
proces
sing board and are not documented in the MATLAB manual. For more
information about these commands, enter HELP followed by the name of the function.
The
ssrat()
function does
not
work with the EZ

KIT Lite boards
—
they have a fixed
sampling rate of 44,100
samples/second.) Set the input signal generator to a sinewave
with frequency 1 kHz and amplitude 2 V (peak). By observing the output waveform,
determine the sampling rate. (Increase the oscilloscope sweep rate until only a single
sinewave appears acros
s the oscilloscope screen.)
Route the output (D/A) from the digital signal processing board to a spectrum analyzer or
a PC with LabWindows. (There should be cables running over the top of the lab.) Using
the Oscilloscope Menu from LabWindows [TM], cap
ture and printout the spectrum of the
output signal. Observe the aliasing that occurs.
Increase the frequency of the input sinewave to 2 kHz. Observe and sketch the output
waveform, and capture and printout the output signal spectrum. Repeat for 4 kHz,
5 kHz,
6 kHz, 8 kHz and 9 kHz. (You should observe the aliasing effect from both the
oscilloscope waveform and the spectrum.) Repeat for a 1 kHz, 2 V (peak) squarewave.
Explain the resultant spectrum.
Signal Acquisition and Reconstruction
Set the sig
nal generator back to 1 kHz sinewave. Enter back into MATLAB and enter the
following (special) command:
>> x = ad(100)
(This command acquires 100 samples from the analog

to

digital converter on the digital
signal processing board, and places these sampl
es into an array
x
.) Plot this array using
the command
>> plot(x)
(You should see a number of sinewaves displayed on the screen.) Printout the screen
plot using the Print Scrn key.
Now “rectify” the signal
x
using the command
>> x = abs(x)
Plot (a
nd print

out) this modified signal. Finally ``play back'' or reconstruct the rectified
signal (out to the digital

to

analog converter on the digital signal processing board) using
the command
>> da(x)
Observe and sketch the output waveform. Exit MATLAB
and capture and display the
output waveform using the oscilloscope menu in LabWindows (or just draw what you see
on an oscilloscope). Does this waveform (exactly) represent the MATLAB plot? What is
happening during the reconstruction to alter the MATLAB
waveform? (Try several more
acquisitions, rectifications and reconstructions.)
Waveform Synthesis
Using the
da
() function, synthesize the periodic waveform pictured in Figure 1. The
frequency of the waveform is to be 1000 Hz. Each period of the wav
eform is to have fifty
samples. The amplitude of this waveform is half of the maximum output voltage of the
digital

to

analog signal (half of 5 V or 2.5 V). The maximum (positive) output voltage of
the digital

to

analog signal corresponds to the number 2
047.
To synthesize this waveform, first construct MATLAB arrays for the first half and the
second half of the waveform, combine the two arrays into one array, use the
da()
function, and then adjust the sampling rate (or rather the reconstruction or digita
l

to

analog conversion rate) appropriately. (In your lab report list those MATLAB commands
that were used to synthesize this waveform.) Capture the output signal using the
Oscilloscope window in LabWindows and printout the display (or draw what you see
on
the oscilloscope).
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
0
0.5
1
1.5
2
2.5
time (ms)
voltage (volts)
Waveform
Figure 1.
Waveform to be generated.
Questions
1.
We have a signal
x(t)
which is a sum of two sinewaves:
.
cos
cos
2
)
(
t
t
t
x
b
a
Let
x
s
(t)
be the sampled version of
x(t)
, and let the sampling frequency be
s
.
Sketch the spectrum of
x
s
(t)
in the following cases.
a.
a
= 0.2
s
,
b
= 0.4
s
.
b.
a
= 0.4
s
,
b
= 0.6
s
.
2.
We would like to get MATLAB to act as a ``Schmitt Trigger'' converting a sinewave
into a squarewave. Suppose that a sinewave is contained in th
e array
x
. What
sequence of MATLAB commands would convert this sinewave into a squarewave?
Enter the password to open this PDF file:
File name:

File size:

Title:

Author:

Subject:

Keywords:

Creation Date:

Modification Date:

Creator:

PDF Producer:

PDF Version:

Page Count:

Preparing document for printing…
0%
Comments 0
Log in to post a comment