Question Signal Processing First
Lab 03: AM and FM Sinusoidal Signals
T
Pre-Lab and Warm-Up: You should read at least the Pre-Lab and Warm-up sections of this lab assignment
and go over all exercises in the Pre-Lab section before going to your assigned lab session.
Verification: The Warm-up section of each lab must be completed during your assigned Lab time and
the steps marked Instructor Verification must also be signed off during the lab time. One of the laboratory
instructors must verify the appropriate steps by signing on the Instructor Verification line. When you have
completed a step that requires verification, simply demonstrate the step to the TA or instructor. Turn in the
completed verification sheet to your TA when you leave the lab.
Lab Report: It is only necessary to turn in a report on Section 4 with graphs and explanations. You are
asked to label the axes of your plots and include a title for every plot. In order to keep track of plots, include
your plot inlined within your report. If you are unsure about what is expected, ask the TA who will grade
your report.
1 Introduction
The objective of this lab is to introduce more complicated signals that are related to the basic sinusoid.
These signals, which implement frequency modulation (FM) and amplitude modulation (AM), are widely
used in communication systems such as radio and television, but they also can be used to create interesting
sounds that mimic musical instruments. There are a number of demonstrations on the CD-ROM that provide
examples of these signals for many different conditions.
2 Pre-Lab
We have spent a lot of time learning about the properties of sinusoidal waveforms of the form:
x(t) = A cos(2π fot + 6) = Re { Aejøej 2π fot}
(1)
In this lab, we will extend our treatment of sinusoidal waveforms to more complicated signals composed of
sums of sinusoidal signals, or sinusoids with changing frequency.
2.1 Amplitude Modulation
If we add several sinusoids, each with a different frequency (fk) we can express the result as:
N
N
xr(t) = Σ Ak cos (27 fxt + ox) = 3 {[(Anej øk) c2m fit }
j2π
k=1
k=1
McClellan, Schafer, and Yoder, Signal Processing First, ISBN 0-13-065562-7.
Prentice Hall, Upper Saddle River, NJ 07458. ©2003 Pearson Education, Inc.
(2)
where Arejk is the complex amplitude of the kth complex exponential term. The choice of f/ will deter-
mine the nature of the signal for amplitude modulation or beat signals we pick two or three frequencies
very close together. See Chapter 3 for a more detailed discussion of beat signals.
CD-ROM
Chap3
Demos
FM Syn-
thesis 2.2 Frequency Modulated Signals
We will also look at signals in which the frequency varies as a function of time. In the constant-frequency
sinusoid (1) the argument of the cosine is also the exponent of the complex exponential, so the angle of this
signal is the exponent (2π fot +). This angle function changes linearly versus time, and its time derivative
is 2π fo which equals the constant frequency of the cosine in rad/sec.
A generalization is available if we adopt the following notation for the class of signals represented by a
cosine function with a time-varying angle:
x(t) = A cos(v(t)) = {Aej(t)}
The time derivative of the angle from (3) gives a frequency in rad/sec
wi(t) = (t) (rad/sec)
d
dt
but we prefer units of hertz, so we divide by 2π to define the instantaneous frequency:
1 d
fi(t) = 2/(t) (Hz)
2π dt
2.4 MATLAB Synthesis of Chirp Signals
The following MATLAB code will synthesize a chirp:
= 11025;
2.3 Chirp, or Linearly Swept Frequency
A chirp signal is a sinusoid whose frequency changes linearly from a starting value to an ending one. The
formula for such a signal can be defined by creating a complex exponential signal with quadratic angle by
defining (t) in (3) as
fsamp
dt
dur
= 1.8;
tt = 0 : dt: dur;
psi
XX = real ( 7.7*exp(j*psi) );
soundsc (xx, fsamp);
T
y(t) = 2ñµt² + 2π fot + þ
The derivative of ½(t) yields an instantaneous frequency (4) that changes linearly versus time.
fi(t) = 2ut + fo
-
The slope of fi(t) is equal to 2µ and its intercept is equal to fo. If the signal starts at time t
0 secs., then
fo is also the starting frequency. The frequency variation produced by such a time-varying angle is called
frequency modulation. This kind of signal is an example of an frequency modulated (FM) signal. More
generally, we often consider them to be part of a larger class called angle modulation signals. Finally, since
the linear variation of the frequency can produce an audible sound similar to a siren or a chirp, the linear-FM
signals are also called "chirps."
=
=
1/fsamp;
2*pi* (100 + 200*tt + 500*tt.*tt);
(3)
(4)
McClellan, Schafer, and Yoder, Signal Processing First, ISBN 0-13-065562-7.
Prentice Hall, Upper Saddle River, NJ 07458. ©2003 Pearson Education, Inc.
(a) Determine the total duration of the synthesized signal in seconds, and also the length of the tt vector
(number of samples).
2
CD-ROM
FM Syn-
thesis
CD-ROM
Spectrograms
Sounds:
Wide-
band
FM (b) In MATLAB, signals can only be synthesized by evaluating the signal's defining formula at discrete
instants of time. These are called samples of the signal. For the chirp we do the following:
x(tn) = А cos(2πµt² + 2π fotn + 0)
where tn nT, represents discrete time instants. In the MATLAB code above, what is the value for
tn? What are the values of A, µ, fo, and o?
=
(c) Determine the range of frequencies (in hertz) that will be synthesized by the MATLAB script above.
Make a sketch by hand of the instantaneous frequency versus time. What are the minimum and
maximum frequencies that will be heard?
(d) Listen to the signal to determine whether the signal's frequency content is increasing or decreasing
(use soundsc()). Notice that soundsc () needs to know the sampling rate at which the signal
samples were created. For more information do help sound and help sound ().
3 Warm-up
The instructor verification sheet may be found at the end of this lab. The "Beat Control GUI" is part of the
SP First toolbox.
3.1 Beat Control GUI
To assist you in your experiments with beat notes and AM signals, the tool called beatcon has been
created. This user interface controller will exhibit the basic signal shapes for beat signals and play the
signals. A small control panel will appear on the screen with buttons and sliders that vary the different
parameters for the beat signals. It can also call a user-written function called beat.m. Experiment with the
beat con control panel and use it to produce a beat signal with two frequency components at 850 Hz and
870 Hz. Demonstrate the plot and sound to your TA.
Instructor Verification (separate page)
3.2 Function for a Chirp
Use the code provided in the warm-up as a starting point in order to write a MATLAB function that will
synthesize a "chirp" signal according to the following comments:
function
MYCHIRP
응
응 usage:
응
응
f1 =
£2 =
dur =
T
응
응 fsamp
%
응
=
XX =
tt =
[xx,tt] =
mychirp f1, f2, dur, fsamp)
generate a linear-FM chirp signal
XX = mychirp f1, f2, dur, fsamp)
starting frequency
ending frequency
total time duration
sampling frequency (OPTIONAL: default is 11025)
(vector of) samples of the chirp signal
vector of time instants for t=0 to t=dur
McClellan, Schafer, and Yoder, Signal Processing First, ISBN 0-13-065562-7.
Prentice Hall, Upper Saddle River, NJ 07458. ©2003 Pearson Education, Inc.
3
CD-ROM
beatcon.m if( nargin < 4 )
fsamp = 11025;
T
-- Allow optional input argument
end
As a test case, generate a chirp sound whose frequency starts at 2500 Hz and ends at 500 Hz; its duration
should be 1.5 sec. Listen to the chirp using the soundsc function. Include a listing of the mychirp.m
function that you wrote.
Instructor Verification (separate page)
3.3 Advanced Topic: Spectrograms
It is often useful to think of signals in terms of their spectra. A signal's spectrum is a representation of the
frequencies present in the signal. For a constant frequency sinusoid as in (1) the spectrum consists of two
components, one at 2π fo, the other at -2 fo. For more complicated signals, the spectrum may be very
interesting and, in the case of FM, the spectrum is considered to be time-varying. One way to represent the
time-varying spectrum of a signal is the spectrogram (see Chapter 3 in the text). A spectrogram is found
by estimating the frequency content in short sections of the signal. The magnitude of the spectrum over
individual sections is plotted as intensity or color on a two-dimensional plot versus frequency and time.
When unsure about a command, use help.
There are a few important things to know about spectrograms:
1. In MATLAB the function specgram will compute the spectrogram, as already explained in a recent
lecture. Type help specgram to learn more about this function and its arguments.
2. Spectrograms are numerically calculated and only provide an estimate of the time-varying frequency
content of a signal. There are theoretical limits on how well spectrograms can actually represent the
frequency content of a signal. A later lab will treat this problem when we use the spectrogram to
extract the frequencies of piano notes.
3. A common call to the function is specgram (xx, 1024, fs). The second argument¹ is the window
length which could be varied to get different looking spectrograms. The spectrogram is able to "see"
the separate spectrum lines with a longer window length, e.g., 1024 or 2048.²
4. If you are working at home, you might not have the specgram () function because it is part of the
"Signal Processing Toolbox." In that case, use the function plotspec (xx, fs) which was loaded
when you installed the SP First toolbox.
=
McClellan, Schafer, and Yoder, Signal Processing First, ISBN 0-13-065562-7.
Prentice Hall, Upper Saddle River, NJ 07458. ©2003 Pearson Education, Inc.
● Note: The argument list for plot spec () has a different order from specgram, because plotspec ()
uses an optional third argument for the window length (default value is 256). In addition, plotspec ()
does not use color for the spectrogram; instead, darker shades of gray indicate larger values with black
being the largest.
In order to see what the spectrogram produces, run the following code:
fs=8000; xX cos (3000*pi* (0:1/fs:0.5)); specgram (xx, 1024, fs); colorbar
or, if you are using plotspec (xx,fs):
fs=8000; xx = cos (3000*pi* (0:1/fs:0.5)); plotspec (xx, fs,1024); colorbar
Notice that the spectrogram image contains one horizontal line at the correct frequency of the sinusoid.
'If the second argument is made equal to the "empty matrix" then its default value of 256 is used.
2Usually the window length is chosen to be a power of two, because a special algorithm called the FFT is used in the computa-
tion. The fastest FFT programs are those where the signal length is a power of 2.
CD-ROM
4
Sounds
& Spec-
trograms 4 Lab Exercise: Chirps and Beats
For the lab exercise and lab report, you will synthesize some AM and FM signals. In order to verify that
they have the correct frequency content, you will use the spectrogram. Your lab report should discuss the
connection between the “time-domain" definition of the signal and its "frequency-domain" content.
4.1 Beat Notes
In the section on beat notes in Chapter 3 of the text, we analyzed the situation in which we had two sinusoidal
signals of slightly different frequencies; i.e.,
x(t) = A cos(2π (fc − ƒ^)t) + B cos(2π(fc + ƒ^)t)
In this part, we will compute samples of such a signal and listen to the result.
(a) Write an M-file called beat.m that implements (5) and has the following as its first lines:
function
%BEAT
응
응
응
응
olo olo olo olo
응
응
응
%
응
010 010
응
usage:
[xx, tt] = beat (A, B, fc, delf, fsamp, dur)
samples of the sum of two cosine waves
compute
[xx, tt]
=
T
--Second Output:
A = amplitude of lower frequency cosine
B = amplitude of higher frequency cosine
fc = center frequency
delf = frequency difference
fsamp
sampling rate
dur
=
XX =
beat (A, B, fc, delf, fsamp, dur)
total time duration in seconds
output vector of samples
tt = time vector corresponding to xx
(5)
Include a copy of your M-file in your lab report. You might want to call the syn_sin () function
written in Lab 2 to do the calculation. The function should also generate its own time vector, because
that vector can be used to define the horizontal axis when plotting.
(b) To assist you in your experiments with beat notes, a tool called beat con has been created. This user
interface controller is able to call your function beat.m, if you check the box Use External beat()
in the lower left-hand corner of the GUI. Therefore, before you invoke beatcon you should be sure
your M-file is free of errors. Also, make sure that your beat.m function is on the MATLAB path.
Test the M-file written in part (a) via beatcon by using the values A=10, B=10, fc=1000,
delf=10, fsamp=11025, and dur=1 secs. Plot the first 0.2 seconds of the resulting signal. De-
scribe the waveform and explain its properties. Hand in a copy of your plot with measurements of the
period of the "envelope" and period of the high frequency signal underneath the envelope.
McClellan, Schafer, and Yoder, Signal Processing First, ISBN 0-13-065562-7.
Prentice Hall, Upper Saddle River, NJ 07458. ©2003 Pearson Education, Inc.
(c) (Optional)³ Experiment with different values of the frequency difference f▲. Listen to the sounds
(there is a button on beat con that will do this for you automatically) and think about the relationship
between the sound and waveform.
3"Optional" means that you do not have to include this in your lab report.
5
CD-ROM
beatcon.m