Software Receiver Design
Software Receiver Design
WILLIAM A. SETHARES
University of Wisconsin in Madison
ANDREW G. KLEIN
Worcester Polytechnic Institute
To the Instructor . . .
Software Receiver Design helps the reader build a complete digital radio
that includes each part of a typical digital communication system. Chapter by
R
realization of the various pieces of the
chapter, the reader creates a Matlab
system, exploring the key ideas along the way. In the nal chapters, the reader
puts it all together to build fully functional receivers, though as Matlab code
they are not intended to operate in real time. Software Receiver Design
explores telecommunication systems from a very particular point of view: the
construction of a workable receiver. This viewpoint provides a sense of continuity
to the study of communication systems.
The three basic tasks in the creation of a working digital radio are
1. building the pieces,
2. assessing the performance of the pieces,
3. integrating the pieces.
In order to accomplish this in a single semester, we have had to strip away
some topics that are commonly covered in an introductory course and emphasize some topics that are often covered only supercially. We have chosen not to
present an encyclopedic catalog of every method that can be used to implement
each function of the receiver. For example, we focus on frequency division multiplexing rather than time or code division methods, and we concentrate only
on pulse amplitude modulation and quadrature amplitude modulation. On the
other hand, some topics (such as synchronization) loom large in digital receivers,
and we have devoted a correspondingly greater amount of space to these. Our
belief is that it is better to learn one complete system from start to nish than
to half-learn the properties of many.
vi
To the Instructor . . .
approach provides a unied framework for deriving the AGC, clock recovery, carrier recovery, and equalization algorithms. Fortunately, this can be accomplished
using only the mathematical tools that an electrical engineer (at the level of a
college junior) is likely to have, and Software Receiver Design requires no
more than knowledge of calculus, matrix algebra, and Fourier transforms. Any
of the ne texts cited for further reading in Section 3.8 would be ne.
Software Receiver Design emphasizes two ways to assess the behavior of
the components of a communication system: by studying the performance functions and by conducting experiments. The algorithms embodied in the various
components can be derived without making assumptions about details of the
constituent signals (such as Gaussian noise). The use of probability is limited to
naive ideas such as the notion of an average of a collection of numbers, rather
than requiring the machinery of stochastic processes. The absence of an advanced
probability prerequisite for Software Receiver Design makes it possible to
place it earlier in the curriculum.
The integration phase of the receiver design is accomplished in Chapters 9 and
15. Since any real digital radio operates in a highly complex environment, analytical models cannot hope to approach the real situation. Common practice
is to build a simulation and to run a series of experiments. Software Receiver
Design provides a set of guidelines (in Chapter 15) for a series of tests to verify
the operation of the receiver. The nal project challenges the digital radio that
the student has built by adding many dierent kinds of imperfections, including additive noise, multipath disturbances, phase jitter, frequency inaccuracies,
and clock errors. A successful design can operate even in the presence of such
distortions.
It should be clear that these choices distinguish Software Receiver Design
from other, more encyclopedic texts. We believe that this hands-on method
makes Software Receiver Design ideal for use as a learning tool, though it is
less comprehensive than a reference book. In addition, the instructor may nd
that the order of presentation of topics in the ve easy steps is dierent from
that used by other books. Section 1.3 provides an overview of the ow of topics,
and our reasons for structuring the course as we have.
Finally, we believe that Software Receiver Design may be of use to nontraditional students. Besides the many standard kinds of exercises, there are
many problems in the text that are self-checking in the sense that the reader
will know when/whether they have found the correct answer. These may also be
useful to the self-motivated design engineer who is using Software Receiver
Design to learn about digital radio.
To the Instructor . . .
vii
viii
To the Instructor . . .
Some Extras
The course website contains extra material of interest, especially to the instructor. First, we have assembled a complete collection of slides (in .pdf format)
that may help in lesson planning. The nal project is available in two complete
forms, one that exploits the block coding of Chapter 14 and one that does not.
In addition, there are several received signals on the website, which can be
used for assignments and for the project. Finally, all the Matlab code that is
presented in the text is available on the website. Once these are added to the
Matlab path, they can be used for assignments and for further exploration.1
Mathematical Prerequisites
r G. B. Thomas and R. L. Finney, Calculus and Analytic Geometry, 8th edition,
Addison-Wesley, 1992.
r B. Kolman and D. R. Hill, Elementary Linear Algebra, 8th edition, PrenticeHall, 2003.
The .m scripts will run with either Matlab or GNU Octave, which is freely available at
http://www.gnu.org/software/octave. When using the scripts with Matlab, the Signal Processing Toolbox is required; all scripts have been tested with Matlab v7.10/R2010a, but
are expected to work with older versions of Matlab. For Octave, the scripts were tested
with Octave v3.2.3 and the required Octave-Forge toolboxes signal v1.0.11, specfun v1.0.9,
optim v1.0.12, miscellaneous v1.0.9, and audio v1.1.4. When using Octave, the script
firpm octave.m can be renamed firpm.m so that identical code will run in the two platforms.
Contents
To the Instructor . . .
A Digital Radio
1.1 What Is a Digital Radio?
1.2 An Illustrative Design
1.3 Walk This Way
page v
1
2
2
3
12
15
A Telecommunication System
2.1 Electromagnetic Transmission of Analog Waveforms
2.2 Bandwidth
2.3 Upconversion at the Transmitter
2.4 Frequency Division Multiplexing
2.5 Filters that Remove Frequencies
2.6 Analog Downconversion
2.7 Analog Core of a Digital Communication System
2.8 Sampling at the Receiver
2.9 Digital Communications Around an Analog Core
2.10 Pulse Shaping
2.11 Synchronization: Good Times Bad Times
2.12 Equalization
2.13 Decisions and Error Measures
2.14 Coding and Decoding
2.15 A Telecommunication System
2.16 Stairway to Radio
16
16
18
20
22
23
24
26
28
29
30
33
34
35
37
38
38
The
3.1
3.2
3.3
40
41
44
46
Six Elements
Finding the Spectrum of a Signal
The First Element: Oscillators
The Second Element: Linear Filters
Contents
3.4
3.5
3.6
3.7
3.8
49
52
53
55
56
58
Modeling Corruption
4.1 When Bad Things Happen to Good Signals
4.2 Linear Systems: Linear Filters
4.3 The Delta Function
4.4 Convolution in Time: Its What Linear Systems Do
4.5 Convolution Multiplication
4.6 Improving SNR
59
59
65
65
70
72
76
Analog (De)modulation
5.1 Amplitude Modulation with Large Carrier
5.2 Amplitude Modulation with Suppressed Carrier
5.3 Quadrature Modulation
5.4 Injection to Intermediate Frequency
80
81
84
90
93
98
99
103
108
110
114
115
120
127
129
130
130
141
Bits
8.1
8.2
8.3
8.4
8.5
152
152
155
157
160
161
to Symbols to Signals
Bits to Symbols
Symbols to Signals
Correlation
Receive Filtering: From Signals to Symbols
Frame Synchronization: From Symbols to Bits
Contents
Stu Happens
9.1 An Ideal Digital Communication System
9.2 Simulating the Ideal System
9.3 Flat Fading: A Simple Impairment and a Simple Fix
9.4 Other Impairments: More What Ifs
9.5 A B 3IG Deal
xi
165
166
167
175
178
187
191
10
Carrier Recovery
10.1 Phase and Frequency Estimation via an FFT
10.2 Squared Dierence Loop
10.3 The Phase-Locked Loop
10.4 The Costas Loop
10.5 Decision-Directed Phase Tracking
10.6 Frequency Tracking
192
194
197
202
206
210
216
11
226
227
229
231
237
242
247
12
Timing Recovery
12.1 The Problem of Timing Recovery
12.2 An Example
12.3 Decision-Directed Timing Recovery
12.4 Timing Recovery via Output Power Maximization
12.5 Two Examples
250
251
252
256
261
266
13
Linear Equalization
13.1 Multipath Interference
13.2 Trained Least-Squares Linear Equalization
13.3 An Adaptive Approach to Trained Equalization
13.4 Decision-Directed Linear Equalization
13.5 Dispersion-Minimizing Linear Equalization
13.6 Examples and Observations
270
272
273
284
288
290
294
14
Coding
14.1 What Is Information?
14.2 Redundancy
303
304
308
xii
Contents
14.3
14.4
14.5
14.6
14.7
Entropy
Channel Capacity
Source Coding
Channel Coding
Encoding a Compact Disc
315
318
323
328
339
341
15
Make It So
15.1 How the Received Signal Is Constructed
15.2 A Design Methodology for the M6 Receiver
15.3 No Soap Radio: The M6 Receiver Design Challenge
342
343
345
354
16
357
357
358
363
367
378
380
384
387
391
397
398
Appendices
404
404
404
405
409
409
410
411
Simulating Noise
412
416
421
421
422
Contents
The
F.1
F.2
F.3
F.4
The
H.1
H.2
H.3
Z-Transform
Z-Transforms
Sketching the Frequency Response from the Z-Transform
Measuring Intersymbol Interference
Analysis of Loop Structures
B 3IG Transmitter
Constructing the Received Signal
Matlab Code for the Notorious B 3IG
Notes on Debugging and Signal Measurement
Index
xiii
425
428
428
432
435
438
442
442
443
446
451
453
455
459
460
xiv
Contents
Dedicated to ...
Samantha and Franklin
A Digital Radio
1.1
A Digital Radio
1.2
An Illustrative Design
The rst design is a brief tour of a digital radio. If some of the terminology
seems obscure or unfamiliar, rest assured that succeeding sections and chapters
will revisit the words and rene the ideas. The design is shown in Figures 1.1
through 1.5. While talking about these gures, it will become clear that some
ideas are being oversimplied. Eventually, it will be necessary to come back and
examine these more closely.
The boxed notes are reminders to
return and think about these areas
more deeply later on.
In keeping with Shannons goal of reproducing at one point a message known
at another point, suppose that it is desired to transmit a text message from one
place to another. Of course, there is nothing magical about text; however, .mp3
sound les, .jpg photos, snippets of speech, raster-scanned television images,
or any other kind of information would do, as long as it can be appropriately
digitized into ones and zeros.
Can every kind of message be digitized
into ones and zeros?
Perhaps the simplest possible scheme would be to transmit a pulse to represent
a one and to transmit nothing to represent a zero. With this scheme, however,
it is hard to tell the dierence between a string of zeros and no transmission at
Text
Symbols
s[k]
Scaling
factor
Coder
Initiation
trigger
T-wide
analog
pulse
shape p(t)
generator
Baseband
signal y(t)
baseband transmitter.
1
+ kT
symbol string
1, 1, 3, 1
1, 1, 3, 1
1, 1, 3, 3
1, 1, 1, 3
..
.
(1.1)
In this example, the symbols are clustered into groups of four, and each cluster
is called a frame. Coding schemes can be designed to increase the security of a
transmission, to minimize the errors, or to maximize the rate at which data are
sent. This particular scheme is not optimized in any of these senses, but it is
convenient to use in simulation studies.
Some codes are better than others. How
can we tell?
To be concrete, let
Many such choices are possible. These particular values were chosen because they are equidistant and so noise would be no more likely to ip a 3 into a 1 than to ip a 1 into a 1.
A Digital Radio
(1.2)
which is plotted in Figure 1.2(a). The transmitter of Figure 1.1 is designed so that
every T seconds it produces a copy of p() that is scaled by the symbol value s[].
A typical output of the transmitter in Figure 1.1 is illustrated in Figure 1.2(b)
using the rectangular pulse shape. Thus the rst pulse begins at some time
and it is scaled by s[0], producing s[0]p(t ). The second pulse begins at time
+ T and is scaled by s[1], resulting in s[1]p(t T ). The third pulse gives
s[2]p(t 2T ), and so on. The complete output of the transmitter is the sum
of all these scaled pulses:
s[i]p(t iT ).
y(t) =
i
Since each pulse ends before the next one begins, successive symbols should
not interfere with each other at the receiver. The general method of sending
information by scaling a pulse shape with the amplitude of the symbols is called
Pulse Amplitude Modulation (PAM). When there are four symbols as in (1.1),
it is called 4-PAM.
For now, assume that the path between the transmitter and receiver, which is
often called the channel, is ideal. This implies that the signal at the receiver is
the same as the transmitted signal, though it will inevitably be delayed (slightly)
due to the nite speed of the wave, and attenuated by the distance. When the
ideal channel has a gain g and a delay , the received version of the transmitted
signal in Figure 1.2(b) is as shown in Figure 1.2(c).
There are many ways in which a real signal may change as it passes from the
transmitter to the receiver through a real (nonideal) channel. It may be reected
from mountains or buildings. It may be diracted as it passes through the atmosphere. The waveform may smear in time so that successive pulses overlap. Other
signals may interfere additively (for instance, a radio station broadcasting at the
same frequency in a dierent city). Noises may enter and change the shape of
the waveform.
There are two compelling reasons to consider the telecommunication system
in the simplied (idealized) case before worrying about all the things that might
go wrong. First, at the heart of any working receiver is a structure that is able to
function in the ideal case. The classic approach to receiver design (and also the
approach of Software Receiver Design) is to build for the ideal case and later
to rene so that the receiver will still work when bad things happen. Second,
many of the basic ideas are clearer in the ideal case.
The job of the receiver is to take the received signal (such as that in Figure
1.2(c)) and to recover the original text message. This can be accomplished by an
idealized receiver such as that shown in Figure 1.3. The rst task this receiver
must accomplish is to sample the signal to turn it into computer-friendly digital
y(t)
3
r(t)
p(t)
3g
g
0
T
1
(a)
+T
g
3g
+2T +3T
(b)
+ ++T
++2T ++3T
++4T
(c)
+4T
Figure 1.2 (a) An isolated rectangular pulse. (b) The transmitted signal consists of a
sequence of pulses, one corresponding to each symbol. Each pulse has the same shape
as in (a), though oset in time (by ) and scaled in magnitude (by the symbols s[k]).
(c) In the ideal case, the received signal is the same as the transmitted signal of (b),
though attenuated in magnitude (by g) and delayed in time (by ).
Reconstructed
symbols
Received
signal
Quantizer
Reconstructed
text
Decoder
baseband receiver.
+ kT
Sampler
form. But when should the samples be taken? On comparing Figures 1.2(b) and
1.2(c), it is clear that if the received signal were sampled somewhere near the
middle of each rectangular pulse segment, then the quantizer could reproduce
the sequence of source symbols. This quantizer must either
1. know g so the sampled signal can be scaled by 1/g to recover the symbol
values, or
2. separate g from 3g and output symbol values 1 and 3.
Once the symbols have been reconstructed, then the original message can be
decoded by reversing the assignment of letters to symbols used at the transmitter
(for example, by reading (1.1) backwards). On the other hand, if the samples
were taken at the moment of transition from one symbol to another, then the
values might become confused.
To investigate the timing question more fully, let T be the sample interval and
be the time at which the rst pulse begins. Let be the time it takes for the signal
to move from the transmitter to the receiver. Thus the (k + 1)st pulse, which
begins at time + kT , arrives at the receiver at time + kT + . The midpoint
of the pulse, which is the best time to sample, occurs at + kT + + T /2. As
indicated in Figure 1.3, the receiver begins sampling at time , and then samples
regularly at + kT for all integers k. If were chosen so that
= + + T /2,
(1.3)
A Digital Radio
then all would be well. But there are two problems: the receiver does not know
when the transmission began, nor does it know how long it takes for the signal
to reach the receiver. Thus both and are unknown!
Somehow, the receiver must gure out
when to sample.
Basically, some extra synchronization procedure is needed in order to satisfy
(1.3). Fortunately, in the ideal case, it is not really necessary to sample exactly at
the midpoint; it is necessary only to avoid the edges. Even if the samples are not
taken at the center of each rectangular pulse, the transmitted symbol sequence
can still be recovered. But if the pulse shape were not a simple rectangle, then
the selection of would become more critical.
How does the pulse shape interact with
timing synchronization?
Just as no two clocks ever tell exactly the same time, no two independent
oscillators2 are ever exactly synchronized. Since the symbol period at the transmitter, call it Ttrans , is created by a separate oscillator from that creating the
symbol period at the receiver, call it Trec , they will inevitably dier. Thus another
aspect of timing synchronization that must ultimately be considered is how to
automatically adjust Trec so that it aligns with Ttrans .
Similarly, no clock ticks out each second exactly evenly. Inevitably, there is
some jitter, or wobble in the value of Ttrans and/or Trec . Again, it may be
necessary to adjust to retain sampling near the center of the pulse shape
as the clock times wiggle about. The timing adjustment mechanisms are not
explicitly indicated in the sampler box in Figure 1.3. For the present idealized
transmission system, the receiver sampler period and the symbol period of the
transmitter are assumed to be identical (both are called T in Figures 1.1 and
1.3) and the clocks are assumed to be free of jitter.
What about clock jitter?
Even under the idealized assumptions above, there is another kind of synchronization that is needed. Imagine joining a broadcast in progress, or one in
which the rst K symbols have been lost during acquisition. Even if the symbol
sequence is perfectly recovered after time K, the receiver would not know which
recovered symbol corresponds to the start of each frame. For example, using the
letters-to-symbol code of (1.1), each letter of the alphabet is translated into a
sequence of four symbols. If the start of the frame is o by even a single sym2
Oscillators, electronic components that generate repetitive signals, are discussed at length in
Chapter 3.
bol, the translation from symbols back into letters will be scrambled. Does this
sequence represent a or X?
a
1, 1, 1, 3, 1
1, 1, 1, 3, 1
X
Thus proper decoding requires locating where the frame starts, a step called
frame synchronization. Frame synchronization is implicit in Figure 1.3 in the
choice of , which sets the time t (= with k = 0) of the rst symbol of the rst
(character) frame of the message of interest.
How to nd the start of a frame?
In the ideal situation, there must be no other signals occupying the same frequency range as the transmission. What bandwidth (what range of frequencies)
does the transmitter (1.1) require? Consider transmitting a single T -second-wide
rectangular pulse. Fourier transform theory shows that any such time-limited
pulse cannot be truly bandlimited, that is, cannot have its frequency content
restricted to a nite range. Indeed, the Fourier transform of a rectangular pulse
in time is a sinc function in frequency (see Equation (A.20) in Appendix A). The
magnitude of this sinc is overbounded by a function that decays as the inverse of
frequency (peek ahead to Figure 2.11). Thus, to accommodate this single-pulse
transmission, all other transmitters must have negligible energy below some factor of B = 1/T . For the sake of argument, suppose that a factor of 5 is safe, that
is, all other transmitters must have no signicant energy within 5B Hz. But this
is only for a single pulse. What happens when a sequence of T -spaced, T -wide
rectangular pulses of various amplitudes is transmitted? Fortunately, as will be
established in Section 11.1, the bandwidth requirements remain about the same,
at least for most messages.
What is the relation between the pulse
shape and the bandwidth?
One fundamental limitation to data transmission is the trade-o between the
data rate and the bandwidth. One obvious way to increase the rate at which data
are sent is to use shorter pulses, which pack more symbols into a shorter time.
This essentially reduces T . The cost is that this would require excluding other
transmitters from an even wider range of frequencies since reducing T increases
B.
What is the relation between the data
rate and the bandwidth?
A Digital Radio
If the safety factor of 5B is excessive, other pulse shapes that would decay
faster as a function of frequency could be used. For example, rounding the sharp
corners of a rectangular pulse reduces its high-frequency content. Similarly, if
other transmitters operated at high frequencies outside 5B Hz, it would be sensible to add a lowpass lter at the front end of the receiver. Rejecting frequencies
outside the protected 5B baseband turf also removes a bit of the higher-frequency
content of the rectangular pulse. The eect of this in the time domain is that the
received version of the rectangle would be wiggly near the edges. In both cases,
the timing of the samples becomes more critical as the received pulse deviates
further from rectangular.
One shortcoming of the telecommunication system embodied in the transmitter of Figure 1.1 and the receiver of Figure 1.3 is that only one such transmitter
at a time can operate in any particular geographical region, since it hogs all the
frequencies in the baseband, that is, all frequencies below 5B Hz. Fortunately,
there is a way to have multiple transmitters operating in the same region simultaneously. The trick is to translate the frequency content so that instead of all
transmitters trying to operate in the 0 and 5B Hz band, one might use the 5B
to 10B band, another the 10B to 15B band, etc. Conceivably, this could be
accomplished by selecting a dierent pulse shape (other than the rectangle) that
has no low-frequency content, but the most common approach is to modulate
(change frequency) by multiplying the pulse-shaped signal by a high-frequency
sinusoid. Such a radio-frequency (RF) transmitter is shown in Figure 1.4,
though it should be understood that the actual frequencies used may place it
in the television band or in the range of frequencies reserved for cell phones,
depending on the application.
At the receiver, the signal can be returned to its original frequency (demodulated) by multiplying by another high-frequency sinusoid (and then lowpass
ltering). These frequency translations are described in more detail in Section
2.6, where it is shown that the modulating sinusoid and the demodulating sinusoid must have the same frequencies and the same phases in order to return
the signal to its original form. Just as it is impossible to align any two clocks
exactly, it is also impossible to generate two independent sinusoids of exactly the
same frequency and phase. Hence there will ultimately need to be some kind of
carrier synchronization, a way of aligning these oscillators.
How can the frequencies and phases of
these two sinusoids be aligned?
Adding frequency translation to the transmitter and receiver of Figures 1.1 and
1.3 produces the transmitter in Figure 1.4 and the associated receiver in Figure
1.5. The new block in the transmitter is an analog component that eectively
adds the same value (in Hz) to the frequencies of all of the components of the
baseband pulse train. As noted, this can be achieved with multiplication by a
carrier sinusoid with a frequency equal to the desired translation. The new
10
Text
Symbols
Coder
Pulseshape
filter
Received
Baseband
signal
signal
Frequency
Sampler
translator
Baseband
signal
Frequency
translator
Passband
signal
Reconstructed
text
Quantizer
Decoder
Figure 1.4
Radio-frequency
transmitter.
Figure 1.5
Radio-frequency
receiver.
block in the receiver of Figure 1.5 is an analog component that processes the
received analog signal prior to sampling in order to subtract the same value (in
Hz) from all components of the received signal. The output of this block should
be identical to the input to the sampler in Figure 1.3.
This process of translating the spectrum of the transmitted signal to higher
frequencies allows many transmitters to operate simultaneously in the same geographical area. But there is a price. Since the signals are not completely bandlimited to within their assigned 5B-wide slot, there is some inevitable overlap.
Thus the residual energy of one transmitter (the energy outside its designated
band) may interfere with other transmissions. Solving the problem of multiple
transmissions has thus violated one of the assumptions for an ideal transmission.
A common theme throughout Software Receiver Design is that a solution to
one problem often causes another!
There is no free lunch. How much does
the x cost?
In fact, there are many other ways in which the transmission channel can deviate from the ideal, and these will be discussed in detail later on (for instance, in
Section 4.1 and throughout Chapter 9). Typically, the cluttered electromagnetic
spectrum results in a variety of distortions and interferences:
A Digital Radio
Transmitted
signal
Gain
with
delay
Interference Broadband
noises
from other
sources
Received
signal
+
+
11
Self-interference
Multipath
These channel imperfections are all incorporated in the channel model shown in
Figure 1.6, which sits in the communication system between Figures 1.4 and 1.5.
Many of these imperfections in the channel can be mitigated by clever use of
ltering at the receiver. Narrowband interference can be removed with a notch
lter that rejects frequency components in the narrow range of the interferer
without removing too much of the broadband signal. Out-of-band interference
and broadband noise can be reduced using a bandpass lter that suppresses
the signal in the out-of-band frequency range and passes the in-band frequency
components without distortion. With regard to Figure 1.5, it is reasonable to
wonder whether it is better to perform such ltering before or after the sampler
(i.e., by an analog or a digital lter). In modern receivers, the trend is to minimize
the amount of analog processing since digital methods are (often) cheaper and
(usually) more exible since they can be implemented as recongurable software
rather than xed hardware.
Analog or digital processing?
Conducting more of the processing digitally requires moving the sampler closer
to the antenna. The sampling theorem (discussed in Section 6.1) says that no
information is lost as long as the sampling occurs at a rate faster than twice the
highest frequency of the signal. Thus, if the signal has been modulated to (say)
the band from 20B to 25B Hz, then the sampler must be able to operate at least
as fast as 50B samples per second in order to be able to exactly reconstruct the
value of the signal at any arbitrary time instant. Assuming this is feasible, the
received analog signal can be sampled using a free-running sampler. Interpolation can be used to gure out values of the signal at any desired intermediate
instant, such as at time + kT (recall (1.3)) for a particular that is not an
integer multiple of T . Thus, the timing synchronization can be incorporated into
the post-sampler digital signal processing box, which is shown generically in
Figure 1.7. Observe that Figure 1.5 is one particular version of 1.7.
How exactly does interpolation work?
12
Received
signal
Analog
signal
processing
+ kT
Digital
signal
processing
Recovered
source
r
r
r
r
r
r
r
1.3
A Digital Radio
13
r Step 2: The Basic Components. The next two chapters provide more depth and
detail by outlining a complete telecommunication system. When the transmitted signal is passed through the air using electromagnetic waves, it must
take the form of a continuous (analog) waveform. A good way to understand
such analog signals is via the Fourier transform, and this is reviewed briey in
Chapter 2. The six basic elements of the receiver will be familiar to many readers, and they are presented in Chapter 3 in a form that will be directly useful
when creating Matlab implementations of the various parts of the communication system. By the end of the second step, the basic system architecture
is xed and the ordering of the blocks in the system diagram is stabilized.
Step 3: The Idealized System. The third step encompasses Chapters 4 through
9. Step 3 gives a closer look at the idealized receiverhow things work when
everything is just right: when the timing is known, when the clocks run at
exactly the right speed, when there are no reections, diractions, or diusions of the electromagnetic waves. This step also integrates ideas from previous systems courses, and introduces a few Matlab tools that are needed
to implement the digital radio. The order in which topics are discussed is
precisely the order in which they appear in the receiver:
frequency
channel translation sampling
Chapter 4
Chapter 5
Chapter 6
decision
receive
decoding
equalization
device
ltering
Chapter 7
Chapter 8
Channel impairments and linear systems Chapter
Frequency translation and modulation Chapter
Sampling and gain control
Chapter
Receive (digital) ltering
Chapter
Symbols to bits to signals
Chapter
4
5
6
7
8
14
Chapter 10
Chapter 11
Chapter 12
Chapter 13
Chapter 14
r Step 5: Putting It All Together. The nal steps are the projects of Chapters
15 and 16 which integrate all the xes of the fourth step into the receiver
structure of the third step to create a fully functional digital receiver. The wellfabricated receiver is robust with respect to distortions such as those caused
by noise, multipath interference, timing inaccuracies, and clock mismatches.
The next two chapters provide more depth and detail by outlining a complete
telecommunication system. When the transmitted signal is passed through the
air using electromagnetic waves, it must take the form of a continuous (analog)
waveform. A good way to understand such analog signals is via the Fourier
transform, and this is reviewed briey in Chapter 2. The six basic elements of
the receiver will be familiar to many readers, and they are presented in Chapter 3
in a form that will be directly useful when creating Matlab implementations of
the various parts of the communications system. By the end of the second step,
the basic system architecture is xed; the ordering of the blocks in the system
diagram has stabilized.
A Telecommunication System
2.1
A Telecommunication System
17
3 108 m/s
= 3 104 m.
104 /s
Ecient transmission requires an antenna longer than 0.1, which is 3 km! Sinusoids in the speech band would require even larger antennas. Fortunately, there is
an alternative to building mammoth antennas. The frequencies in the signal can
be translated (shifted, upconverted, or modulated) to a much higher frequency
called the carrier frequency, at which the antenna requirements are easier to
meet. For instance,
r
r
r
r
r
r
r
Recall that 1 kHz = 103 Hz; 1 MHz = 106 Hz; 1 GHz = 109 Hz.
A second experimental fact is that electromagnetic waves in the atmosphere
exhibit dierent behaviors, depending on the frequency of the waves.
r Below 2 MHz, electromagnetic waves follow the contour of the Earth. This
r
r
r
Humanmade media in wired systems also exhibit frequency-dependent behavior. In the phone system, due to its original goal of carrying voice signals, severe
attenuation occurs above 4 kHz.
The notion of frequency is central to the process of long-distance communications. Because of its role as a carrier (the AM/UHF/VHF/PCS bands mentioned
above) and its role in specifying the bandwidth (the range of frequencies occupied
by a given signal), it is important to have tools with which to easily measure the
frequency content in a signal. The tool of choice for this job is the Fourier trans-
18
form (and its discrete counterparts, the DFT and the FFT).1 Fourier transforms
are useful in assessing energy or power at particular frequencies. The Fourier
transform of a signal w(t) is dened as
W (f ) =
w(t)ej2f t dt = F {w(t)},
(2.1)
t=
The complex exponential ej2f t can be interpreted as a (complex-valued) sinusoidal wave since it is the sum of a sine term and a cosine term, both of frequency
f (via Eulers formula). Since W (f ) is a complex number at each f , (2.2) can
be interpreted as describing or decomposing w(t) into sinusoidal elements of frequencies f weighted by the W (f ). The discrete approximation to the Fourier
transform, called the DFT, is discussed in some detail in Chapter 7, and a table
of useful properties appears in Appendix A.
2.2
Bandwidth
If, at any particular frequency f0 , the magnitude spectrum is strictly positive
(|W (f0 )| > 0), then the frequency f0 is said to be present in w(t). The set of
all frequencies that are present in the signal is the frequency content, and if the
frequency content consists only of frequencies below some given f , then the
signal is said to be bandlimited to f . Some bandlimited signals are
These are the discrete Fourier transform, which is a computer implementation of the Fourier
transform, and the fast Fourier transform, which is a slick, computationally ecient method
of calculating the DFT.
A Telecommunication System
19
|W( f )|
1
2
= 0.707
2
Half-power
BW
Null-to-null BW
Power BW
Absolute BW
But real-world signals are never completely bandlimited, and there is almost
always some energy at every frequency. Several alternative denitions of bandwidth are in common use; these try to capture the idea that most of the
energy is contained in a specied frequency region. Usually, these are applied
across positive frequencies, with the presumption that the underlying signals are
real-valued (and hence have symmetric spectra). Here are some of the alternative
denitions.
1. Absolute bandwidth is the smallest interval f2 f1 for which the spectrum is
zero outside of f1 < f < f2 (only the positive frequencies need be considered).
2. 3-dB (or half-power) bandwidth is f2 f1 , where, for frequencies outside f1 <
f < f2 , |H(f )| is never greater than 1/ 2 times its maximum value.
3. Null-to-null (or zero-crossing) bandwidth is f2 f1 , where f2 is the rst null
in |H(f )| above f0 and, for bandpass systems, f1 is the rst null in the envelope below f0 , where f0 is the frequency of maximum |H(f )|. For baseband
systems, f1 is usually zero.
4. Power bandwidth is f2 f1 , where f1 < f < f2 denes the frequency band in
which 99% of the total power resides. Occupied bandwidth is such that 0.5%
of power is above f2 and 0.5% below f1 .
These denitions are illustrated in Figure 2.1.
The various denitions of bandwidth refer directly to the frequency content
of a signal. Since the frequency response of a linear lter is the transform of its
impulse response, bandwidth is also used to talk about the frequency range over
which a linear system or lter operates.
20
Exercise 2.1. TRUE or FALSE: Absolute bandwidth is never less than 3-dB
power bandwidth.
Exercise 2.2. Suppose that a signal is complex-valued and hence has a spectrum
that is not symmetric about zero frequency. State versions of the various denitions of bandwidth that make sense in this situation. Illustrate your denitions
as in Figure 2.1.
2.3
(2.3)
where f0 is called the carrier frequency. The Fourier transform can now be used
to show that this multiplication shifts all frequencies present in the message by
exactly f0 Hz.
Using one of Eulers identities (A.2),
cos(2f0 t) =
1 j2f0 t
e
+ ej2f0 t ,
2
(2.4)
one can calculate the spectrum (or frequency content) of the signal s(t) from the
denition of the Fourier transform given in (2.1). In complete detail, this is
S(f ) = F {s(t)} = F {w(t) cos(2f0 t)}
1 j2f0 t
e
+ ej2f0 t
= F w(t)
2
1 j2f0 t
w(t)
+ ej2f0 t ej2f t dt
=
e
2
1
=
w(t) ej2(f f0 )t + ej2(f +f0 )t dt
2
1
1
=
w(t)ej2(f f0 )t dt +
w(t)ej2(f +f0 )t dt
2
2
1
1
= W (f f0 ) + W (f + f0 ).
2
2
(2.5)
21
A Telecommunication System
|W( f )|
|S( f )|
0.5
f
(a)
f0 f
f0
f0 + f
f0 f
f0
f0 + f
(b)
Figure 2.2 Action of a modulator: If the message signal w(t) has the magnitude
spectrum shown in part (a), then the modulated signal s(t) has the magnitude
spectrum shown in part (b).
Thus, the spectrum of s(t) consists of two copies of the spectrum of w(t),
each shifted in frequency by f0 (one up and one down) and each half as large.
This is sometimes called the frequency-shifting property of the Fourier transform, and sometimes called the modulation property. Figure 2.2 shows how the
spectra relate. If w(t) has the magnitude spectrum shown in part (a) (this is
shown bandlimited to f and centered at 0 Hz or baseband, though it could be
elsewhere), then the magnitude spectrum of s(t) appears as in part (b). This
kind of modulation (or upconversion, or frequency shift) is ideal for translating
speech, music, or other low-frequency signals into much higher frequencies (for
instance, f0 might be in the AM or UHF bands) so that they can be transmitted eciently. It can also be used to convert a high-frequency signal back down
to baseband when needed, as will be discussed in Section 2.6 and in detail in
Chapter 5.
Any sine wave is characterized by three parameters: the amplitude, frequency,
and phase. Any of these characteristics can be used as the basis of a modulation
scheme: modulating the frequency is familiar from the FM radio, and phase
modulation is common in computer modems. A major example in this book is
amplitude modulation as in (2.3), where the message w(t) is multiplied by a highfrequency sinusoid with xed frequency and phase. Whatever the modulation
scheme used, the idea is the same: a sinusoid is used to translate the message
into a form suitable for transmission.
Exercise 2.3. Referring to Figure 2.2, nd which frequencies are present in
W (f ) and not in S(f ). Which frequencies are present in S(f ) but not in W (f )?
Exercise 2.4. Using (2.5), draw analogous pictures for the phase spectrum of
s(t) as it relates to the phase spectrum of w(t).
Exercise 2.5. Suppose that s(t) is modulated again, this time via multiplication
with a cosine of frequency f1 . What is the resulting magnitude spectrum? Hint:
let r(t) = s(t) cos(2f1 t), and apply (2.5) to nd R(f ).
22
2.4
f3 f * f3 + f *
Figure 2.3 Three dierent
f3
f2
f1
f
f1
f2
f2 f * f2 + f *
f3
A Telecommunication System
|W( f )|
23
Bandpass
filter
Figure 2.4 Separation
of a single FDM
transmission using a
bandpass lter.
f1
2.5
f2 f *
f2
f2 + f *
f3
Formally, the frequency response can be calculated as the Fourier transform of the impulse
response of the lter.
24
|W( f )|
fl
(a)
fl
|H( f )|
fl
(b)
fl
fl
(c)
fl
Exercise 2.7. An ideal highpass lter passes all frequencies above some given
fh and removes all frequencies below. Show the result of applying a highpass
lter to the signal in Figure 2.5 with fh = fl .
Exercise 2.8. An ideal bandpass lter passes all frequencies between an upper
limit f and a lower limit f. Show the result of applying a bandpass lter to the
signal in Figure 2.5 with f = 2fl /3 and f = fl /3.
The problem of how to design and implement such lters is considered in detail
in Chapter 7.
2.6
Analog Downconversion
Because transmitters typically modulate the message signal with a highfrequency carrier, the receiver must somehow remove the carrier from the message that it carries. One way is to multiply the received signal by a cosine wave
of the same frequency (and the same phase) as was used at the transmitter. This
creates a (scaled) copy of the original signal centered at zero frequency, plus some
other high-frequency replicas. A lowpass lter can then remove everything but
the scaled copy of the original message. This is how the box labelled frequency
translator in Figure 1.5 is typically implemented.
To see this procedure in detail, suppose that s(t) = w(t) cos(2f0 t) arrives at
the receiver, which multiplies s(t) by another cosine wave of exactly the same
A Telecommunication System
25
1 1
+ cos(2x),
2 2
26
|W( f )|
f
0
(a)
|S( f )|
f0
(b)
f0
Lowpass filter
{s(t) cos(2f0t)}
2f0
0
(c)
2f0
Figure 2.6 The message can be recovered by downconversion and lowpass ltering. (a)
shows the original spectrum of the message; (b) shows the message modulated by the
carrier f0 ; (c) shows the demodulated signal. Filtering with an LPF recovers the
original spectrum.
2f3
f3 f2 f3 f1
f1 f3
f2 f3
f3 f2
f3 f1
f3+f1
f3+f2
2f3
Figure 2.7 The signal containing the three messages of Figure 2.3 is modulated by a
sinusoid of frequency f3 . This translates all three spectra by f3 , placing two
identical semicircular spectra at the origin. These overlapping spectra, shown as
dashed lines, sum to form the larger solid semicircle. Applying an LPF isolates just
this one message.
2.7
A Telecommunication System
Other
FDM
Other
users interference
Received
signal
Message
waveform
Upconversion
Bandpass
filter for
FDM user
selection
Carrier
specification
Downconversion
27
Lowpass
filter
Carrier
synchronization
bandpass ltered (to extract the desired user), downconverted (requiring carrier
synchronization), and lowpass ltered (to recover the actual message).
But no transmission system operates perfectly. Each of the blocks in Figure 2.8
may be noisy, may have components which are inaccurate, and may be subject
to fundamental limitations. For instance,
r the bandwidth of a lter may be dierent from its specication (e.g., the
r
r
r
r
shoulders might not drop o fast enough to avoid passing some of the adjacent
signal),
the frequency of an oscillator might not be exact, and hence the modulation
and/or demodulation might not be exact,
the phase of the carrier is unknown at the receiver, since it depends on the
time of travel between the transmitter and the receiver,
perfect lters are impossible, even in principle,
no oscillator is perfectly regular, there is always some jitter in frequency.
Even within the frequency range of the message signal, the medium can
aect dierent frequencies in dierent ways. (These are called frequency selective
eects.) For example, a signal may arrive at the receiver, and a moment later a
copy of the same signal might arrive after having bounced o a mountain or a
nearby building. This is called multipath interference, and it can be viewed as
a sum of weighted and delayed versions of the transmitted signal. This may be
familiar to the (analog broadcast) TV viewer as ghosts, misty copies of the
original signal that are shifted and superimposed over the main image. In the
simple case of a sinusoid, a delay corresponds to a phase shift, making it more
dicult to reassemble the original message. A special lter called the equalizer is
often added to the receiver to help improve the situation. An equalizer is a kind
of deghosting circuit,3 and equalization is addressed in detail in Chapter 13.
3
28
2.8
A Telecommunication System
f3 fI
f3 + fI
f3 fI
29
f3 + fI
priced A/D samplers. Thus directly sampling the received signal (and performing
all the downconversion digitally) might not be feasible, even though it appears
desirable for a fully software-based receiver.
In the second case, the downconversion (and subsequent lowpass ltering)
are done in analog circuitry, and the samples are taken at the output of the
lowpass lter. Sampling can take place at a rate twice the highest frequency
f in the baseband, which is considerably smaller than twice f3 + f . Since the
downconversion must be done accurately in order to have the shifted spectra
of the desired user line up exactly (and overlap correctly), the analog circuitry
must be quite accurate. This, too, can be expensive.
In the third case, the downconversion is done in two steps: an analog circuit
downconverts to some intermediate frequency, where the signal is sampled. The
resulting signal is then digitally downconverted to baseband. The advantage of
this (seemingly redundant) method is that the analog downconversion can be
performed with minimal precision (and hence inexpensively), while the sampling
can be done at a reasonable rate (and hence inexpensively). In Figure 2.9, the
frequency fI of the intermediate downconversion is chosen to be large enough
so that the whole FDM band is moved below the upshifted portion. Also, fI is
chosen to be small enough so that the downshifted positive frequency portion
lower edge does not reach zero. An analog bandpass lter extracts the whole
FDM band at an intermediate frequency (IF), and then it is only necessary to
sample at a rate greater than 2(f3 + f fI ).
Downconversion to an intermediate frequency is common since the analog
circuitry can be xed, and the tuning (when the receiver chooses between users)
can be done digitally. This is advantageous since tunable analog circuitry is
considerably more expensive than tunable digital circuitry.
2.9
30
r
r
r
r
r
r
r
r
Pulse Shaping
In order to transmit a digital data stream, it must be turned into an analog
signal. The rst step in this conversion is to clump the bits into symbols that
lend themselves to translation into analog form. For instance, a mapping from
the letters of the English alphabet into bits and then into the 4-PAM symbols
1, 3 was given explicitly in (1.1). This was converted into an analog waveform
using the rectangular pulse shape (1.2), which results in signals that look like
31
A Telecommunication System
(t)
1
T/2
(2.7)
where the s[k] are the values of the symbols, and the function p(t) is the pulse
shape. Thus, each member of the 4-PAM data sequence is multiplied by a pulse
that is nonzero over the appropriate time window. Adding all the scaled pulses
results in an analog waveform that can be upconverted and transmitted. If the
channel is perfect (distortionless and noise-free), then the transmitted signal will
arrive unchanged at the receiver. Is the rectangular pulse shape a good idea?
Unfortunately, though rectangular pulse shapes are easy to understand, they
can be a poor choice for a pulse shape because they spread substantial energy
into adjacent frequencies. This spreading complicates the packing of users in
frequency division multiplexing, and makes it more dicult to avoid having
dierent messages interfere with each other.
To see this, dene the rectangular pulse
1 T /2 t T /2
(t) =
(2.8)
0
otherwise
as shown in Figure 2.10. The shifted pulses (2.8) are sometimes easier to work
with than (1.2), and their magnitude spectra are the same by virtue of the timeshifting property (A.37). The Fourier transform can be calculated directly from
the denition (2.1)
T /2
T /2
ej2f t
j2f t
j2f t
(t)e
dt =
(1)e
dt =
W (f ) =
j2f t=T /2
t=
t=T /2
=
sin(f T )
ejf T ejf T
=T
T sinc(f T ).
j2f
f T
(2.9)
32
1
Envelope
1/(x)
0.5
sinc(x)
0
8
pulses (weighted by the message values). As long as each individual pulse is zero
at all integer multiples of T , then the value sampled at those times is just the
value of the original pulse (plus many additions of zero). The rectangular pulse
of width T seconds satises this criterion, as does any other pulse shape that
is exactly zero outside a window of width T . But many other pulse shapes also
satisfy this condition, without being identically zero outside a window of width
T.
In fact, Figure 2.11 shows one such pulse shapethe sinc function itself! It is
zero at all integers4 (except at zero, where it is unity). Hence, the sinc can be
used as a pulse shape. As in (2.7), the shifted pulse shape is multiplied by each
member of the data sequence, and then added together. If the channel is perfect
(distortionless and noise-free), the transmitted signal will arrive unchanged at
the receiver. The original data can be recovered from the received waveform by
sampling at exactly the right times. This is one reason why timing synchronization is so important in digital systems. Sampling at the wrong times may garble
the data.
To assess the usefulness of the sinc pulse shape, consider its transform. The
Fourier transform of the rectangular pulse shape in the time domain is the sinc
function in the frequency domain. Analogously, the Fourier transform of the sinc
function in the time domain is a rectangular pulse in the frequency domain (see
(A.22)). Thus, the spectrum of the sinc is bandlimited, and so it is appropriate
for situations requiring bandlimited messages, such as FDM. Unfortunately, the
sinc is not entirely practical because it is doubly innite in time. In any real
implementation, it will need to be truncated.
The rectangular and the sinc pulse shapes give two extremes. Practical pulse
shapes compromise between a small amount of out-of-band content (in frequency) and an impulse response that falls o rapidly enough to allow reasonable truncation (in the time domain). Commonly used pulse shapes such as the
square-root raised cosine shape are described in detail in Chapter 11.
4
In other applications, it may be desirable to have the zero crossings occur at places other
than the integers. This can be done by suitably scaling the x.
A Telecommunication System
p1(t)
p2(t)
p3(t)
T/2
1
T/2
1
T/2
33
Exercise 2.9. Consider the three pulse shapes sketched in Figure 2.12 for a
T -spaced PAM system.
a. Which of the three pulse shapes in Figure 2.12 has the largest baseband power
bandwidth? Justify your answer.
b. Which of the three pulse shapes in Figure 2.12 has the smallest baseband
power bandwidth? Justify your answer.
Exercise 2.10. TRUE or FALSE: The atter the top of the pulse shape, the
less sensitive the receiver is to small timing osets. Explain your reasoning.
2.11
34
design (recall that the cosine wave used to demodulate the received signal in
(2.6) was aligned in both phase and frequency with the modulating sinusoid at
the transmitter), though the details of implementation may dier.
In many applications (such as cell phones), messages come in clusters called
packets, and each packet has a header (that is located in some agreed-upon
place within each data block) that contains important information. The process
of identifying where the header appears in the received signal is called frame
synchronization, and is often implemented using a correlation technique.
The point of view adopted in Software Receiver Design is that many of
these synchronization tasks can be stated quite simply as optimization problems.
Accordingly, many of the standard solutions to synchronization tasks can be
viewed as solutions to these optimization problems.
r The problem of clock (or timing) recovery can be stated as that of nding
a timing oset to maximize the energy of the received signal. Solving this
optimization problem via a gradient technique leads to a standard algorithm
for timing recovery.
The problem of carrier phase synchronization can be stated as that of nding
a phase oset to minimize a particular function of the modulated received
signal. Solving this optimization problem via a gradient technique leads to
the phase-locked loop, a standard method of carrier recovery.
Carrier phase synchronization can also be stated using an alternative performance function that leads directly to the Costas loop, another standard
method of carrier recovery.
2.12
Equalization
When all is well in the digital receiver, there is no interaction between adjacent
data values and all frequencies are treated equally. In most real wireless systems
(and many wired systems as well), however, the transmission channel causes
multiple copies of the transmitted symbols, each scaled dierently, to arrive at
the receiver at dierent times. This intersymbol interference can garble the data.
The channel may also attenuate dierent frequencies by dierent amounts. Thus
frequency selectivity can render the data indecipherable.
The solution to both of these problems is to build a lter in the receiver that
attempts to undo the eects of the channel. This lter, called an equalizer, cannot
A Telecommunication System
35
2.13
r The decoded signal b() is the nal (binary) output of the receiver.
If all goes well and the message is transmitted, received, and decoded successfully, then the output should be the same as the input, although there may be
some delay between the time of transmission and the time when the output is
available. When the output diers from the message, then errors have occurred
during transmission.
There are several ways to measure the quality of the system. For instance, the
symbol recovery error
e(kT ) = w((k )T ) m(kT )
measures the dierence between the message and the soft decision. The average
squared error,
M
1 2
e (kT ),
M
k=1
36
Binary
message
sequence b
{3, 1, 1, 3}
Coding
P( f )
Pulse
shaping
Analog
upconversion
Carrier
specification
Antenna
Analog
Digital downPulseconversion
conversion
matched
to IF
to baseband
filter
Analog
Ts
received
Input to the
Carrier
signal
software synchronization
receiver
Other FDM
Noise
users
Transmitted
signal
Channel
Reconstructed
message
m Q(m) {3, 1, 1, 3} ^
T
b
Downsampling Equalizer Decision
Decoding
Timing
synchronization
Source and
error coding,
with frame
synchronization
gives a measure of the performance of the system. This can be used as in Chapter
13 to adjust the parameters of an equalizer when the source message is known.
Alternatively, the dierence between the message w() and the quantized output
of the receiver Q{m()} can be used to measure the hard-decision error
e(kT ) = w((k )T ) Q{m(kT )}.
The decision-directed error replaces this with
e(kT ) = Q{m(kT )} m(kT ),
the error between the soft decisions and the associated hard decisions. This error
is used in Section 13.4 as a way to adjust the parameters in an equalizer when
the source message is unknown, as a way of adjusting the phase of the carrier in
Section 10.5, and as a way of adjusting the symbol timing in Section 12.3.
There are other useful indicators of the performance of digital communication
receivers. Let Tb be the bit duration (when there are two bits per symbol, Tb =
T /2). The indicator
1 if b((k )Tb ) = b(kTb )
c(kTb ) =
0 if b((k )Tb ) = b(kTb )
counts how many bits have been incorrectly received, and the bit error rate is
BER =
M
1
c(kTb ).
M
(2.10)
k=1
A Telecommunication System
37
percentage of typical listeners who can accurately decipher the output of the
receiver.
No matter what the exact form of the error measure, the ultimate goal is the
accurate and ecient transmission of the message.
2.14
38
2.15
A Telecommunication System
The complete system diagram, including the digital receiver that will be built in
this text, is shown in Figure 2.13. This system includes the following.
2.16
Stairway to Radio
The path taken by Software Receiver Design is to break down the telecommunication system into its constituent elements: the modulators and demodulators,
the samplers and lters, the coders and decoders. In the various tasks within
each chapter, you are asked to build a simulation of the relevant piece of the system. In the early chapters, the parts need to operate only in a pristine, idealized
environment, but as we progress, impairments and noises inevitably intrude. The
design evolves to handle the increasingly realistic scenarios.
A Telecommunication System
39
Throughout this text, we ask you to consider a variety of small questions, some
of which are mathematical in nature, most of which are what if questions best
answered by trial and simulation. We hope that this combination of reection
and activity will be useful in enlarging your understanding and in training your
intuition.
Three introductory texts that delay the introduction of probability until the
latter chapters are the following:
At rst glance, block diagrams such as the communication system shown in Figure 2.13 probably appear complex and intimidating. There are so many dierent
blocks and so many unfamiliar names and acronyms! Fortunately, all the blocks
can be built from six simple elements:
r signal generators such as oscillators, which create sine and cosine waves,
r linear time-invariant lters, which augment or diminish the amplitude of particular frequencies or frequency ranges in a signal,
r static nonlinearities such as squarers and quantizers, which can add frequency
content to a signal,
r adaptive elements, which track the desired values of parameters as they slowly
change over time.
This section provides a brief overview of these six elements. In doing so, it also
reviews some of the key ideas from signals and systems. Later chapters explore
how the elements work, how they can be modied to accomplish particular tasks
within the communication system, and how they can be combined to create a
large variety of blocks such as those that appear in Figure 2.13.
The elements of a communication system have inputs and outputs; the element
itself operates on its input signal to create its output signal. The signals that
form the inputs and outputs are functions that represent the dependence of some
variable of interest (such as a voltage, current, power, air pressure, temperature,
etc.) on time.
The action of an element can be described by the manner in which it operates
in the time domain, that is, how the element changes the input waveform
moment by moment into the output waveform. Another way of describing the
action of an element is by how it operates in the frequency domain, that is,
41
Amplitude
Amplitude
Time
Input signal as a
function of time
x(t)
X( f )
Time
Output signal as a
function of time
y(t)
Y( f )
Element
Frequency
The magnitude spectrum
shows the frequency context
of the input signal
Output signal as a
function of frequency
Magnitude
Magnitude
Input signal as a
function of frequency
Frequency
The magnitude spectrum
shows the frequency content
of the output signal
by how the frequency content of the input relates to the frequency content of
the output. Figure 3.1 illustrates these two complementary ways of viewing the
elements. Understanding both the time-domain and frequency-domain behavior
is essential. Accordingly, the following sections describe the action of the six
elements in both time and frequency.
Readers who have studied signals and systems (as is often required in electrical engineering degrees) will recognize that the time-domain representation
of a signal and its frequency-domain representation are related by the Fourier
transform, which is briey reviewed in the next section.
3.1
42
the signal is dened by measurements of some physical process. For instance, the
signal might be the waveform at the input to the receiver, the output of a linear
lter, or a sound waveform encoded as an MP3 le. In all these cases, it is not
possible to nd the spectrum by calculating a Fourier transform since the signal
is not known in analytical form.
Rather, the discrete Fourier transform (and its cousin, the more rapidly computable fast Fourier transform, or FFT) can be used to nd the spectrum or frequency content of a measured signal. The Matlab function plotspec.m, which
plots the spectrum of a signal, is available on the website. Its help le1 notes
% p l o t s p e c ( x , Ts ) p l o t s th e spectrum o f x
% Ts=time ( i n s e c s ) between a d j a c e n t s a m p l e s
The function plotspec.m is easy to use. For instance, the spectrum of a square
wave can be found using the following sequence:
Listing 3.1. specsquare.m plot the spectrum of a square wave
f =10;
time =2;
Ts =1/1000;
t=Ts : Ts : time ;
x=sign ( cos (2 * pi * f * t ) ) ;
p l o t s p e c ( x , Ts )
%
%
%
%
%
%
frequency of square
l e n g t h o f time
time i n t e r v a l between
c r e a t e a time v e c t o r
s q u a r e wave = s i g n o f
c a l l p l o t s p e c to draw
wave
s a m p l es
c o s wave
spectrum
The output of specsquare.m is shown2 in Figure 3.2. The top plot shows time=2
seconds of a square wave with f=10 cycles per second. The bottom plot shows a
series of spikes that dene the frequency content. In this case, the largest spike
occurs at 10 Hz, followed by smaller spikes at all the odd-integer multiples (i.e.,
at 30, 50, 70, etc.).
Similarly, the spectrum of a noise signal can be calculated as
Listing 3.2. specnoise.m plot the spectrum of a noise signal
time =1;
Ts =1/10000;
x=randn ( 1 , time /Ts ) ;
p l o t s p e c ( x , Ts )
%
%
%
%
l e n g t h o f time
time i n t e r v a l between s a m p l es
Ts p o i n t s o f n o i s e f o r time s e c o n d s
c a l l p l o t s p e c to draw spectrum
A typical run of specnoise.m is shown in Figure 3.3. The top plot shows
the noisy signal as a function of time, while the bottom shows the magnitude
spectrum. Because successive values of the noise are generated independently, all
frequencies are roughly equal in magnitude. Each run of specnoise.m produces
plots that are qualitatively similar, though the details will dier.
1
You can view the help le for the Matlab function xxx by typing help xxx at the Matlab
prompt. If you get an error such as xxx not found, then this means either that the function
does not exist, or that it needs to be moved into the same directory as the Matlab application. If you dont know what the proper command to do a job is, then use lookfor. For
instance, to nd the command that inverts a matrix, type lookfor inverse. You will nd
the desired command inv.
All code listings in Software Receiver Design can be found on the website. We encourage
you to open Matlab and explore the code as you read.
Amplitude
1
0.5
0
0.5
1
0
Magnitude
43
0.2 0.4
0.6
1.6
1.8
1200
800
400
0
Exercise 3.4. Matlab has several commands that create random numbers.
a. Use rand to create a signal that is uniformly distributed on [1, 1]. Find the
spectrum of the signal by mimicking the code in specnoise.m.
b. Use rand and the sign function to create a signal that is +1 with probability
1/2 and 1 with probability 1/2. Find the spectrum of the signal.
c. Use randn to create a signal that is normally distributed with mean 0 and
variance 3. Find the spectrum of the signal.
44
Amplitude
4
2
0
2
Magnitude
0.2
0.4
0.6
Seconds
0.8
300
200
100
0
4000
2000
0
Frequency
2000
4000
Exercise 3.5. Modify the code in plotspec.m to also plot the phase spectrum.
a. Plot the phase spectrum of a sine wave and a cosine wave, both of the same
frequency. How do they dier?
b. Plot the phase spectrum of the random signal created in Exercise 3.4(a).
While plotspec.m can be quite useful, ultimately, it will be necessary to have
more exibility, which, in turn, requires one to understand how the FFT function
inside plotspec.m works. This will be discussed at length in Chapter 7. The
next six sections describe the six elements that are at the heart of communications systems. The elements are described both in the time domain and in the
frequency domain.
3.2
cos(2f0t+(t))
(t)
Amplitude
1
0.5
0
0.5
1
120
Magnitude
45
80
40
0
50 40 30 20 10 0 10
Frequency
20
30
40
50
There are many ways to build oscillators from analog components. Generally,
there is an amplier and a feedback circuit that returns a portion of the amplied
wave back to the input. When the feedback is aligned properly in phase, sustained
oscillations occur.
Digital oscillators are simpler. Since they can be directly calculated, no amplier or feedback is needed. For example, a digital sine wave of frequency f Hz
and a phase of radians can be represented mathematically as
s(kTs ) = cos(2f kTs + ),
(3.1)
%
%
%
%
%
%
s p e c i f y f r e q u e n c y and phase
l e n g t h o f time
time i n t e r v a l between s a m p l es
c r e a t e a time v e c t o r
c r e a t e c o s wave
draw waveform and spectrum
The output of speccos.m is shown in Figure 3.5. As expected, the time plot
shows an undulating sinusoidal signal with f = 10 repetitions in each second.
The spectrum shows two spikes, one at f = 10 Hz and one at f = 10 Hz. Why
are there two spikes? Basic Fourier theory shows that the Fourier transform of
a cosine wave is a pair of delta functions at plus and minus the frequency of the
cosine wave (see Equation (A.18)). The two spikes of Figure 3.5 mirror these
two delta functions. Alternatively, recall that a cosine wave can be written using
Eulers formula as the sum of two complex exponentials, as in (A.2). The spikes of
Figure 3.5 represent the magnitudes of these two (complex-valued) exponentials.
46
3.3
f
f
is
is
is
is
a
a
a
a
function
function
function
function
of
of
of
of
time.
time.
time.
time.
Try
Try
Try
Try
(t) = 10t.
(t) = t2 .
f (t) = sin(2t).
f (t) = t2 .
47
X( f ) Mag.
Figure 3.6 A white
Y1( f )
Freq.
White input
f*
f*
y1(t)
LPF
f*
x(t)
f*
Y2( f )
f*f*
f* f*
BPF
y2(t)
f*f*
f* f*
Y3( f )
f*
f*
f*
HPF
f*
y3(t)
Figure 3.6 shows the action of ideal lters. How close are actual implementations? The Matlab code in filternoise.m shows that it is possible to create
digital lters that reliably and accurately carry out these tasks.
Listing 3.4. filternoise.m lter a noisy signal three ways
time =3;
Ts =1/10000;
x=randn ( 1 , time /Ts ) ;
f i g u r e ( 1 ) , p l o t s p e c ( x , Ts )
f r e q s =[0 0 . 2 0 . 2 1 1 ] ;
amps=[1 1 0 0 ] ;
b=f i r p m ( 1 0 0 , f r e q s , amps ) ;
y l p=f i l t e r ( b , 1 , x ) ;
f i g u r e ( 2 ) , p l o t s p e c ( ylp , Ts )
f r e q s =[0 0 . 2 4 0 . 2 6 0 . 5 0 . 5 1 1 ] ;
amps=[0 0 1 1 0 0 ] ;
b=f i r p m ( 1 0 0 , f r e q s , amps ) ;
ybp=f i l t e r ( b , 1 , x ) ;
f i g u r e ( 3 ) , p l o t s p e c ( ybp , Ts )
f r e q s =[0 0 . 7 4 0 . 7 6 1 ] ;
amps=[0 0 1 1 ] ;
b=f i r p m ( 1 0 0 , f r e q s , amps ) ;
yhp=f i l t e r ( b , 1 , x ) ;
f i g u r e ( 4 ) , p l o t s p e c ( yhp , Ts )
%
%
%
%
l e n g t h o f time
time i n t e r v a l between s a m p l es
generate noise s i gnal
draw spectrum o f i n p u t
% s p e c i f y th e LP f i l t e r
% do th e f i l t e r i n g
% p l o t th e o u t p u t spectr um
% BP f i l t e r
% do th e f i l t e r i n g
% p l o t th e o u t p u t spectr um
% s p e c i f y th e HP f i l t e r
% do th e f i l t e r i n g
% p l o t th e o u t p u t spectr um
The output of filternoise.m is shown in Figure 3.7. Observe that the spectra at the output of the lters are close approximations to the ideals shown in
Figure 3.6. There are some dierences, however. While the idealized spectra are
completely at in the passband, the actual ones are rippled. While the idealized
spectra completely reject the out-of-band frequencies, the actual ones have small
(but nonzero) energy at all frequencies. Two new Matlab commands are used
in filternoise.m. The firpm command species the contour of the lter as a
line graph (Octave and early versions of Matlab call this command remez). For
instance, typing
plot ( [ 0 0 . 2 4 0 . 2 6 0 . 5 0 . 5 1 1 ] , [ 0 0 1 1 0 0 ] )
48
4000
2000
0
2000
4000
Magnitude spectrum at output of highpass filter
at the Matlab prompt draws a box that represents the action of the BPF
designed in filternoise.m (over the positive frequencies). The frequencies
are specied as percentages of fN Y Q = 1/(2Ts ), which in this case is equal to
5000 Hz. (fN Y Q is discussed further in the next section.) Thus the BPF in
filternoise.m passes frequencies between 0.265000 Hz and 0.55000 Hz, and
rejects all others. The filter command uses the output of firpm to carry out
the ltering operation on the vector specied in its third argument. More details
about these commands are given in the section on practical ltering in Chapter 7.
Exercise 3.9. Mimic the code in filternoise.m to create a lter that
a. passes all frequencies above 500 Hz,
b. passes all frequencies below 3000 Hz,
c. rejects all frequencies between 1500 and 2500 Hz.
Exercise 3.10. Change the sampling rate to Ts=1/20000. Redesign the three
lters from Exercise 3.9.
Exercise 3.11. Let x1 (t) be a cosine wave of frequency f = 800, x2 (t) be a cosine
wave of frequency f = 2000, and x3 (t) be a cosine wave of frequency f = 4500.
Let x(t) = x1 (t) + 0.5 x2 (t) + 2 x3 (t). Use x(t) as input to each of the three
lters in filternoise.m. Plot the spectra, and explain what you see.
Exercise 3.12. TRUE or FALSE: A linear, time-invariant system exists that
has input a cos(bt) and output c sin(dt) with a = c and |b| = |d|. Explain.
Exercise 3.13. TRUE or FALSE: Filtering a passband signal with absolute
bandwidth B through certain xed linear lters can result in an absolute bandwidth of the lter output greater than B. Explain.
49
Exercise 3.14. TRUE or FALSE: A linear, time-invariant, nite-impulseresponse lter with a frequency response having unit magnitude over all frequencies and a straight-line, sloped phase curve has as its transfer function a
pure delay. Explain.
Exercise 3.15. TRUE or FALSE: Processing a bandlimited signal through a
linear, time-invariant lter can increase its half-power bandwidth. Explain.
3.4
=
T s)
]
x[1
x(
)=
]
x[2
Ts
x(2
x(t)
3
x[
Ts
]
x[4
Ts
x(4
)=
Ts
x(kTs) = x[k]
3
x(
x(t)
)=
(a)
Ts
2Ts
3Ts
4Ts
(b)
Figure 3.8 The sampling process is shown in (b) as an evaluation of the signal x(t) at
times . . . , 2Ts , Ts , 0, Ts , 2Ts , . . .. This procedure is schematized in (a) as an element
that has the continuous-time signal x(t) as input and the discrete-time signal x(kTs )
as output.
50
Periodic in time
P
f=
...
...
1
P
f 2f 3f 4f 5f
Fourier Transform
Ts
...
fs =
Uniform sampling in time
1 3f
s
Ts
2
...
fs
2
fs
2
3fs
2
Periodic in frequency
Figure 3.9 Fouriers result says that any signal that is periodic in time has a spectrum
illustrated in the top portion of Figure 3.9, which shows the time-domain representation on the left and the corresponding frequency-domain representation on
the right.
The basic insight from Fourier series is that any signal which is periodic in
time can be reexpressed as a collection of uniformly spaced spikes in frequency;
that is,
Periodic in Time Uniform Sampling in Frequency.
The same arguments show the basic result of sampling, which is that
Uniform Sampling in Time Periodic in Frequency.
Thus, whenever a signal is uniformly sampled in time (say, with sampling interval
Ts seconds), the spectrum will be periodic; that is, it will repeat every fs = 1/Ts
Hz.
Two conventions are often observed when drawing periodic spectra that arise
from sampling. First, the spectrum is usually drawn centered at 0 Hz. Thus, if
the period of repetition is fs , this is drawn from fs /2 to fs /2, rather than from
0 to fs . This makes sense because the spectra of individual real-valued sinusoidal
components contain two spikes symmetrically located around 0 Hz (as we saw in
Section 3.2). Accordingly, the highest frequency that can be represented unambiguously is fs /2, and this frequency is often called the Nyquist frequency fN Y Q .
The second convention is to draw only one period of the spectrum. After all,
the others are identical copies that contain no new information. This is evident
x[k]
y[i]
51
in the bottom right diagram of Figure 3.9 where the spectrum between 3fs /2
and fs /2 is the same as the spectrum between fs /2 and 3fs /2. In fact, we
have been observing this convention throughout Sections 3.2 and 3.3, since all
of the gures of spectra (Figures 3.2, 3.3, 3.5, and 3.7) show just one period of
the complete spectrum.
Perhaps you noticed that plotspec.m changes the frequency axis when the
sampling interval Ts is changed. (If not, go back and redo Exercise 3.1(c).) By
the second convention, plotspec.m shows exactly one period of the complete
spectrum. By the rst convention, the plots are labeled from fN Y Q to fN Y Q .
What happens when the frequency of the signal is too high for the sampling
rate? The representation becomes ambiguous. This is called aliasing, and is investigated by simulation in the problems below. Aliasing and other sampling-related
issues (such as reconstructing an analog signal from its samples) are covered in
more depth in Chapter 6.
Closely related to the digital sampling of an analog signal is the (digital)
downsampling of a digital signal, which changes the rate at which the signal is
represented. The simplest case downsamples by a factor of m, removing all but
one out of every m samples. This can be written
y[i] = x[im + n],
where n is an integer between 0 and m 1. For example, with m = 3 and n = 1,
y[i] is the sequence that consists of every third value of x[k],
y[0] = x[1], y[1] = x[4], y[2] = x[7], y[3] = x[10], etc.
This is commonly drawn in block form as in Figure 3.10. If the spectrum of x[k]
is bandlimited to 1/m of the Nyquist rate, then downsampling by m loses no
information. Otherwise, aliasing occurs. Like analog-to-digital sampling, downsampling is a time-varying operation.
Exercise 3.16. Mimicking the code in speccos.m with the sampling interval
Ts=1/100, nd the spectrum of a cosine wave cos(2f t) when f=30, 40, 49,
50, 51, 60 Hz. Which of these show aliasing?
Exercise 3.17. Create a cosine wave with frequency 50 Hz. Plot the spectrum when this wave is sampled at Ts=1/50, 1/90, 1/100, 1/110, and 1/200.
Which of these show aliasing?
Exercise 3.18. Mimic the code in speccos.m with sampling interval Ts=1/100
to nd the spectrum of a square wave with fundamental f=10, 20, 30, 33,
52
43 Hz. Can you predict where the spikes will occur in each case? Which of the
square waves show aliasing?
3.5
53
Exercise 3.23. Suppose that the output of a nonlinear block is the rectication
(absolute value) of the input y(t) = |x(t)|. Find the spectrum of the output when
the input is
a. x(t) = cos(2f t) for f = 100 Hz,
b. x(t) = cos(2f1 t) + cos(2f2 t) for f1 = 100 and f2 = 125 Hz.
c. Repeat (b) for f1 = 110 and f2 = 200 Hz. Can you predict what frequencies
will be present for any f1 and f2 ?
d. What frequencies will be present if x(t) is the sum of three sinusoids f1 , f2 ,
and f3 ?
Exercise 3.24. Suppose that the output of a nonlinear block is y(t) = g(x(t)),
where
1 x(t) > 0
g(t) =
1 x(t) 0
is a quantizer that outputs plus one when the input is positive and minus one
when the input is negative. Find the spectrum of the output when the input is
a. x(t) = cos(2f t) for f = 100 Hz,
b. x(t) = cos(2f1 t) + cos(2f2 t) for f1 = 100 and f2 = 150 Hz.
Exercise 3.25. Quantization of an input is another kind of common nonlinearity. The Matlab function quantalph.m (available on the website) quantizes a
signal to the nearest element of a desired set. Its help le reads
%
%
%
%
%
%
%
%
%
y=q u a n t a l p h ( x , a l p h a b e t )
q u a n t i z e th e i n p u t s i g n a l x to th e a l p h a b e t
u s i n g n e a r e s t n e i g h b o r method
i n p u t x v e c t o r to be q u a n t i z e d
alphabet vector of d i s c r e t e values
t h a t y can assume
sorted in ascending order
output y quantized v ecto r
3.6
54
speech occurs in the range below about 8 kHz. In order to transmit this, it is
upconverted (as in Section 2.3) to radio frequencies at which the energy can
easily propagate over long distances. At the receiver, it is downconverted (as in
Section 2.6) to the original frequencies. Thus the spectrum is shifted twice.
One way of accomplishing this kind of frequency shifting is to multiply the
signal by a cosine wave, as shown in Figure 3.11. The following Matlab code
implements a simple modulation.
Listing 3.5. modulate.m change the frequency of the input
time = . 5 ; Ts =1/10000;
t=Ts : Ts : time ;
f c =1000; cmod=cos (2 * pi * f c * t ) ;
f i =100; x=cos (2 * pi * f i * t ) ;
y=cmod . * x ;
f i g u r e ( 1 ) , p l o t s p e c ( cmod , Ts )
f i g u r e ( 2 ) , p l o t s p e c ( x , Ts )
f i g u r e ( 3 ) , p l o t s p e c ( y , Ts )
%
%
%
%
%
%
time and s a m p l i n g i n t e r v a l
d e f i n e a time v e c t o r
cr eate cos of f r eq f c
input i s cos of f r eq f i
m u l t i p l y i n p u t by cmod
f i n d s p e c t r a and p l o t
The rst three lines of the code create the modulating sinusoid (i.e., an oscillator).
The next line species the input (in this case another cosine wave). The Matlab
syntax .* calculates a point-by-point multiplication of the two vectors cmod and
x.
The output of modulate.m is shown in Figure 3.12. The spectrum of the input
contains spikes representing the input sinusoid at 100 Hz and the spectrum
of the modulating sinusoid contains spikes at 1000 Hz. As expected from the
modulation property of the transform, the output contains sinusoids at 1000
100 Hz, which appear in the spectrum as the two pairs of spikes at 900 and
1100 Hz. Of course, this modulation can be applied to any signal, not just to
an input sinusoid. In all cases, the output will contain two copies of the input,
one shifted up in frequency and the other shifted down in frequency.
Exercise 3.26. Mimic the code in modulate.m to nd the spectrum of the output
y(t) of a modulator block (with modulation frequency fc = 1000 Hz) when
a.
b.
c.
d.
e.
the
the
the
the
the
input
input
input
input
input
is
is
is
is
is
x(t)
cos(2f0t+)
x(t) cos(2f0t+)
55
3.7
Input
Output
Quality
Assessment
56
3.8
Summary
The bewildering array of blocks and acronyms in a typical communication system
diagram really consists of just a handful4 of simple elements: oscillators, linear
lters, samplers, static nonlinearities, mixers, and adaptive elements. For the
most part, these are ideas that the reader will have encountered to some degree in
previous studies, but they have been summarized here in order to present them in
the same form and using the same notation as in later chapters. In addition, this
chapter has emphasized the how-to aspects by providing a series of Matlab
exercises, which will be useful when creating simulations of the various parts of
a receiver.
57
There are also many wonderful books about digital signal processing, and these
provide both depth and detail about basic issues such as sampling and lter
design. Some of the best are the following:
The next step encompasses Chapters 4 through 9. This gives a closer look at
the idealized receiverhow things work when everything is just right: when the
timing is known, when the clocks run at exactly the right speed, when there are
no reections, diractions, or diusions of the electromagnetic waves. This step
also introduces a few Matlab tools that are needed to implement the digital
radio. The order in which topics are discussed is precisely the order in which
they appear in the receiver:
frequency
channel translation sampling
Chapter 4
Chapter 5
Chapter 6
receive
decision
equalization
decoding
ltering
device
Chapter 7
Chapter 8
Chapter 9 provides a complete (though idealized) software-dened digital radio
system.
Modeling Corruption
If every signal that went from here to there arrived at its intended receiver
unchanged, the life of a communications engineer would be easy. Unfortunately,
the path between here and there can be degraded in several ways, including
multipath interference, changing (fading) channel gains, interference from other
users, broadband noise, and narrowband interference.
This chapter begins by describing some of the funny things that can happen
to signals, some of which are diagrammed in Figure 4.1. More important than
locating the sources of the problems is xing them. The received signal can
be processed using linear lters to help reduce the interferences and to undo,
to some extent, the eects of the degradations. The central question is how to
specify lters that can successfully mitigate these problems, and answering this
requires a fairly detailed understanding of ltering. Thus, a discussion of linear
lters occupies the bulk of this chapter, which also provides a background for
other uses of lters throughout the receiver, such as the lowpass lters used in the
demodulators of Chapter 5, the pulse-shaping and matched lters of Chapter 11,
and the equalizing lters of Chapter 13.
4.1
60
Types of corruption
Transmitted
signal
Multipath
4.1.1
Changing
gain
corruption include
multipath interference,
changing channel gains,
interference from other
users, broadband noise,
and narrowband
interferences.
Other Users
Many dierent users must be able to broadcast at the same time. This requires
that there be a way for a receiver to separate the desired transmission from all
the others (for instance, to tune to a particular radio or TV station among a
large number that may be broadcasting simultaneously in the same geographical
region). One standard method is to allocate dierent frequency bands to each
user. This was called frequency-division multiplexing (FDM) in Chapter 2, and
was shown diagrammatically in Figure 2.3 on page 22. The signals from the
dierent users can be separated using a bandpass lter, as in Figure 2.4 on page
23. Of course, practical lters do not completely remove out-of-band signals, nor
do they pass in-band signals completely without distortions. Recall the three
lters in Figure 3.7 on page 48.
4.1.2
Broadband Noise
When the signal arrives at the receiver, it is small and must be amplied. While
it is possible to build high-gain ampliers, the noises and interferences will also
be amplied along with the signal. In particular, any noise in the amplier itself
will be increased. This is often called thermal noise and is usually modeled as
white (independent) broadband noise. Thermal noise is inherent in any electronic
component and is caused by small random motions of electrons, like the Brownian
motion of small particles suspended in water.
Such broadband noise is another reason why a bandpass lter is applied at
the front end of the receiver. By applying a suitable lter, the total power in
the noise (compared with the total power in the signal) can often be reduced.
Figure 4.2 shows the spectrum of the signal as a pair of triangles centered at the
carrier frequency fc with bandwidth 2B. The total power in the signal is the
area under the triangles. The spectrum of the noise is the at region, and its
power is the shaded area. After applying the bandpass lter, the power in the
signal remains (more or less) unchanged, while the power in the noise is greatly
reduced. Thus, the signal-to-noise ratio (SNR) improves.
Modeling Corruption
Power
in noise
fc B
fc + B
fc B
fc + B
(a)
(b)
fc B
4.1.3
fc + B
0
(c)
Power
in signal
fc B
fc + B
fc B
fc + B
Total
power in noise
is decreased
fc B
61
Power
in signal
is unchanged
fc + B
Narrowband Noise
Noises are not always white; that is, the spectrum need not always be at. Stray
sine waves (and other signals with narrow spectra) may also impinge on the
receiver. These may be caused by errant transmitters that accidentally broadcast in the frequency range of the signal, or they may be harmonics of a lowerfrequency wave as it experiences nonlinear distortion. If these narrowband disturbances occur out of band, they will automatically be attenuated by the bandpass
lter just as if they were a component of the wideband noise. However, if they
occur in the frequency region of the signal, they decrease the SNR in proportion
to their power. Judicious use of a notch lter (one designed to remove just the
oending frequency) can be an eective tool.
Figure 4.3 shows the spectrum of the signal as the pair of triangles, along with
three narrowband interferers represented by the three pairs of spikes. After the
bandpass lter (BPF), the two pairs of out-of-band spikes are removed, but the
in-band pair remains. Applying a narrow notch lter tuned to the frequency
of the interferer allows its removal, although this cannot be done without also
aecting the signal somewhat.
4.1.4
Multipath Interference
In some situations, an electromagnetic wave can propagate directly from one
place to another. For instance, when a radio signal from a spacecraft is transmitted back to Earth, the vacuum of space guarantees that the wave will arrive
more or less intact (though greatly attenuated by distance). Often, however, the
wave reects, refracts, or diracts, and the signal arriving is quite dierent from
the one that was sent.
62
BPF
Removal of
out-of-band
interferers
Notch
filter
Removal of
in-band
interferers also
modifier signals
(4.1)
As will become clear in Section 4.4, this model of the channel has the form of
a linear lter (since the expression on the right-hand side is a convolution of
the transmitted signal and the hi s). This is shown in part (a) of Figure 4.5.
Since this channel model is a linear lter, it can also be viewed in the frequency
domain, and part (b) shows its frequency response. When this is combined with
the BPF and the spectrum of the signal (shown in (c)), the result is the distorted
spectrum shown in (d).
What can be done?
Modeling Corruption
63
Cloud
Buildings
Line of sigh
Receiver
Transmitter
Mountain
Transmitted
signal
(a)
Received
signal
h(t)
Fourier Transform
H( f )
(b)
(c)
(d)
Frequency
If the kinds of distortions introduced by the channel are known (or can somehow be determined), then the bandpass lter at the receiver can be modied
in order to undo the eects of the channel. This can be seen most clearly in
the frequency domain, as in Figure 4.6. Observe that the BPF is shaped (part
(d)) to approximately invert the debilitating eects of the channel (part (a)) in
the frequency band of the signal and to remove all the out-of-band frequencies.
The resulting received signal spectrum (part (e)) is again a close copy of the
transmitted signal spectrum, in stark contrast to the received signal spectrum
in Figure 4.5 where no shaping was attempted.
64
Frequency
response of
channel
(a)
Spectrum
of
signal
(b)
Product of
(a) & (b)
(c)
BPF with
shaping
(d)
Product of
(c) & (d)
(e)
Figure 4.6 (a) The frequency response of the channel. (b) The spectrum of the signal.
(c) The product of (a) and (b), which is the spectrum of the received signal. (d) A
BPF lter that has been shaped to undo the eect of the channel. (e) The product of
(c) and (d), which combine to give a clean representation of the original spectrum of
the signal.
Thus, ltering in the receiver can be used to reshape the received signal within
the frequency band of the transmission as well as to remove unwanted out-ofband frequencies.
4.1.5
Fading
Another kind of corruption that a signal may encounter on its journey from the
transmitter to the receiver is called fading, where the frequency response of the
channel changes slowly over time. This may be caused because the transmission
path changes. For instance, a reection from a cloud might disappear when the
cloud dissipates, an additional reection might appear when a truck moves into a
narrow city street, or in a mobile device such as a cell phone the operator might
turn a corner and cause a large change in the local geometry of reections.
Fading may also occur when the transmitter and/or the receiver are moving.
The Doppler eect shifts the frequencies slightly, causing interferences that may
slowly change.
Such time-varying problems cannot be xed by a single xed lter; rather, the
lter must somehow compensate dierently at dierent times. This is an ideal
application for the adaptive elements of Section 3.7, though results from the
study of linear lters will be crucial in understanding how the time variations
Modeling Corruption
65
4.2
r The impulse response h(t) is a function of time that denes the output of a
linear system when the input is an impulse (or ) function. When the input
to the linear system is more complicated than a single impulse, the output
can be calculated from the impulse response via the convolution operator.
The frequency response H(f ) is a function of frequency that denes how the
spectrum of the input is changed into the spectrum of the output. The frequency response and the impulse response are intimately related: H(f ) is the
Fourier transform of h(t).
A linear dierence equation with constant coecients (such as (4.1)) shows
explicitly how the linear system can be implemented and can be useful in
assessing stability and performance.
This chapter describes the three representations of linear systems and shows
how they interrelate. The discussion begins by exploring the function, and then
showing how it is used to dene the impulse response. The convolution property
of the Fourier transform then shows that the transform of the impulse response
describes how the system behaves in terms of the input and output spectra, and
so it is called the frequency response. The nal step is to show how the action
of the linear system can be redescribed in the time domain as a dierence (or as
a dierential) equation. This is postponed to Chapter 7, and is also discussed in
some detail in Appendix F.
4.3
66
over a very short amount of time, yet must be energetic in order to have any
eect. This section denes the impulse (or delta) function (t), which is a useful
kick for the study of linear systems.
The criterion that the impulse be energetic is translated to the mathematical
statement that its integral over all time must be nonzero, and it is typically
scaled to unity, that is,
(t)dt = 1.
(4.2)
The criterion that it occur over a very short time span is translated to the
statement that, for every positive ,
0 t < ,
(t) =
(4.3)
0 t > .
Thus, the impulse (t) is explicitly dened to be equal to zero for all t = 0. On
the other hand, (t) is implicitly dened when t = 0 by the requirement that its
integral be unity. Together, these guarantee that (t) is no ordinary function.1
The most important consequence of the denitions (4.2) and (4.3) is the sifting
property
w(t)(t t0 )dt = w(t)|t=t0 = w(t0 ),
(4.4)
which says that the delta function picks out the value of the function w(t) from
under the integral at exactly the time when the argument of the function is
zero, that is, when t = t0 . To see this, observe that (t t0 ) is zero whenever
t = t0 , and hence w(t)(t t0 ) is zero whenever t = t0 . Thus,
w(t)(t t0 )dt =
w(t0 )(t t0 )dt
0 t < 1/(2n),
n (t) = n 1/(2n) t 1/(2n),
0 t > 1/(2n).
Then (t) = limn n (t) fullls both criteria (4.2) and (4.3). Informally, it is not
unreasonable to think of (t) as being zero everywhere except at t = 0, where it is
innite. While it is not really possible to plot the delta function (t t0 ), it can
be represented in graphical form as zero everywhere except for an up-pointing
arrow at t0 . When the function is scaled by a constant, the value of the constant
is often placed in parentheses near the arrowhead. Sometimes, when the constant
1
The impulse is called a distribution and is the subject of considerable mathematical investigation.
Modeling Corruption
67
(3)
Figure 4.7 The function w(t) = (t + 10)
(1)
10
10
(2)
is negative, the arrow is drawn pointing down. For instance, Figure 4.7 shows a
graphical representation of the function w(t) = (t + 10) 2(t + 1) + 3(t 5).
What is the spectrum (Fourier transform) of (t)? This can be calculated
directly from the denition by replacing w(t) in (2.1) with (t):
(t)ej2f t dt.
(4.5)
F {(t)} =
Apply the sifting property (4.4) with w(t) = ej2f t and t0 = 0. Thus F {(t)} =
ej2f t |t=0 = 1.
Alternatively, suppose that is a function of frequency, that is, a spike at
zero frequency. The corresponding time-domain function can be calculated analogously using the denition of the inverse Fourier transform, that is, by substituting (f ) for W (f ) in (A.16) and integrating:
(f )ej2f t df = ej2f t |f =0 = 1.
F 1 {(f )} =
%
%
%
%
%
%
l e n g t h o f time
time i n t e r v a l between s a m p l es
c r e a t e time v e c t o r
create si gnal of a l l zeros
delta function
draw waveform and spectrum
Amplitude
Magnitude
68
0
0
0.2
0.4 0.6
1.6 1.8
1
0
40 30 20 10 0 10
Frequency
20
30
40
Exercise 4.2. Use the denition of the IFT (A.16) to show that
(f f0 ) ej2f0 t .
1
(t kTs )
(f nfs ),
(4.6)
Ts n=
k=
Modeling Corruption
69
|W( f )|
(A/2)
f0
(A/2)
f0
Example 4.1. Let w(t) = A sin(2f0 t), and use Eulers identity (A.3) to rewrite
w(t) as
w(t) =
A j2f0 t
e
ej2f0 t .
2j
Applying the linearity property (A.31) and the result of Exercise 4.2 gives
A
F {ej2f0 t } F{ej2f0 t }
2j
A
= j [(f f0 ) + (f + f0 )] .
2
F {w(t)} =
(4.7)
Thus, the spectrum of a sine wave is a pair of functions with opposite signs,
located symmetrically about zero frequency. The corresponding magnitude spectrum, shown in Figure 4.9, is at the heart of one important interpretation of the
Fourier transform: it shows the frequency content of any signal by displaying
which frequencies are present in (and absent from) the waveform. For example,
Figure 4.10(a) shows the magnitude spectrum W (f ) of a real-valued signal w(t).
This can be interpreted as saying that w(t) contains (or is made up of) all the
frequencies up to B Hz, and that it contains no sinusoids with higher frequency.
Similarly, the modulated signal s(t) in Figure 4.10(b) contains all positive frequencies between fc B and fc + B, and no others.
Note that the Fourier transform in (4.7) is purely imaginary, as it must be
because w(t) is odd (see (A.37)). The phase spectrum is a at line at 90
because of the factor j.
Exercise 4.6. What is the magnitude spectrum of sin(2f0 t + )? Hint: use the
frequency-shift property (A.34). Show that the spectrum of cos(2f0 t) is 12 ((f
f0 ) + (f + f0 )). Compare this analytical result with the numerical results from
Exercise 3.6.
Exercise 4.7. Let wi (t) = ai sin(2fi t) for i = 1, 2, 3. Without doing any calculations, write down the spectrum of v(t) = w1 (t) + w2 (t) + w3 (t). Hint: use
linearity. Graph the magnitude spectrum of v(t) in the same manner as in Figure 4.9. Verify your results with a simulation mimicking that in Exercise 3.7.
70
|W( f )|
1
|S( f )|
1/2
+B
(a)
fc B
fc
fc + B
fc B
fc
fc + B
(b)
Figure 4.10 The magnitude spectrum of a message signal w(t) is shown in (a). When
4.4
This integral denes the convolution operator and provides a way of nding
the output y(t) of any linear system, given its impulse response h(t) and the
input x(t).
Matlab has several functions that simplify the numerical evaluation of convolutions. The most obvious of these is conv, which is used in convolex.m to
calculate the convolution of an input x (consisting of two delta functions at times
t = 1 and t = 3) and a system with impulse response h that is an exponential
pulse. The convolution gives the output of the system.
Listing 4.2. convolex.m example of numerical convolution
Ts =1/100; time =10;
t =0:Ts : time ;
h=exp( t ) ;
x=zeros ( s i z e ( t ) ) ;
%
%
%
%
s a m p l i n g i n t e r v a l and t o t a l time
c r e a t e time v e c t o r
def i ne impulse response
i n p u t = sum o f two d e l t a f u n c t i o n s
Modeling Corruption
71
Input
3
2
1
Impulse response
0
1
0.5
0
Output
3
2
1
0
0
3
4
5
Time in seconds
x (1 / Ts )=3; x (3 / Ts )=2;
% a t t i m e s t=1 and t=3
y=conv ( h , x ) ;
% do c o n v o l u t i o n
subplot ( 3 , 1 , 1 ) , plot ( t , x )
% and p l o t
subplot ( 3 , 1 , 2 ) , plot ( t , h )
subplot ( 3 , 1 , 3 ) , plot ( t , y ( 1 : length ( t ) ) )
Figure 4.11 shows the input to the system in the top plot, the impulse response
in the middle plot, and the output of the system in the bottom plot. Nothing
happens before time t = 1, and the output is zero. When the rst spike occurs,
the system responds by jumping to 3 and then decaying slowly at a rate dictated
by the shape of h(t). The decay continues smoothly until time t = 3, when the
second spike enters. At this point, the output jumps up by 2, and is the sum of
the response to the second spike, plus the remainder of the response to the rst
spike. Since there are no more inputs, the output slowly dies away.
Exercise 4.9. Suppose that the impulse response h(t) of a linear system is the
exponential pulse
t
t 0,
e
(4.9)
h(t) =
0
t < 0.
Suppose that the input to the system is 3(t 1) + 2(t 3). Use the denition
of convolution (4.8) to show that the output is 3h(t 1) + 2h(t 3), where
t+t
0
e
t t0 ,
h(t t0 ) =
0
t < t0 .
How does your answer compare with Figure 4.11?
72
Exercise 4.10. Suppose that a system has an impulse response that is an exponential pulse. Mimic the code in convolex.m to nd its output when the input
is a white noise (recall specnoise.m on page 42).
Exercise 4.11. Mimic the code in convolex.m to nd the output of a system
when the input is an exponential pulse and the impulse response is a sum of two
delta functions at times t = 1 and t = 3.
The next two problems show that linear lters commute with dierentiation, and
with each other.
Exercise 4.12. Use the denition to show that convolution is commutative (i.e.,
that w1 (t) w2 (t) = w2 (t) w1 (t)). Hint: apply the change of variables = t
in (4.8).
Exercise 4.13. Suppose a lter has impulse response h(t). When the input is
x(t), the output is y(t). If the input is xd (t) = x(t)/t, the output is yd (t). Show
that yd (t) is the derivative of y(t). Hint: use (4.8) and the result of Exercise 4.12.
Exercise 4.14. Let w(t) = (t) be the rectangular pulse of (2.8). What is
w(t) w(t)? Hint: a pulse shaped like a triangle.
Exercise 4.15. Redo Exercise 4.14 numerically by suitably modifying
convolex.m. Let T = 1.5 s.
Exercise 4.16. Suppose that a system has an impulse response that is a sinc
function, as shown in Figure 2.11, and that the input to the system is a white
noise (as in specnoise.m on page 42).
a. Mimic convolex.m to numerically nd the output.
b. Plot the spectrum of the input and the spectrum of the output (using
plotspec.m). What kind of lter would you call this?
4.5
Convolution Multiplication
While the convolution operator (4.8) describes mathematically how a linear system acts on a given input, time-domain approaches are often not particularly
revealing about the general behavior of the system. Who would guess, for instance
in Exercises 4.11 and 4.16, that convolution with exponentials and sinc functions
would act like lowpass lters? By working in the frequency domain, however, the
convolution operator is transformed into a simpler point-by-point multiplication,
and the generic behavior of the system becomes clearer.
The rst step is to understand the relationship between convolution in time
and multiplication in frequency. Suppose that the two time signals w1 (t) and
Modeling Corruption
73
(4.10)
To justify this property, begin with the denition of the Fourier transform (2.1)
and apply the denition of convolution (4.8) to obtain
F {w1 (t) w2 (t)} =
w1 (t) w2 (t)ej2f t dt
t=
=
w1 ()w2 (t )d ej2f t dt.
t=
Reversing the order of integration and using the time-shift property (A.37) produces
j2f t
w1 ()
w2 (t )e
dt d
F {w1 (t) w2 (t)} =
t=
=
=
w1 () W2 (f )ej2f d
=
= W2 (f )
w1 ()ej2f d = W1 (f )W2 (f ).
=
Thus, convolution in the time domain is the same as multiplication in the frequency domain. See (A.40).
The companion to the convolution property is the multiplication property,
which says that multiplication in the time domain is equivalent to convolution
in the frequency domain (see (A.41)); that is,
W1 ()W2 (f )d.
(4.11)
F {w1 (t)w2 (t)} = W1 (f ) W2 (f ) =
Y (f )
,
X(f )
(4.12)
which is called the frequency response of the system because it shows, for each
frequency f , how the system responds. For instance, suppose that H(f1 ) = 3 at
some frequency f1 . Then, whenever a sinusoid of frequency f1 is input into the
system, it will be amplied by a factor of 3. Alternatively, suppose that H(f2 ) = 0
at some frequency f2 . Then whenever a sinusoid of frequency f2 is input into
74
the system, it is removed from the output (because it has been multiplied by a
factor of 0).
The frequency response shows how the system treats inputs containing various
frequencies. In fact, this property was already used repeatedly in Chapter 1 when
drawing curves that describe the behavior of lowpass and bandpass lters. For
example, the lters of Figures 2.4, 2.5, and 2.6 are used to remove unwanted
frequencies from the communications system. In each of these cases, the plot of
the frequency response describes concretely and concisely how the system (or
lter) aects the input, and how the frequency content of the output relates to
that of the input. Sometimes, the frequency response H(f ) is called the transfer
function of the system, since it transfers the input x(t) (with transform X(f ))
into the output y(t) (with transform Y (f )).
Thus, the impulse response describes how a system behaves directly in time,
while the frequency response describes how it behaves in frequency. The two
descriptions are intimately related because the frequency response is the Fourier
transform of the impulse response. This will be used repeatedly in Section 7.2
to design lters for the manipulation (augmentation or removal) of specied
frequencies.
Example 4.2. In Exercise 4.16, a system was dened to have an impulse response
that is a sinc function. The Fourier transform of a sinc function in time is a rect
function in frequency (A.22). Hence, the frequency response of the system is a
rectangle that passes all frequencies below fc = 1/T and removes all frequencies
above (i.e., the system is a lowpass lter).
Matlab can help to visualize the relationship between the impulse response
and the frequency response. For instance, the system in convolex.m is dened
via its impulse response, which is a decaying exponential. Figure 4.11 shows
its output when the input is a simple sum of delta functions, and Exercise 4.10
explores the output when the input is a white noise. In freqresp.m, the behavior
of this system is explained by looking at its frequency response.
Listing 4.3. freqresp.m numerical example of impulse and frequency response
Ts =1/100; time =10;
t =0:Ts : time ;
h=exp( t ) ;
p l o t s p e c ( h , Ts )
%
%
%
%
s a m p l i n g i n t e r v a l and t o t a l time
c r e a t e time v e c t o r
def i ne impulse response
f i n d and p l o t f r e q u e n c y r e s p o n s e
Modeling Corruption
75
Amplitude
6
Seconds
10
Magnitude
100
40 30
20
10
0
10
Frequency
20
30
40
Exercise 4.17. Suppose a system has an impulse response that is a sinc function. Using freqresp.m, nd the frequency response of the system. What kind
of lter does this represent? Hint: center the sinc in time; for instance, use
h=sinc(10*(t-time/2)).
Exercise 4.18. Suppose a system has an impulse response that is a sin function. Using freqresp.m, nd the frequency response of the system. What kind
of lter does this represent? Can you predict the relationship between the frequency of the sine wave and the location of the peaks in the spectrum? Hint: try
h=sin(25*t).
Exercise 4.19. Create a simulation (analogous to convolex.m) that inputs
white noise into a system with an impulse response that is a sinc function (as in
Exercise 4.17). Calculate the spectra of the input and output using plotspec.m.
Verify that the system behaves as suggested by the frequency response in Exercise 4.17.
Exercise 4.20. Create a simulation (analogous to convolex.m) that inputs
white noise into a system with an impulse response that is a sin function (as in
Exercise 4.18). Calculate the spectra of the input and output using plotspec.m.
Verify that the system behaves as suggested by the frequency response in Exercise 4.18.
So far, Section 4.5 has emphasized the idea of nding the frequency response of
a system as a way to understand its behavior. Reversing things suggests another
use. Suppose it was necessary to build a lter with some special characteristic
in the frequency domain (for instance, in order to accomplish one of the goals
of bandpass ltering in Section 4.1). It is easy to specify the lter in the frequency domain. Its impulse response can then be found by taking the inverse
Fourier transform, and the lter can be implemented using convolution. Thus,
76
the relationship between impulse response and frequency response can be used
both to study and to design systems.
In general, this method of designing lters is not optimal (in the sense that
other design methods can lead to more ecient designs), but it does show clearly
what the lter is doing, and why. Whatever the design procedure, the representation of the lter in the time domain and its representation in the frequency
domain are related by nothing more than a Fourier transform.
4.6
Improving SNR
Section 4.1 described several kinds of corruption that a signal may encounter
as it travels from the transmitter to the receiver. This section shows how linear
lters can help. Perhaps the simplest way a linear bandpass lter can be used
is to remove broadband noise from a signal. (Recall Section 4.1.2 and especially
Figure 4.2.)
A common way to quantify noise is the signal-to-noise ratio (SNR), which is
the ratio of the power of the signal to the power of the noise at a given point in
the system. If the SNR at one point is larger than the SNR at another point, the
performance is better at the rst point because there is more signal in comparison
with the amount of noise. For example, consider the SNR at the input and output
of a BPF as shown in Figure 4.13. The signal at the input (r(t) in part (a)) is
composed of the message signal x(t) and the noise signal n(t), and the SNR at
the input is therefore
SNRinput =
power in x(t)
.
power in n(t)
Similarly, the output y(t) is composed of a ltered version of the message (yx (t)
in part (b)) and a ltered version of the noise (yn (t) in part (b)). The SNR at
the output can therefore be calculated as
power in yx (t)
SNRoutput =
.
power in yn (t)
Observe that the SNR at the output cannot be calculated directly from y(t) (since
the two components are scrambled together). But, since the lter is linear,
y(t) = BPF{x(t) + n(t)} = BPF{x(t)} + BPF{n(t)} = yx + yn ,
which eectively shows the equivalence of parts (a) and (b) of Figure 4.13.
The Matlab program improvesnr.m explores this scenario concretely. The
signal x is a bandlimited signal, containing only frequencies between 3000 and
4000 Hz. This is corrupted by a broadband noise n (perhaps caused by an
internally generated thermal noise) to form the received signal. The SNR of this
input snrinp is calculated as the ratio of the power of the signal x to the power
of the noise n. The output of the BPF at the receiver is y, which is calculated
77
Modeling Corruption
n(t)
n(t)
x(t)
BPF
yn(t)
r(t)
y(t)
x(t)
yx(t)
BPF
BPF
y(t)
+
(b)
(a)
Figure 4.13 Two equivalent ways to draw the same system. In part (a) it is easy to
calculate the SNR at the input, while the alternative form (b) allows easy calculation
of the SNR at the output of the BPF.
as a BPF version of x+n. The BPF is created using the firpm command just
like the bandpass lter in filternoise.m on page 47. To calculate the SNR of
y, however, the code also implements the system in the alternative form of part
(b) of Figure 4.13. Thus, yx and yn represent the signal x ltered through the
BPF and the noise n passed through the same BPF. The SNR at the output is
then the ratio of the power in yx to the power in yn, which is calculated using
the function pow.m available on the website.
Listing 4.4. improvesnr.m using a linear lter to improve SNR
time =3; Ts =1/20000;
f r e q s =[0 0 . 2 9 0 . 3 0 . 4 0 . 4 1 1 ] ;
amps=[0 0 1 1 0 0 ] ;
b=f i r p m ( 1 0 0 , f r e q s , amps ) ;
n =0.25 * randn ( 1 , time /Ts ) ;
x=f i l t e r ( b , 1 , 2 * randn ( 1 , time /Ts ) ) ;
y=f i l t e r ( b , 1 , x+n ) ;
yx=f i l t e r ( b , 1 , x ) ;
yn=f i l t e r ( b , 1 , n ) ;
z=yx+yn ;
d i f f z y=max( abs ( zy ) )
s n r i n p=pow ( x )/ pow ( n )
s n r o u t=pow ( yx )/ pow ( yn )
%
%
%
%
%
%
%
%
%
%
%
%
%
time and s a m p l i n g i n t e r v a l
f i l t e r design , bandlimited
. . . between 3K and 4K
BP f i l t e r
g e n e r a t e w h i te n o i s e s i g n a l
do th e f i l t e r i n g
( a ) f i l t e r th e s i g n a l+n o i s e
or ( b) f i l t e r s i g n a l
. . . and n o i s e s e p a r a t e l y
add them
and make s u r e y = z
SNR a t i n p u t
SNR a t o u t p u t
Since the data generated in improvesnr.m are random, the numbers are
slightly dierent each time the program is run. Using the default values, the
SNR at the input is about 7.8, while the SNR at the output is about 61. This is
certainly a noticeable improvement. The variable diffzy shows the largest difference between the two ways of calculating the output (that is, between parts
(a) and (b) of Figure 4.13). This is on the order of 1015 , which is eectively
the numerical resolution of Matlab calculations, indicating that the two are
(eectively) the same.
Figure 4.14 plots the spectra of the input and the output of a typical run
of improvesnr.m. Observe the large noise oor in the left plot, and how this is
reduced by passage through the BPF. Observe also that the signal is still changed
by the noise in the passband between 3000 and 4000 Hz, since the BPF has no
eect there.
78
Figure 4.14 The spectrum of the input to the BPF is shown in the left plot. The
spectrum of the output is shown on the right. The overall improvement in SNR is
clear.
x1(t)
y(t)
transmitter
x2(t)
LPF
cos(2fct+)
cos(2fct+)
multiuser transmission
system of Exercise
4.23.
Modeling Corruption
79
Analog (De)modulation
Several parts of a communication system modulate the signal and change the
underlying frequency band in which the signal lies. These frequency changes
must be reversible; after processing, the receiver must be able to reconstruct (a
close approximation to) the transmitted signal.
The input message w(kT ) in Figure 5.1 is a discrete-time sequence drawn from
a nite alphabet. The ultimate output m(kT ) produced by the decision device
(or quantizer) is also discrete-time and is drawn from the same alphabet. If all
goes well and the message is transmitted, received, and decoded successfully, then
the output should be the same as the input, although there may be some delay
between the time of transmission and the time when the output is available.
Though the system is digital in terms of the message communicated and the
performance assessment, the middle of the system is inherently analog from the
(pulse-shaping) lter of the transmitter to the sampler at the receiver.
At the transmitter in Figure 5.1, the digital message has already been turned
into an analog signal by the pulse shaping (which was discussed briey in Section
2.10 and is considered in detail in Chapter 11). For ecient transmission, the
analog version of the message must be shifted in frequency, and this process
of changing frequencies is called modulation or upconversion. At the receiver,
the frequency must be shifted back down, and this is called demodulation or
downconversion. Sometimes the demodulation is done in one step (all analog) and
sometimes the demodulation proceeds in two steps, an analog downconversion to
the intermediate frequency and then a digital downconversion to the baseband.
This two-step procedure is shown in Figure 5.1.
There are many ways in which signals can be modulated. Perhaps the simplest is amplitude modulation (AM), which is discussed in two forms (large and
small carrier) in the next two sections. This is generalized to the simultaneous transmission of two signals using quadrature modulation in Section 5.3, and
it is shown that quadrature modulation uses bandwidth more eciently than
amplitude modulation. This gain in eciency can also be obtained using singlesideband and vestigial-sideband methods, which are discussed in the document
Analog (De)modulation
81
Interferers Noise
Analog
Pulse
upconversion
shaping
Message
w(kT) {3, 1, 1, 3}
Analog
conversion
to IF
Ts
Digital downconversion
to baseband
f
Decision
Reconstructed
message
m(kT ) {3, 1, 1, 3}
Carrier synchronization
Figure 5.1 A complete digital communication system has many parts. This chapter
focuses on the upconversion and the downconversion, which can done in many ways,
including large-carrier AM as in Section 5.1, suppressed-carrier AM as in Section 5.2,
and quadrature modulation as in Section 5.3.
5.1
82
w(t)
v(t)
v(t)
m(t)
|.|
LPF
envelope detector
Ac cos(2fct)
(b) Receiver
(a) Transmitter
Figure 5.2 A communications system using amplitude modulation with a large carrier.
In the transmitter (a), the message signal w(t) is modulated by a carrier wave at
frequency fc and then added to the carrier to give the transmitted signal v(t). In (b),
the received signal is passed through an envelope detector consisting of an
absolute-value nonlinearity followed by a lowpass lter. When all goes well, the
output m(t) of the receiver is approximately equal to the original message.
(Ac)
B +B
(b) |V( f )|
(Ac/2)
(Ac/2)
fc
fc
(c) |F{|cos(2fct)|}|
4fc
2fc
2fc
4fc
2fc
4fc
(d) |F{|v(t)|}|
4fc
2fc
Analog (De)modulation
83
%
%
%
%
%
%
s a m p l i n g i n t e r v a l & time
d e f i n e a time v e c t o r
d e f i n e c a r r i e r at f r e q f c
c r e a t e message > 1
modulate w/ l a r g e c a r r i e r
LPF d e s i g n
% i m p u l s e r e s p o n s e o f LPF
% f i nd envelope
The output of this program is shown in Figure 5.4. The slowly increasing
sinusoidal message w(t) is modulated by the carrier c(t) at fc = 1000 Hz.
The heart of the modulation is the point-by-point multiplication of the message
and the carrier in the fth line. This product v(t) is shown in Figure 5.4(c). The
enveloping operation is accomplished by applying a lowpass lter to the real part
of 2v(t)ej2fc t (as discussed in Appendix C). This recovers the original message
signal, though it is oset by 1 and delayed by the linear lter.
Exercise 5.1. Using AMlarge.m, plot the spectrum of the message w(t), the
spectrum of the carrier c(t), and the spectrum of the received signal v(t). What
is the spectrum of the envelope? How close are your results to the theoretical
predictions in (5.1)?
Exercise 5.2. One of the advantages of transmissions using AM with a large
carrier is that there is no need to know the (exact) phase or frequency of the
transmitted signal. Verify this using AMlarge.m.
a. Change the phase of the transmitted signal; for instance, let c=cos(2*pi*
fc*t+phase) with phase=0.1, 0.5, pi/3, pi/2, pi, and verify that the
recovered envelope remains unchanged.
b. Change the frequency of the transmitted signal; for instance, let c=cos(2*
pi*(fc+g)*t) with g=10, -10, 100, -100, and verify that the recovered
envelope remains unchanged. Can g be too large?
Exercise 5.3. Create your own message signal w(t), and rerun AMlarge.m.
Repeat Exercise 5.1 with this new message. What dierences do you see?
Exercise 5.4. In AMlarge.m, verify that the original message w and the recovered
envelope envv are oset by 1, except at the end points where the lter does not
have enough data. Hint: the delay induced by the linear lter is approximately
fl/2.
Amplitude
84
4
2
0
Amplitude
(b) carrier
Amplitude
Amplitude
4
2
0
2
(c) modulated signal
4
2
0
0
0.01
0.02
0.03
0.04
0.05 0.06
Seconds
(d) output of envelope detector
0.07
5.2
1
1
Ac W (f + fc ) + Ac W (f fc ).
2
2
As with AM with a large carrier, the upconverted signal v(t) for AM with a
suppressed carrier has twice the bandwidth of the original message signal. If the
Analog (De)modulation
w(t)
v(t)
v(t)
x(t)
85
m(t)
LPF
Ac cos(2fct)
(a) Transmitter
cos(2(fc + )t + )
(b) Receiver
carrier. In the transmitter (a), the message signal w(t) is modulated by a carrier wave
at frequency fc to give the transmitted signal v(t). In (b), the received signal is
demodulated by a wave with frequency fc + and phase , and then lowpass ltered.
When all goes well, the output of the receiver m(t) is approximately equal to the
original message.
original message occupies the frequencies between B Hz, then the modulated
message has support between fc B and fc + B, a bandwidth of 2B. See Figure
4.10 on page 70.
As illustrated in (2.6) on page 25, the received signal can be demodulated by
mixing with a cosine that has the same frequency and phase as the modulating
cosine, and the original message can then be recovered by lowpass ltering. But,
as a practical matter, the frequency and phase of the modulating cosine (located
at the transmitter) can never be known exactly at the receiver.
Suppose that the frequency of the modulator is fc but that the frequency at
the receiver is fc + , for some small . Similarly, suppose that the phase of the
modulator is 0 but that the phase at the receiver is . Figure 5.5(b) shows this
downconverter, which can be described by
x(t) = v(t) cos(2(fc + )t + )
(5.2)
and
m(t) = LPF{x(t)},
where LPF represents a lowpass ltering of the demodulated signal x(t) in an
attempt to recover the message. Thus, the downconversion described in (5.2)
acknowledges that the receivers local oscillator might not have the same frequency or phase as the transmitters local oscillator. In practice, accurate a
priori information is available for the carrier frequency, but the (relative) phase
could be anything, since it depends on the distance between the transmitter and
the receiver as well as when the transmission begins. Because the frequencies are
high, the wavelengths are small and even small motions can change the phase
signicantly.
The remainder of this section investigates what happens when the frequency
and phase are not known exactly, that is, when or (or both and ) are
nonzero. Using the frequency-shift property of Fourier transforms (5.3) on x(t)
86
(5.3)
Ac j
[(e + ej )W (f ) + ej W (f 2fc ) + ej W (f + 2fc )].
4
Ac
w(t) cos().
(5.4)
2
The factor cos() attenuates the received signal (except for the special case when
= 0 2k for integers k). If were suciently close to 0 2k for some integer
k, then this would be tolerable. But there is no way to know the relative phase,
and hence cos() can assume any possible value within [1, 1]. The worst case
occurs as approaches /2, when the message is attenuated to zero! A scheme
for carrier-phase synchronization, which automatically tries to align the phase
of the cosine at the receiver with the phase at the transmitter, is vital. This is
discussed in detail in Chapter 10.
To continue the investigation, suppose that the carrier-phase oset is zero,
(i.e., = 0), but that the frequency oset is not. Then the spectrum of x(t)
from (5.3) is
m(t) =
X(f ) =
Ac
[W (f ) + W (f 2fc ) + W (f + 2fc + ) + W (f + )],
4
Ac
w(t) cos(2t).
(5.5)
2
Instead of recovering the message w(t), the frequency oset causes the receiver
to recover a low-frequency amplitude-modulated version of it. This is bad with
m(t) =
Analog (De)modulation
|M( f )|
87
|W( f + )|
Figure 5.6 When there is a
Ac
4
|W( f )|
even a small carrier-frequency oset. While cos() in (5.4) is a xed scaling, cos(2t) in (5.5) is a time-varying scaling that will alternately recover
m(t) (when cos(2t) 1) and make recovery impossible (when cos(2t) 0).
Transmitters are typically expected to maintain suitable accuracy to a nominal
carrier-frequency setting known to the receiver. Ways of automatically tracking
(inevitable) small frequency deviations are discussed at length in Chapter 10.
The following code AM.m generates a message w(t) and modulates it with a
carrier at frequency fc . The demodulation is done with a cosine of frequency fc +
and a phase oset of . When = 0 and = 0, the output (a lowpass version
of the demodulated signal) is nearly identical to the original message, except for
the inevitable delay caused by the linear lter. Figure 5.7 shows four plots: the
message w(t) on top, followed by the upconverted signal v(t) = w(t)cos(2fc t),
followed in turn by the downconverted signal x(t). The lowpass-ltered version
is shown in the bottom plot; observe that it is nearly identical to the original
message, albeit with a slight delay.
Listing 5.2. AM.m suppressed carrier with (possible) freq and phase oset
time = 0 . 3 ; Ts =1/10000;
t=Ts : Ts : time ; l e n t=length ( t ) ;
fm=20; f c =1000; c=cos (2 * pi * f c * t ) ;
w=5/ l e n t * ( 1 : l e n t )+cos (2 * pi * fm * t ) ;
v=c . * w ;
gam=0; p h i =0;
c2=cos (2 * pi * ( f c+gam ) * t+p h i ) ;
x=v . * c2 ;
f b e =[0 0 . 1 0 . 2 1 ] ; damps=[1 1 0 0 ] ;
f l =100; b=f i r p m ( f l , f b e , damps ) ;
m=2* f i l t e r ( b , 1 , x ) ;
%
%
%
%
%
%
%
%
%
%
%
s a m p l i n g i n t e r v a l & time
d e f i n e a time v e c t o r
c a r r i e r at f r e q f c
c r e a t e message
modulate with c a r r i e r
f r e q & phase o f f s e t
c r e a t e c o s i n e f o r demod
demod r e c e i v e d s i g n a l
LPF d e s i g n
i m p u l s e r e s p o n s e o f LPF
LPF th e demodulated s i g n a l
Exercise 5.5. Using AM.m as a starting point, plot the spectra of w(t), v(t), x(t),
and m(t).
Exercise 5.6. Try dierent phase osets = [, /2, /3, /6, 0, /6,
/3, /2, ]. How well does the recovered message m(t) match the actual message
w(t)? For each case, what is the spectrum of m(t)?
Exercise 5.7. TRUE or FALSE: A small, xed phase oset in the receiver
demodulating AM with suppressed carrier produces an undesirable low-frequency
modulated version of the analog message.
3
1
1
(a) message signal
0
Amplitude
88
2
(b) message after modulation
3
1
1
0.02
0.04
0.06
0.08
(d) recovered message is a LPF applied to (c)
Addition
w(t)
+
A0 cos(2fct)
Square-law
device
()
Bandpass
filter
Centered
at fc
2A0w(t)cos(2fct)
mixing transmitter of
Exercises 5.9 through
5.11.
Exercise 5.8. Try dierent frequency osets gam = [0.014, 0.1, 1.0, 10]. How
well does the recovered message m(t) match the actual message w(t)? For each
case, what is the spectrum of m(t)? Hint: look over more than just the rst 0.1 s
to see the eect.
Exercise 5.9. Consider the system shown in Figure 5.8. Show that the output
of the system is 2A0 w(t) cos(2fc t), as indicated.
Exercise 5.10. Create a Matlab routine to implement the square-law mixing
modulator of Figure 5.8.
a. Create a signal w(t) that has bandwidth 100 Hz.
b. Modulate the signal to 1000 Hz.
c. Demodulate using the AM demodulator from AM.m (to recover the original
w(t)).
89
Analog (De)modulation
|W( f )|
2
sin(2f4t) + cos(2f5t)
(a)
r(t)
x(t)
(c)
2000
(b)
300
300
w(t)
2000
x(t)
BPF
lower cutoff f2
cos(2f1t + 1) upper cutoff f3
BPF
(d)
r(t)
BPF
y(t)
LPF
lower cutoff f6
cutoff f9
upper cutoff f7 cos(2f8t + 2)
Figure 5.9 The transmission system for Exercise 5.12: (a) the magnitude spectrum of
the message, (b) the transmitter, (c) the channel, and (d) the receiver.
Exercise 5.11. Exercise 5.10 essentially creates a transmitter and receiver based
on the square-law modulator (rather than the more standard mixing modulator).
Using this system, do the following.
a. Show how the received signal degrades if the phase of the cosine wave is not
known exactly.
b. Show how the received signal degrades if the frequency of the cosine wave is
not exact.
c. Show how the received signal degrades if the bandpass lter is not centered
at the specied frequency.
Exercise 5.12. Consider the transmission system of Figure 5.9. The message
signal w(t) has the magnitude spectrum shown in part (a). The transmitter in
part (b) produces the transmitted signal x(t), which passes through the channel in part (c). The channel scales the signal and adds narrowband interferers
to create the received signal r(t). The transmitter and channel parameters are
1 = 0.3 radians, f1 = 24.1 kHz, f2 = 23.9 kHz, f3 = 27.5 kHz, f4 = 29.3 kHz,
and f5 = 22.6 kHz. The receiver processing r(t) is shown in Figure 5.9(d). All
bandpass and lowpass lters are considered ideal, with a gain of unity in the
passband and zero in the stopband.
a. Sketch |R(f )| for 30 kHz f 30 kHz. Clearly indicate the amplitudes and
frequencies of key points in the sketch.
b. Assume that 2 is chosen to maximize the magnitude of y(t) and reects the
value of 1 and the delays imposed by the two ideal bandpass lters that form
the received signal r(t). Select the receiver parameters f6 , f7 , f8 , and f9 , so
the receiver output y(t) is a scaled version of w(t).
Exercise 5.13. An analog baseband message signal w(t) has all energy between
B and B Hz. It is upconverted to the transmitted passband signal x(t) via AM
90
5.3
Quadrature Modulation
In AM transmission, where the baseband signal and its modulated passband version are real-valued, the spectrum of the modulated signal has twice the bandwidth of the baseband signal. As pictured in Figure 4.10 on page 70, the spectrum
of the baseband signal is nonzero only for frequencies between B and B. After
modulation, the spectrum is nonzero in the interval [fc B, fc + B] and in
the interval [fc B, fc + B]. Thus the total width of frequencies occupied by the
modulated signal is twice that occupied by the baseband signal. This represents
a kind of ineciency or redundancy in the transmission. Quadrature modulation
provides one way of removing this redundancy by sending two messages in the
frequency ranges between [fc B, fc + B] and [fc B, fc + B], thus utilizing
the spectrum more eciently.
To see how this can work, suppose that there are two message streams m1 (t)
and m2 (t). Modulate one message with a cosine to create the in-phase signal,
and the other with (the negative of) a sine to form the quadrature signal. These
91
Analog (De)modulation
cos(2fct)
cos(2fct)
m1(t)
x1(t)
LPF
s1(t)
+
Transmitter
m2(t)
Receiver
sin(2fct)
x2(t)
LPF
s2(t)
sin(2fct)
(5.6)
which is then transmitted. A receiver structure that can recover the two messages
is shown in Figure 5.10. The signal s1 (t) at the output of the receiver is intended
to recover the rst message m1 (t). Similarly, the signal s2 (t) at the output of the
receiver is intended to recover the (negative of the) second message m2 (t).
To examine the recovered signals s1 (t) and s2 (t) in Figure 5.10, rst evaluate
the signals before the lowpass ltering. Using the trigonometric identities (A.4)
and (A.8), x1 (t) becomes
x1 (t) = v(t) cos(2fc t) = m1 (t) cos2 (2fc t) m2 (t) sin(2fc t) cos(2fc t)
m1 (t)
m2 (t)
(1 + cos(4fc t))
sin(4fc t).
=
2
2
Lowpass ltering x1 (t) produces
m1 (t)
.
2
Similarly, x2 (t) can be rewritten using (A.5) and (A.8) as
s1 (t) =
These are also sometimes modeled as the real and the imaginary parts of a single
complex-valued signal. This complex representation is explored more fully in Appendix
C.
92
cos(2f1t)
x1(t)
x2(t)
x3(t)
x4(t)
BPF
x5(t)
x6(t)
LPF
lower cutoff f3
cutoff f6
upper cutoff f4 cos(2f5t + )
cos(2f2t)
What
What
What
What
What
is
is
is
is
is
the
the
the
the
the
93
Analog (De)modulation
the bulk of Software Receiver Design focuses on the real PAM case and the
complex-valued quadrature case is postponed until Chapter 16. There are also
other ways of recapturing the lost bandwidth: both single-sideband and vestigialsideband (discussed in the document Other Modulations on the website) send a
single message, but use only half the bandwidth.
5.4
r all frequency bands can be downconverted to the same IF, which allows use
of standardized ampliers, modulators, and lters on the IF signals; and
r sampling can be done at the Nyquist rate of the IF rather than the Nyquist
rate of the transmission.
The downconversion to an intermediate frequency (followed by bandpass ltering
to extract the passband around the IF) can be accomplished in two ways: by a
local oscillator modulating from above the carrier frequency (called high-side
injection) or from below (low-side injection). To see this, consider the double
sideband modulation (from Section 5.2) that creates the transmitted signal
v(t) = 2w(t)cos(2fc t)
from the message signal w(t) and the downconversion to IF via
x(t) = 2[v(t) + n(t)]cos(2fI t),
where n(t) represents interference such as noise and spurious signals from other
users. By virtue of the frequency-shifting property (A.33),
V (f ) = W (f + fc ) + W (f fc ),
(5.7)
(5.8)
94
|V( f ) + N( f )|
1780
850
3085 2156
105
850
1780
(a)
|X( f )|
|X( f )|
f (kHz)
105
f (kHz)
455 290
1245
1385
2175
1200 1410
2156
3085
500
f (kHz)
455
475
455
(b)
500
1410 1200
290
455
(c)
475
(a) transmitted spectrum, (b) low-side injected spectrum, and (c) high-side injected
spectrum.
r High-side injection separates the undesired images further from the lowerr
frequency portion (which will ultimately be retained to reconstruct the message). This eases the requirements on the bandpass lter.
Both high-side and low-side injection can place frequency interferers in undesirable places. This highlights the need for adequate out-of-band rejection by
a bandpass lter before downconversion to IF.
95
Analog (De)modulation
|W( f )|
w(t)
22
22 f (kHz)
+
cos(2fct)
n(t)
r(t)
x(t)
cos(2frt)
Exercise 5.17. Consider the system described in Figure 5.13. The message w(t)
has a bandwidth of 22 kHz and a magnitude spectrum as shown. The message is
upconverted by a mixer with carrier frequency fc . The channel adds an interferer
n. The received signal r is downconverted to the IF signal x(t) by a mixer with
frequency fr .
a. With n(t) = 0, fr = 36 kHz, and fc = 83 kHz, indicate all frequency ranges
(i)(x) that include any part of the IF passband signal x(t).
(i) 020 kHz, (ii) 2040 kHz, (iii) 4060 kHz, (iv) 6080 kHz, (v) 80100 kHz,
(vi) 100120 kHz, (vii) 120140 kHz, (viii) 140160 kHz, (ix) 160180 kHz,
(x) 180200 kHz.
b. With fr = 36 kHz and fc = 83 kHz, indicate all frequency ranges (i)(x) that
include any frequency that causes a narrowband interferer n to appear in the
nonzero portions of the magnitude spectrum of the IF passband signal x(t).
c. With fr = 84 kHz and fc = 62 kHz, indicate every range (i)(x) that includes
any frequency that causes a narrowband interferer n to appear in the nonzero
portions of the magnitude spectrum of the IF passband signal x(t).
Exercise 5.18. A transmitter operates as a standard AM with suppressed carrier
transmitter (as in AM.m). Create a demodulation routine that operates in two
steps, by mixing with a cosine of frequency 3fc /4 and subsequently mixing with
a cosine of frequency fc /4. Where must pass/reject lters be placed in order to
ensure reconstruction of the message? Let fc = 2000.
Exercise 5.19. Consider the scheme shown in Figure 5.14. The absolute bandwidth of the baseband signal x1 is 4 kHz, f1 = 28 kHz, f2 = 20 kHz, and f3 = 26
kHz.
a.
b.
c.
d.
e.
What
What
What
What
What
is
is
is
is
is
the
the
the
the
the
Exercise 5.20. Using your Matlab code from Exercise 5.18, investigate the
eect of a sinusoidal interference
96
x1(t)
x2(t)
X2
BPF
lower cutoff f2
upper cutoff f3
Squaring
nonlinearity
cos(2f1t)
x4(t)
x3(t)
cos(2f3t) + cos(2f4t)
|X1( f )|
1
x1(t)
f1
f1
x4(t)
x5(kTs)
x2(t)
x3(t)
lower cutoff f5
upper cutoff f6
cos(2f2t)
x6(kTs)
x7(kTs)
LPF
Ts=1/f7
x4(t)
BPF
x8(kT)
M
cutoff f9
cos(2f8t)
a. at frequency fc /6,
b. at frequency fc /3,
c. at frequency 3fc .
Exercise 5.21. Consider the PAM communication system in Figure 5.15. The
input x1 (t) has a triangular baseband magnitude spectrum. The frequency specications are f1 = 100 kHz, f2 = 1720 kHz, f3 = 1940 kHz, f4 = 1580 kHz,
f5 = 1720 kHz, f6 = 1880 kHz, and f7 = 1300 kHz.
a. Draw the magnitude spectrum |X5 (f )| between 3000 kHz. Be certain to
give specic values of frequency and magnitude at all breakpoints and local
maxima.
b. Specify values of f8 and f9 for which the system can recover the original
message without corruption with M = 2.
Exercise 5.22. This problem asks you to build a receiver from a limited number
of components. The parts available are
a. two product modulators with input u and output y related by
y(t) = u(t) cos(2fc t)
and carrier frequencies fc of 12 MHz and 50 MHz,
b. two linear bandpass lters with ideal rectangular magnitude spectrum of unity
gain between fU and fL and between fL and fU and zero elsewhere with
(fL , fU ) of (12 MHz, 32 MHz) and (35 MHz, 50 MHz),
Analog (De)modulation
97
|R( f )|
(1)
(1)
Figure 5.16 Spectrum of
the received signal for
Exercise 5.22.
46 40 36 30
10
10
30 36 40
46
f (MHz)
u(t)(t kTs )
k=
Antenna
BPF
Analog
r(t)
conversion
to IF
Analog
received
signal
AGC
Sampler
& Quantizer
s(kTs) = s[k]
Quality
Assessment
99
surpass the highest level that can be represented), and that it does not lose
dynamic range (the digitized signal does not always remain in a small number
of the possible levels). The key in the AGC is that the gain must automatically
adjust to account for the signal strength, which may vary slowly over time.
The AGC provides the simplest example of a system element that must adapt
to changes in its environment (recall the fth element of Chapter 3). How
can such elements be designed? Software Receiver Design suggests a general
method based on gradient-directed optimization. First, a goal and an associated objective function are chosen. Since it is desired to maintain the output
of the AGC at a roughly constant power, the associated objective function is
dened to be the average deviation of the power from that constant; the goal is
to minimize the objective function. The gain parameter is then adjusted according to a steepest descent method that moves the estimate downhill towards
the optimal value that minimizes the objective. In this case the adaptive gain
parameter is increased (when the average power is too small) or decreased (when
the average power is too large), thus maintaining a steady power. While it would
undoubtedly be possible to design a successful AGC without recourse to such a
general optimization method, the framework developed in Sections 6.5 through
6.7 will also be useful in designing other adaptive elements such as the phasetracking loops of Chapter 10, the clock recovery algorithms of Chapter 12, and
the equalization schemes of Chapter 13.
6.1
100
Signal w(t)
Pulse train
(t kTs)
is multiplied point-by-point by a
pulse train. This eectively
samples the analog signal at a
rate Ts .
Impulse
sampling
ws(t)
Point sampling
w[k] = w(kTs)
= w(t)|t = kTs
ws (t) = w(t)
(t kTs ) =
k=
w(t)(t kTs )
k=
(6.1)
k=
and it is illustrated in Figure 6.2. The eect of multiplication by the pulse train
is clear in the time domain. But the relationship between ws (t) and w(t) is
clearer in the frequency domain, which can be understood by writing Ws (f ) as
a function of W (f ).
The transform Ws (f ) is given in (A.27) and (A.28). With fs = 1/Ts , this is
Ws (f ) = fs
W (f nfs ).
(6.2)
n=
Thus, the spectrum of the sampled signal ws (t) diers from the spectrum of the
original w(t) in two ways:
Observe that the notation w(kTs ) means w(t) evaluated at the time t = kTs . This is also
notated w[k] (with the square brackets), where the sampling rate Ts is implicit.
101
|W( f )|
fs B 0 B fs
2
2
|Ws( f )|
of a sampled signal is
periodic with period
equal to fs . In case (a),
the original spectrum
W (f ) is bandlimited to
less than fs /2 and there
is no overlapping of the
replicas. When W (f ) is
not bandlimited to less
than fs /2, as in (b), the
overlap of the replicas is
called aliasing.
2fs
fs
B 0 B
fs
fs B
fs+B
(a)
|W( f )|
B fs
2
fs
2
|Ws( f )|
fs
B
B
0
fs
fs+B
fs B
(b)
where the period is dened by the sampling rate. Readers familiar with Fourier
series will recognize this as the dual of the property that periodic in time is
the equivalent of sampling in frequency. Indeed, Equation (6.2) shows why the
relationships in Figure 3.9 on page 50 hold.
Figure 6.3 shows these replicas in two possible cases. In (a), fs 2B, where B
is the bandwidth of w(t), and the replicas do not overlap. Hence, it is possible to
extract the one replica centered at zero by using a lowpass lter. Assuming that
the ltering is without error, W (f ) is recovered from the sampled version Ws (f ).
Since the transform is invertible, this means that w(t) can be recovered from
ws (t). Therefore, no loss of information occurs in the sampling process.2 This
result is known as the Nyquist sampling theorem, and the minimum allowable
sampling rate is called the Nyquist rate.
2
Be clear about this: the analog signal w(t) is sampled to give ws (t), which is nonzero only
at the sampling instants kTs . If ws (t) is then input into a perfect analog lowpass lter, its
output is the same as the original w(t). Such ltering cannot be done with any digital lter
operating at the sampling rate fs . In terms of Figure 6.3, the digital lter can remove and
reshape the frequencies between the bumps, but can never remove the periodic bumps.
102
103
|W( f )|
x1[k]
r(t)
x2[k]
x3[k]
LPF
kT1
cos(2kT2)
Figure 6.4 The triangularly shaped magnitude spectrum of the real message signal
w(t) is shown on the left. The receiver structure in Exercise 6.4 is shown on the right.
|X( f )|
v1(t)
x(t)
v2(kTs)
v3(kTs)
X2
square law
450 400 350
v4(kTs)
LPF
Ts = 0.001 s
cos(400kTs)
Figure 6.5 The signal x(t) with spectrum X(f ) is input into this communication
system. Exercise 6.5 asks for the absolute bandwidth of the signal at each point as it
moves through the system.
Exercise 6.5. The signal x(t) with magnitude spectrum shown in the left part
of Figure 6.5 is input to the transmission system on the right. The lowpass lter
with output v4 (kTs ) has a cuto frequency of 200 Hz, a passband gain of 1,
and a stopband gain of zero. Specify all frequencies between zero and 2000 Hz
at which the magnitude spectra of |V1 (f )|, |V2 (f )|, |V3 (f )|, and |V4 (f )| have
nonzero values.
6.2
104
|W( f )|
1
(a)
|S( f )|
1/2
fcB fc+B
fc
(b)
fcB fc+B
fc
|Y( f )|
3fc /2
fc
fc /2
0
(c)
fc /2
(= fc fs)
fc
sampling downconverter
such as Figure 6.7. The
(bandlimited analog) signal
W (f ) shown in (a) is
upconverted to the
transmitted signal in (b).
Directly sampling this (at a
rate equal to fs = fc /2)
results in the spectrum
shown in the bottom plot.
3fc /2
f
(= fc+fs)
is shown in Figure 6.6(a), and the spectrum after upconversion is shown in part
(b); this is the transmitted signal s(t). At the receiver, s(t) is sampled, which
can be modeled as a multiplication with a train of delta functions in time,
y(t) = s(t)
(t nTs ),
n=
1
Y (f ) =
S(f nfs ),
Ts n=
w(t)
s(t)
105
m(t)
y(t)
LPF
Ts
fcutoff = B
cos(2fct)
Figure 6.7 System diagram showing how sampling can be used to downconvert a
signal. The spectra corresponding to w(t), s(t), and y(t) are shown in Figure 6.6. The
output of the LPF contains only the M-shaped portion nearest zero.
exactly fc /2). The middle method downconverts part of the way by sampling
and part of the way by mixing with a cosine. The middle method is used in the
M6 receiver project in Chapter 15.
Exercise 6.6. Create a simulation of a sampling-based modulator that takes a
signal with bandwidth 100 Hz and transforms it into the same signal centered
at 5000 Hz. Be careful; there are two sampling rates in this problem. One
reects the assumed sampling rate for the modulation and the other represents
the sampling rate that is used in Matlab to represent a continuous time
signal. You may wish to reuse code from sine100hzsamp.m. What choices have
you made for these two sampling rates?
Exercise 6.7. Implement the procedure diagrammed in Figure 6.7. Comment
on the choice of sampling rates. How have you specied the LPF?
Exercise 6.8. Using your code from Exercise 6.7, examine the eect of incorrect sampling rates by demodulating with fs + instead of fs . This is analogous
to the problem that occurs in cosine mixing demodulation when the frequency is
not accurate. Is there an analogy to the phase problem that occurs, for instance,
with nonzero in (5.4)?
Exercise 6.9. Consider the part of a communication system shown in Figure
6.8.
a. Sketch the magnitude spectrum |X1 (f )| of
x1 (t) = w(t)cos(1500t).
Be certain to give specic values of frequency and magnitude at all signicant
points in the sketch.
b. Draw the magnitude spectrum |X2 (f )| of
x2 (t) = w(t)x1 (t).
Be certain to give specic values of frequency and magnitude at all signicant
points in the sketch.
106
|W( f )|
x1(t)
w(t)
0.2
x2(t)
x3(t)
Ts
220
220
cos(1500t)
Figure 6.8 Input spectrum and system diagram for Exercise 6.9.
w(t)
x2[k]
x1(t)
kTs
cos(2fct) cos(2fIt)
x3[k]
LPF
x4[k]
cutoff frequency: f2
cos(2f1kTs)
receiver used in
Exercise 6.10.
c. Between 3750 Hz and 3750 Hz, draw the magnitude spectrum |X3 (f )| of
x3 (t) = x2 (t)
(t kTs ).
k=
Exercise 6.10. Consider the digital receiver shown in Figure 6.9. The baseband
signal w(t) has absolute bandwidth B and the carrier frequency is fc . The channel
adds a narrowband interferer at frequency fI . The received signal is sampled with
period Ts . As shown, the sampled signal is demodulated by mixing with a cosine
of frequency f1 and the ideal lowpass lter has a cuto frequency of f2 . For the
following designs you are to decide whether they are successful, i.e., whether or
not the magnitude spectrum of the lowpass lter output x4 is the same (up to
a scale factor) as the magnitude spectrum of the sampled w(t) with a sample
period of Ts .
a. Candidate System A: B = 7 kHz, fc = 34 kHz, fI = 49 kHz, Ts = 1/34 ms,
f1 = 0, and f2 = 16 kHz.
b. Candidate System B: B = 11 kHz, fc = 39 kHz, fI = 130 kHz, Ts = 1/52 ms,
f1 = 13 kHz, and f2 = 12 kHz.
107
|R( f )|
(1.5)
(1.5)
r(t)
y(t)
BPF
Ts
4 2
cos(2fot)
f (MHz)
r four ideal linear bandpass lters with passband (fL , fU ) of (0.5 MHz, 6 MHz),
(1.2 MHz, 6.2 MHz), (3.4 MHz, 7.2 MHz), and (4.2 MHz, 8.3 MHz),
u(t)(t kTs )
k=
Exercise 6.12. The message signal u(t) and additive interferer w(t) with magnitude spectra shown in Figure 6.11(a) are applied to the system in Figure 6.11(b).
The analog mixer frequencies are fc = 1600 kHz and fd = 1240 kHz. The BPF
with output x(t) is assumed ideal, is centered at fc , and has lower cuto frequency
fL , upper cuto frequency fU , and zero phase at fc . The period of the sampler
1
104 s . The phase of the discrete-time mixer is assumed to be
is Ts = 71
adjusted to the value that maximizes the ratio of signal to interferer noise power
in y(kTs ). The LPF with output y(kTs ) is assumed ideal with cuto frequency
108
|W( f )|
|U( f )|
40 f (kHz) 40
(a)
w(t)
860 720
720 860
f (kHz)
(b)
x(t)
u(t)
y(kTs)
BPF
LPF
Ts
cos(2fct)
x(t)
(c)
cos(2fdt) cos(2kTs +)
r(t)
y(kTs)
LPF
kTs
cos(2fct)
cos(2fckTs)
. The design objective is for the spectrum of y(kTs ) to estimate the spectrum
of a sampled u(t). You are to select the upper and lower cuto frequencies of the
BPF, the frequency of the discrete-time mixer, and the cuto frequency of the
LPF in order to meet this objective.
a. Design the desired BPF by specifying its upper fU and lower fL cuto frequencies.
b. Compute the desired discrete-time mixer frequency .
c. Design the desired LPF by specifying its cuto frequency .
Exercise 6.13. Consider the digital receiver in Figure 6.12 producing y(kTs ),
which is intended to match the input x(t) sampled every Ts seconds. The absolute bandwidth of x(t) is B. The carrier frequency fc is 10 times B. The sample
frequency 1/Ts is 2.5 times fc . Note that the sample frequency 1/Ts is above the
Nyquist frequency of the received signal r(t). Determine the maximum cuto
frequency as a function of the input bandwidth B for the lowpass lter producing y(kTs) so the design objective of matching samples of x(t) with a sample
frequency of 1/Ts is achieved.
6.3
109
%
%
%
%
%
%
f r e q u e n c y o f wave
t o t a l time i n s e c o n d s
sampling i n t e r v a l
d e f i n e a time v e c t o r
d e f i n e th e s i n e wave
p l o t th e s i n e v s . time
Running sine100hz.m plots the rst 10 periods of the sine wave. Each period
lasts 0.01 s, and each period contains 100 points, as can be veried by looking
at w(1:100). Changing the variable time or Ts displays dierent numbers of
cycles of the same sine wave, while changing f plots sine waves with dierent
underlying frequencies.
Exercise 6.14. What must the sampling rate be so that each period of the wave
is represented by 20 samples? Check your answer using the program above.
Exercise 6.15. Let Ts=1/500. How does the plot of the sine wave appear? Let
Ts=1/100, and answer the same question. How large can Ts be if the plot is to
retain the appearance of a sine wave? Compare your answer with the theoretical
limit. Why are they dierent?
When the sampling is rapid compared with the underlying frequency of the signal (for instance, the program sine100hz.m creates 100 samples in each period),
then the plot appears and acts much like an analog signal, even though it is still,
in reality, a discrete-time sequence. Such a sequence is called oversampled relative
to the signal period. The following program simulates the process of sampling
the 100 Hz oversampled sine wave. This is downsampling, as shown in Figure
3.10 on page 51.
110
Amplitude
0.01
0.02
Seconds
0.03
0.04
%
%
%
%
%
%
%
s e t time v e c t o r s
c r e a t e s i n e wave w( t )
t a k e 1 i n s s s a m p l es
th e sampled s e q u e n c e
sampled waveform ws ( t )
p l o t th e waveform
p l o t sampled wave
Running sine100hzsamp.m results in the plot shown in Figure 6.13, where the
continuous sine wave w is downsampled by a factor of ss=10; that is, all but
one of each ss samples is removed. Thus, the waveform w represents the analog
signal that is to be sampled at the eective sampling interval ss*Ts. The spiky
signal ws corresponds to the sampled signal ws (t), while the sequence wk contains
just the amplitude values at the tips of the spikes.
Exercise 6.16. Modify sine100hzsamp.m to create an oversampled sinc wave,
and then sample this with ss=10. Repeat this exercise with ss=30, ss=100, and
ss=200. Comment on what is happening. Hint: in each case, what is the eective
sampling interval?
Exercise 6.17. Plot the spectrum of the 100 Hz sine wave when it is created
with dierent downsampling rates ss=10, ss=11, ss=30, and ss=200. Explain
what you see.
6.4
111
where ws (t) (dened in (6.1)) is zero everywhere except at the sampling instants
t = kTs . Substituting (6.1) into w( ) shows that this integral is identical to the
sum
kTs
.
(6.3)
w( ) =
w(kTs ) sinc
Ts
k=
In principle, if the sum is taken over all time, the value of w( ) is exact. As a
practical matter, the sum must be taken over a suitable (nite) time window.
To see why interpolation works, note that the formula (6.3) is a convolution
(in time) of the signal w(kTs ) and the sinc function. Since convolution in time
is the same as multiplication in frequency by (A.40), the transform of w( ) is
equal to the product of F {ws (kTs )} and the transform of the sinc. By (A.22),
the transform of the sinc function in time is a rect function in frequency. This
rect function is a lowpass lter, since it passes all frequencies below fs /2 and
removes all frequencies above. Since the process of sampling a continuous-time
signal generates replicas of the spectrum at integer multiples of fs by (6.2), the
lowpass lter removes all but one of these replicas. In eect, the sampled data
are passed through an analog lowpass lter to create a continuous-time function,
and the value of this function at time is the required interpolated value. When
= nTs , then sinc( nTs ) = 1, and sinc( nTs ) = 0 for all kTs with k = n.
When is between sampling instants, the sinc is nonzero at all kTs , and (6.3)
combines them to recover w( ).
To see how (6.3) works, the following code generates a sine wave w of frequency
20 Hz with a sampling rate of 100 Hz. This is a modestly sampled sine wave,
having only ve samples per period, and its graph is jumpy and discontinuous.
Because the sampling rate is greater than the Nyquist rate, it is possible in
principle to recover the underlying smooth sine wave from which the samples
are drawn. Running sininterp.m shows that it is also possible in practice. The
plot in Figure 6.14 shows the original wave (which appears choppy because it is
sampled only ve times per period), and the reconstructed or smoothed waveform
(which looks just like a sine wave). The variable intfac species how many extra
1
Amplitude
112
1
10
10.1
10.2
Time
10.3
10.4
interpolated points are calculated, and need not be an integer. Larger numbers
result in smoother curves but also require more computation.
Listing 6.3. sininterp.m demonstrate interpolation/reconstruction using sin wave
f =20; Ts =1/100; time =20;
% s a m p l i n g i n t e r v a l and time
t=Ts : Ts : time ;
% time v e c t o r
w=s i n (2 * pi * f * t ) ;
% w( t ) = a s i n e wave o f f H e r tz
o v e r =100;
% # o f data p o i n t s i n smoothing
i n t f a c =10;
% how many i n t e r p o l a t e d p o i n t s
tnow =10.0/ Ts : 1 / i n t f a c : 1 0 . 5 / Ts ;
% i n t e r p o l a t e from 10 to 1 0 . 5
wsmooth=zeros ( s i z e ( tnow ) ) ;
% s a v e smoothed data h e r e
f o r i =1: length ( tnow )
% and l o o p f o r n e x t p o i n t
wsmooth ( i )= i n t e r p s i n c (w, tnow ( i ) , o v e r ) ;
end
In implementing (6.3), some approximations are used. First, the sum cannot
be calculated over an innite time horizon, and the variable over replaces the
over
sum
k= with
k=over . Each pass through the for loop calculates one
point of the smoothed curve wsmooth using the Matlab function interpsinc.m,
which is shown below. The value of the sinc is calculated at each time using the
function srrc.m with the appropriate oset tau, and then the convolution is
performed by the conv command. This code is slow and unoptimized. A clever
programmer will see that there is no need to calculate the sinc for every point, and
ecient implementations use sophisticated look-up tables to avoid the calculation
of transcendental functions completely.
Listing 6.4. interpsinc.m interpolate to nd a single point using the direct method
function y=i n t e r p s i n c ( x , t , l , beta )
% x = sampled data
% t = p l a c e a t which v a l u e d e s i r e d
% l = ones i d e d l e n g t h o f data to i n t e r p o l a t e
% b eta = r o l l o f f f a c t o r f o r s r r c f u n c t i o n
%
= 0 is a sinc
i f nargin==3, beta =0; end ;
% i f u n s p e c i f i e d , b e ta i s 0
tnow=round ( t ) ;
% s e t i n d e x tnow=i n t e g e r p a r t
tau=tround ( t ) ;
% p l u s tau=f r a c t i o n a l p a r t
% i n t e r p o l a t e s i n c a t o f f s e t tau
s t a u=s r r c ( l , beta , 1 , tau ) ;
x t a u=conv ( x ( tnowl : tnow+l ) , s t a u ) ; % i n t e r p o l a t e th e s i g n a l
% to g e t th e new sample
y=x t a u (2 * l +1);
While the indexing needed in interpsinc.m is a bit tricky, the basic idea is
not: the sinc interpolation of (6.3) is just a linear lter with impulse response
h(t) = sinc(t). (Remember, convolutions are the hallmark of linear lters.) Thus,
113
it is a lowpass lter, since the frequency response is a rect function. The delay
is proportional to the phase of the frequency response.
Exercise 6.18. In sininterp.m, what happens when the sampling rate is too
low? How large can the sampling interval Ts be? How high can the frequency f
be?
Exercise 6.19. In sininterp.m, what happens when the window is reduced?
Make over smaller and nd out. What happens when too few points are interpolated? Make intfac smaller and nd out.
Exercise 6.20. Create a more interesting (more complex) wave w(t). Answer
the above questions for this w(t).
Exercise 6.21. Let w(t) be a sum of ve sinusoids for t between 10 and 10 s.
Let w(kT ) represent samples of w(t) with T = 0.01 s. Use interpsinc.m to interpolate the values w(0.011), w(0.013), and w(0.015). Compare the interpolated
values with the actual values. Explain any discrepancies.
Observe that sinc(t) dies away (slowly) in time at a rate proportional to
1/(t). This is one of the reasons why so many terms are used in the convolution (i.e., why the variable over is large). A simple way to reduce the number of terms is to use a function that dies away more quickly than the sinc; a
common choice is the square-root raised cosine (SRRC) function, which plays
an important role in pulse shaping in Chapter 11. The functional form of the
SRRC is given in Equation (11.8). The SRRC can easily be incorporated into
the interpolation code by replacing the code interpsinc(w,tnow(i),over) with
interpsinc(w,tnow(i),over,beta).
Exercise 6.22. With beta=0, the SRRC is exactly the sinc. Redo the above
exercises trying various values of beta between 0 and 1.
The function srrc.m is available on the website. Its help le is
%
%
%
%
%
%
%
%
Matlab also has a built-in function called resample, which has the following
help le:
% Change th e s a m p l i n g r a t e o f a s i g n a l
% Y = r e s a m p l e (X, P ,Q) r e s a m p l e s th e s e q u e n c e
% i n v e c t o r X a t P/Q t i m e s th e o r i g i n a l sample
114
% r a t e u s i n g a p o l y p h a s e i m p l em en ta ti o n .
% Y i s P/Q t i m e s th e l e n g t h o f X.
% P and Q must be p o s i t i v e i n t e g e r s .
This technique is dierent from that used in (6.3). It is more ecient numerically at reconstructing entire waveforms, but it works only when the desired
resampling rate is rationally related to the original. The method of (6.3) is far
more ecient when isolated (not necessarily evenly spaced) interpolating points
are required, which is crucial for synchronization tasks in Chapter 12.
6.5
115
The nal step in implementing any solution is to check that the method
behaves as desired, despite any simplifying assumptions that may have been
made in its derivation. This may involve a detailed analysis of the resulting
methodology, or it may involve simulations. Thorough testing would involve both
analysis and simulation in a variety of settings that mimic, as closely as possible,
the situations in which the method will be used.
Imagine being lost on a mountainside on a foggy night. Your goal is to
get to the village which lies at the bottom of a valley below. Though
you cannot see far, you can reach out and feel the nearby ground. If you
repeatedly step in the direction that heads downhill most steeply, you
eventually reach a depression in which all directions lead up. If the contour of the land is smooth, and without any local depressions that can
trap you, then you will eventually arrive at the village. The optimization
procedure called steepest descent implements this scenario mathematically, where the mountainside is dened by the performance function
and the optimal answer lies in the valley at the minimum value. Many
standard communications algorithms (adaptive elements) can be viewed
in this way.
6.6
(6.4)
achieves its minimum value. Thus step (1) is set. As any calculus book will
suggest, the direct way to nd the minimum is to take the derivative, set it
equal to zero, and solve for x. Thus, dJ(x)/dx = 2x 4 = 0 is solved when x =
2. This is indeed the value of x for which the parabola J(x) reaches bottom.
Sometimes (one might truthfully say often), however, such direct approaches
are impossible. Maybe the derivative is just too complicated to solve (which can
happen when the functions involved in J(x) are extremely nonlinear). Or maybe
the derivative of J(x) cannot be calculated precisely from the available data, and
instead must be estimated from a noisy data stream.
One alternative to the direct solution technique is an adaptive method called
steepest descent (when the goal is to minimize) or hill climbing (when the
goal is to maximize). Steepest descent begins with an initial guess of the location of the minimum, evaluates which direction from this estimate is most steeply
downhill, and then makes a new estimate along the downhill direction. Similarly, hill climbing begins with an initial guess of the location of the maximum,
evaluates which direction climbs the most rapidly, and then makes a new esti-
116
J(x)
Gradient direction
has same sign as
the derivative
Derivative is
slope of line
tangent to
J(x) at x
xn
Minimum
xp
mate along the uphill direction. With luck, the new estimates are better than
the old. The process repeats, ideally getting closer to the optimal location at
each step. The key ingredient in this procedure is to recognize that the uphill
direction is dened by the gradient evaluated at the current location, while the
downhill direction is the negative of this gradient.
To apply steepest descent to the minimization of the polynomial J(x) in (6.4),
suppose that a current estimate of x is available at time k, which is denoted x[k].
A new estimate of x at time k + 1 can be made using
dJ(x)
x[k + 1] = x[k]
,
(6.5)
dx x=x[k]
where is a small positive number called the stepsize, and the gradient (derivative) of J(x) is evaluated at the current point x[k]. This is then repeated again
and again as k increments. This procedure is shown in Figure 6.15. When the
current estimate x[k] is to the right of the minimum, the negative of the gradient
points left. When the current estimate is to the left of the minimum, the negative gradient points to the right. In either case, as long as the stepsize is suitably
small, the new estimate x[k + 1] is closer to the minimum than the old estimate
x[k]; that is, J(x[k + 1]) is less than J(x[k]).
To make this explicit, the iteration dened by (6.5) is
x[k + 1] = x[k] (2x[k] 4),
or, rearranging,
x[k + 1] = (1 2)x[k] + 4.
(6.6)
In principle, if (6.6) is iterated over and over, the sequence x[k] should approach
the minimum value x = 2. Does this actually happen?
There are two ways to answer this question. It is straightforward to simulate
the process. Here is some Matlab code that takes an initial estimate of x called
x(1) and iterates Equation (6.6) for N=500 steps.
Listing 6.5. polyconverge.m nd the minimum of J(x) = x2 4x + 4 via steepest
descent
N=500;
% number o f i t e r a t i o n s
117
Starting values
4
3
2
1
0
1
2
0
50
100
150
200 250
Time
mu= . 0 1 ;
x=zeros ( 1 ,N ) ;
x(1)=3;
f o r k =1:N1
x ( k+1)=(12*mu) * x ( k)+4 *mu ;
end
300
350
400
% algorithm s t e p s i z e
% i n i t i a l i z e x to z e r o
% s t a r t i n g point x (1)
% update e q u a t i o n
Figure 6.16 shows the output of polyconverge.m for 50 dierent x(1) starting
values superimposed; all converge smoothly to the minimum at x = 2.
Exercise 6.23. Explore the behavior of steepest descent by running
polyconverge.m with dierent parameters.
a. Try mu = 0.01, 0, 0.0001, 0.02, 0.03, 0.05, 1.0, 10.0. Can mu be too large or
too small?
b. Try N = 5, 40, 100, 5000. Can N be too large or too small?
c. Try a variety of values of x(1). Can x(1) be too large or too small?
As an alternative to simulation, observe that the process (6.6) is itself a linear
time-invariant system, of the general form
x[k + 1] = ax[k] + b,
(6.7)
which is stable as long as |a| < 1. For a constant input, the nal-value theorem of
z-transforms (see (A.55)) can be used to show that the asymptotic (convergent)
output value is limk xk = b/(1 a). To see this without reference to arcane
theory, observe that if xk is to converge, then it must converge to some value,
say x . At convergence, x[k + 1] = x[k] = x , so (6.7) implies that x = ax +
b, which implies that x = b/(1 a). (This holds assuming that |a| < 1.) For
example, for (6.6), x = 4/[1 (1 2)] = 2, which is indeed the minimum.
Thus, both simulation and analysis suggest that the iteration (6.6) is a viable
way to nd the minimum of the function J(x), as long as is suitably small. As
will become clearer in later sections, such solutions to optimization problems are
almost always possibleas long as the function J(x) is dierentiable. Similarly, it
118
(6.8)
sign(x) =
1
1
x>0
x<0
(6.9)
is the formal derivative of |x|. Solving directly for the minimum point is nontrivial
(try it!). Yet implementing a steepest-descent search for the minimum can be
done in a straightforward manner using the iteration
x[k + 1] = x[k] e0.1 |x[k]| (cos(x[k]) 0.1 sin(x[k])sign(x)).
(6.10)
119
40
0.5
20
J(x)
J(x)
30
10
0.5
0
4
2
x
20 15 10 5
0
x
10
15
20
Figure 6.17 Error surfaces corresponding to (a) the objective function (6.4) and (b)
the objective function (6.8).
120
where the absolute bandwidth of the baseband message waveform w(t) is less
than fc /2. The signals x and y are generated via
x(t) = LPF{r(t) cos(2fc t + )},
y(t) = LPF{r(t) sin(2fc t + )},
where the LPF cuto frequency is fc /2.
a. Determine x(t) in terms of w(t), fc , , and .
b. Show that
d 1 2
x (t) = x(t)y(t)
d 2
using the fact that derivatives and lters commute as in (G.5).
c. Determine the values of maximizing x2 (t).
Exercise 6.28. Consider the function
J(x) = (1 |x 2|)2 .
a. Sketch J(x) for 5 x 5.
b. Analytically determine all local minima and maxima of J(x) for 5 x 5.
Hint: d|fdb(b)| = sign(f (b)) dfdb(b) where sign(a) is dened in (6.9).
c. Is J(x) unimodal as a function of x? Explain your answer.
d. Develop an iterative gradient-descent algorithm for updating x to minimize
J.
e. For an initial estimate of x = 1.2, what is the convergent value of x determined
by an iterative gradient-descent algorithm with a satisfactorily small stepsize?
f. Compute the direction (either increasing x or decreasing x) of the update
from (d) for x = 1.2.
g. Does the direction determined in part (f) point from x = 1.2 toward the convergent value of part (e)? Should it (for a correct answer to (e))? Explain your
answer.
6.7
quantization levels
121
(a)
Sampler
Input
r(t)
a
(b)
Output
s(kT) = s[k]
Quality
Assessment
While more power is generally better from the point of view of trying to decipher the transmitted message, there are always limits to the power-handling
capabilities of the receiver. Hence, if the received signal is too large (on average),
it must be attenuated. Similarly, if the received signal is weak (on average), then
it must be amplied.
Figure 6.18 shows the two extremes that the AGC is designed to avoid. In part
(a), the signal is much larger than the levels of the sampling device (indicated
by the horizontal lines). The gain must be made smaller. In part (b), the signal
is much too small to be captured eectively, and the gain must be increased.
There are two basic approaches to an AGC. The traditional approach uses analog circuitry to adjust the gain before the sampling. The more modern approach
uses the output of the sampler to adjust the gain. The advantage of the analog
method is that the two blocks (the gain and the sampling) are separate and
do not interact. The advantage of the digital adjustment is that less additional
hardware is required since the DSP is already present for other tasks.
A simple digital system for AGC adjustment is shown in Figure 6.19. The
input r(t) is multiplied by the gain a to give the normalized signal s(t). This is
then sampled to give the output s[k]. The assessment block measures s[k] and
determines whether a must be increased or decreased.
The goal is to choose a so that the power (or average energy) of s(t) is approximately equal to some specied S 2 . Since
a2 avg{r2 (t)}t=kT avg{s2 (kT )} avg{s2 [k]},
122
S2
,
avg{r2 (kT )}
(6.11)
because this would imply that avg{s2 (kT )} S 2 . The averaging operation (in
this case a moving average over a block of data of size N ) is dened by
avg{x[k]} =
1
N
k
x[i]
i=kN +1
123
(6.16)
124
choice of stepsize: a larger allows a[k] to change faster, while a smaller allows
greater smoothing. Thus, can be chosen by the system designer to trade o
the bandwidth of a[k] (the speed at which a[k] can track variations in the energy
levels of the incoming signal) versus the amount of jitter or noise. Similarly, the
length over which the averaging is done (specied by the parameter lenavg)
will also inuence the speed of adaptation; longer averages imply slower-moving,
smoother estimates while shorter averages imply faster-moving, more jittery estimates.
Listing 6.6. agcgrad.m minimize the performance function J(a) = avg{|a|((1/3)a2 r2
ds)} by choice of a
n =10000;
% number o f s t e p s i n s i m u l a t i o n
vr =1.0;
% power o f th e i n p u t
r=sqrt ( v r ) * randn ( n , 1 ) ;
% g e n e r a t e random i n p u t s
ds = 0 . 1 5 ;
% d e s i r e d power o f o u t p u t
mu= 0 . 0 0 1 ;
% algorithm s t e p s i z e
l e n a v g =10;
% l e n g t h o v e r which to a v e r a g e
a=zeros ( n , 1 ) ; a ( 1 ) = 1 ;
% i n i t i a l i z e AGC p a r a m e te r
s=zeros ( n , 1 ) ;
% i n i t i a l i z e outputs
a v e c=zeros ( 1 , l e n a v g ) ;
% v e c t o r to s t o r e a v e r a g i n g terms
f o r k =1:n1
s ( k)=a ( k ) * r ( k ) ;
% n o r m a l i z e by a ( k ) & add to a v e c
a v e c =[ sign ( a ( k ) ) * ( s ( k)2 ds ) , a v e c ( 1 : l e n a v g 1 ) ] ;
a ( k+1)=a ( k)mu*mean( a v e c ) ;
% a v e r a g e a d a p t i v e update o f a ( k )
end
In this case, with the default values, a converges to about 0.22, which is the
value that minimizes the least-square objective JLS (a). Thus, the answer which
minimizes JLS (a) is dierent from the answer which minimizes JN (a)! More on
this later.
As it is easy to see when playing with the parameters in agcgrad.m, the
size of the averaging parameter lenavg is relatively unimportant. Even with
lenavg=1, the algorithms converge and perform approximately the same! This
is because the algorithm updates are themselves in the form of a lowpass lter.
(See Appendix G for a discussion of the similarity between averagers and lowpass
lters.) Removing the averaging from the update gives the simpler form for JN (a)
a ( k+1)=a ( k)mu* sign ( a ( k ) ) * ( s ( k)2 ds ) ;
125
2
1.5
1
0.5
0
Amplitude
Input r(k)
0
5
5
Output s(k)
0
5
2000
4000
6000
Iterations
8000
10000
Try them!
Perhaps the best way to formally describe how the algorithms work is to plot
the performance functions. But it is not possible to directly plot JLS (a) or JN (a),
since they depend on the data sequence s[k]. What is possible (and often leads
to useful insights) is to plot the performance function averaged over a number
of data points (also called the error surface). As long as the stepsize is small
enough and the average is long enough, the mean behavior of the algorithm will
be dictated by the shape of the error surface in the same way that the objective
function of the exact steepest-descent algorithm (for instance, the objectives
(6.4) and (6.8)) dictates the evolution of the algorithms (6.6) and (6.10).
The following code agcerrorsurf.m shows how to calculate the error surface
for JN (a). The variable n species the number of terms to average over, and tot
sums up the behavior of the algorithm for all n updates at each possible parameter value a. The average of these (tot/n) is a close (numerical) approximation
to JN (a) of (6.15). Plotting over all a gives the error surface.
Listing 6.7. agcerrorsurf.m draw the error surface for the AGC
n =10000;
% number o f s t e p s i n s i m u l a t i o n
r=randn ( n , 1 ) ;
% g e n e r a t e random i n p u t s
ds = 0 . 1 5 ;
% d e s i r e d power o f o u t p u t
range = [ 0 . 7 : 0 . 0 2 : 0 . 7 ] ;
% s p e c i f y range o f v a l u es o f a
Jagc=zeros ( s i z e ( r a n g e ) ) ; j =0;
f o r a=r a n g e
% f o r each v a l u e a
j=j +1; t o t =0;
% t ot al cost
f o r i =1:n
% over a l l p o s s i b i l i t i e s
t o t=t o t+abs ( a ) * ( ( 1 / 3 ) * a 2 * r ( i )2 ds ) ;
end
Jagc ( j )= t o t /n ;
% take average value
end
0.02
cost JN(a)
0.025
cost JLS(a)
126
0.015
0
0.02
0.005
0
0.04
Figure 6.21 The error surface for the AGC objective functions (6.12) and (6.15) each
have two minima. As long as a can be initialized with the correct (positive) sign,
there is little danger of converging to the wrong minimum.
Similarly, the error surface for JLS (a) can be plotted using
t o t=t o t + 0 . 2 5 * ( a 2 * r ( i )2 ds ) 2 ;
% e r r o r s u r f a c e f o r JLS
127
Exercise 6.30. Show that the value of a that achieves the minimum of JLS (a)
can be expressed as
S 2 k rk2
4 .
k rk
Is there a way to use this (closed-form) solution to replace the iteration (6.14)?
Exercise 6.31. Consider the alternative objective function J(a) =
1 2 2
2
2 a (s [k]/6 S ). Calculate the derivative and implement a variation of
the AGC algorithm that minimizes this objective. How does this version
compare with the algorithms (6.14) and (6.16)? Draw the error surface for this
algorithm. Which version is preferable?
Exercise 6.32. Try initializing the estimate a(1)=-2 in agcgrad.m. Which minimum does the algorithm nd? What happens to the data record?
Exercise 6.33. Create your own objective function J(a) for the AGC problem.
Calculate the derivative and implement a variation of the AGC algorithm that
minimizes this objective. How does this version compare with the algorithms
(6.14) and (6.16)? Draw the error surface for your algorithm. Which version do
you prefer?
Exercise 6.34. Investigate how the error surface depends on the input signal.
Replace randn with rand in agcerrorsurf.m and draw the error surfaces for
JN (a) and JLS (a).
6.8
128
Input r[k]
5
0
5
1.5
1
0.5
0
5
Output s[k]
0
5
0
3
Iterations
5
x104
%
%
%
%
%
%
%
%
# steps in simulation
g e n e r a t e random i n p u t s
th e f a d i n g p r o f i l e
a p p l y to raw i n p u t r [ k ]
d e s i r e d power o f o u t p u t
i n i t i a l i z e AGC p a r a m e te r
i n i t i a l i z e outputs
algorithm s t e p s i z e
% n o r m a l i z e by a to g e t s
% a d a p t i v e update o f a ( k )
The fading prole dened by the vector env is slow compared with the rate
at which the adaptive gain moves, which allows the gain to track the changes.
Also, the power of the input never dies away completely. The problems that
follow ask you to investigate what happens in more extreme situations.
Exercise 6.35. Mimic the code in agcvsfading.m to investigate what happens
when the input signal dies away. (Try removing the abs command from the
fading prole variable.) Can you explain what you see?
Exercise 6.36. Mimic the code in agcvsfading.m to investigate what happens
when the power of the input signal varies rapidly. What happens if the sign of
the gain estimate is incorrect?
Exercise 6.37. Would the answers to the previous two problems change on
using algorithm (6.14) instead of (6.16)?
6.9
129
Summary
Sampling transforms a continuous-time analog signal into a discrete-time digital
signal. In the time domain, this can be viewed as a multiplication by a train of
pulses. In the frequency domain this corresponds to a replication of the spectrum.
As long as the sampling rate is fast enough that the replicated spectra do not
overlap, the sampling process is reversible; that is, the original analog signal can
be reconstructed from the samples.
An AGC can be used to make sure that the power of the analog signal remains
in the region where the sampling device operates eectively. The same AGC,
when adaptive, can also provide a protection against signal fades. The AGC can
be designed using a steepest-descent (optimization) algorithm that updates the
adaptive parameter by moving in the direction of the negative of the derivative.
This steepest-descent approach to the solution of optimization problems will be
used throughout Software Receiver Design.
Once the received signal is sampled, the real story of the digital receiver begins.
An analog bandpass lter at the front end of the receiver removes extraneous
signals (for instance, it removes television-frequency signals from a radio receiver)
but some portion of the signal from other FDM users may remain. While it would
be conceptually possible to remove all but the desired user at the start, accurate
retunable analog lters are complicated and expensive to implement. Digital
lters, on the other hand, are easy to design, inexpensive (once the appropriate
DSP hardware is present), and easy to retune. The job of cleaning up out-ofband interferences left over by the analog BPF can be left to the digital portion
of the receiver.
Of course, there are many other uses for digital lters in the receiver, and
this chapter focuses on how to build digital lters. The discussion begins by
considering the digital impulse response and the related notion of discrete-time
convolution. Conceptually, this closely parallels the discussion of linear systems in
Chapter 4. The meaning of the DFT (discrete Fourier transform) closely parallels
the meaning of the Fourier transform, and several examples encourage uency in
the spectral analysis of discrete data signals. The nal section on practical ltering shows how to design digital lters with (more or less) any desired frequency
response by using special Matlab commands.
7.1
131
Just as the impulse function (t) plays a key role in dening signals and systems
in continuous time, the discrete pulse
1 k=0
[k] =
(7.1)
0 k = 0
can be used to decompose discrete signals and to characterize discrete-time
systems.1 Any discrete-time signal can be written as a linear combination
of discrete impulses. For instance, if the signal w[k] is the repeating pattern
{1, 1, 2, 1, 1, 1, 2, 1, . . .}, it can be written
w[k] = [k] + [k 1] + 2[k 2] + [k 3] [k 4]
+ [k 5] + 2[k 6] + [k 7] . . .
In general, the discrete-time signal w[k] can be written
w[k] =
w[j][k j].
j=
This is the discrete analog of the sifting property (4.4); simply replace the integral
with a sum, and replace (t) with [k].
Like their continuous-time counterparts, discrete-time systems map input signals into output signals. Discrete-time LTI (linear time-invariant) systems are
characterized by an impulse response h[k], which is the output of the system
when the input is an impulse, though, of course, (7.1) is used instead of (4.2).
When an input x[k] is more complicated than a single pulse, the output y[k] can
be calculated by summing all the responses to all the individual terms, and this
leads directly to the denition of discrete-time convolution:
y[k] =
(7.2)
j=
Observe that the convolution of discrete-time sequences appears in the reconstruction formula (6.3), and that (7.2) parallels continuous-time convolution in
(4.8) with the integral replaced by a sum and the impulse response h(t) replaced
by h[k].
The discrete-time counterpart of the Fourier transform is the discrete Fourier
transform (DFT). Like the Fourier transform, the DFT decomposes signals into
their constituent sinusoidal components. Like the Fourier transform, the DFT
provides an elegant way to understand the behavior of LTI systems by looking
at the frequency response (which is equal to the DFT of the impulse response).
Like the Fourier transform, the DFT is an invertible, information-preserving
transformation.
1
The pulse in discrete time is considerably more straightforward than the implicit denition
of the continuous-time impulse function in (4.2) and (4.3).
132
The DFT diers from the Fourier transform in three useful ways. First, it
applies to discrete-time sequences, which can be stored and manipulated directly
in computers (rather than to analog waveforms, which cannot be directly stored
in digital computers). Second, it is a sum rather than an integral, and so is easy
to implement either in hardware or in software. Third, it operates on a nite
data record, rather than an integration over all time. Given a data record (or
vector) w[k] of length N , the DFT is dened by
W [n] =
N
1
w[k]ej(2/N )nk
(7.3)
k=0
N 1
1
W [n]ej(2/N )nk
N n=0
(7.4)
133
r Symmetryif the time signal w[k] is real, then W [n] = W [N n]. This is
analogous to (A.35).
r The frequency response H[n] of an LTI system is the DFT of the impulse
r
r
r
r
r
r
response h[k]. This is analogous to the continuous-time result that the frequency response H(f ) is the Fourier transform of the impulse response h(t).
Time-delay property in discrete timew[k l] W [n]ej(2/N )l . This is
analogous to (A.37).
Modulation propertythis frequency-shifting property is analogous to (A.34).
If w[k] = sin(2f k/T ) is a periodic sine wave, then the spectrum is a sum of
two delta impulses. This is analogous to the result in Example 4.1.
Convolution2 in (discrete) time is the same as multiplication in (discrete)
frequency. This is analogous to (4.10).
Multiplication in (discrete) time is the same as convolution in (discrete) frequency. This is analogous to (4.11).
The transfer function of a LTI system is the ratio of the DFT of the output
and the DFT of the input. This is analogous to (4.12).
7.1.1
To be precise, this should be circular convolution. However, for the purposes of designing
a workable receiver, this distinction is not essential. The interested reader can explore the
relationship of discrete-time convolution in the time and frequency domains in a concrete
way using waystofilt.m on page 143.
134
1
1
1
1
1
1 ej2/N
ej4/N
ej6/N
ej2(N 1)/N
j4/N
j8/N
j12/N
e
e
ej4(N 1)/N
1 e
1 ej6/N
ej12/N
ej18/N ej6(N 1)/N .
.
..
..
..
..
.
.
.
.
.
2
j2(N 1)/N j4(N 1)/N j6(N 1)/N
j2(N 1) /N
e
e
e
1e
Then the IDFT equation (7.4) can be rewritten as a matrix multiplication
w=
1 1
M W
N
(7.5)
(7.6)
Since the inverse of an orthonormal matrix is equal to its own complex conjugate
transpose, M in (7.6) is the same as M 1 in (7.5) with the signs on all the
exponents ipped.
The matrix M 1 is highly structured. Let Cn be the nth column of M 1 . On
multiplying both sides by N , (7.5) can be rewritten as
N w = W [0] C0 + W [1] C1 + + W [N 1] CN 1 =
N
1
W [n]Cn .
(7.7)
n=0
This form displays the time vector w as a linear combination3 of the columns Cn .
What are these columns? They are vectors of discrete (complex-valued) sinusoids,
each at a dierent frequency. Accordingly, the DFT reexpresses the time vector
as a linear combination of these sinusoids. The complex scaling factors W [n]
dene how much of each sinusoid is present in the original signal w[k].
To see how this works, consider the rst few columns. C0 is a vector of all ones;
it is the zero-frequency sinusoid, or DC. C1 is more interesting. The ith element
of C1 is ej2i/N , which means that, as i goes from 0 to N 1, the exponential
assumes N uniformly spaced points around the unit circle. This is clearer in
polar coordinates, where the magnitude is always unity and the angle is 2i/N
radians. Thus, C1 is the lowest-frequency sinusoid that can be represented (other
than DC); it is the sinusoid that ts exactly one period in the time interval N Ts ,
where Ts is the distance in time between adjacent samples. C2 is similar, except
that the ith element is ej4i/N . Again, the magnitude is unity and the phase is
4i/N radians. Thus, as i goes from 0 to N 1, the elements are N uniformly
spaced points which go around the circle twice. Thus, C2 has frequency twice
that of C1 , and it represents a complex sinusoid that ts exactly two periods into
3
Those familiar with advanced linear algebra will recognize that M 1 can be thought of as a
change of basis that reexpresses w in a basis dened by the columns of M 1 .
135
7.1.2
The discrete version of the symmetry property (A.35) shows that W [n] = W [N n]. Hence
the magnitudes are equal but the phases have opposite signs.
Magnitude
200
400
600
N = 210
800
1000
1200
Magnitude
136
500
1000
1500
N = 211
2000
2500
While the FFT/IFFT commands are easy to invoke, their meaning is not
always instantly transparent. The intent of this section is to provide some examples that show how to interpret (and how not to interpret) the frequency-analysis
commands in Matlab.
Begin with a simple sine wave of frequency f sampled every Ts seconds, as
is familiar from previous programs such as speccos.m. The rst step in any
frequency analysis is to dene the window over which the analysis will take
place, since the FFT/DFT must operate on a nite data record. The program
specsin0.m denes the length of the analysis with the variable N (powers of
two make for fast calculations), and then analyzes the rst N samples of w. It is
tempting to simply invoke the Matlab commands fft and to plot the results.
Typing plot(fft(w(1:N))) gives a meaningless answer (try it!) because the
output of the fft command is a vector of complex numbers. When Matlab
plots complex numbers, it plots the imaginary vs. the real parts. In order to view
the magnitude spectrum, rst use the abs command, as shown in specsin0.m.
Listing 7.1. specsin0.m naive and deceptive spectrum of a sine wave via the FFT
f =100; Ts =1/1000; time = 5 . 0 ;
t=Ts : Ts : time ;
w=s i n (2 * pi * f * t ) ;
N=210;
fw=abs ( f f t (w ( 1 :N ) ) ) ;
plot ( fw )
%
%
%
%
%
%
f r e q , s a m p l i n g i n t e r v a l , time
d e f i n e a time v e c t o r
d e f i n e th e s i n u s o i d
s i z e o f a n a l y s i s window
f i n d magnitude o f DFT/FFT
p l o t th e waveform
Running this program results in a plot of the magnitude of the output of the
FFT analysis of the waveform w. The top plot in Figure 7.1 shows two large
spikes, one near 100 and one near 900. What do these mean? Try a simple
experiment. Change the value of N from 210 to 211 . This is shown in the bottom
plot of Figure 7.1, where the two spikes now occur at about 200 and at about
1850. But the frequency of the sine wave hasnt changed! It does not seem
reasonable that the window over which the analysis is done should change the
frequencies in the signal.
Magnitude
137
100
200
300
400
500
Magnitude
500 400 300 200 100 0 100 200 300 400 500
Frequency
There are two problems. First, specsin0.m plots the magnitude data against
the index of the vector fw, and this index (by itself) is meaningless. The discussion surrounding (7.7) shows that each element of W [n] represents a scaling
of the complex sinusoid with frequency ej2n/N . Hence, these indices must be
scaled by the time over which the analysis is conducted, which involves both
the sampling interval and the number of points in the FFT analysis. The second
problem is the ordering of the frequencies. Like the columns Cn of the DFT
matrix M (7.6), the frequencies represented by the W [N n] are the negative
of the frequencies represented by W [n].
There are two solutions. The rst is appropriate only when the original signal is real-valued. In this case, the W [n]s are symmetric and there is no extra
information contained in the negative frequencies. This suggests plotting only
the positive frequencies, a strategy that is followed in specsin1.m.
Listing 7.2. specsin1.m spectrum of a sine wave via the FFT/DFT
f =100; Ts =1/1000; time = 5 . 0 ;
t=Ts : Ts : time ;
w=s i n (2 * pi * f * t ) ;
N=210;
s s f =(0:N/2 1)/( Ts *N ) ;
fw=abs ( f f t (w ( 1 :N ) ) ) ;
plot ( s s f , fw ( 1 :N/ 2 ) )
%
%
%
%
%
%
%
f r e q , s a m p l i n g i n t e r v a l , time
d e f i n e a time v e c t o r
d e f i n e th e s i n u s o i d
s i z e o f a n a l y s i s window
frequency vector
f i n d magnitude o f DFT/FFT
pl ot f o r p o s i t i v e f r eq only
The output of specsin1.m is shown in the top plot of Figure 7.2. The magnitude
spectrum shows a single spike at 100 Hz, as is expected. Change f to other values,
and observe that the location of the peak in frequency moves accordingly. Change
the width and location of the analysis window N and verify that the location of
the peak does not change. Change the sampling interval Ts and verify that the
analyzed peak remains at the same frequency.
The second solution requires more bookkeeping of indices, but gives plots
that more closely accord with continuous-time intuition and graphs. specsin2.m
exploits the built-in function fftshift, which shues the output of the FFT command so that the negative frequencies occur on the left, the positive frequencies
on the right, and DC in the middle.
138
%
%
%
%
%
%
%
%
f r e q , s a m p l i n g i n t e r v a l , time
d e f i n e a time v e c t o r
d e f i n e th e s i n u s o i d
s i z e o f a n a l y s i s window
frequency vector
do DFT/FFT
shift it for plotting
p l o t magnitude spectrum
Running this program results in the bottom plot of Figure 7.2, which shows the
complete magnitude spectrum both for positive and for negative frequencies. It
is also easy to plot the phase spectrum by substituting phase for abs in either
of the preceding two programs.
Exercise 7.5. Explore the limits of the FFT/DFT technique by choosing
extreme values. What happens in the following cases?
a. f becomes too large. Try f = 200, 300, 450, 550, 600, 800, 2200 Hz. Comment
on the relationship between f and Ts.
b. Ts becomes too large. Try Ts = 1/500, 1/250, 1/50. Comment on the relationship between f and Ts. (You may have to increase time in order to have
enough samples to operate on.)
c. N becomes too large or too small. What happens to the location in the peak
of the magnitude spectrum when N = 211 , 214 , 28 , 24 , 22 , 220 ? What happens
to the width of the peak in each of these cases? (You may have to increase
time in order to have enough samples to operate on.)
Exercise 7.6. Replace the sin function with sin2 . Use w=sin(2*pi*f*t).2. What
is the spectrum of sin2 ? What is the spectrum of sin3 ? Consider sink . What is the
largest k for which the results make sense? Explain what limitations there are.
Exercise 7.7. Replace the sin function with sinc. What is the spectrum of the
sinc function? What is the spectrum of sinc2 ?
Exercise 7.8. Plot the spectrum of w(t) = sin(t) + jet . Should you use the
technique of specsin1.m or of specsin2.m? Hint: think symmetry.
Exercise 7.9. The FFT of a real sequence is typically complex, and sometimes
it is important to look at the phase (as well as the magnitude).
a. Let w=sin(2*pi*f*t+phi). For phi = 0, 0.2, 0.4, 0.8, 1.5, 3.14, nd the phase of
the FFT output at the frequencies f.
b. Find the phase of the output of the FFT when w=sin(2*pi*f*t+phi).2.
These are all examples of simple functions, which can be investigated (in
principle, anyway) analytically. The greatest strength of the FFT/DFT is that
it can also be used for the analysis of data when no functional form is known.
139
Running specgong.m results in the plot shown in Figure 7.3. The top gure
shows the time behavior of the sound as it rises very quickly (when the gong
is struck) and then slowly decays over about 1.5 s. The variable N denes the
window over which the frequency analysis occurs. The lower-left plot shows the
complete spectrum, and the bottom-right plot zooms in on the low-frequency
portion where the largest spikes occur. This sound consists primarily of three
major frequencies, at about 520, 630, and 660 Hz. Physically, these represent the
three largest resonant modes of the vibrating plate.
With N = 216 , specgong.m analyzes approximately 1.5 s (Ts*N seconds, to
be precise). It is reasonable to suppose that the gong sound might undergo
important transients during the rst few milliseconds. This can be investigated
by decreasing N and applying the DFT to dierent segments of the data record.
Exercise 7.10. Determine the spectrum of the gong sound during the rst 0.1 s.
What value of N is needed? Compare this with the spectrum of a 0.1 s segment
chosen from the middle of the sound. How do they dier?
Exercise 7.11. A common practice when taking FFTs is to plot the magnitude
on a log scale. This can be done in Matlab by replacing the plot command
with semilogy. Try it in specgong.m. What extra details can you see?
Exercise 7.12. The waveform of the sound produced by another, much larger
gong is given in gong2.wav on the website. Conduct a thorough analysis of this
sound, looking at the spectrum for a variety of analysis windows (values of N)
and at a variety of times within the waveform.
Exercise 7.13. Choose a .wav le from the website (in the Sounds folder) or
download a .wav le of a song from the Internet. Conduct a FFT analysis of the
rst few seconds of sound, and then another analysis in the middle of the song.
140
Amplitude
1
0
Magnitude
0.5
1
Time in seconds
1.5
0.5
1
1.5
2
Frequency in Hertz
2.5
x104
0
400 450 500 550 600 650 700 750 800
Frequency in Hertz
Figure 7.3 Time and frequency plots of the gong waveform. The top gure shows the
decay of the signal over 1.5 s. The bottom left gure shows the magnitude spectrum,
and the right gure zooms in on the low-frequency portion so that the frequencies are
more legible.
How do the two compare? Can you correlate the FFT analysis with the pitch of
the material? With the rhythm? With the sound quality?
The key factors in a DFT- or FFT-based frequency analysis are as follows.
r The sampling interval Ts is the time resolution, the shortest time over which
r
r
any event can be observed. The sampling rate fs = 1/Ts is inversely proportional.
The total time is T = N Ts , where N is the number of samples in the analysis.
The frequency resolution is 1/T = 1/(N Ts ) = fs /N . Sinusoids closer together
(in frequency) than this value are indistinguishable.
For instance, in the analysis of the gong conducted in specgong.m, the sampling
interval Ts = 1/44100 is dened by the recording. With N = 216 , the total time
is N Ts = 1.48 s, and the frequency resolution is 1/(N Ts ) = 0.67 Hz.
Sometimes the total absolute time T is xed. Sampling faster decreases Ts and
increases N , but cannot give better resolution in frequency. Sometimes it is possible to increase the total time. Assuming a xed Ts , this implies an increase in
N and better frequency resolution. Assuming a xed N , this implies an increase
in Ts and worse resolution in time. Thus, better resolution in frequency means
worse resolution in time. Conversely, better resolution in time means worse resolution in frequency. If this is still confusing, or if you would like to see it from
a dierent perspective, check out Appendix D.
The DFT is a key tool in analyzing and understanding the behavior of communications systems. Whenever data ow through a system, it is a good idea
to plot the data as a function of time, and also as a function of frequency; that
is, to look at the data in the time domain and in the frequency domain. Often,
141
aspects of the data that are clearer in time are hard to see in frequency, and
aspects that are obvious in frequency are obscure in time. Using both points of
view is common sense.
7.2
Practical Filtering
Filtering can be viewed as the process of emphasizing or attenuating certain
frequencies within a signal. Linear time-invariant lters are common because they
are easy to understand and straightforward to implement. Whether in discrete
or continuous time, an LTI lter is characterized by its impulse response (i.e.,
its output when the input is an impulse). The process of convolution aggregates
the impulse responses from all the input instants into a formula for the output.
It is hard to visualize the action of convolution directly in the time domain,
making analysis in the frequency domain an important conceptual tool. The
Fourier transform (or the DFT in discrete time) of the impulse response gives
the frequency response, which is easily interpreted as a plot that shows how much
gain or attenuation (or phase shift) each frequency experiences as a result of the
ltering operation. Thus, while implementing the lter in the time domain as a
convolution, it is normal to specify, design, and understand it in the frequency
domain as a point-by-point multiplication of the spectrum of the input and the
frequency response of the lter.
In principle, this provides a method not only of understanding the action
of a lter, but also of designing a lter. Suppose that a particular frequency
response is desired, say one that removes certain frequencies, while leaving others
unchanged. For example, if the noise is known to lie in one frequency band while
the important signal lies in another frequency band, then it is natural to design
a lter that removes the noisy frequencies and passes the signal frequencies.
This intuitive notion translates directly into a mathematical specication for the
frequency response. The impulse response can then be calculated directly by
taking the inverse transform, and this impulse response denes the desired lter.
While this is the basic principle of lter design, a number of subtleties can arise,
and sophisticated routines are available in Matlab that make the lter design
process exible, even if they are not foolproof.
Filters are classied in several ways.
r Lowpass lters (LPF) try to pass all frequencies below some cuto frequency
and remove all frequencies above.
r Highpass lters try to pass all frequencies above some specied value and
remove all frequencies below.
r Bandpass lters try to pass all frequencies in a particular range and to reject
all others.
142
The region of frequencies allowed to pass through a lter is called the passband,
while the region of frequencies removed is called the stopband. Sometimes there
is a region between where it is relatively less important what happens, and this
is called the transition band.
By linearity, more complex lter specications can be implemented as sums
and concatenations of the above basic lter types. For instance, if h1 [k] is the
impulse response of a bandpass lter that passes only frequencies between 100
and 200 Hz, and h2 [k] is the impulse response of a bandpass lter that passes
only frequencies between 500 and 600 Hz, then h[k] = h1 [k] + h2 [k] passes only
frequencies between 100 and 200 Hz or between 500 and 600 Hz. Similarly, if
hl [k] is the impulse response of a lowpass lter that passes all frequencies below
600 Hz, and hh [k] is the impulse response of a highpass lter that passes all
frequencies above 500 Hz, then h[k] = hl [k] hh [k] is a bandpass lter that passes
only frequencies between 500 and 600 Hz, where represents convolution.
Filters are also classied by the length of their impulse response. If the output
of a lter depends only on a specied number of samples, the lter is said to
have a nite impulse response, abbreviated FIR. Otherwise, it is said to have an
innite impulse response, abbreviated IIR. The bulk of the lters in Software
Receiver Design are FIR lters with a at passband, because these are the
most common lters in a typical receiver. But other lter proles are possible,
and the techniques of lter design are not restricted to at passbands. Section
7.2.1 shows several ways that digital FIR lters can be implemented in Matlab.
IIR lters arise whenever there is a loop (such as in a phase-locked loop), and
one special case (the integrator) is an intrinsic piece of the adaptive elements.
Section 7.2.2 shows how to implement IIR lters. Section 7.2.3 shows how to
design lters with specic properties, and how they behave on a number of test
signals.
7.2.1
r filter implements the convolution so as to supply one output value for each
input value; the output is of length M .
r In the frequency domain, take the FFT of the input and the FFT of the
output, multiply the two, and take the IFFT to return to the time domain.
r In the time domain, pass through the input data, at each time multiplying by
the impulse response and summing the result.
Probably the easiest way to see the dierences is to play with the four methods.
143
Listing 7.5. waystofilt.m conv vs. lter vs. freq domain vs. time domain
h=[1 1 2 2 3 3 ] ;
% impulse response h [ k ]
x =[1 2 3 4 5 6 5 4 3 2 1 ] ;
% i n p u t data x [ k ]
yconv=conv ( h , x )
% convolve x [ k ] * h [ k ]
y f i l t =f i l t e r ( h , 1 , x )
% f i l t e r x [ k ] with h [ k ]
n=length ( h)+length ( x ) 1;
% pad l e n g t h f o r FFT
f f t h=f f t ( [ h zeros ( 1 , nlength ( h ) ) ] ) ;
% FFT o f h [ k ] i s H[ n ]
f f t x=f f t ( [ x , zeros ( 1 , nlength ( x ) ) ] ) ;
% FFT o f i n p u t i s X[ n ]
f f t y=f f t h . * f f t x ;
% p r o d u c t o f H[ n ] and X[ n ]
y f r e q=r e a l ( i f f t ( f f t y ) )
% IFFT o f p r o d u c t g i v e s y [ k ]
z =[ zeros ( 1 , length ( h ) 1) , x ] ;
% i n i t i a l f i l t e r s t a t e =0
f o r k =1: length ( x )
% time domain method
ytim ( k)= f l i p l r ( h ) * z ( k : k+length ( h ) 1 ) ; % do f o r each x [ k ]
end
% to d i r e c t l y c a l c u l a t e y [ k ]
Observe that the rst M terms of yconv, yfilt, yfreq, and ytim are the same,
but that both yconv and yfreq have N-1 extra values at the end. For both the
time-domain method and the filter command, the output values are aligned
in time with the input values, one output for each input. Eectively, the filter
command is a single-line implementation of the time-domain for loop.
For the FFT method, the two vectors (input and convolution) must both have
length N+M-1. The raw output has complex values due to numerical roundo,
and the command real is used to strip away the imaginary parts. Thus, the
FFT-based method requires more Matlab commands to implement. Observe
also that conv(h,x) and conv(x,h) are the same, whereas filter(h,1,x) is
not the same as filter(x,1,h).
To view the frequency response of the lter h, Matlab provides the command
freqz, which automatically zero pads5 the impulse response and then plots both
the magnitude and the phase. Type
freqz (h)
By default, the Matlab command freqz creates a vector of length 512 that contains the
specied impulse response followed by zeros. The FFT of this elongated vector is used for
the magnitude and phase plots, giving the plots a smoother appearance than when taking
the FFT of the raw impulse response.
Magnitude (dB)
144
20
0
20
40
Phase (degrees)
100
0
100
0
7.2.2
0.2
0.4
0.6
0.8
Normalized frequency (Nyquist = 1)
(7.8)
where a and b are constants. This is shown in the left-hand portion of Figure
7.5, where the time delay between successive terms (between k and k + 1 for
instance) is represented by z 1 . This is an example of the Z-transform, and is
described more fully in Appendix F. If the initial value is y[0] = 0, the response
of the system (7.8) to an impulse x[k] = [k] (where [k] is the discrete impulse
function (7.1)) is
b, ba, ba2, ba3 , ba4 , . . . .
(7.9)
If |a| > 1, this impulse response increases towards innity and the system is
said to be unstable. If |a| < 1, the values in the sequence die away towards (but
never quite reaching) zero, and the system is stable. In both cases, the impulse
response is innitely long and so the system (7.8) is IIR. The special case when
a = 1 is called a summer (or, in analogy with continuous time, an integrator)
because y[k] = y[0] + b k1
i=0 x[i] sums up all the inputs. The summer is often
represented symbolically as in the right-hand part of Figure 7.5.
The general form of an IIR lter is
y[k + 1] = a0 y[k] + a1 y[k 1] + + an y[k n]
+ b0 x[k] + b1 x[k 1] + + bm x[k m],
which can be rewritten more concisely as
y[k + 1] = aT y[k] + bT x[k]
x[k]
b
Delay
y[k+1]
z1
x[k]
y[k]
145
y[k]
a
Figure 7.5 The LTI system y[k + 1] = ay[k] + bx[k], with input x[k] and output y[k], is
represented schematically using the delay z 1 in this simple block diagram. The
special case when a = 1 is called a summer because it eectively adds up all the input
values, and it is often drawn more concisely as on the right side of the gure.
where
a = [a0 , a1 , . . . , an ]T
b = [b0 , b1 , . . . , bm ]T
are column vectors of the parameters of the lter and where
x[k] = [x[k], x[k 1], . . . , x[k m]]T
y[k] = [y[k], y[k 1], . . . , y[k n]]T
are vectors of past input and output data. The symbol z T indicates the transpose
of the vector z. In Matlab, transpose is represented using the single apostrophe
, but take care: when using complex numbers, the apostrophe actually implements a complex conjugate as well as transpose.
Matlab has a number of functions that make it easy to explore IIR ltering.
For example, the function impz plots the impulse response of a discrete IIR (or
FIR) lter. The impulse response of the system (7.8) is found by entering
b=1;
a =[1 , 0. 8] ;
impz ( b , a )
% autoregressive co efficients
% moving a v e r a g e c o e f f i c i e n t s
% data to f i l t e r
146
i f l e n a >=l en b ,
h=impz ( b , a ) ;
y f i l t =f i l t e r ( h , 1 , d )
end
y f i l t 2 =f i l t e r ( b , a , d )
y=zeros ( l e n a , 1 ) ; x=zeros ( l en b , 1 ) ;
f o r k =1: length ( d) l e n b
x=[d ( k ) ; x ( 1 : l e n b 1 ) ] ;
ytim ( k)=a ( 2 : l e n a +1) * y+b * x ;
y=[ ytim ( k ) ; y ( 1 : l e n a 1 ) ] ;
end
% d i m p u l s e n e e d s l e n a >=l e n b
% impulse response of f i l t e r
% f i l t e r x [ k ] with h [ k ]
%
%
%
%
%
%
f i l t e r u s i n g a and b
i n i t i a l states in f i l t e r
time domain method
past values of inputs
directly calculate y[ k ]
past values of outputs
Like FIR lters, IIR lters can be lowpass, bandpass, and highpass, or can
have almost any imaginable eect on the spectrum of their input.
Exercise 7.14. Some IIR lters can be used as inverses to some FIR lters.
Show that the FIR lter
1
a
x[k] = r[k] r[k 1]
b
b
is an inverse of the IIR lter (7.8).
Exercise 7.15. FIR lters can be used to approximate the behavior of IIR lters
by truncating the impulse response. Create a FIR lter with impulse response
given by the rst 10 terms of (7.9) for a = 0.9 and b = 2. Simulate the FIR lter
and the IIR lter (7.8) in Matlab, using the same random input to both. Verify
that the outputs are (approximately) the same.
7.2.3
Filter Design
This section gives an extended explanation of how to use Matlab to design a
bandpass lter to t a specied frequency response with a at passband. The
same procedure (with suitable modication) also works for the design of other
basic lter types.
A bandpass lter is intended to scale, but not distort, signals with frequencies that fall within the passband, and to reject signals with frequencies in the
stopband. An ideal, distortionless response for the passband would be perfectly
at in magnitude, and would have linear phase (corresponding to a delay). The
transition band from the passband to the stopband should be as narrow as possible. In the stopband, the frequency response magnitude should be suciently
small and the phase is of no concern. These objectives are captured in Figure
7.6. Recall (from (A.35)) for a real w(t) that |W (f )| is even and W (f ) is odd,
as illustrated in Figure 7.6.
Matlab has several commands that carry out lter design. The firpm command6 provides a linear phase impulse response (with real, symmetric coecients
6
Transition
region
147
Transition
region
|H( f )|
Passband
Stopband
Lower
H( f ) band
edge
Upper
band
edge
r fl species (one fewer than) the number of terms in the impulse response
r
r
7
of the desired lter. Generally, more is better in terms of meeting the design
specications. However, larger fl are also more costly in terms of computation
and in terms of the total throughput delay, so a compromise is usually made.
fbe is a vector of frequency band edge values as a fraction of the prevailing
Nyquist frequency. For example, the lter specied in Figure 7.6 needs six
values: the bottom of the stopband (presumably zero), the top edge of the
lower stopband (which is also the lower edge of the lower transition band),
the lower edge of the passband, the upper edge of the passband, the lower edge
of the upper stopband, and the upper edge of the upper stopband (generally
the last value will be 1). The transition bands must have some nonzero width
(the upper edge of the lower stopband cannot equal the lower passband edge)
or Matlab produces an error message.
damps is the vector of desired amplitudes of the frequency response at each
band edge. The length of damps must match the length of fbe.
b is the output vector containing the impulse response of the specied lter.
There are many possible meanings of the word best; for the firpm algorithm, best is
dened in terms of maintaining an equal ripple in the at portions.
Phase (degrees)
148
20
0
20
40
60
80
500
0
500
1000
1500
0
The following Matlab script designs a lter that mimics Figure 7.6:
Listing 7.7. bandex.m design a bandpass lter and plot frequency response
f b e =[0 0 . 2 4 0 . 2 6 0 . 7 4 0 . 7 6 1 ] ;
damps=[0 0 1 1 0 0 ] ;
f l =30;
b=f i r p m ( f l , f b e , damps ) ;
figure (1)
freqz (b)
%
%
%
%
%
f r e q band e d g e s a s a f r a c t i o n o f
th e N y q u i s t f r e q u e n c y
d e s i r e d a m p l i t u d e s a t band e d g e s
f i lt e r size
b i s th e d e s i g n e d i m p u l s e r e s p o n s e
% p l o t f r e q r e s p o n s e to c h e c k d e s i g n
The frequency response of the resulting nite impulse response (FIR) lter is
shown in Figure 7.7. Observe that the stopband is about 14 dB lower than the
passband, a marginal improvement over the naive lowpass lter of Figure 7.4,
but the design is much atter in the passband. The equiripple nature of this
lter is apparent in the slow undulations of the magnitude in the passband.
Designing IIR lters is also straightforward. For example, the code
[ b , a ]= cheby1 ( 1 0 , 5 , 0 . 2 5 ) ;
149
Exercise 7.16. Rerun bandex.m with very narrow transition regions, for
instance fbe = [0, 0.24, 0.2401, 0.6, 0.601, 1]. What happens to the ripple in
the passband? Compare the minimum magnitude in the passband with the maximum value in the stopband.
Exercise 7.17. Returning to the lter specied in Figure 7.6, try using dierent
numbers of terms in the impulse response, fl = 5, 10, 100, 500, 1000. Comment
on the resulting designs in terms of atness of the frequency response in the
passband, attenuation from the passband to the stopband, and the width of the
transition band.
Exercise 7.18. Specify and design a lowpass lter with cuto at 0.15. What
values of fl, fbe, and damps work best?
Exercise 7.19. Specify and design a lter that has two passbands, one between
[0.2, 0.3] and another between [0.5, 0.6]. What values of fl, fbe, and damps work
best?
Exercise 7.20. Use the lter designed in bandex.m to lter a whitenoise sequence (generated by randn) using the time-domain method from
waystofilt.m. Verify that the output has a bandpass spectrum.
The preceding lter designs do not explicitly require the sampling rate of the
signal. However, since the sampling rate determines the Nyquist rate, it is used
implicitly. The next exercise asks that you familiarize yourself with real units
of frequency in the lter design task.
Exercise 7.21. In Exercise 7.10, the program specgong.m was used to analyze the sound of an Indonesian gong. The three most prominent partials (or
narrowband components) were found to be at about 520, 630, and 660 Hz.
a. Design a lter using firpm that will remove the two highest partials from this
sound without aecting the lowest partial.
b. Use the filter command to process the gong.wav le with your lter.
c. Take the FFT of the resulting signal (the output of your lter) and verify that
the partial at 520 remains while the others are removed.
d. If a sound card is attached to your computer, compare the sound of the raw
and the ltered gong sound by using Matlabs sound command. Comment
on what you hear.
The next set of problems examines how accurate digital lters really are.
Exercise 7.22. With a sampling rate of 44100 Hz, let x[k] be a sinusoid of
frequency 3000 Hz. Design a lowpass lter with a cuto frequency fl of 1500
Hz, and let y[k] = LPF{x[k]} be the output of the lter.
150
a. How much does the lter attenuate the signal? (Express your answer as the
ratio of the power in the output y[k] to the power in the input x[k].)
b. Now use an LPF with a cuto of 2500 Hz. How much does the lter attenuate
the signal?
c. Now use an LPF with a cuto of 2900 Hz. How much does the lter attenuate
the signal?
Exercise 7.23. Repeat Exercise 7.22 without using the filter command
(implement the ltering, using the time-domain method in waystofilt.m).
Exercise 7.24. With the same setup as in Exercise 7.22, generate x[k] as a
bandlimited noise signal containing frequencies between 3000 Hz and the Nyquist
rate.
a. Use an LPF with cuto frequency fl of 1500 Hz. How much does the lter
attenuate the signal?
b. Now use an LPF with a cuto of 2500 Hz. How much does the lter attenuate
the signal?
c. Now use an LPF with a cuto of 3100 Hz. How much does the lter attenuate
the signal?
d. Now use an LPF with a cuto of 4000 Hz. How much does the lter attenuate
the signal?
Exercise 7.25. Let f1 < f2 < f3 . Suppose x[k] has no frequencies above f1 Hz,
while z[k] has no frequencies below f3 . If an LPF has cuto frequency f2 , in
principle,
LPF{x[k] + z[k]} = LPF{x[k]} + LPF{z[k]} = x[k] + 0 = x[k].
Explain how this is (and is not) consistent with the results of Exercises 7.22
and 7.24.
Exercise 7.26. Let the output y[k] of an LTI system be created from the input
x[k] according to the formula
y[k + 1] = y[k] + x[k],
where is a small constant. This is drawn in Figure 7.5.
a. What is the impulse response of this lter?
b. What is the frequency response of this lter?
c. Would you call this lter lowpass, highpass, or bandpass?
Exercise 7.27. Using one of the alternative lter design routines (cfirpm,
firls, fir1, fir2, butter, cheby1, cheby2, or ellip), repeat Exercises 7.16
7.21. Comment on the subtle (and the not-so-subtle) dierences in the resulting
designs.
151
Any message, whether analog or digital, can be translated into a string of binary
digits. In order to transmit or store these digits, they are often clustered or
encoded into a more convenient representation whose elements are the symbols
of an alphabet. In order to utilize bandwidth eciently, these symbols are then
translated (again!) into short analog waveforms called pulse shapes that are combined to form the actual transmitted signal.
The receiver must undo each of these translations. First, it examines the
received analog waveform and decodes the symbols. Then it translates the symbols back into binary digits, from which the original message can, with luck, be
reconstructed.
This chapter briey examines each of these translations, and the tools needed
to make the receiver work. One of the key ideas is correlation, which can be used
as a kind of pattern-matching tool for discovering key locations within the signal
stream. Section 8.3 shows how correlation can be viewed as a kind of linear lter,
and hence its properties can be readily understood both in the time and in the
frequency domain.
8.1
Bits to Symbols
The information that is to be transmitted by a communication system comes in
many forms: a pressure wave in the air, a ow of electrons in a wire, a digitized
image or sound le, the text in a book. If the information is in analog form, then
it can be sampled (as in Chapter 6). For instance, an analog-to-digital converter
can transform the output of a microphone into a stream of numbers representing
the pressure wave in the air, or it can turn measurements of the current in the wire
into a sequence of numbers that are proportional to the electron ow. The sound
le, which is already digital, contains a long list of numbers that correspond to
the instantaneous amplitude of the sound. Similarly, the picture le contains a
list of numbers that describe the intensity and color of the pixels in the image.
153
The text can be transformed into a numerical list using the ASCII code. In all
these cases, the raw data represent the information that must be transmitted by
the communication system. The receiver, in turn, must ultimately translate the
received signal back into the data.
Once the information is encoded into a sequence of numbers, it can be reexpressed as a string of binary digits 0 and 1. This is discussed at length in
Chapter 14. But the binary 01 representation is not usually very convenient
from the point of view of ecient and reliable data transmission. For example,
directly modulating a binary string with a cosine wave would result in a small
piece of the cosine wave for each 1 and nothing (the zero waveform) for each 0.
It would be very hard to tell the dierence between a message that contained a
string of zeros, and no message at all!
The simplest solution is to recode the binary 0, 1 into binary 1. This can be
accomplished using either the linear operation 2x 1 (which maps 0 into 1,
and 1 into 1), or 2x + 1 (which maps 0 into 1, and 1 into 1). This binary
1 is an example of a two-element symbol set. There are many other common
symbol sets. In multilevel signaling, the binary terms are gathered into groups.
Regrouping in pairs, for instance, recodes the information into a four-level signal.
For example, the binary sequence might be paired thus:
. . . 000010110101 . . . . . . 00 00 10 11 01 01 . . . .
(8.1)
+3
+1
1
3
(8.2)
Example 8.1. Text is commonly encoded using ASCII, and Matlab automatically represents any string le as a list of ASCII numbers. For instance, let
str=I am text be a text string. This can be viewed in its internal form by
typing real(str), which returns the vector 73 32 97 109 32 116 101 120 116,
which is the (decimal) ASCII representation of this string. This can be viewed
154
in binary using dec2base(str,2,8), which returns the binary (base 2) representation of the decimal numbers, each with eight digits.
The Matlab function letters2pam.m, provided on the website, changes a
text string into the four-level alphabet 1, 3. Each letter is represented by a
sequence of four elements, for instance the letter I is 1, 3, 1, 1. The function is invoked with the syntax letters2pam(str). The inverse operation is
pam2letters.m. Thus pam2letters(letters2pam(str)) returns the original
string.
One complication in the decoding procedure is that the receiver must gure
out when the groups begin in order to parse the digits properly. For example,
if the rst element of the sequence in (8.1) were lost, the message would be
mistranslated as
. . . 00010110101 . . . . . .00 01 01 10 10 . . .
. . . 3, 1, 1, 1, 1, . . . .
Similar parsing problems occur whenever messages start or stop. For example,
if the message consists of pixel values for a television image, it is important that
the decoder be able to determine precisely when the image scan begins. These
kinds of synchronization issues are typically handled by sending a special start
of frame sequence that is known both to the transmitter and to the receiver.
The decoder then searches for the start sequence, usually using some kind of
correlation (pattern-matching) technique. This is discussed in detail in Section
8.3.
Example 8.2. There are many ways to translate data into binary equivalents. Example 8.1 showed one way to convert text into 4-PAM and then into
binary. Another way exploits the Matlab function text2bin.m and its inverse
bin2text.m, which use the 7-bit version of the ASCII code (rather than the
8-bit version). This representation is more ecient, since each pair of text letters
can be represented by 14 bits (or seven 4-PAM symbols) rather than 16 bits (or
eight 4-PAM symbols). On the other hand, the 7-bit version can encode only
half as many characters as the 8-bit version. Again, it is important to be able to
correctly identify the start of each letter when decoding.
Exercise 8.1. The Matlab code in naivecode.m, which is on the website,
implements the translation from binary to 4-PAM (and back again) suggested in
(8.2). Examine the resiliency of this translation to noise by plotting the number
of errors as a function of the noise variance v. What is the largest variance for
which no errors occur? At what variance are the errors near 50%?
Exercise 8.2. A Gray code has the property that the binary representation for
each symbol diers from its neighbors by exactly one bit. A Gray code for the
155
+3
+1
1
3
Mimic the code in naivecode.m to implement this alternative and plot the number of errors as a function of the noise variance v. Compare your answer with
Exercise 8.1. Which code is better?
8.2
Symbols to Signals
Even though the original message is translated into the desired alphabet, it is
not yet ready for transmission: it must be turned into an analog waveform. In the
binary case, a simple method is to use a rectangular pulse of duration T seconds
to represent +1, and the same rectangular pulse inverted (i.e., multiplied by 1)
to represent the element 1. This is called a polar non-return-to-zero line code.
The problem with such simple codes is that they use bandwidth ineciently.
Recall that the Fourier transform of the rectangular pulse in time is the sinc(f )
function in frequency (A.20), which dies away slowly as f increases. Thus, simple
codes like the non-return-to-zero are compact in time, but wide in frequency,
limiting the number of simultaneous nonoverlapping users in a given spectral
band.
More generally, consider the four-level signal of (8.2). This can be turned into
an analog signal for transmission by choosing a pulse shape p(t) (that is not
necessarily rectangular and not necessarily of duration T ) and then transmitting
p(t kT ) if
p(t kT ) if
3p(t kT ) if
3p(t kT ) if
the
the
the
the
kth
kth
kth
kth
symbol
symbol
symbol
symbol
is 1
is 1
is 3
is 3
r the value of the message at time k does not interfere with the value of the
r
r
message at other sample times (the pulse shape causes no intersymbol interference),
the transmission makes ecient use of bandwidth, and
the system is resilient to noise.
156
1
0.8
0.6
0.4
0.2
0
0.1
10
0.2
0.3
0.4
0.5
0.6
The pulse shape
0.7
0.8
0.9
20
30
40
50
60
70
80
90
The waveform representing Transmit this text
100
3
2
1
0
1
2
3
Figure 8.1 The process of pulse shaping replaces each symbol of the alphabet (in this
case, 1, 3) with an analog pulse (in this case, the short blip function shown in the
top panel).
157
Exercise 8.3. Assume the sampling period is T = 0.1, and then plot the spectrum of the output x. What is the bandwidth of this signal?
Exercise 8.4. Again with T = 0.1, plot the spectrum of the output x when the
pulse shape is changed to a rectangular pulse. (Change the denition of ps in
the next-to-last line of pulseshape.m.) What is the bandwidth of this signal?
Exercise 8.5. Can you think of a pulse shape that will have a narrower bandwidth than either of the above but that will still be time limited by T ? Implement
it by changing the denition of ps, and check to see whether you are correct.
Thus the raw message is prepared for transmission by
8.3
Correlation
Suppose there are two signals or sequences. Are they similar, or are they dierent? If one is just shifted in time relative to the other, how can the time shift
be determined? The approach called correlation shifts one of the sequences in
time, and calculates how well they match (by multiplying point by point and
summing) at each shift. When the sum is small, they are not much alike; when
the sum is large, many terms are similar. Thus, correlation is a simple form of
pattern matching, which is useful in communication systems for aligning signals
in time. This can be applied at the level of symbols when it is necessary to nd
appropriate sampling times, and it can be applied at the frame level when it
is necessary to nd the start of a message (for instance, the beginning of each
frame of a television signal). This section discusses various techniques of crosscorrelation and autocorrelation, which can be viewed in either the time domain
or the frequency domain.
158
T /2
w[k]v[k + j].
(8.3)
k=T /2
For nite data records, the sum need only be accumulated over the nonzero
elements, and the normalization by 1/T is often ignored. (This is how
Matlabs xcorr function works.) While this may look like the convolution
Equation (7.2), it is not identical since the indices are dierent (in convolution, the index of v() is j k instead of k + j). The operation and meaning
of the two processes are also not identical: convolution represents the manner in which the impulse response of a linear system acts on its inputs to
give the outputs, while cross-correlation quanties the similarity of two signals.
In many communication systems, each message is parcelled into segments or
frames, each having a predened header. As the receiver decodes the transmitted
message, it must determine where the message segments start. The following
code simulates this in a simple setting in which the header is a predened binary
string and the data consist of a much longer binary string that contains the
header hidden somewhere inside. After performing the correlation, the index
with the largest value is taken as the most likely location of the header.
Listing 8.2. correx.m correlation can locate the header within the data
h e a d e r =[1 1 1 1 1 1 1 1 1 1 ] ;
% header i s p r ed e f i n e d s t r i n g
l o c =30; r =25;
% p l a ce header i n p o s i t i o n l o c
data =[ sign ( randn ( 1 , l o c 1)) h e a d e r sign ( randn ( 1 , r ) ) ] ; % make s i g n a l
sd = 0 . 2 5 ; data=data+sd * randn ( s i z e ( data ) ) ;
% add n o i s e
y=x c o r r ( header , data ) ;
% do c r o s s c o r r e l a t i o n
[m, i n d ]=max( y ) ;
% find largest correlation
h e a d s t a r t=length ( data ) i n d +1;
% p l a c e where h ea d er s t a r t s
Running correx.m results in a trio of gures much like those in Figure 8.2.
(Details will dier each time it is run, because the actual data are randomly
generated with Matlabs randn function.) The top plot in Figure 8.2 shows the
10-sample binary header. The data vector is constructed to contain l = 30 data
values followed by the header (with noise added), and then r = 25 more data
points, for a total block of 65 points. It is plotted in the middle of Figure 8.2.
Observe that it is dicult to see where the header lies among the noisy data
record. The correlation between the data and the header is calculated and plotted
at the bottom of Figure 8.2 as a function of the lag index. The index for which
the correlation attains its largest value denes where the best match between the
data and the header occurs. Most likely this will be at index ind=35 (as in Figure
8.2). Because of the way Matlab orders its output, the calculations represent
sliding the rst vector (the header), term by term, across the second vector (the
159
Header
1
0.5
0
0.5
1
10
2
1
0
1
2
10
20
30
40
50
60
70
10
Correlation of header with data
5
0
5
10
20
40
60
80
100
120
140
Figure 8.2 The correlation can be used to locate a known header within a long signal.
The predened header is shown in the top graph. The data consist of a random
binary string with the header embedded and noise added. The bottom plot shows the
correlation. The location of the header is determined by the peak occurring at 35.
data). The long string of zeros at the end1 occurs because the two vectors are of
dierent lengths. The start of the header is given by length(data)-ind+1.
One way in which the correlation might fail to nd the correct location of
the header is if the header string accidently occurred in the data values. If this
happened, then the correlation would be as large at the accidental location
as at the intended location. This becomes increasingly unlikely as the header
is made longer, though a longer header also wastes bandwidth. Another way to
decrease the likelihood of false hits is to average over several headers.
Exercise 8.6. Rerun correx.m with dierent-length data vectors (try loc=100,
r=100 and loc=10, r=10). Observe how the location of the peak changes.
Exercise 8.7. Rerun correx.m with dierent-length headers. Does the peak in
the correlation become more or less distinct as the number of terms in the header
increases?
1
Some versions of Matlab use a dierent convention with the xcorr command. If you nd
that the string of zeros occurs at the beginning, try reversing the order of the arguments.
160
Exercise 8.8. Rerun correx.m with dierent amounts of noise. Try sd=0, 0.1,
0.3, 0.5, 1, 2. How large can the noise be made if the correlation is still to
nd the true location of the header?
Exercise 8.9. The code in corrvsconv.m explores the relationship between
the correlation and convolution. The convolution of two sequences is essentially
the same as the cross-correlation of the time-reversed signal, except that the
correlation is padded with extra zeros. (The Matlab function fliplr carries
out the time reversal.) If h is made longer than x, what needs to be changed so
that yconv and ycorr remain equal?
Listing 8.3. corrvsconv.m comparing correlation and convolution
h=[1 1 2 2 3 3 ] ;
x =[1 2 3 4 5 6 5 4 3 2 1 ] ;
yconv=conv ( x , h )
y c o r r=x c o r r ( h , f l i p l r ( x ) )
8.4
%
%
%
%
def i ne sequence h [ k ]
def i ne sequence x [ k ]
convolve x [ k ] * h [ k ]
c o r r e l a t e f l i p p e d x and h
Because of the connections between cross-correlation, convolution, and ltering, this process
is often called pulse-matched ltering because the impulse response of the lter is matched
to the shape of the pulse.
161
nearest elements of the second vector (in this case quantizing z to the nearest
elements of [3, 1, 1, 3]).
If all has gone well, the quantized output mprime should be identical to the
original message string. The function pam2letters.m rebuilds the message from
the received signal. The nal line of the program calculates how many symbol
errors have occurred (how many of the 1, 3 dier between the message m and
the reconstructed message mprime).
Listing 8.4. recfilt.m undo pulse shaping using correlation
y=x c o r r ( x , ps ) ;
z=y (N*M:M:N*M) / ( pow ( ps ) *M) ;
mprime=q u a n t a l p h ( z , [ 3 , 1 , 1 , 3 ] ) ;
p a m 2 l e t t e r s ( mprime )
sum( abs ( sign ( mprimem) ) )
%
%
%
%
%
%
run p u l s e s h a p e .m & c r e a t e x
co r r e l at e pulse & si gnal
downsample to symbol r a t e
q u a n t i z e to a l p h a b e t
r e c o n s t r u c t message
c a l c u l a t e number o f e r r o r s
Exercise 8.12. The received signal might not always arrive at the
receiver unchanged. Simulate a noisy channel by including the command
x=x+1.0*randn(size(x)) before the xcorr command in recfilt.m. What percentage errors occur? What happens as you increase or decrease the amount of noise
(by changing the 1.0 to a larger or smaller number)?
8.5
162
y. Since this starting point will not generally be known beforehand, it must
somehow be located. This is an ideal job for correlation and a marker sequence.
The marker is a set of predened symbols embedded at some specied location
within each frame. The receiver can locate the marker by cross-correlating it with
the incoming signal stream. What makes a good marker sequence? This section
shows that not all markers are created equally.
Consider the binary data sequence
. . . + 1, 1, +1, +1, 1, 1, 1, +1, M, +1, 1, +1, . . .,
(8.4)
r marker A: 1, 1, 1, 1, 1, 1, 1
r marker B: 1, 1, 1, 1, 1, 1, 1
The correlation of the signal with each of the markers can be performed as
indicated in Figure 8.3.
For marker A, correlation corresponds to a simple sum of the last seven values.
Starting at the location of the seventh value available to us in the data sequence
(two data points before the marker), marker A produces the sequence
1, 1, 1, 1, 1, 3, 5, 7, 7, 7, 5, 5.
For marker B, starting at the same point in the data sequence and performing
the associated moving weighted sum produces
1, 1, 3, 1, 5, 1, 1, 1, 7, 1, 1, 3.
With the two correlator output sequences shown, started two values prior to
the start of the seven-symbol marker, we want the ag indicating a frame start
to occur with point number 9 in the correlator sequences shown. Clearly, the
correlator output for marker B has a much sharper peak at its ninth value than
does the correlator output of marker A. This should enhance the robustness of
the use of marker B relative to that of marker A against the unavoidable presence
of noise.
Marker B is a maximum-length pseudo-noise (PN) sequence. One property
of a maximum-length PN sequence {ci } of plus and minus ones is that its autocorrelation is quite peaked:
N 1
1
1
k = N,
cn cn+k =
Rc (k) =
1/N k = N.
N
n=0
Another technique that involves the chunking of data and the need to locate
boundaries between chunks is called scrambling. Scrambling is used to whiten
a message sequence (to make its spectrum atter) by decorrelating the message.
The transmitter and receiver agree on a binary scrambling sequence s that is
repeated over and over to form a periodic string S that is the same size as the
message. S is then added (using modulo 2 arithmetic) bit by bit to the message
m1
m2
m3
m4
m5
m6
m7
m1
m2
m3
m4
m5
m6
m7
m1
m1
m2
m3
m4
m5
m6
m7
m1
m2
m1
m2
m3
m4
m5
m6
m7
m1
m2
m3
m4
m5
m6
m7
m1
m2
m3
m4
m5
m6
m7
m1
m2
m3
m4
m5
m6
m7
sum = m1 m2 + m3 + m4 m5 m6 m7
m1
m2
m3
m4
m5
m6
m7
163
Sum products of
corresponding values
1
Shift marker to
right and repeat
Shift marker to
right and repeat
Shift marker to
right and repeat
sum = m1 + m2 + m3 m4 m5 m6 + m7
m2
m3
m4
m5
m6
m7
sum = m1 + m2 m3 m4 m5 + m6 + m1m7
m3
m4
m5
m6
m7
Shift marker to
right and repeat
m at the transmitter, and then S is added bit by bit again at the receiver. Since
both 1 + 1 = 0 and 0 + 0 = 0,
m+S+S =m
and the message is recaptured after the two summing operations. The scrambling
sequence must be aligned so that the additions at the receiver correspond to the
164
Stu Happens
There is nothing new in this chapter. Really. By peeling away the outer, most
accessible layers of the communication system, the previous chapters have provided all of the pieces needed to build an idealized digital communication system,
and this chapter just shows how to combine the pieces into a functioning system.
Then we get to play with the system a bit, asking a series of what if questions.
In outline, the idealized system consists of two parts, rather than three, since
the channel is assumed to be noiseless and disturbance-free.
The Transmitter
r codes a message (in the form of a character string) into a sequence of symbols,
r transforms the symbol sequence into an analog signal using a pulse shape, and
r modulates the scaled pulses up to the passband.
The Digital Receiver
r
r
r
r
r
r
Each of these procedures is familiar from earlier chapters, and you may have
already written Matlab code to perform them. It is time to combine the elements into a full simulation of a transmitter and receiver pair that can function
successfully in an ideal setting.
166
9.1
Message
character
string
T-spaced
symbol
sequence
Baseband
signal
Passband
signal
Pulse
filter
Coder
cos(2fct)
(a) Transmitter
Received
signal
Ts-spaced
passband
signal
Ts-spaced
baseband
signal
Lowpass
filter
kTs
k = 0, 1, 2, ...
MTs-spaced
soft
decisions
Pulse
correlator
filter
Downsampler
Mixer
MTs-spaced
hard
decisions
Quantizer
n(MTs) + lTs
n = 0, 1, 2, ...
cos(2fckTs)
Sampler
Mixer
Demodulator
(b) Receiver
Figure 9.1 Block diagram of an ideal communication system.
Recovered
character
string
Decoder
Stu Happens
167
9.2
168
i=0
Since the channel is assumed to be ideal, this is equal to the received signal r(t).
This ideal transmitter is simulated in the rst part of idsys.m.
Listing 9.1. idsys.m (part 1) idealized transmission system - the transmitter
% e n c o d e t e x t s t r i n g a s Ts p a c e d 4PAM s e q u e n c e
s t r= 01234 I wish I were an Oscar Meyer wiener 56789 ;
m=l e t t e r s 2 p a m ( s t r ) ; N=length (m) ;
% 4 l e v e l s i g n a l o f l e n g t h N
% z e r o pad Ts p a c e d symbol s e q u e n c e to c r e a t e upsampled
% T/Ms p a c e d s e q u e n c e o f s c a l e d Ts p a c e d p u l s e s (T=1)
M=100;
% oversampling f a c t o r
mup=zeros ( 1 ,N*M) ;
% Hamming p u l s e f i l t e r with
mup ( 1 :M:N*M)=m;
% T/Ms p a ced i m p u l s e r e s p o n s e
p=hamming (M) ;
% b l i p p u l s e o f width M
x=f i l t e r ( p , 1 , mup ) ;
% c o n v o l v e p u l s e shape with data
f i g u r e ( 1 ) , p l o t s p e c ( x , 1 /M)
% baseband AM m o d u l a ti o n
t =1/M: 1 /M: length ( x )/M;
% T/Ms p a c e d time v e c t o r
f c =20;
% c a r r i e r frequency
c=cos (2 * pi * f c * t ) ;
% carrier
r=c . * x ;
% modulate message with c a r r i e r
Since Matlab cannot deal directly with analog signals, the analog signal
r(t) is sampled at M times the symbol rate, and r(t)|t=kTs (the signal r(t)
sampled at times t = kTs ) is the vector r in the Matlab code. The vector r is
also the input to the digital portion of the receiver. Thus, the rst sampling block
in the receiver of Figure 9.1 is implicit in the way Matlab emulates the analog
signal. To be specic, k can be represented as the sum of an integer multiple of
M and some positive integer smaller than M such that
kTs = (iM + )Ts .
Since T = M Ts ,
kTs = iT + Ts .
Stu Happens
169
N
1
i=0
N
1
i=0
Magnitude
Amplitude
3
2
1
0
1
2
3
40
80
120
Seconds
160
200
8000
6000
4000
2000
Amplitude
0
50 40 30 20 10 0 10
Frequency
Magnitude
170
3
2
1
0
1
2
3
20
40
60
20
30
40
50
4000
3000
2000
1000
0
50 40 30 20 10 0 10
Frequency
20
30
40
50
Magnitude
Amplitude
Stu Happens
3
2
1
0
1
2
3
0
20
40
60
4000
3000
2000
1000
0
50 40 30 20 10 0 10
Frequency
20
30
40
50
20
0
20
40
60
80
100
Phase (degrees)
200
400
600
800
1000
171
To suppress the components centered around 40 in Figure 9.4 and to pass the
baseband component without alteration (except for possibly a delay), the lowpass
lter is designed with a cuto near 10. For M = 100, the Nyquist frequency is 50.
(Section 7.2.3 details the use of firpm for lter design.) The frequency response
of the resulting FIR lter (from freqz(b)) is shown in Figure 9.5. To make
sense of the horizontal axes, observe that the 1 in Figure 9.5 corresponds to
the 50 in Figure 9.4. Thus the cuto between normalized frequencies 0.1 and
0.2 corresponds to an unnormalized frequency near 10, as desired.
The output of the lowpass lter in the demodulator is a signal with the spectrum shown in Figure 9.6 (drawn using plotspec(x3,1/M)). The spectrum in
Figure 9.6 should compare quite closely to that of the transmitter baseband in
Figure 9.2, as indeed it does. It is easy to check the eectiveness of the lowpass lter design by attempting to use a variety of dierent lowpass lters, as
suggested in Exercise 9.4.
Recall the discussion in Section 8.4 of matching two scaled pulse shapes. Viewing the pulse shape as a kind of marker, it is reasonable to correlate the pulse
Magnitude
Amplitude
3
2
1
0
1
2
3
20
40
60
8000
6000
4000
2000
0
50 40 30 20 10 0 10
Frequency
20
30
40
50
172
Delay
2
1
0
1
2
3
0
0
50
2T
3T
T-spaced samples
4T
shape with the received signal in order to locate the pulses. (More justication for this procedure is forthcoming in Chapter 11.) This appears in Figure
9.1 as the block labelled pulse correlation lter. The code in idsys.m implements this using the filter command to carry out the correlation (rather than
the xcorr function), though the choice was a matter of convenience. (Refer to
corrvsconv.m in Exercise 8.9 to see how the two functions are related.)
The rst 4M samples of the resulting signal y are plotted in Figure 9.7 (via
plot(y(1:4*M))). The rst three symbols of the message (i.e., m(1:3)) are 3,
3, and 3, and Figure 9.7 shows why it is best to take the samples at indices
125 + kM . The initial delay of 125 corresponds to half the length of the lowpass
lter (0.5*fl) plus half the length of the correlator lter (0.5*M) plus half a
symbol period (0.5*M), which accounts for the delay from the start of each pulse
to its peak.
Stu Happens
173
3
2
1
0
2
3
0
50
100
150
200
250
300
350
400
Selecting this delay and the associated downsampling are accomplished in the
code
z=y ( 0 . 5 * f l +M:M: end ) ;
% downsample to symbol r a t e
then the reshape command can be used to form a matrix with 4*M rows and ul
columns. This is easily plotted using
plot ( reshape ( y ( l : u l * 4 *M+124) ,4 *M, u l ) )
and the result is shown in Figure 9.8. Note that the rst element plotted in Figure
9.8 is the lth element of Figure 9.7. This type of gure, called an eye diagram, is
commonly used in practice as an aid in troubleshooting. Eye diagrams will also
be used routinely in succeeding chapters.
Four is an interesting grouping size for this particular problem because four
symbols are used to represent each character in the coding and decoding implemented in letters2pam.m and pam2letters.m. One idiosyncrasy is that each
character starts o with a negative symbol. Another is that the second symbol in
174
4
3
2
Figure 9.9 Values of the
0
1
2
3
4
20
40
60
each character is never 1 in our chosen message. These are not generic eects;
they are a consequence of the particular coding and message used in idsys.m.
Had we chosen to implement a scrambling scheme (recall Exercise 8.19) the
received signal would be whitened and these particular peculiarities would not
occur.
The vector z contains estimates of the decoded symbols, and the command
plot([1:length(z)],z,.) produces a time history of the output of the downsampler, as shown in Figure 9.9. This is called the time history of a constellation
diagram in which all the dots are meant to lie near the allowable symbol values.
Indeed, the points in Figure 9.9 cluster tightly about the alphabet values 1 and
3. How tightly they cluster can be quantied using the cluster variance, which
is the average of the square of the dierence between the decoded symbol values
(the soft decisions) in z and the nearest member of the alphabet (the nal hard
decisions).
The Matlab function quantalph.m is used in idsys.m to calculate the hard
decisions, which are then converted back into a text character string using
pam2letters.m. If all goes well, this reproduces the original message. The only
aw is that the last symbol of the message has been lost due to the inherent delay
of the lowpass ltering and the pulse-shape correlation. Because four symbols are
needed to decode a single character, the loss of the last symbol also results in
the loss of the last character. The function pam2letters.m provides a friendly
reminder in the Matlab command window that this has happened.
The problems that follow give a few more ways to explore the behavior of the
ideal system.
Exercise 9.1. Using idsys.m, examine the eect of using dierent carrier frequencies. Try fc = 50, 30, 3, 1, 0.5. What are the limiting factors that cause
some to work and others to fail?
Stu Happens
175
Exercise 9.2. Using idsys.m, examine the eect of using dierent oversampling
frequencies. Try M = 1000, 25, 10. What are the limiting factors that cause some
to work and others to fail?
Exercise 9.3. What happens if the LPF at the beginning of the receiver is
removed? What do you think will happen if there are other users present? Try
adding in another user at fc = 30.
Exercise 9.4. What are the limits to the LPF design at the beginning of the
receiver? What is the lowest cuto frequency that works? The highest?
Exercise 9.5. Using the same specications (fbe=[0 0.1 0.2 1]; damps= [1
1 0 0 ];), how short can you make the LPF? Explain.
9.3
176
3
2
1
0
uncompensated at fading.
2
3
4
20
40
60
The resulting plot of the soft decisions in Figure 9.10 (obtained via
plot([1:length(z)], z,.)) shows the eect of the fade in the latter 80%
of the response. Shrinking the magnitude of the symbols 3 by half puts them
in the decision region for 1, which generates a large number of symbol errors.
Indeed, the recovered message looks nothing like the original.
Section 6.8 has already introduced an adaptive element designed to compensate for at fading: the automatic gain control, which acts to maintain the
power of a signal at a constant known level. Stripping out the AGC code from
agcvsfading.m on page 128 and combining it with the fading channel just discussed creates a simulation in which the fade occurs, but in which the AGC can
actively work to restore the power of the received signal to its desired nominal
value ds 1.
Listing 9.4. idsysmod2.m modication of idsys.m with fading plus automatic gain control
ds=pow ( r ) ;
l r=length ( r ) ;
f p =[ o n e s ( 1 , f l o o r ( 0 . 2 * l r ) ) , . . .
0 . 5 * o n e s ( 1 , l r f l o o r ( 0 . 2 *
r=r . * f p ;
g=zeros ( 1 , l r ) ; g ( 1 ) = 1 ;
nr=zeros ( 1 , l r ) ;
mu= 0 . 0 0 0 3 ;
f o r i =1: l r 1
nr ( i )=g ( i ) * r ( i ) ;
g ( i +1)=g ( i )mu* ( nr ( i )2 ds ) ;
end
r=nr ;
% d e s i r e d a v e r a g e power o f s i g n a l
% length of transmitted s i gnal
l r ) ) ] ; % f l a t fading p r o f i l e
% a p p l y to t r a n s m i t t e d s i g n a l
% i n i t i a l i z e gain
%
%
%
%
stepsize
a d a p t i v e AGC e l e m e n t
AGC o u t p u t
adapt g a i n
% received signal is
still
called r
Inserting this segment into idsys.m (immediately after the time-varying fading
channel modication) results in only a small number of errors that occur right at
the time of the fade. Very quickly, the AGC kicks in to restore the received power.
The resulting plot of the soft decisions (via plot([1:length(z)],z,.)) in
Figure 9.11 shows how quickly after the abrupt fade the soft decisions return
Stu Happens
177
4
3
2
1
Figure 9.11 Soft decisions with an
AGC compensating for an abrupt
at fade.
0
1
2
3
4
20
40
60
2.6
2.2
1.8
1.4
1
0
0.4
0.8
1.2
Iteration
1.6
2
x104
to the appropriate sector. (Look for where the larger soft decisions exceed a
magnitude of 2.)
Figure 9.12 plots the trajectory of the AGC gain g as it moves from the
vicinity of unity to the vicinity of 2 (just what is needed to counteract a 50%
fade). Increasing the stepsize mu can speed up this transition, but also increases
the range of variability in the gain as it responds to short periods when the
square of the received signal does not closely match its long-term average.
Exercise 9.6. Another idealized assumption made in idsys.m is that the
receiver knows the start of each frame; that is, it knows where each foursymbol group begins. This is a kind of frame synchronization problem and
was absorbed into the specication of a parameter l which appears in the code
as 0.5*fl+M. With the default settings, l is 125. This problem poses the following
question. What if this is not known, and how can it be xed?
a. Verify, using idsys.m, that the message becomes scrambled if the receiver
is mistaken about the start of each group of four. Add a random number of
4-PAM symbols before the message sequence, but do not tell the receiver
178
that you have done so (i.e., do not change l). What value of l would x the
problem? Can l really be known beforehand?
b. Section 8.5 proposed the insertion of a marker sequence as a way to synchronize the frame. Add a seven-symbol marker sequence just prior to the rst
character of the text. In the receiver, implement a correlator that searches for
the known marker. Demonstrate the success of this modication by adding
random symbols at the start of the transmission. Where in the receiver have
you chosen to put the correlation procedure? Why?
c. One quirk of the system (observed in the eye diagram in Figure 9.8) is that
each group of four begins with a negative number. Use this feature (rather
than a separate marker sequence) to create a correlator in the receiver that
can be used to nd the start of the frames.
d. The previous two exercises showed two possible solutions to the framesynchronization problem. Explain the pros and cons of each method, and
argue which is a better solution.
9.4
Stu Happens
179
The rst few lines of impsys.m prompt the user for parameters that dene the
impairments. The channel noise gain parameter cng is a gain factor associated
with a Gaussian noise that is added to the received signal. The suggested values
of 0, 0.6, and 2 represent no impairment, mild impairment (that only rarely
causes symbol recovery errors), and a harsh impairment (that causes multiple
symbol errors), respectively.
The second prompt selects the multipath interference: none, mild, or harsh.
In the mild and harsh cases, three copies of the transmitted signal are summed
at the receiver, each with a dierent delay and amplitude. This is implemented
by passing the transmitted signal through a lter whose impulse response is
specied by the variable mc. As occurs in practice, the transmission delays are
not necessarily integer multiples of the symbol interval. Each of the multipath
models has its largest tap rst. If the largest path gain were not rst, this could
be interpreted as a delay between the receipt of the rst sample of the rst pulse
of the message and the optimal sampling instant.
The next pair of prompts concern the transmitter and receiver oscillators.
The receiver assumes that the phase of the oscillator at the transmitter is zero
at the time of arrival of the rst sample of the message. In the ideal system,
this assumption was correct. In impsys.m, however, the receiver makes the same
assumption, but it might no longer be correct. Mismatch between the phase of
the oscillator at the transmitter and the phase of the oscillator at the receiver is
an inescapable impairment (unless there is also a separate communication link or
added signal such as an embedded pilot tone that synchronizes the oscillators).
The user is prompted for a carrier phase oset in radians (the variable po) that
is added to the phase of the oscillator at the transmitter, but not at the receiver.
Similarly, the frequencies of the oscillators at the transmitter and receiver may
dier by a small amount. The user species the frequency oset in the variable
fo as a percentage of the carrier frequency. This is used to scale the carrier
frequency of the transmitter, but not of the receiver. This represents a dierence
180
between the nominal values used by the receiver and the actual values achieved
by the transmitter.
Just as the receiver oscillator need not be fully synchronized with the transmitter oscillator, the symbol clock at the receiver need not be properly synchronized
with the transmitter symbol period clock. Eectively, the receiver must choose
when to sample the received signal on the basis of its best guess as to the phase
and frequency of the symbol clock at the transmitter. In the ideal case, the delay
between the receipt of the start of the signal and the rst sample time was readily calculated using the parameter l. But l cannot be known in a real system
because the rst sample depends, for instance, on when the receiver is turned
on. Thus, the phase of the symbol clock is unknown at the receiver. This impairment is simulated in impsys.m using the timing oset parameter toper, which
is specied as a percentage of the symbol period. Subsequent samples are taken
at positive integer multiples of the presumed sampling interval. If this interval
is incorrect, then the subsequent sample times will also be incorrect. The nal
impairment is specied by the symbol period oset, which sets the symbol
period at the transmitter to so less than that at the receiver.
Using impsys.m, it is now easy to investigate how each impairment degrades
the performance of the system.
9.4.1
Stu Happens
181
Amplitude
Magnitude
20
40
60
5000
4000
3000
2000
1000
0
50 40 30 20 10 0 10
Frequency
20
30
40
50
5
4
3
2
0
1
2
3
4
5
50
100
150
200
250
300
350
400
It should be clear from the noisy eye diagram that it would be very dicult to
correctly decode the symbols directly from this signal. Fortunately, the correlation lter reduces the noise signicantly, as shown in the eye diagram in Figure
9.15. (This is plotted as before, substituting y for x3.) Comparing Figures 9.14
and 9.15 closely, observe that the whole of the latter is shifted over in time by
about 50 samples. This is the eect of the time delay of the correlator lter,
which is half the length of the lter. Clearly, it is much easier to correctly decode
using y than using x3, though the pulse shapes of Figure 9.15 are still blurred
when compared with the ideal pulse shapes in Figure 9.8.
Exercise 9.7. The correlation lter in impsys.m is a lowpass lter with impulse
response given by the pulse shape p.
a. Plot the frequency response of this lter. What is the bandwidth of this lter?
182
4
3
2
1
0
1
2
3
4
50
100
150
200
250
300
350
400
b. Design a lowpass lter using firpm that has the same length and the same
bandwidth as the correlation lter.
c. Use your new lter in place of the correlation lter in impsys.m. Has the
performance improved or worsened? Explain in detail what tests you have
used.
No peeking ahead to Chapter 11.
9.4.2
Multipath Interference
The next impairment is interference caused by a multipath channel, which occurs
whenever there is more than one route between the transmitter and the receiver.
Because these paths experience dierent delays and attenuations, multipath
interference can be modeled as a linear lter. Since lters can have complicated
frequency responses, some frequencies may be attenuated more than others, and
so this is called frequency-selective fading.
The mild multipath interference in impsys.m has three (nonzero) paths
between the transmitter and the receiver. Its frequency response has numerous dips and bumps that vary in magnitude from about +2 to 4 dB. (Verify
this using freqz.) A plot of the soft decisions is shown in Figure 9.16 (from
plot([1:length(z)],z,.)), which should be compared with the ideal constellation diagram in Figure 9.9. The eect of the mild multipath interference
is to smear the lines into stripes. As long as the stripes remain separated, the
quantizer is able to recover the symbols, and hence the message, without errors.
The harsh multipath channel in impsys.m also has three paths between the
transmitter and receiver, but the later reections are larger than in the mild
case. The frequency response of this channel has peaks up to about +4 dB and
down to about 8 dB, so its eects are considerably more severe. The eect
of this channel can be seen directly by looking at the constellation diagram of
the soft decisions in Figure 9.17. The constellation diagram is smeared, and it is
Stu Happens
183
4
3
2
Figure 9.16 With mild multipath
interference, the soft decisions
can readily be segregated into
four stripes that correspond to
the four symbol values.
1
0
1
2
3
4
20
40
60
80
4
3
2
Figure 9.17 With harsher
0
1
2
3
4
20
40
60
80
no longer possible to visually distinguish the four stripes that represent the four
symbol values. It is no surprise that the message becomes garbled. As the output
shows, there are about 10% symbol errors, and most of the recovered characters
are wrong.
9.4.3
184
2
1.5
1
Figure 9.18 Soft decisions for
harsh carrier phase oset are
never greater than 2. The
quantizer nds no 3s and
many symbol errors occur.
0.5
0
0.5
1
1.5
2
20
40
60
80
When running impsys.m, there are two suggested nonzero choices for the
phase-oset parameter po. With po=0.9, cos(0.9) = 0.62, and 3 cos(0.9) < 2.
This is shown in the plot of the soft-decision errors in Figure 9.18. For the
milder carrier phase oset (po=0.7), the soft decisions result in no symbol errors,
because the quantizer will still decode values at 3 cos(0.7) = 2.3 as 3.
As long as the constellation diagram retains distinct horizontal stripes, all is
not lost. In Figure 9.18, even though the maximum magnitude is less than 2,
there are still four distinct stripes. If the quantizer could be scaled properly, the
symbols could be decoded successfully. Such a scaling might be accomplished,
for instance, by another AGC, but such scaling would not improve the signalto-noise ratio. A better approach is to identify the unknown phase oset, as
discussed in Chapter 10.
Exercise 9.8. Using impsys.m as a basis, implement an AGC-style adaptive
element to compensate for a phase oset. Verify that your method works for a
phase oset of 0.9 and for a phase oset of 1.2. Show that the method fails when
the phase oset is /2.
9.4.4
Stu Happens
185
3
2
1
Figure 9.19 Soft decisions for
0.01% carrier frequency oset.
0
1
2
3
9.4.5
20
40
60
80
9.4.6
186
1
0
1
2
3
50
100
150
200
250
300
350
400
to sample are at l + nT . When there is a period oset, it means that the value
of T used at the receiver diers from the value actually used at the transmitter.
The prompt in impsys.m for symbol period oset suggests trying 0 or 1. A
response of 1 results in the transmitter creating the signal assuming that there
are M 1 samples per symbol period, while the receiver retains the setting of
M samples per symbol, which is used to specify the correlator lter and to
pick subsequent downsampling instants once the initial sample time has been
selected. The symptom of a misaligned sample period is a periodic collapse of
the constellation, similar to that observed when there is a carrier frequency oset
(recall Figure 9.19). For an oset of 1, the soft decisions are plotted in Figure
9.21. Can you connect the value of the period of this periodic collapse to the
parameters of the simulated example?
9.4.7
Repairing Impairments
When stu happens and the receiver continues to operate as if all were well,
the transmitted message can become unintelligible. The various impairments of
the preceding sections point the way to the next step in the design process by
showing the kinds of problems that may arise. Clearly, the receiver must be
improved to counteract these impairments.
Coding (Chapter 14) and matched receive ltering (Chapter 11) are intended
primarily to counter the eects of noise. Equalization (Chapter 13) compensates
for multipath interference, and can reject narrowband interferers. Carrier recovery (Chapter 10) will be used to adjust the phase, and possibly the frequency
as well, of the receiver oscillator. Timing recovery (Chapter 12) aims to reduce
downsampler timing and period oset. All of these xes can be viewed as digital
signal processing (DSP) solutions to the impairments explored in impsys.m.
Stu Happens
3
2
1
0
1
2
3
3
2
1
0
1
2
3
187
50
20
100
40
150
60
80
200
250
100 120
300
140
160
350
180
400
1% downsampler period
oset, all is lost, as shown
by the eye diagram in the
top plot and the soft
decisions in the bottom.
200
9.5
A B 3IG Deal
While the idealized communication systems in idsys.m and impsys.m illustrate
the basic operation of a transmitterreceiver pair, practical systems are a bit
more complicated. One of the problems is keeping track of all the problems that
can arise! In order to help organize all the possibilities, this section introduces
the Basic Black Box Impairment Generator, or B 3IG, as shown in Figure 9.22.
MATLAB
script
defining
transmitter
parameters
Signal r as it
enters the receiver
Basic Black Box
Impairment Generator
Figure 9.22 The Basic Black Box Impairment Generator, or B 3IG, inputs a Matlab
script that species the operation of the transmitter along with any desired
impairments. The output is the (received) signal r that enters the receiver. You can
nd out how the system operates by peering ahead to Appendix H, but we really
shouldnt mention it at this point.
188
There are four inputs to the B 3IG. The message that is to be transmitted is specied in the variable m. The frame parameters frameParams include a specication
for how many symbols are included in each block and a string that represents
the preamble (or header). These are familiar from Chapter 8. In order to mimic
the idealized transmission in idsys.m and impsys.m, the length of a block is set
to 1 and there is no preamble. The message includes the Oscar Meyer jingle and
some numbers. The complete list of parameters is given in Listing 9.7.
Listing 9.7. Parameters in the script BigIdeal.m allow the B 3IG transmission to mimic
the idealized system idsys.m and impsys.m.
% Message Gen er a ti o n
m= 01234 I wish I were an Oscar Meyer ...
wiener 56789 ;
% Frame p a r a m e te r s
frameParams . u s er D a ta L en g th =1;
frameParams . preamble= ;
frameParams . chanCodingFlag =0;
frameParams . b i t E n c o d i n g F l a g =0;
% Channel p a r a m eter s , Adj Users , I n t . ,
chanParams . c1 =[1 0 0 ] ;
chanParams . c2 =[1 0 0 ] ;
chanParams . randomWalkVariance=0;
chanParams .SNR=I n f ;
chanParams . a d j a c e n t U s er 1 P o w er=I n f ;
chanParams . a d j a c e n t U s e r 1 f i f =0;
chanParams . a d j a c e n t U s er 1 C h a n =[1 0 0 ] ;
chanParams . a d j a c e n t U s er 2 P o w er=I n f ;
chanParams . a d j a c e n t U s e r 2 f i f =0;
chanParams . a d j a c e n t U s er 2 C h a n =[1 0 0 ] ;
chanParams . NBIfreq =0;
chanParams . NBIPower=I n f ;
% RF P a r a m e t e r s
Stu Happens
189
rfParams . f i f e r r =0;
rfParams . T t e r r =0;
rfParams . p h a s e N o i s e V a r i a n c e =0;
rfParams . SRRCLength =4;
rfParams . S R R C r o l l o f f = 0 . 3 ;
rfParams . f s =100;
rfParams . T t =1;
rfParams . f i f =20;
190
mprime=q u a n t a l p h ( z , [ 3 , 1 , 1 , 3 ] ) ;
% q u a n t i z e to a l p h a b e t
c v a r =(mprimez ) * ( mprimez ) / length ( mprime ) % c l u s t e r v a r i a n c e
lmp=length ( mprime ) ;
p e r e r r =100 *sum( abs ( sign ( mprimel e t t e r s 2 p a m (m) ) ) ) / lmp % symb e r r
% decode d e c i s i o n d ev i ce output to tex t s t r i n g
r e c o n s t r u c t e d m e s s a g e=p a m 2 l e t t e r s ( mprime )
Exercise 9.11. Use the AGC code from agcgrad.m to nd the proper gain for
the receiver in BigIdeal.m. If the AGC converges slowly, you may wish to use a
longer message m.
Exercise 9.12. Observe that when the parameter dstart is specied incorrectly,
the message is not reconstructed correctly, even when there is no additive noise.
Implement a strategy to identify dstart from the received signal. Hint: perhaps
a header or frame would help.
Exercise 9.13. How would you change the frame, channel, or RF parameters
to reproduce Figures 9.16 and 9.17?
Exercise 9.14. How would you change the frame, channel, or RF parameters
to reproduce Figure 9.19?
The fourth step describes all the practical xes that are needed in order to create
a workable radio. One by one the various pragmatic problems are studied and
solutions are proposed, implemented, and tested. These include xes for additive
noise, for timing oset problems, for clock frequency mismatches and jitter, and
for multipath reections. The order in which topics are discussed is the order in
which they appear in the receiver.
Carrier recovery
the timing of frequency translation
Receive ltering
the design of pulse shapes
Clock recovery
the timing of sampling
Equalization
lters that adapt to the channel
Coding
making data resilient to noise
Chapter 10
Chapter 11
Chapter 12
Chapter 13
Chapter 14
10 Carrier Recovery
Figure 10.1 shows a generic transmitter and receiver pair that emphasizes the
modulation and corresponding demodulation. Even assuming that the transmission path is ideal (as in Figure 10.1), the signal that arrives at the receiver is a
complicated analog waveform that must be downconverted and sampled before
the message can be recovered. For the demodulation to be successful, the receiver
must be able to gure out both the frequency and the phase of the modulating
sinusoid used in the transmitter, as was shown in (5.4) and (5.5) and graphically
illustrated in Figures 9.18 and 9.19. This chapter discusses a variety of strategies
that can be used to estimate the phase and frequency of the carrier and to x the
gain problem (of (5.4) and Figure 9.18) and the problem of vanishing amplitudes
(in (5.5) and Figure 9.19). This process of estimating the frequency and phase
of the carrier is called carrier recovery.
Figure 10.1 shows two downconversion steps: one analog and one digital. In
a purely analog system, no sampler or digital downconversion would be needed.
The problem is that accurate analog downconversion requires highly precise analog components, which can be expensive. In a purely digital receiver, the sampler
would directly digitize the received signal, and no analog downconversion would
be required. The problem is that sampling this fast can be prohibitively expensive. The happy compromise is to use an inexpensive analog downconverter to
translate to some lower intermediate frequency, at which it is possible to sample
cheaply enough. At the same time, sophisticated digital processing can be used to
compensate for inaccuracies in the cheap analog components. Indeed, the same
adaptive elements that estimate and remove the unknown phase oset between
the transmitter and the receiver automatically compensate for any additional
phase inaccuracies in the analog portion of the receiver.
Normally, the transmitter and receiver agree to use a particular frequency for
the carrier, and in an ideal world, the frequency of the carrier of the transmitted
signal would be known exactly. But even expensive oscillators may drift apart
in frequency over time, and cheap (inaccurate) oscillators may be an economic
necessity. Thus, there needs to be a way to align the frequency of the oscillator at
Carrier Recovery
Message
m(kT)
Received
signal
Pulse
shaping
Modulation
fc
Analog
conversion
to IF
Ts
Digital downconversion
to baseband
Resampling
193
Reconstructed
message
m(kT)
Decision
Timing
synchronization
Frequency and
phase tracking
f0
the transmitter with the frequency of the oscillator at the receiver. Since the goal
is to nd the frequency and phase of a signal, why not use a Fourier transform
(or, more properly, an FFT)? Section 10.1 shows how to isolate a sinusoid that is
at twice the frequency of the carrier by squaring and ltering the received signal.
The frequency and phase of this sinusoid can then be found in a straightforward
manner by using the FFT, and the frequency and phase of the carrier can then
be simply deduced. Though feasible, this method is rarely used because of the
computational cost.
The strategy of the following sections is to replace the FFT operation with
an adaptive element that achieves its optimum value when the phase of an estimated carrier equals the phase of the actual carrier. By moving the estimates in
the direction of the gradient of a suitable performance function, the element can
recursively hone in on the correct value. Assuming initially that the frequency
is known, there are various ways to structure adaptive elements that iteratively
estimate the unknown phase of a carrier. One such performance function, discussed in Section 10.2, is the square of the dierence between the received signal
and a locally generated sinusoid. Another performance function leads to the
well-known phase-locked loop, which is discussed in depth in Section 10.3, and
yet another performance function leads to the Costas loop of Section 10.4. An
alternative approach uses the decision-directed method detailed in Section 10.5.
Each of these methods is derived from an appropriate performance function, each
is simulated in Matlab, and each can be understood by looking at the appropriate error surface. This approach should be familiar from Chapter 6, where it
was used in the design of the AGC.
Section 10.6 then shows how to modify the adaptive elements to attack the
frequency-estimation problem. Three ways are shown. The rst tries (unsuccessfully) to apply a direct adaptive method, and the reasons for the failure
provide a cautionary counterpoint to the indiscriminate application of adaptive
elements. The second, a simple indirect method detailed in Section 10.6.2, uses
two loops. Since the phase of a sinusoid is the derivative of its frequency, the
rst loop tracks a line (the frequency oset) and the second loop ne-tunes
the estimation of the phase. The third technique, in Section 10.6.3, shows how
194
10.1
% # symbols , o v e r s a m p l i n g f a c t o r
% s a m p l i n g i n t e r v a l & time v e c t o r
% 4 l e v e l s i g n a l o f l e n g t h N
%
%
%
%
%
%
%
o v er s a m p l e by i n t e g e r l e n g t h M
b l i p p u l s e o f width M
c o n v o l v e p u l s e shape with data
c a r r i e r f r e q and phase
construct c a r r i e r
modulated s i g n a l ( s m a l l c a r r i e r )
modulated s i g n a l ( l a r g e c a r r i e r )
Figure 10.2 plots the spectra of the large- and suppressed-carrier signals rlc
and rsc. The carrier itself is clearly visible in the top plot, and its frequency and
phase can readily be found by locating the maximum value in the FFT:
f f t r l c =f f t ( r l c ) ;
[m, imax]=max( abs ( f f t r l c ( 1 : end / 2 ) ) ) ;
s s f =(0: length ( t ) 1)/( Ts * length ( t ) ) ;
1
% spectrum o f r l c
% i n d e x o f max peak
% frequency vector
This is not a common (or a particularly useful) pulse shape. It is just easy to use. Good
pulse shapes are considered in detail in Chapter 11.
Carrier Recovery
1000
2000
3000
4000
5000
1000
2000
3000
4000
5000
1000
2000
3000
4000
5000
195
Figure 10.2 The magnitude spectrum of the received signal of a system using AM with
large carrier has a prominent spike at the frequency of the carrier, as shown in the top
plot. When using the suppressed-carrier method in the middle plot, the carrier is not
clearly visible. After preprocessing of the suppressed-carrier signal using the scheme
in Figure 10.3, a spike is clearly visible at twice the desired frequency (and with twice
the desired phase). In the time domain, this corresponds to an undulating sine wave.
f r e q L=s s f ( imax )
phaseL=angle ( f f t r l c ( imax ) )
% f r e q a t th e peak
% phase a t th e peak
Changing the default phase oset phoff changes the phaseL variable accordingly.
Changing the frequency fc of the carrier changes the frequency freqL at which
the maximum occurs. Note that the max function used in this fashion returns
both the maximum value m and the index imax at which the maximum occurs.
On the other hand, applying the same code to the FFT of the suppressedcarrier signal does not recover the phase oset. In fact, the maximum often
occurs at frequencies other than the carrier, and the phase values reported bear
no resemblance to the desired phase oset phoff. There needs to be a way to
process the received signal to emphasize the carrier.
A common scheme uses a squaring nonlinearity followed by a bandpass lter,
as shown in Figure 10.3. When the received signal r(t) consists of the pulsemodulated data signal s(t) times the carrier cos(2f c t + ), the output of the
squaring block is
r2 (t) = s2 (t) cos2 (2fc t + ).
(10.1)
This can be rewritten using the identity 2 cos2 (x) = 1 + cos(2x) in (A.4) to produce
r2 (t) = (1/2)s2 (t)[1 + cos(4fc t + 2)].
Rewriting s2 (t) as the sum of its (positive) average value and the variation about
this average yields
s2 (t) = s2avg + v(t).
196
Thus,
r2 (t) = (1/2)[s2avg + v(t) + s2avg cos(4fc t + 2) + v(t) cos(4fc t + 2)].
A narrow bandpass lter centered near 2fc passes the pure cosine term in r2 and
suppresses the DC component, the (presumably) lowpass v(t), and the upconverted v(t). The output of the bandpass lter is approximately
1 2
s cos(4fc t + 2 + ),
(10.2)
2 avg
where is the phase shift added by the BPF at frequency 2fc . Since is known
at the receiver, rp (t) can be used to nd the frequency and phase of the carrier. Of
course, the primary component in rp (t) is at twice the frequency of the carrier,
the phase is twice the original unknown phase, and it is necessary to take
into account. Thus some extra bookkeeping is needed. The amplitude of rp (t)
undulates slowly as s2avg changes.
The following Matlab code carries out the preprocessing of Figure 10.3. First,
run pulrecsig.m to generate the suppressed carrier signal rsc.
rp (t) = BPF{r2 (t)}
Listing 10.2. pllpreprocess.m send received signal through square and BPF
r=r s c ;
q=r . 2 ;
f l =500; f f =[0 . 3 8 . 3 9 . 4 1 . 4 2 1 ] ;
f a =[0 0 1 1 0 0 ] ;
h=f i r p m ( f l , f f , f a ) ;
rp=f i l t e r ( h , 1 , q ) ;
%
%
%
%
%
%
suppressed c a r r i e r r
square n o n l i n e a r i t y
BPF c e n t e r f r e q u e n c y a t . 4
which i s t w i c e f c
BPF d e s i g n v i a f i r p m
f i l t e r gives preprocessed r
Then the phase and frequency of rp can be found directly by using the FFT.
% r e c o v e r unknown f r e q and phase u s i n g
f f tr B P F=f f t ( rp ) ;
%
[m, imax]=max( abs ( f f tr B P F ( 1 : end / 2 ) ) ) ; %
s s f =(0: length ( rp ) ) / ( Ts * length ( rp ) ) ; %
f r e q S=s s f ( imax )
%
phasep=angle ( f f tr B P F ( imax ) ) ;
%
[ IR , f ]= f r e q z ( h , 1 , length ( rp ) , 1 / Ts ) ;
%
[ mi , im]=min( abs ( f f r e q S ) ) ;
%
phaseBPF=angle ( IR ( im ) ) ;
%
phaseS=mod ( phasep phaseBPF , pi )
%
FFT
spectrum o f rBPF
f i n d f r e q o f max peak
frequency vector
f r e q a t th e peak
phase a t th e peak
freq response of f i l t e r
f r e q where peak o c c u r s
< o f BPF a t peak f r e q
estimated angle
Observe that both freqS and phaseS are twice the nominal values of fc and
phoff, though there may be a ambiguity (as will occur in any phase estimation).
The intent of this section is to clearly depict the problem of recovering the frequency and phase of the carrier even when it is buried within the data-modulated
signal. The method used to solve the problem (application of the FFT) is not
common, primarily because of the numerical complexity. Most practical receivers
use some kind of adaptive element to iteratively locate and track the frequency
and phase of the carrier. Such elements are explored in the remainder of this
chapter.
Carrier Recovery
r(t)
X2
Squaring
nonlinearity
r2(t)
BPF
197
rp(t) ~ cos(4 fc t + 2 + )
Center frequency
~ 2fc
Figure 10.3 Preprocessing the input to a PLL via a squaring nonlinearity and BPF
results in a sinusoidal signal at twice the frequency with a phase oset equal to twice
the original plus a term introduced by the known bandpass ltering.
10.2
(10.3)
which suppresses2 the dependence on the known phase shift of the BPF and
sets the constant s2avg /2 to unity (compare with (10.2)). The form of rp (t) implies
that there is an essential ambiguity in the phase since can be replaced by
+ n for any integer n without changing the value of (10.3). What can be
done to recover (modulo ) from rp (t)?
2
198
Is there some way to use an adaptive element? Section 6.5 suggested that there
are three steps to the creation of a good adaptive element: setting a goal, nding
a method, and then testing. As a rst try, consider the goal of minimizing the
average of the squared dierence between rp (t) and a sinusoid generated, using
an estimate of the phase; that is, seek to minimize
1
(10.4)
avg{(rp (kTs ) cos(4f0 kTs + 2))2 }
4
by choice of , where rp (kTs ) is the value of rp (t) sampled at time kTs and
where f0 is presumed equal to fc . (The subscript SD stands for squared dierence, and is used to distinguish this performance function from others that will
appear in this and other chapters.) This goal makes sense because, if could be
found so that = + n, then the value of the performance function would be
zero. When = + n, then rp (kTs ) = cos(4f0 kTs + 2), e(, k) = 0, and so
JSD () > 0. Hence, (10.4) is minimized when has correctly identied the phase
oset, modulo the inevitable ambiguity.
While there are many methods of minimizing (10.4), an adaptive element that
descends the gradient of the performance function JSD () leads to the algorithm3
dJSD ()
[k + 1] = [k]
,
(10.5)
d =[k]
JSD () = avg{e2 (, k)} =
which is the same as (6.5) with the variable changed from x to . Using the
approximation detailed in (G.12), which holds for small , the derivative and
the average commute. Thus,
2
d avg{e2 (, k)}
de (, k)
dJSD ()
=
avg
d
d
d
1
de(, k)
= avg e(, k)
(10.6)
2
d
= avg{(rp (kTs ) cos(4f0 kTs + 2)) sin(4f0 kTs + 2)}.
Substituting this into (10.5) and evaluating at = [k] gives4
[k + 1] = [k] avg{(rp (kTs ) cos(4f0 kTs + 2[k]))
sin(4f0 kTs + 2[k])}.
(10.7)
% time i n t e r v a l & v e c t o r
Carrier Recovery
199
Phase offset
2
1
0
1
2
3
0
5
6
Time
10
f c =100; p h o f f = 0.8;
% c a r r i e r f r e q and phase
rp=cos (4 * pi * f c * t +2* p h o f f ) ;
% si m p l i f i e d rec s i gnal
mu= . 0 0 1 ;
% algorithm s t e p s i z e
t h e t a=zeros ( 1 , length ( t ) ) ; t h e t a ( 1 ) = 0 ;
% i n i t i a l i z e estimates
f l =25; h=o n e s ( 1 , f l )/ f l ;
% averaging c o e f f i c i e n t s
z=zeros ( 1 , f l ) ; f 0=f c ;
% b u f f e r f o r avg
f o r k =1: length ( t )1
% run a l g o r i t h m
f i l t i n =(rp ( k)cos (4 * pi * f 0 * t ( k)+2 * t h e t a ( k ) ) ) . . .
* s i n (4 * pi * f 0 * t ( k)+2 * t h e t a ( k ) ) ;
z =[ z ( 2 : f l ) , f i l t i n ] ;
% z contains past inputs
t h e t a ( k+1)= t h e t a ( k)mu* f l i p l r ( h ) * z ;
% update = z c o n v o l v e h
end
200
a. What happens if the phase slowly changes over time? Consider a slow, smallamplitude undulation in phoff.
b. Consider a slow linear drift in phoff.
c. What happens if the frequency f0 used in the algorithm is (slightly) dierent
from the frequency fc used to construct the carrier?
d. What happens if the frequency f0 used in the algorithm is greatly dierent
from the frequency fc used to construct the carrier?
Exercise 10.5. How much averaging is necessary? Reduce the length of the
averaging lter. Is it possible to make the algorithm work with no averaging?
Why does this work? Hint: yes, it is possible. Consider the relationship between
(10.7) and (G.4).
Exercise 10.6. Derive (10.6), following the technique used in Example G.3.
The performance function JSD () of (10.4) provides a mathematical statement
of the goal of an adaptive phase-tracking element. The method is dened by the
algorithm (10.7) and simulations such as pllsd.m suggest that the algorithm
can function as desired. But why does it work?
One way to understand adaptive elements, as discussed in Section 6.6 and
shown in Figure 6.17 on page 119, is to draw the error surface for the performance function. But it is not immediately clear what this looks like, since
JSD () depends on the frequency f0 , the time kTs , and the unknown (through
rp (kTs )), as well as the estimate . Recognizing that the averaging operation acts
as a kind of lowpass lter (see Appendix G if this makes you nervous) allows
considerable simplication of JSD (). Rewrite (10.4) as
JSD () =
1
LPF{(rp (kTs ) cos(4f0 kTs + 2))2 }.
4
(10.8)
JSD () =
1
LPF{cos2 (4f0 kTs + 2) 2 cos(4f0 kTs + 2)
4
cos(4f0 kTs + 2) + cos2 (4f0 kTs + 2)}.
Using the trigonometric formula (A.4) for the square of a cosine and the formula
(A.13) for the cosine angle sum (i.e., expand cos(x + y) with x = 4f0 kTs and
y = 2, and then again with y = 2) yields
JSD () =
1
LPF{2 + cos(8f0 kTs + 4) 2 cos(2 2)
8
2 cos(8f0 kTs + 2 + 2) + cos(8f0 kTs + 4)}.
Carrier Recovery
201
JSD
0.8
0.4
JPLL
0
0.4
0
JC
0.4
0.8
0.4
0
4
0
2
4
Phase estimates
1
(1 cos(2 2)),
4
(10.9)
which is shown in the top plot of Figure 10.5 for = 0.8. The algorithm (10.7)
is initialized with [0] at some point on the surface of the undulating sinusoidal
curve. At each iteration of the algorithm, it moves downhill. Eventually, it will
reach one of the nearby minima, which occur at = 0.8 n for some n.
Thus, Figure 10.5 provides evidence that the algorithm can successfully locate
the unknown phase, assuming that the preprocessed signal rp (t) has the form
of (10.3).
Figure 10.6 shows the algorithm (10.7) with the averaging operation replaced
by the more general LPF. In fact, this provides a concrete answer to Exercise 10.5;
the averaging, the LPF, and the integral block all act as lowpass lters. All that
was required of the ltering in order to arrive at (10.9) from (10.8) was that it
remove frequencies above 4f0 . This mild requirement is accomplished even by
the integrator alone.
Exercise 10.7. The code in pllsd.m is simplied in the sense that the received
signal rp contains just the unmodulated carrier. Implement a more realistic
scenario by combining pulrecsig.m to include a binary message sequence,
pllpreprocess.m to create rp, and pllsd.m to recover the unknown phase oset
of the carrier.
202
rp(kTs)
cos(4f0kTs + 2[k])
LPF
[k]
sin(4f0kTs + 2[k])
2
Figure 10.6 A block diagram of the squared-dierence phase-tracking algorithm (10.7).
The input rp (kTs ) is a preprocessed version of the received signal as shown in
Figure 10.3. The integrator block has a lowpass character, and is equivalent to a
sum and delay as shown in Figure 7.5.
10.3
Carrier Recovery
203
element ascending the gradient of a simple performance function. The key idea
is to modulate the (processed) received signal rp (t) of Figure 10.3 down to DC,
using a cosine of known frequency 2f0 and phase 2 + . After ltering to remove
the high-frequency components, the magnitude of the DC term can be adjusted
by changing the phase. The value of that maximizes the DC component is the
same as the phase of rp (t).
To be specic, let
1
(10.10)
LPF{rp (kTs ) cos(4f0 kTs + 2 + )}.
2
Using the cosine product relationship (A.9) and the denition of rp (t) from (10.3)
under the assumption that fc = f0 ,
JP LL () =
1
LPF{cos(4f0 kTs + 2 + ) cos(4f0 kTs + 2 + )}
2
1
= LPF{cos(2 2) + cos(8f0 kTs + 2 + 2 + 2)}
4
1
1
= LPF{cos(2 2)} + LPF{cos(8f0 kTs + 2 + 2 + 2)}
4
4
1
(10.11)
cos(2 2),
4
assuming that the cuto frequency of the lowpass lter is well below 4f0 . This
is shown in the middle plot of Figure 10.5 and is the same as JSD (), except
for a constant and a sign. The sign change implies that, while JSD () needs to
be minimized to nd the correct answer, JP LL () needs to be maximized. The
substantive dierence between the SD and the PLL performance functions lies
in the way that the signals needed in the algorithm are extracted.
Assuming a small stepsize, the derivative of (10.10) with respect to at time
k can be approximated (using (G.12)) as
d LPF{rp (kTs ) cos(4f0 kTs + 2 + )}
d
=[k]
#
drp (kTs ) cos(4f0 kTs + 2 + )
LPF
d
=[k]
JP LL () =
(10.12)
is shown in Figure 10.7. Observe that the sign of the derivative is preserved in
the update (rather than its negative), indicating that the algorithm is searching
for a maximum of the error surface rather than a minimum. One dierence
between the PLL and SD algorithms is clear from a comparison of Figures 10.6
and 10.7. The PLL requires one fewer oscillator (and one fewer addition block).
Since the performance functions JSD () and JP LL () are eectively the same,
the performance characteristics of the two are roughly equivalent.
204
rp(kTs)
e[k]
LPF F(z)
[k]
sin(4f0kTs + 2[k] + )
2
Figure 10.7 A block diagram of the digital phase-locked-loop algorithm (10.12). The
input signal rp (kTs ) has already been preprocessed to emphasize the carrier as in
Figure 10.3. The sinusoid mixes with the input and shifts the frequencies; after the
LPF only the components near DC remain. The loop adjusts to maximize this
low-frequency energy.
Figures 10.8(a) and (b) show the output of the program when f0 = fc and
f0 = fc , respectively. When the frequencies are the same, converges to a region
about the correct phase oset and wiggles about, with a size proportional
to the size of and dependent on details of the LPF. When the frequencies
are not the same, has a denite trend (the simulation in Figure 10.8(b) used
f0 = 1000 Hz and fc = 1001 Hz). Can you gure out how the slope of relates
to the frequency oset? The caption in Figure 10.8(b) provides a hint. Can you
imagine how the PLL might be used to estimate the frequency as well as to nd
the phase oset? These questions, and more, will be answered in Section 10.6.
Exercise 10.11. Use the preceding code to play with the phase-locked-loop
algorithm. How does aect the convergence rate? How does aect the oscillations in ? What happens if is too large (say = 1)? Does the convergence
speed depend on the value of the phase oset?
Phase offset
Carrier Recovery
0.2
0.4
205
0.6
0.8
0
0.2
0.4
0.6
Time
(a)
0.8
4
6
Time
(b)
10
Figure 10.8 Using the PLL, the estimates in (a) converge to a region about the
phase oset , and then oscillate. When the frequency estimate is incorrect as in (b),
becomes a line whose slope is proportional to the frequency dierence.
206
10.4
This is sensible because values of that minimize u2 (kTs ) also minimize u(kTs ).
207
Carrier Recovery
received signal r(kTs ) = s(kTs ) cos(2fc kTs + ) by reversing the order of the
processing: rst modulating to DC, then lowpass ltering, and nally squaring.
This reversal of operations leads to the performance function
JC () = avg{( LPF{r(kTs ) cos(2f0 kTs + )})2 }.
(10.13)
The resulting algorithm is called the Costas loop after its inventor J. P. Costas.
Because of the way in which the squaring nonlinearity enters JC (), it can operate
without preprocessing of the received signal as in Figure 10.3. To see why this
works, suppose that fc = f0 , and substitute r(kTs ) into (10.13):
JC () = avg{( LPF{s(kTs ) cos(2f0 kTs + ) cos(2f0 kTs + )})2 }.
Assuming that the cuto of the LPF is larger than the absolute bandwidth of
s(kTs ), and following the same logic as in (10.11) but with instead of 2, in
place of 2, and 2f0 kTs replacing 4f0 kTs shows that
LPF{s(kTs ) cos(2f0 kTs + ) cos(2f0 kTs + )}
1
(10.14)
= LPF{s(kTs )} cos( ).
2
Substituting (10.14) into (10.13) yields
2 #
1
1
s(kTs ) cos( )
JC () = avg
= avg{s2 (kTs ) cos2 ( ))}
2
4
1 2
cos2 ( ),
s
4 avg
where s2avg is the (xed) average value of the square of the data sequence s(kTs ).
Thus JC () is proportional to cos2 ( ). This performance function is plotted
(for an unknown phase oset of = 0.8) in the bottom part of Figure 10.5.
Like the error surface for the PLL (the middle plot), this achieves a maximum
when the estimate is equal to . Other maxima occur at + n for integer n.
In fact, except for a scaling and a constant, this is the same as JP LL because
cos2 ( ) = 12 (1 + cos(2 2)), as shown using (A.4).
The Costas loop can be implemented as a standard adaptive element (10.5).
The derivative of JC () is approximated by swapping the order of the dierentiation and the averaging (as in (G.12)), applying the chain rule, and then
swapping the derivative with the LPF. Thus dJC ()/d can be approximated as
d LPF{r(kTs ) cos(2f0 kTs + )}2
avg
d
d LPF{r(kTs ) cos(2f0 kTs + )}
= 2 avg LPF{r(kTs ) cos(2f0 kTs + )}
d
{dr(kTs ) cos(2f0 kTs + )}
2 avg LPF{r(kTs ) cos(2f0 kTs + )} LPF
d
= 2 avg{ LPF{r(kTs ) cos(2f0 kTs + )} LPF{r(kTs ) sin(2f0 kTs + )}}.
208
2cos(2f0kTs + [k])
Figure 10.9 The Costas loop is a
LPF
r(kTs)
[k]
LPF
2sin(2f0kTs + [k])
(10.15)
Basically, there are two paths. The upper path modulates by a cosine and then
lowpass lters to create (10.14), while the lower path modulates by a sine wave
and then lowpass lters to give s(kTs ) sin( ). These combine to give the
equation update, which is integrated to form the new estimate of the phase. The
latest phase estimate is then fed back (this is the loop in Costas loop) into
the oscillators, and the recursion proceeds.
Suppose that a 4-PAM transmitted signal r is created as in pulrecsig.m
(from page 194) with carrier frequency fc=1000. The Costas-loop phase-tracking
method (10.15) can be implemented in much the same way that the PLL is
implemented in pllconverge.m.
Listing 10.5. costasloop.m simulate the Costas loop with input from pulrecsig.m
r=r s c ;
f l =500; f f =[0 . 0 1 . 0 2 1 ] ; f a =[1 1 0 0 ] ;
h=f i r p m ( f l , f f , f a ) ;
mu= . 0 0 3 ;
f 0 =1000;
t h e t a=zeros ( 1 , length ( t ) ) ; t h e t a ( 1 ) = 0 ;
z s=zeros ( 1 , f l +1); zc=zeros ( 1 , f l +1);
f o r k =1: length ( t )1
% r s c from p u l r e c s i g .m
%
%
%
%
%
%
LPF d e s i g n
algorithm s t e p s i z e
f r e q at r e c e i v e r
estimate vector
b u f f e r s f o r LPFs
z contains past inputs
Carrier Recovery
209
3
2
1
Phase offset
0
1
2
3
4
0
0.4
0.8
1.2
1.6
Time
z s =[ z s ( 2 : f l +1) , 2 * r ( k ) * s i n (2 * pi * f 0 * t ( k)+ t h e t a ( k ) ) ] ;
z c =[ z c ( 2 : f l +1) , 2 * r ( k ) * cos (2 * pi * f 0 * t ( k)+ t h e t a ( k ) ) ] ;
l p f s=f l i p l r ( h ) * zs ; l p f c=f l i p l r ( h ) * zc ; % o u t p u t o f f i l t e r s
t h e t a ( k+1)= t h e t a ( k)mu* l p f s * l p f c ;
% a l g o r i t h m update
end
Exercise 10.20. How does the lter h inuence the performance of the Costas
loop?
210
6
4
Phase offset
2
Figure 10.11 When the
frequency of the carrier is
unknown at the receiver,
the phase estimates
converge to a line.
0
2
4
0.4
0.8
1.2
1.6
Time
10.5
211
Carrier Recovery
cos([k])
2cos(2f0kT)
LPF
r(kTs)
[k]
sin([k])
LPF
2sin(2f0kT)
cos([k])
(10.16)
As shown in Chapter 5, when the frequencies (f0 and fc ) and phases ( and )
are equal, then x(t) = s(t). In particular, x(kTs ) = s(kTs ) at the sample instants
t = kTs , where the s(kTs ) are elements of the alphabet. On the other hand, if
= , then x(kTs ) will not be a member of the alphabet. The dierence between
what x(kTs ) is and what it should be can be used to form a performance function
and hence a phase-tracking algorithm. A quantization function Q(x) is used to
nd the nearest element of the symbol alphabet.
The performance function for the decision-directed method is
JDD () =
1
avg{(Q(x[k]) x[k])2 }.
4
(10.17)
212
2cos(2f0kTs + [k])
x(kT)
LPF
r(kTs)
Q( )
M
LPF
.
x(kT)
+
[k]
M
2sin(2f0kTs + [k])
decision-directed
phase-tracking
algorithm (10.18)
operates on the
dierence between the
soft decisions and the
hard decisions to drive
the updates of the
adaptive element.
This can be used as the basis of an adaptive element by using the approximation
(G.12) to calculate
#
dJDD ()
1
1
dx[k]
d (Q(x[k]) x[k])2
avg
= avg (Q(x[k]) x[k])
,
d
4
d
2
d
which assumes that the derivative of Q with respect to is zero. The derivative
of x[k] can similarly be approximated as (recall that x[k] = x(kTs ) = x(t)|t=kTs
is dened in (10.16))
dx[k]
2 LPF{r[k] sin(2fc kTs + )}.
d
Thus, the decision-directed algorithm for phase tracking is
[k + 1] = [k] avg{(Q(x[k]) x[k]) LPF{r[k] sin(2f0 kTs + [k])}}.
Suppressing the (redundant) outer averaging operation gives
[k + 1] = [k] (Q(x[k]) x[k]) LPF{r[k] sin(2f0 kTs + [k])},
(10.18)
%
%
%
%
%
LPF p a r a m e te r s
& impulse response
initialize filters
i n i t i a l phase
algorithm s t e p s i z e
%
%
%
%
c o s i n e f o r demod
s i n e f o r demod
do th e demods
s t a t e s f o r LPFs
Carrier Recovery
x ( k)= f l i p l r ( h ) * f z c ;
x d e r=f l i p l r ( h ) * f z s ;
i f mod ( 0 . 5 * f l +M/2k ,M)==0
qx=q u a n t a l p h ( x ( k ) , [ 3 , 1 , 1 , 3 ] ) ;
t h e t a ( j +1)= t h e t a ( j )mu * ( qxx ( k ) ) * x d e r ;
j=j +1;
end
end
%
%
%
%
%
213
LPF g i v e s x
& its derivative
downsample f o r t i m i n g
q u a n t i z e to a l p h a b e t
a l g o r i t h m update
The same lowpass lter is used after demodulation with the cosine (to create
x) and with the sine (to create its derivative xder). The ltering is done using
the time-domain method (the fourth method presented in waystofilt.m on page
143) because the demodulated signals are unavailable until the phase estimates
are made. One subtlety in the decision-directed phase-tracking algorithm is that
there are two time scales involved. The input, oscillators, and LPFs operate at
the faster sampling rate Ts , while the algorithm update (10.18) operates at the
slower symbol rate T . The correct relationship between these is maintained in
the code by the mod function, which picks one out of each M Ts -rate sampled data
points.
The output of plldd.m (for many dierent starting values) is shown in Figure
10.14. For initializations near the correct answer = 1.0, the estimates converge to 1.0. Of course, there is the (by now familiar) ambiguity. But there
are also other values for which the DD algorithm converges. What are these
values?
As with any adaptive element, it helps to draw the error surface in order
to understand its behavior. In this case, the error surface is JDD () plotted
as a function of the estimates . The following code approximates JDD () by
averaging over N=1000 symbols drawn from the 4-PAM alphabet.
Listing 10.7. plldderrsys.m error surface for decision-directed phase tracking
N=1000;
m=pam (N, 4 , 5 ) ;
p h i = 1.0;
theta = 2:.01:6;
f o r k =1: length ( t h e t a )
x=m* cos ( phit h e t a ( k ) ) ;
qx=q u a n t a l p h ( x , [ 3 , 1 , 1 , 3 ] ) ;
j t h e t a ( k )=( qx x ) * ( qx x ) /N;
end
plot ( th e ta , j t h e t a )
%
%
%
%
%
%
%
%
a v e r a g e o v e r N symbols ,
u s e 4PAM symbols
unknown phase o f f s e t p h i
g r i d f o r phase e s t i m a t e s
f o r each p o s s i b l e t h e t a
f i n d x with t h i s t h e t a
q( x) f o r t h i s theta
J f o r t h i s theta
The output of plldderrsys.m is shown in Figure 10.15. First, the error surface
inherits a basic periodicity6 in of period 2 from the cosine function. Within
each 2 repetition, there are six minima, two of which are broad and deep. One of
these corresponds to the correct phase at = 1.0 2n and the other (at =
1.0 + 2n) corresponds to the situation in which the cosine takes on a value
6
Actually, the error surface is periodic with period , but the behavior of the algorithm is
easier to understand by considering the fundamental periods in pairs.
Phase estimates
4
3
Figure 10.14 The decision-directed
2
1
0
1
2
Time
1
0.8
Cost JDD()
214
0.6
0.4
0.2
0
2
1
2
3
Phase estimates
Carrier Recovery
215
Exercise 10.24. Use the code in plldd.m to play with the DD algorithm.
a. How large can the stepsize be made?
b. Is the LPF of the derivative really needed?
c. How crucial is it to the algorithm to pick the correct timing? Examine this
question by choosing incorrect j at which to evaluate x.
d. What happens when the assumed frequency f0 is not the same as the frequency fc of the carrier?
Exercise 10.25. The direct calculation of dx(kTs )/d as a ltered version of
(10.16) is only one way to calculate the derivative. Replace this using a numerical
approximation (such as the forward or backward Euler, or the trapezoidal rule).
Compare the performance of your algorithm with that of plldd.m.
Exercise 10.26. Consider the DD phase-tracking algorithm when the message
alphabet is binary 1.
a. Modify plldd.m to simulate this case.
b. Modify plldderrsys.m to draw the error surface. Is the DD algorithm better
(or worse) suited to the binary case than the 4-PAM case?
Exercise 10.27. Consider the DD phase-tracking algorithm when the message
alphabet is 6-PAM.
a. Modify plldd.m to simulate this case.
b. Modify plldderrsys.m to draw the error surface. Is the DD algorithm better
(or worse) suited to 6-PAM than to 4-PAM?
Exercise 10.28. What happens when the number of inputs used to calculate
the error surface is too small? Try N = 100, 10, 1. Can N be too large?
Exercise 10.29. Investigate how the error surface depends on the input signal.
a. Draw the error surface for the DD phase-tracking algorithm when the inputs
are binary 1.
b. Draw the error surface for the DD phase-tracking algorithm when the inputs
are drawn from the 4-PAM constellation, for the case in which the symbol 3
never occurs.
Exercise 10.30. TRUE or FALSE: Decision-directed phase recovery can exhibit
local minima of dierent depths.
Exercise 10.31. This problem uses the B 3IG to test the carrier-recovery algorithm of your choice.
a. Currently, the receiver portion of the script in BigIdeal.m knows the phase
of the carrier. Add a carrier-recovery algorithm of your choice to BigIdeal.m
216
so that the receiver can accommodate unknown carrier phases. Run the modied code and use the carrier-recovery algorithm to estimate the phase oset
. State the carrier-recovery method used and plot the tracking of . If the
receiver employs preprocessing, take care to design the BPF appropriately.
b. Modify the B 3IG so that a phase oset is introduced. In BigTransmitter.m,
set the variable phi=-0.5, and add a phase oset
x_rf=x.*cos(2*pi*rfParams.f_if_tx*...
[1:length(x)]*rfParams.T_t_tx/M+p_noise+phi);
where upconversion is performed. Rerun the code. How does the behavior of
your algorithm dier? Include plots to justify your claim.
c. Repeat part (b) for the case when phi=1.2.
10.6
Frequency Tracking
The problems inherent in even a tiny dierence in the frequency of the carrier
at the transmitter and the assumed frequency at the receiver are shown in (5.5)
and illustrated graphically in Figure 9.19 on page 185. Since no two independent
oscillators are ever exactly aligned, it is important to nd ways of estimating the
frequency from the received signal. The direct method of Section 10.6.1 derives
an algorithm based on a performance function that uses a square dierence in
the time domain. Unfortunately, this does not work well, and its failure can be
traced to the shape of the error surface.
Section 10.6.2 begins with the observation (familiar from Figures 10.8(b) and
10.11) that the estimates of phase made by the phase-tracking algorithms over
time lie on a line whose slope is proportional to the dierence in frequency
between the modulating and the demodulating oscillators. This slope contains
valuable information that can be exploited to indirectly estimate the frequency.
The resulting dual-loop element is actually a special case of a more general (and
ultimately simpler) technique that puts an integrator in the forward part of the
loop in the PLL. This is detailed in Section 10.6.3.
10.6.1
1
LPF{(r(t) cos(2f0 t))2 }.
2
(10.19)
Carrier Recovery
217
Frequency estimates f0
102
100
98
Time
12
16
Following a gradient strategy for updating the estimates f0 leads to the algorithm
dJ(f0 )
f0 [k + 1] = f0 [k]
(10.20)
df0 f0 =f0 [k]
= f0 [k] LPF{2kTs (r(kTs ) cos(2kTs f0 [k])) sin(2kTs f0 [k])}.
How well does this algorithm work? First, observe that the update is multiplied by 2kTs. (This arises from application of the chain rule when taking the
derivative of sin(2kTs f0 [k]) with respect to f0 [k].) This factor increases continuously, and acts like a stepsize that grows over time. Perhaps the easiest way to
make any adaptive element fail is to use a stepsize that is too large; the form of
this update ensures that eventually the stepsize will be too large.
Putting on our best engineering hat, let us just remove this oending term,
and go ahead and simulate the method.7 At rst glance it might seem that the
method works well. Figure 10.16 shows 20 dierent starting values. All 20 appear
to converge nicely within one second to the unknown frequency value at fc=100.
But then something strange happens: one by one, the estimates diverge. In the
gure, one peels o at about 6 seconds, and one at about 17 seconds. Simulations
can never prove conclusively that an algorithm is good for a given task, but if
even simplied and idealized simulations function poorly, it is a safe bet that the
algorithm is somehow awed. What is the aw in this case?
Recall that error surfaces are often a good way of picturing the behavior
of gradient-descent algorithms. Expanding the square and using the standard
identities (A.4) and (A.9), J(f0 ) can be rewritten
1
1
J(f0 ) = LPF 1 + cos(4fc t) cos(2(fc f0 )t)
2
2
1
+ cos(4f0 t) cos(2(fc + f0 )t)
2
1 1
(10.21)
= LPF{cos(2(fc f0 )t)},
2 2
7
218
0.5
J( f0 )
fc
Frequency estimate f0
assuming that the cuto frequency of the lowpass lter is less than fc and that
f0 fc . At the point where f0 = fc , J(f0 ) = 0. For any other value of f0 , however, as time progresses, the cosine term undulates up and down with an average
value of zero. Hence J(f0 ) averages to 12 for any f0 = fc ! This pathological situation is shown in Figure 10.17.
When f0 is far from fc , this analysis does not hold because the LPF no longer
removes the rst two cosine terms in (10.21). Somewhat paradoxically, the algorithm behaves well until the answer is nearly correct. Once f0 fc , the error
surface attens, and the estimates wander around. There is a slight possibility that it might accidently fall into the exact correct answer, but simulations
suggest that such luck is rare. Oh well, never mind.
10.6.2
Or two SD phase-tracking algorithms or two Costas loops, though in the latter case the
squaring preprocessing is unnecessary.
Carrier Recovery
rp(kTs)
e1[k]
LPF F1(z)
219
1[k]
sin(4f0kTs +21[k])
2
X
LPF F2(z)
e2[k]
2[k]
1[k] + 2[k]
Figure 10.18 A pair of PLLs can eciently estimate the frequency oset at the
receiver. The parameter 1 in the top loop converges to a slope that corrects the
frequency oset and the parameter 2 in the bottom loop corrects the residual phase
oset. The sum 1 + 2 is used to drive the sinusoid in the carrier-recovery scheme.
where b is the y-intercept of the ramp. The 1 values are then added to 2 , the
phase estimate in the lower PLL. The output of the bottom oscillator is
sin(4f0 t + 21 (t) + 22 (t)) = sin(4f0 t + 4(fc f0 )t + 2b + 22 (t))
sin(4fc t + 2b + 22 (t)).
Eectively, the top loop has synthesized a signal that has the correct frequency
for the bottom loop. Accordingly, 2 (t) b. Since a sinusoid with frequency
2f0 t and phase 1 (t) + 2 (t) is indistinguishable from a sinusoid with frequency 2fc t and phase 2 (t), these values can be used to generate a sinusoid
that is aligned with rp (t) in both frequency and phase. This signal can then be
used to demodulate the received signal.
Some Matlab code to implement this dual PLL scheme is provided by
dualplls.m.
Listing 10.8. dualplls.m estimation of carrier via dual-loop structure
Ts =1/10000; time =5; t =0: Ts : time Ts ; % time v e c t o r
f c =1000; p h o f f =2;
% c a r r i e r f r e q and phase
rp=cos (4 * pi * f c * t +2* p h o f f ) ;
% p r e p r o c e s s e d s i g n a l rBPF
mu1 = . 0 1 ; mu2 = . 0 0 3 ;
% algorithm s t e p s i z e s
f 0 =1001;
% assumed f r e q a t r e c e i v e r
l e n t=length ( t ) ; th1=zeros ( 1 , l e n t ) ; % i n i t i a l i z e e s t i m a t e s
th2=zeros ( 1 , l e n t ) ; c a r e s t =zeros ( 1 , l e n t ) ;
f o r k =1: l e n t 1
% combine top PLL th1
th1 ( k+1)= th1 ( k)mu1 * rp ( k ) * s i n (4 * pi * f 0 * t ( k)+2 * th1 ( k ) ) ;
th2 ( k+1)= th2 ( k)mu2 * rp ( k ) * s i n (4 * pi * f 0 * t ( k)+2 * th1 ( k)+2 * th2 ( k ) ) ;
% with bottom PLL th2 to form e s t i m a t e o f p r e p r o c e s s e d s i g n a l
c a r e s t ( k)=cos (4 * pi * f 0 * t ( k )+2 * th1 ( k)+2 * th2 ( k ) ) ;
end
The output of this program is shown in Figure 10.19. The upper graph shows
that 1 , the phase estimate of the top PLL, converges to a ramp. The middle plot
20
0
20
Figure 10.19 The output of
0.3
0.2
0.1
0
0.1
error
220
1
0
1
0
Time
shows that 2 , the phase estimate of the bottom PLL, converges to a constant.
Thus the procedure is working. The bottom graph shows the error between the
preprocessed signal rp and a synthesized carrier carest. The parameters f0,
th1, and th2 can then be used to synthesize a cosine wave that has the correct
frequency and phase to demodulate the received signal.
It is clear from the top plot of Figure 10.19 that 1 converges to a line. What
line does it converge to? Looking carefully at the data generated by dualplls.m,
the line can be calculated explicitly. The two points at (2, 11.36) and (4, 23.93)
t a line with slope m = 6.28 and an intercept b = 1.21. Thus,
2(fc f0 ) = 6.28,
or fc f0 = 1. Indeed, this was the value used in the simulation. Reading the
nal converged value of 2 from the simulation shown in the middle plot gives
0.0627. b 0.0627 is 1.147, which is almost exactly away from 2, the value
used in phoff.
Exercise 10.32. Use the preceding code to play with the frequency estimator.
a. How far can f0 be from fc before the estimates deteriorate?
b. What is the eect of the two stepsizes mu? Should one be larger than other?
If so, which one?
c. How does the method fare when the input is noisy?
d. What happens when the input is modulated by pulse-shaped data instead of
by a simple sinusoid?
Exercise 10.33. Build a frequency estimator using two SD phase-tracking algorithms, rather than two PLLs. How does the performance change? Which do you
think is preferable?
Carrier Recovery
221
Exercise 10.34. Build a frequency estimator that incorporates the preprocessing of the received signal from Figure 10.3 (as coded in pllpreprocess.m).
Exercise 10.35. Build a frequency estimator using two Costas loops, rather than
two PLLs. How does the performance change? Which do you think is preferable?
Exercise 10.36. Investigate (via simulation) how the PLL functions when there
is white noise (using randn) added to the received signal. Do the phase estimates
become worse as the noise increases? Make a plot of the standard deviation of
the noise versus the average value of the phase estimates (after convergence).
Make a plot of the standard deviation of the noise versus the jitter in the phase
estimates.
Exercise 10.37. Repeat Exercise 10.36 for the dual SD algorithm.
Exercise 10.38. Repeat Exercise 10.36 for the dual Costas-loop algorithm.
Exercise 10.39. Repeat Exercise 10.36 for the dual DD algorithm.
Exercise 10.40. Investigate (via simulation) how the PLL functions when
there is intersymbol interference caused by a nonunity channel. Pick a channel
(for instance chan=[1, .5, .3, .1];) and incorporate this into the simulation
of the received signal. Using this received signal, are the phase estimates worse
when the channel is present? Are they biased? Are they more noisy?
Exercise 10.41. Repeat Exercise 10.40 for the dual Costas loop.
Exercise 10.42. Repeat Exercise 10.40 for the Costas-loop algorithm.
Exercise 10.43. Repeat Exercise 10.40 for the DD algorithm.
10.6.3
Generalized PLL
Section 10.6.2 showed that two loops can be used in concert to accomplish the
carrier-recovery task: the rst loop estimates frequency oset and the second
loop estimates the phase oset. This section shows an alternative structure that
folds one of the loops into the lowpass lter in the form of an IIR lter and
accomplishes both estimations at once. This is shown in Figure 10.20, which
looks the same as Figure 10.7 but with the FIR lowpass lter F (z) replaced by
an IIR lowpass lter G(z) = GN (z)/GD (z).
To see the operation of the generalized PLL concretely, pllgeneral.m implements the system of Figure 10.20 with GN (z) = 2 2z and GD (z) = z
1. The implementation of the IIR lter follows the time-domain method in
waystofiltIIR.m on page 145. When the frequency oset is zero (when f0=fc),
222
rp(kTs)
G(z)
[k+1]
z1
[k]
sin(4f0kTs + 2[k])
2
Figure 10.20 The general PLL can track both phase and frequency osets using an IIR
LPF G(z). This gure is identical to Figure 10.7, except that the FIR lowpass lter is
replaced by a suitable IIR lowpass lter. Linearizing this structure gives Figure 10.22.
Appendix F presents conditions on G(z) under which the tracking occurs.
theta converges to phoff. When there is a frequency oset (as in the default
values with f0=fc+0.1), theta converges to a line. Essentially, this value converges to 1 + 2 in the dual-loop structure of Figure 10.19.
Listing 10.9. pllgeneral.m the PLL with an IIR LPF
Ts =1/10000; time =1; t=Ts : Ts : time ;
f c =1000; p h o f f = 0 . 8 ;
rp=cos (4 * pi * f c * t +2* p h o f f ) ;
mu= . 0 0 3 ;
a =[1 1 ] ; l e n a=length ( a ) 1;
b=[2 2mu ] ; l e n b=length ( b ) ;
xvec=zeros ( l e n a , 1 ) ;
e v e c=zeros ( l e n b , 1 ) ;
f0 =1000.0;
t h e t a=zeros ( 1 , length ( t ) ) ; t h e t a ( 1 ) = 0 ;
f o r k =1: length ( t )1
e=rp ( k ) * s i n (4 * pi * f 0 * t ( k)+2 * t h e t a ( k ) ) ;
e v e c =[ e ; e v e c ( 1 : l en b 1 ) ] ;
x=a ( 2 : l e n a +1) * xvec+b * e v e c ;
xvec =[x ; xvec ( 1 : l e n a 1 , 1 ) ] ;
t h e t a ( k+1)= t h e t a ( k)+mu* x ;
end
%
%
%
%
%
%
%
time v e c t o r
c a r r i e r f r e q and phase
s i m p l i f i e d r ec d s i g n a l
algorithm s t e p s i z e
a u t o r e g r e s s i v e terms
moving a v e r a g e terms
initialize filters
% f r e q at r e c e i v e r
% i n i t i a l i z e estimates
%
%
%
%
%
i n p u t to f i l t e r
past values of inputs
output o f f i l t e r
past values of outputs
a l g o r i t h m update
All of the PLL structures are nonlinear, which makes them hard to analyze
exactly. One way to study the behavior of a nonlinear system is to replace nonlinear components with nearby linear elements. A linearization is valid only for
a small range of values. For example, the nonlinear function sin(x) is approximately x for small values. This can be seen by looking at sin(x) near the origin:
it is approximately a line with slope unity. As x increases or decreases away from
the origin, the approximation worsens.
The nonlinear components in a loop structure such as Figure 10.7 are the
oscillators and the mixers. Consider a nonideal lowpass lter F (z) with impulse
response f [k] that has a cuto frequency below 2f0 . The output of the LPF is
e[k] = f [k] sin(2[k] 2[k]), where represents convolution. With
and , sin(2[k])
2[k].
Thus the linearization is
f [k] sin(2[k])
f [k] 2[k].
(10.22)
Carrier Recovery
223
224
2[k]
F1(z)
e1[k]
1[k + 1]
1[k]
z1
2
+
F2(z)
e2[k]
2[k +1]
2[k]
z1
21[k] + 22[k]
2
Figure 10.21 A linearization of the dual-loop frequency tracker of Figure 10.18. For
small osets, this linear structure closely represents the behavior of the system.
2[k]
e[k]
GN(z)
GD(z)
[k + 1]
z1
[k]
Figure 10.22 This is the
linearization of Figure
10.20.
2
A
+
B
C
Figure 10.23 The left-hand block diagram with overlapping loops can be redrawn as
Exercise 10.50. This exercise outlines the steps needed to show the conditions
under which the general PLL of Figure 10.20 and the dual-loop structure of
Figure 10.18 are the same (in the sense of having the same linearization).
a.
b.
c.
d.
, B=
, and C = 2.
A=
z 1 + 2
z1
Carrier Recovery
225
Using the block-diagram manipulation of part (c), show that Figures 10.21
and 10.22 are the same when GN (z) = (2z 2 + 2) and GD (z) = z 1.
When the message is digital, it must be converted into an analog signal in order
to be transmitted. This conversion is done by the transmit or pulse-shaping
lter, which changes each symbol in the digital message into a suitable analog
pulse. After transmission, the receive lter assists in recapturing the digital
values from the received pulses. This chapter focuses on the design and specication of these lters.
The symbols in the digital input sequence w(kT ) are chosen from a nite set
of values. For instance, they might be binary 1, or they may take values from
a larger set such as the four-level alphabet 1, 3. As suggested in Figure 11.1,
the sequence w(kT ) is indexed by the integer k, and the data rate is one symbol
every T seconds. Similarly, the output m(kT ) assumes values from the same
alphabet as w(kT ) and at the same rate. Thus the message is fully specied at
times kT for all integers k. But what happens between these times, between kT
and (k + 1)T ? The analog modulation of Chapter 5 operates continuously, and
some values must be used to ll in the digital input between the samples. This
is the job of the pulse-shaping lter: to turn a discrete-time sequence into an
analog signal.
Each symbol w(kT ) of the message initiates an analog pulse that is scaled by
the value of the signal. The pulse progresses through the communications system,
and, if all goes well, the output (after the decision) should be the same as the
input, although perhaps with some delay. If the analog pulse is wider than the
time between adjacent symbols, the outputs from adjacent symbols may overlap,
a problem called intersymbol interference, which is abbreviated ISI. A series of
examples in Section 11.2 shows how this happens, and the eye diagram is used
in Section 11.3 to help visualize the impact of ISI.
What kinds of pulses minimize the ISI? One possibility is to choose a shape
that is one at time kT and zero at mT for all m = k. Then the analog waveform at time kT contains only the value from the desired input symbol, and no
interference from other nearby input symbols. These are called Nyquist pulses in
p(t)
P( f )
Pulse
shaping
x(t)
hc(t)
Hc( f )
Channel
Interferers
Noise
n(t)
g(t)
Message
w(kT) {3, 1, 1, 3}
hR(t)
HR( f )
Receive
filter
227
y(t)
Decision
Reconstructed
message
m(kT) {3, 1, 1, 3}
Section 11.4. Yes, this is the same fellow who brought us the Nyquist sampling
theorem and the Nyquist frequency.
Besides choosing the pulse shape, it is also necessary to choose a receive lter
that helps decode the pulses. The received signal can be thought of as containing
two parts: one part is due to the transmitted signal and the other part is due to
the noise. The ratio of the powers of these two parts is a kind of signal-to-noise
ratio that can be maximized by choice of the pulse shape. This is discussed in
Section 11.5. The chapter concludes in Section 11.6 by considering pulse shaping
and receive lters that both provide a Nyquist pulse and maximize the signalto-noise ratio.
The transmit and receive lter designs rely on the assumption that all other
parts of the system are working well. For instance, the modulation and demodulation blocks have been removed from Figure 11.1, and the assumption is that
they are perfect: the receiver knows the correct frequency and phase of the carrier. Similarly, the downsampling block has been removed, and the assumption
is that this is implemented so that the decision device is a fully synchronized
sampler and quantizer. Chapter 12 examines methods of satisfying these synchronization needs, but, for now, they are assumed to be met. In addition, the
channel is assumed benign.
11.1
as it enters the pulse-shaping lter. The response of the lter, with impulse
response p(t), is the convolution
x(t) = wa (t) p(t),
Pulse shape
228
1
0.8
0.6
0.4
0.2
0
0
0.1
0.1
0.2
0.7
0.8
0.9
0.9
102
100
102
104
0.2
0.8
%
%
%
%
%
4 l e v e l s i g n a l o f l e n g t h N
oversampling f a c t o r
o v e r s a m p l e by M
b l i p p u l s e o f width M
c o n v o l v e p u l s e shape with data
The program pulsespec.m represents the continuous-time or analog signal by oversampling both the data sequence and the pulse shape by a factor of M. This technique was discussed in Section 6.3, where an analog sine
wave sine100hzsamp.m was represented digitally at two sampling intervals, a
slow symbol interval T = M Ts and a faster rate (shorter interval) Ts representing the underlying analog signal. The pulse shape ps is a blip created by the
hamming function, and this is also oversampled at the same rate. The convolution of the oversampled pulse shape and the oversampled data sequence is
accomplished by the filter command. Typical output is shown in the top plot
Output of pulse
shaping filter
3
2
1
0
1
2
3
229
10
15
Symbols
20
0.2
0.8
104
25
102
100
102
104
0
0.1
0.9
Figure 11.3 The top plot shows a segment of the output x of the pulse-shaping lter.
The bottom plot shows the magnitude spectrum of x, which has the same general
contour as the spectrum of a single copy of the pulse. Compare this with the bottom
plot of Figure 11.2.
of Figure 11.3, which shows the analog signal over a time interval of about 25
symbols. Observe that the individual pulse shapes are clearly visible, one scaled
blip for each symbol.
The spectrum of the output x is plotted at the bottom of Figure 11.3. As
expected from the previous discussion, the spectrum X(f ) has the same contour
as the spectrum of the individual pulse shape in Figure 11.2.
11.2
Intersymbol Interference
There are two situations in which adjacent symbols may interfere with each other:
when the pulse shape is wider than a single symbol interval T , and when there is
a nonunity channel that smears nearby pulses, causing them to overlap. Both
of these situations are called intersymbol interference (ISI). Only the rst kind of
ISI will be considered in this chapter; the second kind is postponed until Chapter
13. Before tackling the general setup, this section provides an instructive example
where the ISI is caused by an overly wide pulse shape.
1
0.8
0.6
0.4
0.2
0
0
230
0.5
1
1.5
2
(a) Sample periods
2.5
102
100
102
104
0
0.1
width of the spectrum of the transmitted signal is dictated by the width of the
spectrum of the pulse, this pulse shape is three times as parsimonious in its use
of bandwidth. More FDM users can be active at the same time.
As might be expected, this boon has a price. Figure 11.5 shows the output of
the pulse-shaping lter over a time of about 25 symbols. There is no longer a
clear separation of the pulse corresponding to one data point from the pulses of
its neighbors. The transmission is correspondingly harder to properly decode. If
the ISI caused by the overly wide pulse shape is too severe, symbol errors may
occur.
Thus, there is a trade-o. Wider pulse shapes can occupy less bandwidth,
which is always a good thing. On the other hand, a pulse shape like the Hamming
blip does not need to be very many times wider before it becomes impossible to
decipher the data because the ISI has become too severe. How much wider can it
be without causing symbol errors? The next section provides a way of picturing
ISI that answers this question. Subsequent sections discuss the practical issue of
how such ISI can be prevented by a better choice of pulse shape. Yes, there are
good pulse shapes that are wider than T .
Exercise 11.1. Modify pulsespec.m to reproduce Figures 11.4 and 11.5 for the
double-width pulse shape.
Exercise 11.2. Modify pulsespec.m to examine what happens when Hamming
pulse shapes of width 4T , 6T , and 10T are used. What is the bandwidth of the
resulting transmitted signals? Do you think it is possible to recover the message
from the received signals? Explain.
231
10
15
20
25
Symbols
104
102
100
102
0.1
0.2
0.8
0.9
Figure 11.5 The top plot shows a segment of the output x of the pulse-shaping lter.
With this 3T -wide pulse shape, the pulses from adjacent symbols interfere with each
other. The bottom plot shows the magnitude spectrum of the output, which has the
same general contour as the spectrum of a single copy of the pulse, as in the bottom
plot of Figure 11.4.
11.3
Eye Diagrams
While the dierences between the pulse-shaped sequences in Figures 11.3 and
11.5 are apparent, it is dicult to see directly whether the distortions are serious; that is, whether they cause errors in the reconstructed data (i.e., the hard
decisions) at the receiver. After all, if the reconstructed message is the same as
the real message, then no harm has been done, even if the values of the received
analog waveform are not identical. This section uses a visualization tool called
eye diagrams that show how much smearing there is in the system, and whether
symbol errors will occur. Eye diagrams were encountered briey in Chapter 9
(refer back to Figure 9.8) when visualizing how the performance of the idealized
system degraded when various impairments were added.
Imagine an oscilloscope that traces out the received signal, with the special
feature that it is set to retrigger or restart the trace every nT seconds without
erasing the screen. Thus the horizontal axis of an eye diagram is the time over
which n symbols arrive, and the vertical axis is the value of the received waveform. In the ideal case, the trace begins with n pulses, each of which is a scaled
copy of p(t). Then the (n + 1)st to 2nth pulses arrive, and overlay the rst n,
though each is scaled according to its symbol value. When there is noise, channel
distortion, and timing jitter, the overlays will dier.
232
1
0
1
2
3
Noise
margin
The "eye"
kT
(k + 1)T
233
2
0
4
Eye diagram for the 2T-wide Hamming pulse shape
2
0
0
2
4
Symbols
Symbols
Figure 11.7 Eye diagrams for T -, 2T -, 3T -, and 5T -wide Hamming pulse shapes show
how the sensitivity to noises and timing errors increases as the pulse shape widens.
The closed eye in the bottom plot on the right means that symbol errors are
inevitable.
wide and 5T -wide Hamming pulse shapes. Symbol errors will inevitably occur,
even if all else in the system is ideal. All of the measures (the noise margin, the
sensitivity to timing, and the distortion at zero crossings) become progressively
worse, and ever smaller amounts of noise can cause decision errors.
The following code draws eye diagrams for the pulse shapes dened by the
variable ps. As in the pulse-shaping programs of the previous section, the N
binary data points are oversampled by a factor of M and the convolution of
the pulse shapes with the data uses the filter command. The reshape(x,a,b)
command changes a vector x of size a*b into a matrix with a rows and b columns,
which is used to segment x into b overlays, each a samples long. This works
smoothly with the Matlab plot function.
Listing 11.2. eyediag.m plot eye diagrams for a pulse shape
N=1000; m=pam (N, 2 , 1 ) ;
M=20; mup=zeros ( 1 ,N*M) ;
mup ( 1 :M:N*M)=m;
ps=hamming (M) ;
x=f i l t e r ( ps , 1 , mup ) ;
neye =5;
c=f l o o r ( length ( x ) / ( neye *M) ) ;
xp=x (N*Mneye *M* c +1:N*M) ;
plot ( reshape ( xp , neye *M, c ) )
%
%
%
%
%
%
%
%
%
random s i g n a l o f l e n g t h N
oversampling f a c t o r of M
o v e r s a m p l e by M
hamming p u l s e o f width M
c o n v o l v e p u l s e shape
s i z e of groups
number o f e y e s to p l o t
i gnor e t r a n s i e n t s at s t a r t
p l o t i n groups
234
1
Eye diagram for sinc pulse shape
2
0
2
samples are taken far from the center of the eye. Of the three, the sinc pulse is the
most sensitive, since it must be sampled near the correct instants or erroneous
values will result.
Exercise 11.3. Modify eyediag.m so that the data sequence is drawn from the
alphabet 1, 3, 5. Draw the appropriate eye diagram for the rectangular,
Hamming, and sinc pulse shapes.
Exercise 11.4. Modify eyediag.m to add noise to the pulse-shaped signal x. Use
the Matlab command v*randn for dierent values of v. Draw the appropriate
eye diagrams. For each pulse shape, how large can v be and still have the eye
remain open?
Exercise 11.5. Combine the previous two exercises. Modify eyediag.m as in
Exercise 11.3 so that the data sequence is drawn from the alphabet 1, 3, 5.
Add noise, and answer the same question as in Exercise 11.4. Which alphabet is
more susceptible to noise?
Exercise 11.6. TRUE or FALSE: For two rectangular impulse responses with
the same maximum magnitude but dierent time widths with T1 > T2 , the halfpower bandwidth of the frequency response of the pulse with width T1 exceeds
that of the pulse with width T2 .
m[k] pulseshape
filter
channel
receive
filter
u[k]
y[k]
equalizer
kT+
235
Exercise 11.7. TRUE or FALSE: For the PAM baseband signals created by
a rectangular pulse and a triangular pulse with the same time width and the
same maximum amplitude, the half-power bandwidth of the sequence using the
triangular pulse exceeds that of the rectangular pulse.
Exercise 11.8. Exercise 2.10 asked the following question: TRUE or FALSE:
The atter the top of the pulse shape, the less sensitive the receiver is to small
timing osets. In the absence of noise and without matched ltering, this is
TRUE. Describe a noisy situation and a matched ltering that might cause the
answer to be FALSE.
Exercise 11.9. Consider the baseband communication system in Figure 11.9.
The dierence equation relating the symbols m[k] to the T -spaced equalizer input
u[k] for the chosen baud-timing factor is
u[k] = 0.04m[k ] + 1.00m[k 1 ] + 0.60m[k 2 ] + 0.38m[k 3 ],
where is a nonnegative integer. The nite-impulse-response equalizer (lter) is
described by the dierence equation
y[k] = u[k] + u[k 1].
a. Suppose = 0.4 and the message source is binary 1. Is the system from
the source symbols m[k] to the equalizer output y[k] open-eye? Justify your
answer.
b. If the message source is 4-PAM (1, 3), can the system from m[k] to the
equalizer output y[k] be made open-eye by selection of ? If so, provide a
successful value of . If not, explain.
It is now easy to experiment with various pulse shapes. pulseshape2.m applies
a sinc-shaped pulse to a random binary sequence. Since the sinc pulse extends
innitely in time (both backward and forward), it cannot be represented exactly
in the computer (or in a real communication system) and the parameter L species the duration of the sinc, in terms of the number of symbol periods.
Listing 11.3. pulseshape2.m pulse shape a (random) sequence
N=2000; m=pam (N, 2 , 1 ) ;
M=10; mup=zeros ( 1 ,N*M) ;
mup ( 1 :M:N*M)=m;
L=10; ps=s r r c ( L , 0 ,M) ;
s c=sum( ps )/M;
x=f i l t e r ( ps / sc , 1 , mup ) ;
%
%
%
%
%
%
2PAM s i g n a l o f l e n g t h N
oversampling f a c t o r
o v e r s a m p l e by M
s i n c p u l s e shape 2 * L symbols wide
normalizing constant
c o n v o l v e p u l s e shape with data
236
0.4
0.3
0.2
0.1
0.1
10 8
2 0
2
4
Symbol interval
10
8 10 12 14
Symbol number
16
18
20
Figure 11.10 A binary 1 data sequence is pulse shaped using a sinc pulse.
Figure 11.10 plots the output of pulseshape2.m. The left gure shows the
pulse shape while the right plot shows the analog pulse-shaped signal x(t)
over a duration of about 25 symbols. The function srrc.m rst appeared in the
discussion of interpolation in Section 6.4 (and again in Exercise 6.22), and is used
here to generate the sinc pulse shape. The sinc function that srrc.m produces
is actually scaled, and this eect is removed by normalizing with the variable
sc. Changing the second input argument from beta=0 to other small positive
numbers changes the shape of the curve, each with a sinc-like shape called a
square-root raised cosine. This will be discussed in greater detail in Sections 11.4
and 11.6. Typing help srrc in Matlab gives useful information on using the
function.
Observe that, even though the signal oscillates above and below the 1 lines,
there is no intersymbol interference. When using the Hamming pulse as in Figure 11.3, each binary value was clearly delineated. With the sinc pulse of Figure
11.10, the analog waveform is more complicated. However, at the correct sampling instances, it always returns to 1 (the horizontal lines at 1 are drawn to
help focus the eye on the crossing times). Unlike the T -wide Hamming shape,
the signal need not return to near zero with each symbol.
Exercise 11.10. In pulseshape2.m, examine the eect of using dierent oversampling rates M. Try M = 1, 5, 100.
Exercise 11.11. Change pulseshape2.m so that the data sequence is drawn
from the alphabet 1, 3, 5. Can you visually identify the correct values in the
pulse-shaped signal?
Exercise 11.12. In pulseshape2.m, examine the eect of using sinc approximations of dierent lengths L. Try L = 1, 5, 100, 1000.
Exercise 11.13. In pulseshape2.m, examine the eect of adding noise to the
received signal x. Try Matlab commands randn and rand. How large can the
noise be and still allow the data to be recognizable?
237
11.4
Nyquist Pulses
Consider a multilevel signal drawn from a nite alphabet with values w(kT ),
where T is the sampling interval. Let p(t) be the impulse response of the linear
lter representing the pulse shape. The signal just after pulse shaping is
x(t) = wa (t) p(t),
where wa (t) is the pulse-train signal (11.1).
The corresponding output of the received lter is
y(t) = wa (t) p(t) hc (t) hR (t),
as depicted in Figure 11.1, where hc (t) is the impulse response of the channel and
hR (t) is the impulse response of the receive lter. Let hequiv (t) = p(t) hc (t)
hR (t) be the overall equivalent impulse response. Then the equivalent overall
frequency response (i.e., F {hequiv (t)}) is
Hequiv (f ) = P (f )Hc (f )HR (f ).
(11.2)
238
the impulse response hequiv (t) at all t, since the Fourier transform is invertible.
But such a distortionless response is unnecessary, since it does not really matter
what happens between samples, but only what happens at the sample instants. In
other words, as long as the eye is open, the transmitted symbols are recoverable
by sampling at the correct times. In general, if the pulse shape is zero at all
integer multiples of kT but one, then it can have any shape in between without
causing intersymbol interference.
The condition that one pulse does not interfere with other pulses at subsequent
T -spaced sample instants is formalized by saying that hN Y Q (t) is a Nyquist pulse
if there is a such that
c k=0
(11.3)
hN Y Q (kT + ) =
0 k = 0
for all integers k, where c is some nonzero constant. The timing oset in (11.3)
will need to be found by the receiver.
A rectangular pulse with time-width less than T certainly satises (11.3), as
does any pulse shape that is less than T wide. But the bandwidth of the rectangular pulse (and other narrow pulse shapes such as the Hamming pulse shape)
may be too wide. Narrow pulse shapes do not utilize the spectrum eciently. But
if just any wide shape is used (such as the multiple-T -wide Hamming pulses),
then the eye may close. What is needed is a signal that is wide in time (and
narrow in frequency) that also fullls the Nyquist condition (11.3).
One possibility is the sinc pulse
hsinc (t) =
sin(f0 t)
,
f0 t
with f0 = 1/T . This has the narrowest possible spectrum, since it forms a rectangle in frequency (i.e., the frequency response of a lowpass lter). Assuming
that the clocks at the transmitter and receiver are synchronized so that = 0,
the sinc pulse is Nyquist because hsinc (0) = 1 and
sin(k)
=0
k
for all integers k =
0. But there are several problems with the sinc pulse.
hsinc (kT ) =
r It has innite duration. In any real implementation, the pulse must be truncated.
r The steep band edges of the rectangular frequency function Hsinc (f ) are difcult to approximate.
239
Fortunately, it is not necessary to choose between a pulse shape that is constrained to lie within a single symbol period T and the slowly decaying sinc.
While the sinc has the smallest dispersion in frequency, there are other pulse
shapes that are narrower in time and yet are only a little wider in frequency.
Trading o time and frequency behaviors can be tricky. Desirable pulse shapes
1. have appropriate zero crossings (i.e., they are Nyquist pulses),
2. have sloped band edges in the frequency domain, and
3. decay more rapidly in the time domain (compared with the sinc), while maintaining a narrow prole in the frequency domain.
One popular option is called the raised cosine-rollo (or raised cosine) lter.
It is dened by its Fourier transform
|f | < f1
1
HRC (f ) = 12 + 12 cos ((|f | f1 )/(2f )) f1 < |f | < B
0
|f | > B
where
r
r
r
r
(11.4)
Dene the rollo factor = f /f0 . Figure 11.11 shows the magnitude spectrum
HRC (f ) of the raised cosine lter on the right and the associated time response
hRC (t) on the left, for a variety of rollo factors. With T = 1/(2f0), hRC (kT ) has
a factor sin(k)/(k) that is zero for all integer k = 0. Hence the raised cosine
is a Nyquist pulse. In fact, as 0, hRC (t) becomes a sinc.
The raised cosine pulse hRC (t) with nonzero has the following characteristics:
240
1
=0
=1
0.5
= 0.5
=0
=1
0
= 0.5
0.5
3T
2T
2T
3T
f0/2
f0
Time
3f0/2
2f0
Frequency
Figure 11.11 Raised cosine pulse shape in the time and frequency domains.
V (f nf0 ) = V (f )
(f nf0 ) .
n=
n=
(t kT )} =
k=
V (f nf0 ) =
&
v(t) T
t=
n=
1
(f nf0 ),
T n=
'%
(t kT )
ej2f t dt
k=
T v(kT )ej2f kT .
(11.5)
k=
If v(t) is a Nyquist pulse, the only nonzero term in the sum is v(0), and
V (f nf0 ) = T v(0).
n=
Thus, the sum of the V (f nf0 ) is a constant if v(t) is a Nyquist pulse. Conversely, if the sum of the V (f nf0 ) is a constant, then only the DC term in
(11.5) can be nonzero, and so v(t) is a Nyquist pulse.
Exercise 11.19. Write a Matlab routine that implements the raised cosine
impulse response (11.4) with rollo parameter . Hint 1: if you have trouble
with divide by zero errors, imitate the code in srrc.m. Plot the output of
your program for a variety of . Hint 2: there is an easy way to use the function
srrc.m.
241
p(t)
3
1.5
0.2
0.6
1.0
11.23.
t (ms)
1.5
3
Exercise 11.20. Use your code from the previous exercise, along with
pulseshape2.m to apply raised cosine pulse shaping to a random binary
sequence. Can you spot the appropriate times to sample by eye?
Exercise 11.21. Use the code from the previous exercise and eyediag.m to draw
eye diagrams for the raised cosine pulse with rollo parameters r = 0, 0.5, 0.9,
1.0, 5.0. Compare these with the eye diagrams for rectangular and sinc functions.
Consider
a.
b.
c.
d.
242
parlay this discussion of isolated pulse shapes into usable designs for the pulse
shaping and receive lters.
11.5
Matched Filtering
Communication systems must be robust against the presence of noises and other
disturbances that arise in the channel and in the various stages of processing.
Matched ltering is aimed at reducing the sensitivity to noise, which can be
specied in terms of the power spectral density (this is reviewed in some detail
in Appendix E).
Consider the ltering problem in which a message signal is added to a noise
signal and then both are passed through a linear lter. This occurs, for instance,
when the signal g(t) of Figure 11.1 is the output of the pulse-shaping lter
(i.e., no interferers are present), the channel is the identity, and there is noise
n(t) present. Assume that the noise is white; that is, assume that its power
spectral density Pn (f ) is equal to some constant for all frequencies.
The output y(t) of the linear lter with impulse response hR (t) can be
described as the superposition of two components, one driven by g(t) and the
other by n(t); that is,
y(t) = v(t) + w(t),
where
v(t) = hR (t) g(t) and w(t) = hR (t) n(t).
This is shown in block-diagram form in Figure 11.13. In both components, the
processing and the output signal are the same. The bottom diagram separates
out the component due to the signal (v(kT ), which contains the message ltered
through the pulse shape and the receive lter), and the component due to the
noise (w(kT ), which is the noise ltered through the receive lter). The goal of
this section is to nd the receive lter that maximizes the ratio of the power in
the signal v(kT ) to the power in the noise w(kT ) at the sample instants.
Consider choosing hR (t) so as to maximize the power of the signal v(t) at
time t = compared with the power in w(t) (i.e., to maximize v2 ( ) relative
to the total power of the noise component w(t)). This choice of hR (t) tends to
emphasize the signal v(t) and suppress the noise w(t). The argument proceeds
by nding the transfer function HR (f ) that corresponds to this hR (t).
From (E.2), the total power in w(t) is
Pw (f )df.
Pw =
243
n(t)
m(kT)
g(t)
P( f )
y(t)
Pulse
shaping
Receive
filter
n(t)
HR( f )
Downsample
w(t)
Receive
filter
m(kT)
y(kT)
HR( f )
w(kT)
Downsample
v(t)
g(t)
P( f )
HR( f )
Pulse
shaping
Receive
filter
v(kT)
y(kT)
Downsample
Figure 11.13 The two block diagrams result in the same output. The top shows the
(11.6)
|b(x)| dx ,
2
and equality occurs only when a(x) = kb (x). This converts (11.6) to
(
2
j2f 2
| df
v 2 ( )
|HR (f )| df
|G(f )e
(
,
Pw
|HR (f )|2 df
which is maximized with equality when
HR (f ) = k(G(f )ej2f ) .
(11.7)
244
r Because the impulse response of this lter is a scaled time reversal of the
r
r
r
pulse shape p(t), it is said to be matched to the pulse shape, and is called
a matched lter.
The shape of the magnitude spectrum of the matched lter HR (f ) is the same
as the magnitude spectrum G(f ).
The shape of the magnitude spectrum of G(f ) is the same as the shape of
the frequency response of the pulse shape P (f ) for a broadband m(kT ), as in
Section 11.1.
The matched lter for any lter with an even symmetric (about some t) timelimited impulse response is a delayed replica of that lter. The minimum delay
is the upper limit of the time-limited range of the impulse response.
%
%
%
%
2PAM s i g n a l o f l e n g t h N
oversampling f a c t o r
o v e r s a m p l e by M
d e f i n e p u l s e shape
%
%
%
%
%
%
%
%
%
%
%
%
245
and n o r m a l i z e
noise
c o n v o l v e ps with data
r e c e i v e f i l t e r H sub R
n o r m a l i z e p u l s e shape
matched f i l t e r with data
matched f i l t e r with n o i s e
downsample to symbol r a t e
downsample to symbol r a t e
power i n downsampled v
power i n downsampled w
ratio
of the matched lter with the impulse response h(t). Given the pulse shape p(t)
and the assumption that the noise has at power spectral density, it follows that
p( t) 0 t T,
h(t) =
0
otherwise,
where is the delay used in the matched lter. Because h(t) is zero when t is
negative and when t > T , h( ) is zero for > and < T . Accordingly,
the limits on the integration can be converted to
s()p( ( ))d =
s()p()d.
x() =
=T
=T
2
j2f 2
| /Pn (f )df
v 2 ( )
|H(f )| Pn (f )df
|G(f )e
(
,
2
Pw
|H(f )| Pn (f )df
and equality occurs when a() = kb (); that is,
H(f ) =
kG (f )ej2f
.
Pn (f )
When the noise power spectral density Pn (f ) is not at, it shapes the matched
lter. Recall that the power spectral density of the noise can be computed from
its autocorrelation, as is shown in Appendix E.
246
w[k]
Figure 11.14 Baseband
m[k]
Transmit
filter
f [k]
Receive
filter
g[k]
y[k]
s[i]
k = iN +
communication system
considered in Exercise
11.29.
Exercise 11.25. Let the pulse shape be a T -wide Hamming blip. Use the code
in matchfilt.m to nd the ratio of the power in the downsampled v to that in
the downsampled w when
a. the receive lter is an SRRC with beta = 0, 0.1, 0.5,
b. the receive lter is a rectangular pulse, and
c. the receive lter is a 3T -wide Hamming pulse.
When is the ratio largest?
Exercise 11.26. Let the pulse shape be an SRRC with beta = 0.25. Use the
code in matchfilt.m to nd the ratio of the power in the downsampled v to that
in the downsampled w when
a. the receive lter is an SRRC with beta = 0, 0.1, 0.25, 0.5,
b. the receive lter is a rectangular pulse, and
c. the receive lter is a T -wide Hamming pulse.
When is the ratio largest?
Exercise 11.27. Let the symbol alphabet be 4-PAM.
a. Repeat Exercise 11.25.
b. Repeat Exercise 11.26.
Exercise 11.28. Create a noise sequence that is uniformly distributed (using
rand) with zero mean.
a. Repeat Exercise 11.25.
b. Repeat Exercise 11.26.
Exercise 11.29. Consider the baseband communication system in Figure 11.14.
The symbol period T is an integer multiple of the sample period T s , i.e., T = N Ts .
The message sequence is nonzero only each N th k, i.e., k = N Ts + Ts , where the
integer is within the range 0 < N and Ts is the on-sample baud-timing
oset at the transmitter.
a. Suppose that f [k] = {0.2, 0, 0, 1.0, 1.0, 0, 0, 0.2} for k = 0, 1, 2, 3, 4, 5, 6, 7 and
zero otherwise. Determine the causal g[k] that is the matched lter to f [k].
Arrange g[k] so that the nal nonzero element is as small as possible.
247
b. For the g[k] specied in part (a), determine the smallest possible N so the path
from m[k] to y[k] forms an impulse response that would qualify as a Nyquist
pulse for some well-chosen baud-timing oset when y is downsampled by
N.
c. For the g[k] chosen in part (a) and the N chosen in part (b), determine the
downsampler oset for s[i] to be the nonzero entries of m[k] when w[k] = 0
for all k.
11.6
Signal
Pulse
shape
Receive
filter
communication system.
248
pulse shapes, the rectangle, the sinc, and the raised cosine. When convolved with
themselves, do any of these shapes remain Nyquist?
For a rectangle pulse shape and its rectangular matched lter, the convolution
is a triangle that is twice as wide as the original pulse shape. With precise timing,
(so that the sample occurs at the peak in the middle), this triangular pulse shape
is also a Nyquist pulse. This exact situation will be considered in detail in Section
12.2.
The convolution of a sinc function with itself is more easily viewed in the frequency domain as the point-by-point square of the transform. Since the transform
of the sinc is a rectangle, its square is a rectangle as well. The inverse transform
is consequently still a sinc, and is therefore a Nyquist pulse.
The raised cosine pulse fails. Its square in the frequency domain does not
retain the odd symmetry around the band edges, and the convolution of the
raised cosine with itself does not retain its original zero crossings. But the raised
cosine was the preferred Nyquist pulse because it conserves bandwidth eectively
and because its impulse response dies away quickly. One possibility is to dene
a new pulse shape that is the square root of the raised cosine (the square root is
taken in the frequency domain, not the time domain). This is called the squareroot raised cosine lter (SRRC). By denition, the square in frequency of the
SRRC (which is the raised cosine) is a Nyquist pulse.
The time-domain description of the SRRC pulse is found by taking the inverse
Fourier transform of the square root of the spectrum of the raised cosine pulse.
The answer is a bit complicated:
t=0
(1 + 4/)/ T
(+2)
sin 4
cos 4
+ (2)
t = 4
(11.8)
v(t) =
2T
2T
)+(4t/T ) cos((1+)t/T )
sin((1)t/T
otherwise.
T (t/T )(1(4t/T )2 )
Exercise 11.30. Plot the SRRC pulse in the time domain and show that it is
not a Nyquist pulse (because it does not cross zero at the desired times). The
Matlab routine srrc.m will make this easier.
Though the SRRC is not itself a Nyquist pulse, the convolution in time of two
SRRCs is a Nyquist pulse. The square-root raised cosine is the most commonly
used pulse in bandwidth-constrained communication systems.
Exercise 11.31. Consider the baseband communication system with a symbolscaled impulse train input
s(t) =
si (t iT )
i=
where T is the symbol period in seconds and 0 < < 0.25 ms. The system contains a pulse-shaping lter P (f ), a channel transfer function C(f ) with additive
249
x(t)
n(t)
1
s(t)
1
t (ms)
P( f )
C( f )
y[k]
y(t)
V( f )
kT +
Figure 11.16 The system of Exercise 11.31 and the time signal x(t) corresponding to
the inverse Fourier transform of X(f ).
noise n(t), and a receive lter V (f ), as shown in Figure 11.16. In addition, consider the time signal x(t) shown in the left part of Figure 11.16, where each of
the arcs is a half-circle. Let X(f ) be the Fourier transform of x(t).
a. If the inverse of P (f )C(f )V (f ) is X(f ), what is the highest symbol frequency
with no intersymbol interference supported by this communication system
when = 0?
b. If the inverse of P (f )C(f )V (f ) is X(f ), select a sampler time oset T /2 >
> T /2 to achieve the highest symbol frequency with no intersymbol interference. What is this symbol rate?
c. Consider designing the receive lter under the assumption that a symbol
period T can be (and will be) chosen so that samples yk of the receive lter
output suer no intersymbol interference. If the inverse of P (f )C(f ) is X(f ),
and the power spectral density of n(t) is a constant, plot the impulse response
of the causal, minimum-delay, matched receive lter for V (f ).
12 Timing Recovery
When the signal arrives at the receiver, it is a complicated analog waveform that
must be sampled in order to eventually recover the transmitted message. The
timing-oset experiments of Section 9.4.5 showed that one kind of stu that
can happen to the received signal is that the samples might inadvertently be
taken at inopportune moments. When this happens, the eye becomes closed
and the symbols are incorrectly decoded. Thus there needs to be a way to determine when to take the samples at the receiver. In accordance with the basic
system architecture of Chapter 2, this chapter focuses on baseband methods
of timing recovery (also called clock recovery). The problem is approached in
a familiar way: nd performance functions that have their maximum (or minimum) at the optimal point (i.e., at the correct sampling instants when the eye
is open widest). These performance functions are then used to dene adaptive
elements that iteratively estimate the sampling times. As usual, all other aspects
of the system are presumed to operate awlessly: the up and down conversions
are ideal, there are no interferers, and the channel is benign.
The discussion of timing recovery begins in Section 12.1 by showing how a
sampled version of the received signal x[k] can be written as a function of the
timing parameter , which dictates when to take samples. Section 12.2 gives
several examples that motivate several dierent possible performance functions,
(functions of x[k]), which lead to dierent methods of timing recovery. The
error between the received data values and the transmitted data (called the
source recovery error) is an obvious candidate, but it can be measured only
when the transmitted data are known or when there is an a priori known or
agreed-upon header (or training sequence). An alternative is to use the cluster
variance, which takes the square of the dierence between the received data
values and the nearest element of the source alphabet. This is analogous to
the decision-directed approach to carrier recovery (from Section 10.5), and an
adaptive element based on the cluster variance is derived and studied in Section
12.3. A popular alternative is to measure the power of the T -spaced output of
the matched lter. Maximizing this power (by choice of ) also leads to a good
Timing Recovery
251
12.1
i=
(12.1)
as shown in Figure 12.1, and sampling at interval T /M (M is again the oversampling factor) yields the sampled output at time kT /M + :
kT
s[i]h(t iT ) + w(t) gR (t)
.
+ =
x
M
i=
t=kT /M+
Assuming that the noise has the same distribution no matter when it is sampled, the noise term v[k] = w(t) gR (t)|t=kT /M+ is independent of . Thus, the
goal of the optimization is to nd so as to maximize or minimize some simple
function of the samples, such as
kT
kT
+ =
+ iT + v[k].
(12.2)
s[i]h
x[k] = x
M
M
i=
252
h(t) = gR(t)*c(t)*gT(t)
Figure 12.1 The transfer
gT(t)
gR(t)
c(t)
s[i] Transmit
filter
Channel
Sampler
x(kT/M + )
Receive x(t)
filter
w(t)
Sampler
(a)
ASP
DSP
Sampler
(b)
ASP
DSP
Sampler
(c)
ASP
DSP
Figure 12.2 Three generic structures for timing recovery. In (a), an analog processor
determines when the sampling instants will occur. In (b), a digital post-processor is
used to determine when to sample. In (c), the sampling instants are chosen by a
free-running clock, and digital post-processing is used to recover the values of the
received signal that would have occurred at the optimal sampling instants.
12.2
An Example
This section works out in complete and gory detail what may be the simplest
case of timing recovery. More realistic situations will be considered (by numerical
methods) in later sections.
Timing Recovery
1.0
h(t)
0 0
T T + 0
253
2T
Time t
t=kT +
To keep the computations tractable, suppose that h(t) has the triangular shape
shown in Figure 12.3. This might occur, for instance, if the pulse-shaping lter
and the receive lter are both rectangular pulses of width T and the channel is
the identity.
There are three cases to consider: = 0, > 0, and < 0.
r With = 0 > 0, the only two nonzero points among the sampled impulse
response are at h(0 ) and h(T + 0 ), as illustrated in Figure 12.3. Therefore,
1 0 /T k i = 1,
h(t iT )|t=kT +0 = h((k i)T + 0 ) = 0 /T
k i = 0,
0
otherwise.
254
0
0
+ s[5] 1
.
T
T
Since the data are binary, there are four possibilities for the pair (s[5], s[6]):
(s[5], s[6]) = (+1, +1) x[6] = 0 /T + 1 0 /T = 1,
(s[5], s[6]) = (+1, 1) x[6] = 0 /T + 1 0 /T = 1 20 /T,
(s[5], s[6]) = (1, +1) x[6] = 0 /T 1 + 0 /T = 1 + 20 /T,
(s[5], s[6]) = (1, 1) x[6] = 0 /T 1 + 0 /T = 1.
(12.3)
Note that two of the possibilities for x[6] give correct values for s[5], while
two are incorrect.
With = 0 < 0, the only two nonzero points among the sampled impulse
response are at h(2T + 0 ) and h(T + 0 ). In this case,
1 |0 |/T k i = 1,
h(t iT )|t=kT +0 = |0 |/T
k i = 2,
0
otherwise.
The next two examples look at two possible measures of the quality of : the
cluster variance and the output power.
Example 12.1. The decision device Q(x[k]) quantizes its argument to the nearest
member of the symbol alphabet. For binary data, this is the signum operator that
maps any positive number to +1 and any negative number to 1. If T /2 < 0 <
T /2, then Q(x[k]) = s[k 1] for all k, the eye is open, and the source recovery
error can be written as e[k] = s[k 1] x[k] = Q(x[k]) x[k]. Continuing the
example, and assuming that all symbol-pair choices are equally likely, the average
squared error at time k = 6 is
#
2
2
2|
2|
1
|
|
0
0
(1 1)2 + 1 1
+ 1 1 +
+ (1 (1))2 ,
4
T
T
which simplies to avg{e2 [6]} = 202 /T 2 . The same result occurs for any other
k.
If 0 is outside the range of (T /2, T /2) then Q(x[k]) no longer equals s[k 1]
(but it does equal s[j] for some j = k 1). The cluster variance
CV = avg{e2 [k]} = avg{(Q(x[k]) x[k])2 }
(12.4)
Timing Recovery
255
avg{(Q(x) x)2}
0.5
3T/2
T/2
T/2
3T/2
Timing offset
avg{x2}
1.0
Figure 12.5 Average squared
output as a function of timing
oset .
0.5
3T/2
T/2
T/2
3T/2
Timing offset
Example 12.2. Another measure of the quality of the timing parameter is given
by the power (average energy) of the x[k]. Using the four formulas (12.3), and
observing that analogous formulas also apply when 0 < 0, the average energy
can be calculated for any k by
avg{x2 [k]} = (1/4)[(1)2 + (1 (2| |/T ))2 + (1 + (2| |/T ))2 + (1)2 ]
= (1/4)[2 + 2(1 (2| |/T ))2 ] = 1 (2| |/T ) + (2| |2 /T 2),
assuming that the four symbol pairs are equally likely. The average of x2 [k] is
plotted in Figure 12.5 as a function of . Over T /2 < < T /2, this average is
maximized with = 0. Thus, the problem of timing recovery can also be viewed
as a one-dimensional search for the that maximizes avg{x2 [k]}.
Thus, at least in the simple case of binary transmission with h(t) a triangular
pulse, the optimal timing oset (for the plots in Figures 12.4 and 12.5, at = nT
for integer n) can be obtained either by minimizing the cluster variance or by
maximizing the output power. In more general situations, the two measures
might not be optimized at the same point. Which approach is best when
r
r
r
r
The next two sections show how to design adaptive elements that carry out
these minimizations and maximizations. The error surfaces corresponding to
256
the performance functions will be used to gain insight into the behavior of the
methods even in nonideal situations.
12.3
(12.5)
Solving for directly is nontrivial, but JCV ( ) can be used as the basis for an
adaptive element
dJCV ( )
.
(12.6)
[k + 1] = [k]
d
= [k]
Using the approximation (G.12), which swaps the order of the derivative and the
average, yields
#
dJCV ( )
d (Q(x[k]) x[k])2
avg
d
d
dx[k]
= 2 avg (Q(x[k]) x[k])
.
(12.7)
d
The derivative of x[k] can be approximated numerically. One way of doing this
is to use
dx(kT /M + )
x(kT /M + + ) x(kT /M + )
dx[k]
=
,
(12.8)
d
d
2
which is valid for small . Substituting (12.8) and (12.7) into (12.6) and evaluating at = [k] gives the algorithm
[k + 1] = [k] + avg {(Q(x[k]) x[k])
[x (kT /M + [k] + ) x (kT /M + [k] )]} ,
Timing Recovery
Sampler
x(t)
x[k]
x(kT/M + [k])
Resample
257
Q( )
+
Resample
Resample
x(kT/M + [k] + )
x(kT/M + [k] )
+
[k]
Figure 12.6 One implementation of the adaptive element (12.9) uses three digital
interpolations (resamplers). After the [k] converge, the output x[k] is a sampled
version of the input x(t), with the samples taken at times that minimize the cluster
variance.
(12.9)
If the [k] are too noisy, the stepsize can be decreased (or the length of the
average, if present, can be increased), although these will inevitably slow the
convergence of the algorithm.
The algorithm (12.9) is easy to implement, though it requires samples of the
waveform x(t) at three dierent points: x(kT /M + [k] ), x(kT /M + [k]),
and x(kT /M + [k] + ). One possibility is to straightforwardly sample three
times. Since sampling is done by hardware, this is a hardware-intensive solution. Alternatively, the values can be interpolated. Recall from the sampling
theorem that a waveform can be reconstructed exactly at any point, as long as
it is sampled faster than twice the highest frequency. This is useful since the
values at x(kT /M + [k] ) and at x(kT /M + [k] + ) can be interpolated
from the nearby samples x[k]. Recall that interpolation was discussed in Section 6.4, and the Matlab routine interpsinc.m on page 112 makes it easy to
implement bandlimited interpolation and reconstruction. Of course, this requires
extra calculations, so it is a more software-intensive solution. This strategy is
diagrammed in Figure 12.6.
The following code prepares the transmitted signal that will be used subsequently to simulate the timing-recovery methods. The user species the signal
constellation (the default is 4-PAM), the number of data points n, and the oversampling factor m. The channel is allowed to be nonunity, and a square-root raised
cosine pulse with width 2*l+1 and rollo beta is used as the default transmit
(pulse-shaping) lter. An initial timing oset is specied in toffset, and the
258
code implements this delay with an oset in the srrc.m function. The matched
lter is implemented using the same SRRC (but without the time delay). Thus,
the timing oset is not known at the receiver.
Listing 12.1. clockrecDD.m (part 1) prepare transmitted signal
n =10000;
m=2;
beta = 0 . 3 ;
l =50;
chan = [ 1 ] ;
t o f f s e t = 0.3;
p u l s h a p=s r r c ( l , beta ,m, t o f f s e t ) ;
s=pam ( n , 4 , 5 ) ;
sup=zeros ( 1 , n *m) ;
sup ( 1 :m: n *m)= s ;
hh=conv ( pulshap , chan ) ;
r=conv ( hh , sup ) ;
m a t c h f i l t=s r r c ( l , beta ,m, 0 ) ;
x=conv ( r , m a t c h f i l t ) ;
%
%
%
%
%
%
%
%
%
%
%
%
%
%
number o f data p o i n t s
oversampling f a c t o r
r o l l o f f p a r a m eter f o r s r r c
1/2 l e n g t h o f p u l s e shape
T/m ch a n n e l
i n i t i a l timing o f f s e t
p u l s e shape with o f f s e t
random data s e q u e n c e v a r=5
upsample th e data , p l a c i n g . . .
m1 z e r o s between data p o i n t s
and p u l s e shape
to g e t r e c e i v e d s i g n a l
matched f i l t e r =s r r c
c o n v o l v e with matched f i l t e r
Typical output of the program is plotted in Figure 12.7, which shows the 4PAM constellation diagram, along with the trajectory of the oset estimation as
it converges towards the negative of the unknown value 0.3. Observe that,
initially, the values are widely dispersed about the required 4-PAM values, but,
as the algorithm nears its convergent point, the estimated values of the symbols
converge nicely.
Timing Recovery
259
Offset estimates
Symbol estimates
Constellation history
4
2
0
2
4
1000
2000
3000
4000
5000
1000
2000
3000
Iterations
4000
5000
0.3
2
0.1
0
%
%
%
%
%
%
%
1/2 d u r a t i o n o f p u l s e shape
r o l l o f f f o r p u l s e shape
eval u ate at m d i f f e r e n t p oi nts
make s r r c p u l s e shape
c o n v o l v e 2 s r r c s to g e t r c
t r u n c a t e to same l e n g t h a s ps
e x p e r i m e n t a l p er f o r m a n ce
%
%
%
%
%
f o r each o f f s e t
r c i s s h i f t e d i /m o f a symbol
do i t n t i m e s
random 4PAM v e c t o r
r e c e i v e d data p o i n t w/ I S I
% q u a n t i z e to a l p h a b e t
% DD p e r f o r m a n c e f u n c t i o n
= 0.2
Value of performance function
260
0.5
=0
= 0.4
Figure 12.8 The performance
0.4
0.3
= 0.6
0.2
0.1
0
= 0.8
0
T/2
Timing offset
Timing Recovery
261
Exercise 12.6. Modify the algorithm (12.9) so that it minimizes the source
recovery error (s[k d] x[k])2 , where d is some (integer) delay. You will need to
assume that the message s[k] is known at the receiver. Implement the algorithm
by modifying the code in clockrecDDcost.m. Compare the new algorithm with
the old in terms of convergence speed and nal convergent value.
Exercise 12.7. Using the source recovery error algorithm of Exercise 12.6, examine the eect of dierent pulse shapes. Draw the error surfaces (mimic the code in
clockrecDDcost.m). What happens when you have the wrong d? What happens
when you have the right d?
Exercise 12.8. Investigate how the error surface depends on the input signal.
a. Draw the error surface for the DD timing-recovery algorithm when the inputs
are binary 1.
b. Draw the error surface when the inputs are drawn from the 4-PAM constellation, for the special case in which the symbol 3 never occurs.
12.4
.
d
= [k]
(12.11)
The updates proceed in the same direction as the gradient (rather than minus the
gradient) because the goal is to maximize, to nd the that leads to the largest
value of JOP ( ) (rather than the smallest). The derivative of JOP ( ) can be
approximated using (G.12) to swap the dierentiation and averaging operations
dJOP ( )
avg
d
dx2 [k]
d
dx[k]
= 2 avg x[k]
.
d
(12.12)
262
Sampler
x(t)
Resample
Resample
x(kT/M + [k])
x[k]
x(kT/M + [k] + )
x(kT/M + [k] )
Resample
[k]
Figure 12.9 One implementation of the adaptive element (12.13) uses three digital
interpolations (resamplers). After the [k] converge, the output x[k] is a sampled
version of the input x(t), with the samples taken at times that maximize the power of
the output.
The derivative of x[k] can be approximated numerically. One way of doing this
is to use (12.8), which is valid for small . Substituting (12.8) and (12.12) into
(12.11) and evaluating at = [k] gives the algorithm
kT
kT
[k + 1] = [k] + avg x[k] x
+ [k] + x
+ [k]
,
M
M
where the stepsize =
/. As usual, the small-stepsize algorithm acts as a
lowpass lter to smooth the estimates of , and it is common to remove the
explicit outer averaging operation, leading to
kT
kT
+ [k] + x
+ [k] . (12.13)
[k + 1] = [k] + x[k] x
M
M
If [k] is noisy, then can be decreased (or the length of the average, if present,
can be increased), although these will inevitably slow the convergence of the
algorithm.
Using the algorithm (12.13) is similar to implementing the cluster variance
scheme (12.9), and a software-intensive solution is diagrammed in Figure
12.9. This uses interpolation (resampling) to reconstruct the values of x(t) at
x(kT /M + [k] ) and at x(kT /M + [k] + ) from nearby samples x[k]. As
suggested by Figure 12.2, the same idea can be implemented in analog, hybrid,
or digital form.
The following program implements the timing-recovery algorithm using
the recursive output-power-maximization algorithm (12.13). The user species the transmitted signal, channel, and pulse shaping exactly as in part 1 of
clockrecDD.m. An initial timing oset toffset is specied, and the algorithm
in clockrecOP.m tries to nd (the negative of) this value using only the received
signal.
Listing 12.4. clockrecOP.m clock recovery maximizing output power
tnow=l *m+1; tau =0; x s=zeros ( 1 , n ) ;
% initialize
variables
Offset estimates
Symbol estimates
Timing Recovery
263
Constellation history
1.5
1
0
1
0.4
0.2
0
0
1000
2000
3000
Iterations
4000
5000
% algorithm s t e p s i z e
% time f o r d e r i v a t i v e
% run i t e r a t i o n
%
%
%
%
%
%
i n t e r p a t tnow+tau
v a l u e to r i g h t
v a l u e to l e f t
numerical d e r i v a t i v e
a l g update ( e n e r g y )
save f o r p l o t t i n g
Typical output of the program is plotted in Figure 12.10. For this plot, the
message was drawn from a 2-PAM binary signal, which is recovered nicely by
the algorithm, as shown in the top plot. The bottom plot shows the trajectory
of the oset estimation as it converges to the unknown value at -toffset.
The error surface for the output-power-maximization algorithm can be drawn
using the same experimental method as was used in clockrecDDcost.m.
Replacing the line that calculates the performance function with
c o s t ( i )=sum( x . 2 ) / length ( x ) ;
calculates the error surface for the output power algorithm (12.13). Figure 12.11
shows this, along with three variants:
1. the average value of the absolute value of the output of the sampler
avg{|x[k]|},
2. the average of the fourth power of the output of the sampler avg{x4 [k]}, and
3. the average of the dispersion avg{(x2 [k] 1)2 }.
Clearly, some of these require maximization (the output power and the absolute
value), while others require minimization (the fourth power and the dispersion).
While they all behave more or less analogously in this easy setting (the gure
Fourth Power
Value of performance functions
264
1.2
Output Power
0.8
0.6
Abs. Value
Dispersion
0.4
0.2
0
T/2
Timing offset
shows the 2-PAM case with an SRRC pulse shape with beta=0.5), the maxima
(or minima) may occur at dierent values of in more extreme settings.
Exercise 12.9. TRUE or FALSE: The optimum settings of timing recovery via
output power maximization with and without intersymbol interference in the
analog channel are the same.
Exercise 12.10. Use the code in clockrecOP.m to play with the output power
clock-recovery algorithm. How does mu aect the convergence rate? What range
of stepsizes works? How does the signal constellation of the input aect the
convergent value of tau (try 4-PAM and 8-PAM)?
Exercise 12.11. Implement a rectangular pulse shape. Does this work better or
worse than the SRRC?
Exercise 12.12. Add noise to the signal (add a zero-mean noise to the received
signal using the Matlab randn function). How does this aect the convergence
of the timing-oset parameter tau? Does it change the nal converged value?
Exercise 12.13. Modify clockrecOP.m by setting toffset=-1. This starts the
iteration in a closed-eye situation. How many iterations does it take to open
the eye? What is the convergent value? Try other values of toffset. Can you
predict what the nal convergent value will be? Try toffset=-2.3. Now let the
oversampling factor be m = 4 and answer the same questions.
Exercise 12.14. Redo Figure 12.11 using a sinc pulse shape. What happens to
the output power performance function?
Exercise 12.15. Redo Figure 12.11 using a T -wide Hamming pulse shape.
Which of the four performance functions need to be minimized and which need
to be maximized?
Timing Recovery
265
Exercise 12.16. Consider the sampled version x(kT + ) of the baseband signal
x(t) recovered by the receiver in a 2-PAM communication system with source
alphabet 1. In ideal circumstances, the baud-timing variable could be set
so x(kT + ) exactly matched the source symbol sequence at the transmitter.
Suppose is selected as the value that optimizes
JDM ( ) =
1
N
k
0 +N
(1 x2 (kTs + ))2
k=k0 +1
d
for small > 0 to derive a gradient algorithm that optimizes JDM .
Exercise 12.17. Consider a resampler with input x(kTs ) and output x(kTs + ).
Use the approximation in Exercise 12.16(b) to derive an approximate gradientdescent algorithm that minimizes the fourth-power performance function
JF P ( ) =
1
N
k
0 +N
x4 (kTs + )
k=k0 +1
266
12.5
Two Examples
This section presents two examples in which timing recovery plays a signicant
role. The rst looks at the behavior of the algorithms in the nonideal setting.
When there is channel ISI, the answer to which the algorithms converge is not
the same as in the ISI-free setting. This happens because the ISI of the channel
causes an eective delay in the energy that the algorithm measures. The second example shows how the timing-recovery algorithms can be used to estimate
(slow) changes in the optimal sampling time. When these changes occur linearly,
they are eectively a change in the underlying period, and the timing-recovery
algorithms can be used to estimate the oset of the period in the same way that
the phase estimates of the PLL in Section 10.6 can be used to nd a (small)
frequency oset in the carrier.
% T/m c h a n n e l
Offset estimates
Symbol estimates
Timing Recovery
267
Constellation diagram
3
2
1
0
1
2
3
0.8
0.4
0
0
1000
2000
3000
Iterations
4000
5000
To see the general situation, consider the received analog signal due to a single
symbol triggering the pulse-shape lter and passing through a channel with ISI.
An adjustment in the baud-timing setting at the receiver will sample at slightly
dierent points on the received analog signal. A change in is eectively equivalent to a change in the channel ISI. This will be dealt with in Chapter 13 when
designing equalizers.
Example 12.4. With the signal generated as in clockrecDD.m on page 258, the
following code resamples (using sinc interpolation) the received signal to simulate
a change in the underlying period by a factor of fac.
Listing 12.5. clockrecperiod.m resample to change the period
f a c = 1 . 0 0 0 1 ; z=zeros ( s i z e ( x ) ) ;
t=l +1: f a c : length ( x)2 * l ;
f o r i=l +1: length ( t )
z ( i )= i n t e r p s i n c ( x , t ( i ) , l ) ;
end
x=z ;
%
%
%
%
%
%
p e r c e n t change i n p e r i o d
v e c t o r o f new t i m e s
r e s a m p l e x a t new r a t e
to c r e a t e r e c e i v e d s i g n a l
with p e r i o d o f f s e t
relabel signal
If this code is followed by one of the timing-recovery schemes, then the timing
parameter follows the changing period. For instance, in Figure 12.13, the timing
estimation converges rapidly to a line with slope that is proportional to the
dierence in period between the assumed value of the period at the receiver and
the actual value used at the transmitter.
Thus, the standard timing-recovery algorithms can handle the case in which
the clock periods at the transmitter and receiver are somewhat dierent. More
accurate estimates could be made using two timing-recovery algorithms analogous to the dual-carrier recovery structure of Section 10.6.2 or by mimicking
the second-order lter structure of the PLL in the article Analysis of the Phase
Locked Loop, which can be found on the website. There are also other common
timing-recovery algorithms such as the earlylate method, the method of Mueller
and M
uller, and band-edge timing algorithms.
Symbol estimates
Offset estimates
268
Constellation history
1.5
1
0.5
0
0.5
1
1.5
1
0
1
2
3
4
0.5
1.5
Iterations
x104
Timing Recovery
269
r J. A. C. Bingham, The Theory and Practice of Modem Design, Wiley Interscience, 1988.
13 Linear Equalization
When all is well in the receiver, there is no interaction between successive symbols; each symbol arrives and is decoded independently of all others. But when
symbols interact, when the waveform of one symbol corrupts the value of a nearby
symbol, then the received signal becomes distorted. It is dicult to decipher
the message from such a received signal. This impairment is called intersymbol interference and was discussed in Chapter 11 in terms of non-Nyquist pulse
shapes overlapping in time. This chapter considers another source of interference
between symbols that is caused by multipath reections (or frequency-selective
dispersion) in the channel.
When there is no intersymbol interference (from a multipath channel, from
imperfect pulse shaping, or from imperfect timing), the impulse response of the
system from the source to the recovered message has a single nonzero term.
The amplitude of this single spike depends on the transmission losses, and the
delay is determined by the transmission time. When there is intersymbol interference caused by a multipath channel, this single spike is scattered, duplicated
once for each path in the channel. The number of nonzero terms in the impulse
response increases. The channel can be modeled as a nite-impulse-response,
linear lter C, and the delay spread is the total time interval during which reections with signicant energy arrive. The idea of the equalizer is to build (another)
lter in the receiver that counteracts the eect of the channel. In essence, the
equalizer must unscatter the impulse response. This can be stated as the goal
of designing the equalizer E so that the impulse response of the combined channel and equalizer CE has a single spike. This can be cast as an optimization
problem, and can be solved using techniques familiar from Chapters 6, 10, and
12.
The transmission path may also be corrupted by additive interferences such
as those caused by other users. These noise components are usually presumed
to be uncorrelated with the source sequence and they may be broadband or
narrowband, in band or out of band relative to the bandlimited spectrum of the
source signal. Like the multipath channel interference, they cannot be known to
Linear Equalization
271
Pulse
shaping
Analog
channel
Received
analog
signal
Sampled
received
signal
Ts
Linear
digital
equalizer
Decision
device
the system designer in advance. The second job of the equalizer is to reject such
additive narrowband interferers by designing appropriate linear notch lters onthe-y. At the same time, it is important that the equalizer does not unduly
enhance the broadband noise.
The signal path of a baseband digital communication system is shown in Figure 13.1, which emphasizes the role of the equalizer in trying to counteract the
eects of the multipath channel and the additive interference. As in previous
chapters, all of the inner parts of the system are assumed to operate precisely:
thus, the upconversion and downconversion, the timing recovery, and the carrier synchronization (all those parts of the receiver that are not shown in Figure
13.1) are assumed to be awless and unchanging. Modeling the channel as a timeinvariant FIR lter, the next section focuses on the task of selecting the coecients in the block labeled linear digital equalizer, with the goal of removing the
intersymbol interference and attenuating the additive interferences. These coecients are to be chosen using the sampled received signal sequence and (possibly)
knowledge of a prearranged training sequence. While the channel may actually
be time-varying, the variations are often much slower than the data rate, and
the channel can be viewed as (eectively) time-invariant over small time scales.
This chapter suggests several dierent ways in which the coecients of the
equalizer can be chosen. The rst procedure, in Section 13.2.1, minimizes the
square of the symbol-recovery error1 over a block of data, which can be done
using a matrix pseudoinversion. Minimizing the (square of the) error between the
received data values and the transmitted values can also be achieved using an
adaptive element, as detailed in Section 13.3. When there is no training sequence,
other performance functions are appropriate, and these lead to equalizers such as
the decision-directed approach in Section 13.4 and the dispersion-minimization
method in Section 13.5. The adaptive methods considered here are only modestly
complex to implement, and they can potentially track time variations in the
channel model, assuming that the changes are suciently slow.
1
This is the error between the equalizer output and the transmitted symbol, and is known
whenever there is a training sequence.
272
13.1
Multipath Interference
The villains of this chapter are multipath and other additive interferers. Both
should be familiar from Section 4.1.
The distortion caused by an analog wireless channel can be thought of as a
combination of scaled and delayed reections of the original transmitted signal.
These reections occur when there are dierent paths from the transmitting
antenna to the receiving antenna. Between two microwave towers, for instance,
the paths may include one along the line of sight, reections from nearby hills,
and bounces from a eld or lake between the towers. For indoor digital TV
reception, there are many (local) time-varying reectors, including people in the
receiving room, and nearby vehicles. The strength of the reections depends on
the physical properties of the reecting objects, while the delay of the reections
is primarily determined by the length of the transmission path. Let u(t) be the
transmitted signal. If N delays are represented by 1 , 2 , . . . , N , and the
strength of the reections is 1 , 2 , . . . , N , then the received signal is
y(t) = 1 u(t 1 ) + 2 u(t 2 ) + + N u(t N ) + (t),
(13.1)
where (t) represents additive interferences. This model of the transmission channel has the form of a nite-impulse-response lter, and the total length of time
N 1 over which the impulse response is nonzero is called the delay spread
of the physical medium.
This transmission channel is typically modeled digitally assuming a xed sampling period Ts . Thus, (13.1) is approximated by
y(kTs ) = a0 u(kTs ) + a1 u((k 1)Ts ) + + an u((k n)Ts ) + (kTs ). (13.2)
In order for the model (13.2) to closely represent the system (13.1), the total time
over which the impulse response is nonzero (the time nTs ) must be at least as
large as the maximum delay N . Since the delay is not a function of the symbol
period Ts , smaller values of Ts require more terms in the lter (i.e., larger n).
For example, consider a sampling interval of Ts 40 ns (i.e., a transmission
rate of 25 MHz). A delay spread of approximately 4 s would correspond to 100
taps in the model (13.2). Thus, at any time instant, the received signal would
be a combination of (up to) 100 data values. If Ts were increased to 0.4 s
(i.e., 2.5 MHz), only 10 terms would be needed, and there would be interference
with only the 10 nearest data values. If Ts were larger than 4 s (i.e., 0.25
MHz), only one term would be needed in the discrete-time impulse response.
In this case, adjacent sampled symbols would not interfere. Such nite-duration
impulse-response models as (13.2) can also be used to represent the frequencyselective dynamics that occur in the wired local end-loop in telephony, and other
(approximately) linear, nite-delay-spread channels.
The design objective of the equalizer is to undo the eects of the channel and to
remove the interference. Conceptually, the equalizer attempts to build a system
that is a delayed inverse of (13.2), removing the intersymbol interference while
Linear Equalization
273
13.2
274
Lattice of Ts-spaced
optimal sampling times
with ISI
Lattice of Ts-spaced optimal
sampling times with no ISI
Sum of received pulses
c(t) = p(t) + 0.6 p(t )
p(t)
0.6 p(t )
0
The digital channel
model is given by
Ts-spaced samples of c(t)
Figure 13.2 The optimum sampling times (as found by the energy-maximization
algorithm) dier when there is ISI in the transmission path, and change the eective
digital model of the channel.
Additive
interferers
Source
s[k]
Channel
Received
signal r[k]
Equalizer
output y[k]
Equalizer
Impulse response f
Training signal
Delay
Error
e[k]
Figure 13.3 The problem of linear equalization is to nd a linear system f that undoes
the eects of the channel while minimizing the eects of the interferences.
unknown equalizer parameters that can be used to dene an optimization problem. Then, applying the techniques of Chapters 6, 10, and 12, the optimization
problem can be solved in a variety of ways.
13.2.1
A Matrix Description
The linear equalization problem is depicted in Figure 13.3. A prearranged training sequence s[k] is assumed known at the receiver. The goal is to nd an FIR
lter (called the equalizer) so that the output of the equalizer is approximately
equal to the known source, though possibly delayed in time. Thus, the goal is to
choose the impulse response fi so that y[k] s[k ] for some specic .
Linear Equalization
r[k]
z1
f0
z1
...
z1
f1
275
fn
...
y[k]
Figure 13.4 The direct-form FIR lter of Equation (13.3) can be pictured as a tapped
delay line where each z 1 block represents a time delay of one symbol period. The
impulse response of the lter is f0 , f1 , . . ., fn .
The inputoutput behavior of the FIR linear equalizer can be described as the
convolution
n
y[k] =
fj r[k j],
(13.3)
j=0
where the lower index on j can be no lower than zero (or else the equalizer
is noncausal; that is, it can illogically respond to an input before the input is
applied). This convolution is illustrated in Figure 13.4 as a direct-form FIR or
tapped delay line.
The summation in (13.3) can also be written (e.g., for k = n + 1) as the inner
product of two vectors
f0
f1
(13.4)
y[n + 1] = [r[n + 1], r[n], . . . , r[1]] . .
..
fn
Note that y[n + 1] is the earliest output that can be formed given no knowledge
of r[i] for i < 1. Incrementing the time index in (13.4) gives
f0
f1
y[n + 2] = [r[n + 2], r[n + 1], . . . , r[2]] .
..
fn
and
f0
f1
y[n + 3] = [r[n + 3], r[n + 2], . . . , r[3]] . .
..
fn
Observe that each of these uses the same equalizer parameter vector. Concatenating p n of these measurements into one matrix equation over the available
276
r[n + 1] r[n]
y[n + 1]
y[n + 2] r[n + 2] r[n + 1]
..
..
..
.
.
.
r[p]
r[p 1]
y[p]
r[1]
f0
r[2]
f1
r[3]
. ,
.
..
.
.
fn
r[p n]
(13.5)
(13.6)
Note that R has a special structure, namely that the entries along each diagonal
are the same. R is known as a Toeplitz matrix and the toeplitz command in
Matlab makes it easy to build matrices with this structure.
13.2.2
(13.7)
for a particular . This section shows how the source recovery error can be used
to dene a performance function that depends on the unknown parameters fi .
Calculating the parameters that minimize this performance function provides a
good solution to the equalization problem.
Dene
e[n + 1]
s[n + 1 ]
e[n + 2]
s[n + 2 ]
s[n + 3 ]
(13.8)
S=
and E = e[n + 3] .
..
..
.
.
e[p]
s[p ]
Using (13.6), write
E = S Y = S RF.
(13.9)
p
e2 [i].
(13.10)
i=n+1
Linear Equalization
277
(13.11)
Because JLS is a scalar, (RF )T S and S T RF are also scalars. Since the transpose
of a scalar is equal to itself, (RF )T S = S T RF , and (13.11) can be rewritten as
JLS = S T S 2S T RF + (RF )T RF.
(13.12)
The issue is now one of choosing the n + 1 entries of F to make JLS as small as
possible.
13.2.3
(13.13)
(13.14)
assuming that (RT R)1 exists.2 The corresponding minimum achievable by JLS
at F = F is the summed squared delayed source recovery error. This is the
remaining term in (13.13); that is,
min
JLS
= S T [I R(RT R)1 RT ]S.
(13.15)
The formulas for the optimum F in (13.14) and the associated minimum
achievable JLS in (13.15) are for a specic . To complete the design task, it
is also necessary to nd the optimal delay . The most straightforward approach
is to set up a series of S = RF calculations, one for each possible , to compute
min
the associated values of JLS
, and pick the delay associated with the smallest
one.
This procedure is straightforward to implement in Matlab, and the program
LSequalizer.m allows you to play with the various parameters to get a feel for
their eect. Much of this program will be familiar from openclosed.m. The rst
2
278
three lines dene a channel, create a binary source, and then transmit the source
through the channel using the filter command. At the receiver, the data are
put through a quantizer, and then the error is calculated for a range of delays.
The new part is in the middle.
Listing 13.1. LSequalizer.m nd a LS equalizer f for the channel b
b=[0.5 1 0.6];
% def i ne channel
m=1000; s=sign ( randn ( 1 ,m) ) ;
% binary source of length m
r=f i l t e r ( b , 1 , s ) ;
% output o f channel
n=3;
% length of equal i zer 1
d e l t a =3;
% u s e d e l a y <=n * l e n g t h ( b )
p=length ( r ) d e l t a ;
R=t o e p l i t z ( r ( n+1:p ) , r ( n + 1 : 1 : 1 ) ) ;
% b u i l d m a tr i x R
S=s ( n+1d e l t a : pd e l t a ) ;
% and v e c t o r S
f=inv (R * R) * R * S
% calculate equalizer f
Jmin=S * SS * R* inv (R * R) * R * S
% Jmin f o r t h i s f and d e l t a
y=f i l t e r ( f , 1 , r ) ;
% equalizer is a f i l t e r
dec=sign ( y ) ;
% q u a n t i z e and f i n d e r r o r s
e r r =0.5 *sum( abs ( dec ( d e l t a +1:m) s ( 1 :md e l t a ) ) )
The variable n denes the length of the equalizer, and delta denes the delay
that will be used in constructing the vector S dened in (13.8) (observe that
delta must be positive and less than or equal to n). The Toeplitz matrix R
is dened in (13.5) and (13.6), and the equalizer coecients f are computed
as in (13.14). The value of minimum achievable performance is Jmin, which is
calculated as in (13.15). To demonstrate the eect of the equalizer, the received
signal r is ltered by the equalizer coecients, and the output is then quantized.
If the equalizer has done its job (i.e., if the eye is open), then there should be
some shift sh at which no errors occur.
For example, using the default channel b = [0.5, 1, 0.6], and length-4 equalizer
(n=3), four values of the delay delta give
equalizer f
delay delta Jmin
0
832 {0.33, 0.027, 0.070, 0.01}
134 {0.66, 0.36, 0.16, 0.08}
1
2
30 {0.28, 0.65, 0.30, 0.14}
45 {0.1, 0.27, 0.64, 0.3}
3
(13.16)
The best equalizer is the one corresponding to a delay of 2, since this Jmin is the
smallest. In this case, however, any of the last three will open the eye. Observe
that the number of errors (as reported in err) is zero when the eye is open.
Exercise 13.1. Plot the frequency response (using freqz) of the channel b
in LSequalizer.m. Plot the frequency response of each of the four equalizers
found by the program. For each channel/equalizer pair, form the product of the
magnitude of the frequency responses. How close are these products to unity?
Exercise 13.2. Add (uncorrelated, normally distributed) noise into the simulation using the command r=filter(b,1,s)+sd*randn(size(s)).
Linear Equalization
279
a. For the equalizer with delay 2, what is the largest sd you can add and still
have no errors?
b. Make a plot of Jmin as a function of sd.
c. Now try the equalizer with delay 1. What is the largest sd you can add, and
still have no errors?
d. Which is a better equalizer?
Exercise 13.3. Use LSequalizer.m to nd an equalizer that can open the eye
for the channel b = [1, 1, 0.8, 0.3, 1, 1].
a.
b.
c.
d.
e.
f.
There is a way to convert the exhaustive search over all the delays in the
previous approach into a single matrix operation. Construct the (p ) ( +
1) matrix of training data
s[ + 1] s[]
s[1]
s[ + 2] s[ + 1]
s[2]
(13.17)
S =
,
..
..
..
.
.
.
s[p]
s[p 1] s[p ]
r[ + 1] r[]
r[ n + 1]
r[ + 2] r[ + 1] r[ n + 2]
=
R
(13.18)
,
..
..
..
.
.
.
r[p]
r[p 1]
r[p n]
where each column corresponds to one of the possible delays. Note that > n is
required in order to keep the lowest index of r[] positive. In the (n + 1) ( + 1)
280
matrix
F =
f00
f10
..
.
fn0
f01 f0
f11 f1
..
..
.
.
fn1 fn
F = (R
(13.19)
Thus, these
where S is the th column of S.
min,
JLS
(13.20)
R
T R)
1 R
T ]S.
= ST [I R(
(13.21)
Hence, the minimum value on the diagonal of (e.g., at the (j, j)th entry)
corresponds to the optimum .
Example 13.1. Consider the low-order example with n = 1 (so F has two parameters), = 2 (so > n), and p = 5 (so p > n + ). Thus,
s[3] s[2] s[1]
r[3] r[2]
= r[4] r[3] , and F = f00 f01 f02 .
S = s[4] s[3] s[2] , R
f10 f11 f12
s[5] s[4] s[3]
r[5] r[4]
For the example, assume that the true channel is
r[k] = ar[k 1] + bs[k 1].
A two-tap equalizer F = [f0 , f1 ]T can provide perfect equalization for = 1 with
f0 = 1/b and f1 = a/b, since
y[k] = f0 r[k] + f1 r[k 1] =
=
1
[r[k] ar[k 1]]
b
1
[ar[k 1] + bs[k 1] ar[k 1]] = s[k 1].
b
Linear Equalization
281
Consider
{s[1], s[2], s[3], [s4], s[5]} = {1, 1, 1, 1, 1},
which results in
1 1 1
S = 1 1 1 .
1 1 1
Example 13.2. The eect of channel noise can be simulated by rounding these
values for r in composing
0.1 1.5
= 1.1 0.1 .
R
0.4 1.1
Thus, from (13.21),
Since the second diagonal term in is the smallest diagonal term, = 1 is the
optimum setting (as expected) and the second column of F is the minimum
summed squared delayed recovery error solution (i.e., f0 = 0.9548 ( 1/b = 1)
and f1 = 0.5884 ( a/b = 0.6)).
With a better received signal measurement, for instance,
0.11
1.48
= 1.07 0.11 ,
R
0.36 1.07
the diagonal of is [1.3572, 0.0000, 0.1657] and the optimum delay is again
= 1, and the optimum equalizer settings are 0.9960 and 0.6009, which give a
(measured without
better t to the ideal noise-free answer. Innite precision in R
282
13.2.4
13.2.5
The condition number (i.e., the maximum eigenvalue divided by the minimum eigenvalue) of
should be checked. If the condition number is extremely large, start again with dierent
T R
R
then most likely the channel
T R,
{s[]}. If all choices of {s[]} result in poorly conditioned R
has deep nulls that prohibit the successful application of a T -spaced linear equalizer.
Linear Equalization
283
where j =
13.2.6
284
User 1
s1[k] Channel 2
h1[k]
User 2
s2[k] Channel 1
h2[k]
y[k]
The signal from the second (interfering) user is scaled by h2 [k] = c[k]. The
dierence equation generating the received signal r is
r[k] = s1 [k] + bs1 [k 1] + cs2 [k].
The dierence equation describing the equalizer inputoutput behavior is
x[k] = r[k] + dr[k 1].
The decision device is the sign operator.
a. Write out the dierence equation relating s1 [k] and s2 [k] to x[k].
b. Consider the performance function
JMSE =
1
N
k
0 +N
k=k0 +1
13.3
1
avg{e2 [k]}.
2
(13.22)
Linear Equalization
285
n
fj r[k j],
(13.23)
j=0
which combines (13.7) with (13.3), and where r[k] is the received signal at baseband after sampling. An algorithm for the minimization of JLMS with respect
to the ith equalizer coecient fi is
JLMS
.
(13.24)
fi [k + 1] = fi [k]
fi fi =fi [k]
To create an algorithm that can easily be implemented, it is necessary to evaluate
this derivative with respect to the parameter of interest. This is
1 2
e [k]
avg{ 12 e2 [k]}
JLMS
e[k]
2
= avg e[k]
,
(13.25)
=
avg
fi
fi
fi
fi
where the approximation follows from (G.12) and the nal equality from the
chain rule (A.59). Using (13.23), the derivative of the source recovery error e[k]
with respect to the ith equalizer parameter fi is
e[k]
s[k ] fj r[k j]
=
= r[k i],
fi
fi
fi
j=0
n
(13.26)
(13.27)
To provide tracking capability, the matrix solution of Section 13.2.1 could be recomputed for
successive data blocks, but this requires signicantly more computation.
286
Sampled
received
signal r[k]
f [k]
Sign[]
y[k]
Equalizer
Adaptive
algorithm
e[k]
Decision
device
Performance
evaluation
s[k]
training
signal
Figure 13.6 A trained adaptive linear equalizer uses the dierence between the
received signal and a prespecied training sequence to drive the adaptation of the
coecients of the equalizer.
LSequalizer.m. The heart of the recursion lies in the for loop. For each new
data point, a vector is built containing the new value and the past n values of the
received signal. This is multiplied by f to make a prediction of the next source
symbol, and the error is the dierence between the prediction and the reality.
(This is the calculation of e[k] from (13.23).) The equalizer coecients f are then
updated as in (13.27).
Listing 13.2. LMSequalizer.m nd a LMS equalizer f for the channel b
b=[0.5 1 0.6];
m=1000; s=pam (m, 2 , 1 ) ;
r=f i l t e r ( b , 1 , s ) ;
n=4; f=zeros ( n , 1 ) ;
mu= . 0 1 ; d e l t a =2;
f o r i=n+1:m
r r=r ( i : 1 : i n + 1 ) ;
e=s ( i d e l t a ) r r * f ;
f=f+mu* e * r r ;
end
%
%
%
%
%
%
%
%
%
def i ne channel
binary source of length m
output o f channel
i n i t i a l i z e e q u a l i z e r at 0
s t e p s i z e and d e l a y d e l t a
iterate
vector of received s i gnal
calculate error
update e q u a l i z e r c o e f f i c i e n t s
As with the matrix approach, the default channel b=[0.5 1 -0.6] can be
equalized easily with a short equalizer (one with a small n). The convergent values of the f are very close to the nal values of the matrix approach; that is, for a
given channel, the value of f given by LMSequalizer.m is very close to the value
found using LSequalizer.m. A design consideration in the adaptive approach to
equalization involves the selection of the stepsize. Smaller stepsizes mean that
the trajectory of the estimates is smoother (tends to reject noises better) but
it also results in a slower convergence and slower tracking when the underlying
solution is time-varying. Similarly, if the explicit averaging operation is retained,
longer averages imply smoother estimates but slower convergence. Similar tradeos appear in the block approach in the choice of block size: larger blocks average
the noise better, but give no details about changes in the underlying solution
within the time span covered by a block.
The following code EqualizerTest.m shows one way to verify that the equalizer has (or has not) done a good job. The code generates a new received signal
and passes it through the same channel and the nal converged equalizer from
LMSequalizer.m. The decision sequence dec (the sign of the data for a binary
Linear Equalization
287
transmission) is then compared with the original transmitted data s. Since the
delay of the equalizer cannot be known beforehand, the loop on sh tests all the
possible delays (shifts) that might occur. If one of these is zero (or very small)
then the equalizer is doing a good job.
Listing 13.3. EqualizerTest.m verify the operation of an equalizer f for the channel b
% F i r s t run L M S e q u a l i z e r .m t o s e t c h a n n e l b and e q u a l i z e r f
f i n a l e q=f ;
% test final f i l t e r f
m=1000;
% new data p o i n t s
s=pam (m, 2 , 1 ) ;
% new b i n a r y s o u r c e o f l e n g t h m
r=f i l t e r ( b , 1 , s ) ;
% output o f channel
y t=f i l t e r ( f , 1 , r ) ;
% u s e f i n a l f i l t e r f to t e s t
dec=sign ( r e a l ( y t ) ) ;
% quantization
f o r sh =0:n
% i f e q u a l i z e r i s working , one
e r r ( sh +1)=0.5 *sum( abs ( dec ( sh +1:m) s ( 1 :msh ) ) ) ;
end
% o f t h e s e d e l a y s has z e r o e r r o r
288
13.4
(13.28)
Linear Equalization
Sampled
received
signal r[k]
f [k]
Sign[]
y[k]
Equalizer
Adaptive
algorithm
289
e[k]
Decision
device
Performance
evaluation
Figure 13.7 A decision-directed adaptive linear equalizer uses the dierence between
the received signal and the output of the decision device to drive the adaptation of
the coecients of the equalizer.
When the signal s[k] is multilevel instead of binary, the sign function in (13.28)
can be replaced with a quantizer.
Exercise 13.12. Show that the decision-directed LMS algorithm (13.28)
can be derived as an adaptive element with performance function
(1/2) avg{(sign(y[k]) y[k])2 }. Hint: suppose that the derivative of the sign function dsign(x)/dx is zero everywhere.
Observe that the source signal s[k] does not appear in (13.28). Thus, no training signal is required for its implementation and the decision-directed LMS equalizer adaptation law of (13.28) is called a blind equalizer. Given its genesis, one
should expect decision-directed LMS to exhibit poor behavior when the assumption regarding perfect decisions is violated. The basic rule of thumb is that 5%
(or so) decision errors can be tolerated before decision-directed LMS fails to
converge properly.
The Matlab program DDequalizer.m has a familiar structure. The only code
changed from LMSequalizer.m is the calculation of the error term, which implements e[k] = sign{y[k]} y[k] rather than the LMS error (13.23), and the initialization of the equalizer. Because the equalizer must begin with an open eye,
f=0 is a poor choice. The initialization that follows starts all taps at zero except
for one in the middle that begins at unity. This is called the center-spike initialization. If the channel eye is open, then the combination of the channel and
equalizer will also have an open eye when initialized with the center spike. The
exercises ask you to explore the issue of nding good initial values for the equalizer parameters. As with the LMS equalizer, the code in EqualizerTest.m can
be used to test the operation of the converged equalizer.
Listing 13.4. DDequalizer.m nd a DD equalizer f for the channel b
b=[0.5 1 0.6];
m=1000; s=sign ( randn ( 1 ,m) ) ;
r=f i l t e r ( b , 1 , s ) ;
n=4; f =[0 1 0 0 ] ;
mu= . 1 ;
f o r i=n+1:m
r r=r ( i : 1 : i n + 1 ) ;
%
%
%
%
%
%
%
def i ne channel
binary source of length m
output o f channel
i ni t i a l i z e equalizer
stepsize
iterate
vector of received s i gnal
290
e=sign ( f * r r ) f * r r ;
f=f+mu* e * r r ;
end
% calculate error
% update e q u a l i z e r c o e f f i c i e n t s
13.5
291
Linear Equalization
Sampled
received
signal r[k]
y[k]
Equalizer
Adaptive
algorithm
X2
y2[k]
e[k]
Performance evaluation
Figure 13.8 A dispersion-minimizing adaptive linear equalizer for binary data uses the
dierence between the square of the received signal and unity to drive the adaptation
of the coecients of the equalizer.
Mimicking the derivation in (13.24) through (13.27) yields the dispersionminimizing algorithm5 (DMA) for blindly adapting the coecients of a linear
equalizer. The algorithm is
fi [k + 1] = fi [k] + avg{(1 y 2 [k])y[k]r[k i]}.
Suppressing the averaging operation, this becomes
fi [k + 1] = fi [k] + (1 y 2 [k])y[k]r[k i],
(13.29)
This is also known as the constant-modulus algorithm and as the Godard algorithm.
292
the simplest case, observe that an answer in which all +1s are swapped with
all 1s has the same value at the optimal point. Thus, the convergent delay
and polarity achieved depend on the initialization used. A typical initialization
for DMA is a single nonzero spike located near the center of the equalizer. The
multimodal nature of DMA can be observed in the examples in the next section.
A simple Matlab program that implements the DMA algorithm is given in
DMAequalizer.m. The rst few lines dene the channel, create the binary source,
and pass the input through the channel. The last few lines implement the equalizer and calculate the error between the output of the equalizer and the source as
a way of measuring the performance of the equalizer. These parts of the code are
familiar from LSequalizer.m. The new part of the code is in the center, which
denes the length n of the equalizer, the stepsize mu of the algorithm, and the
initialization of the equalizer (which defaults to a center-spike initialization).
The coecients of the equalizer are updated as in (13.29). As with the other
equalizers, the code in EqualizerTest.m can be used to test the operation of
the converged equalizer.
Listing 13.5. DMAequalizer.m nd a DMA equalizer f for the channel b
b=[0.5 1 0.6];
m=1000; s=sign ( randn ( 1 ,m) ) ;
r=f i l t e r ( b , 1 , s ) ;
n=4; f =[0 1 0 0 ] ;
mu= . 0 1 ;
f o r i=n+1:m
r r=r ( i : 1 : i n + 1 ) ;
e =( f * r r ) * (1 ( f * r r ) 2 ) ;
f=f+mu* e * r r ;
end
%
%
%
%
%
%
%
%
%
def i ne channel
binary source of length m
output o f channel
c e n t e r s p i k e i n i t i a l i z a t i o n
algorithm s t e p s i z e
iterate
vector of received s i gnal
calculate error
update e q u a l i z e r c o e f f i c i e n t s
293
Linear Equalization
1
2
avg{|1
294
13.6
received signal,
optimal equalizer output,
impulse response of the optimal equalizer and the channel,
recovery error at the output of the decision device,
zeros of the channel and the combined channelequalizer pair, and
magnitude and phase frequency responses of the channel, of the equalizer, and
of the combined channelequalizer pair.
For the default channels and values, these plots are shown in Figures 13.913.14.
the minimum average
T R,
The program also prints the condition number of R
squared recovery error (i.e., the minimum value achieved by the performance
function by the optimal equalizer for the optimum delay opt ), the optimal value
of the delay opt , and the percentage of decision device output errors in matching
the delayed source. These values were as follows:
r Channel 0
Throughout these simulations, other aspects of the system are assumed optimal; thus, the
downconversion is numerically perfect and the synchronization algorithms are assumed to
have attained their convergent values.
Linear Equalization
Received signal
295
1
1
0
1
2
1
0
1000 2000 3000 4000
Combined channel and optimal
equalizer impulse response
1000
2000
3000
4000
1.2
0.8
0.5
0
0.4
0.5
0
0
10
20
30
40
1000
2000
3000
4000
Figure 13.9 Trained least-squares equalizer for channel 0: time responses. The received
signal is messy and cannot be used directly to recover the message. After passing
through the optimal equalizer, there is sucient separation to open the eye. The
bottom-left gure shows the impulse response of the channel convolved with the
impulse response of the optimal equalizer; it is close to an ideal response (which
would be unity at one delay and zero everywhere else). The bottom-right plot shows
that the message signal is recovered without error.
r Channel 1
To see what these gures mean, consider the eight plots contained in Figures
13.9 and 13.10. The rst plot is the received signal, which contains the transmitted signal corrupted by the sinusoidal interferer and the white noise. After
the equalizer design, this received signal is passed through the equalizer, and the
output is shown in the plot entitled optimal equalizer output. The equalizer
transforms the data in the received signal into two horizontal stripes. Passing
20
0.5
10
db
Imaginary part
0
0.5
1
0
10
1 0.5 0 0.5
Real part
20
0
1
Real part
1
2
3
Normalized frequency
radians
Imaginary part
296
10
0
10
20
30
40
50
60
1
2
3
Normalized frequency
Figure 13.10 Trained least-squares equalizer for channel 0: singularities and frequency
responses. The large circles show the locations of the zeros of the channel in the
upper-left plot and the locations of the zeros of the combined channelequalizer pair
in the lower-left plot. The dotted line represents the frequency response of the
channel, the dashed line is the frequency response of the equalizer, and the solid line
is the frequency response of the combined channelequalizer pair.
Received signal
1
0.5
0.5
0
0.5
0.5
1
1
0
1.5
Figure 13.9, the equalizer is able to eectively undo the eects of the channel.
Linear Equalization
297
1
0.5
0
0.5
1
10
db
Imaginary part
20
0
10
20
0
1
Real part
2
0
2
4
10 8 6 4 2 0
Real part
4
radians
Imaginary part
1
2
3
4
Normalized frequency
10
20
30
40
1
2
3
4
Normalized frequency
Figure 13.12 Trained least-squares equalizer for channel 1: singularities and frequency
responses. The large circles show the locations of the zeros of the channel in the
upper-left plot and the locations of the zeros of the combined channelequalizer pair
in the lower-left plot. The dotted line represents the frequency response of the
channel, the dashed line is the frequency response of the equalizer, and the solid line
is the frequency response of the combined channelequalizer pair.
this through a simple sign device recovers the transmitted signal.7 The width of
these stripes is related to the cluster variance. The dierence between the sign of
the output of the equalizer and the transmitted data is shown in the plot labeled
decision device recovery error. This is zero, indicating that the equalizer has
done its job. The plot entitled combined channel and optimal equalizer impulse
response shows the convolution of the impulse response of the channel with the
impulse response of the equalizer. If the design was perfect and there was no
interference present, one tap of this combination would be unity and all the rest
would be zero. In this case, the actual design is close to this ideal.
The plots in Figure 13.10 show the same situation, but in the frequency
domain. The zeros of the channel are depicted in the upper-left plot. This constellation of zeros corresponds to the darkest of the frequency responses drawn
in the second plot. The primarily lowpass character of the channel can be intuited directly from the zero plot with the technique of Section F.2. The T -spaced
equalizer, accordingly, has a primarily highpass character, as can be seen from
the dashed frequency response in the upper-right plot of Figure 13.10. Combining these two gives the response in the middle. This middle response (plotted
with the solid line) is mostly at, except for a large dip at 1.4 radians. This
is exactly the frequency of the sinusoidal interferer, and this demonstrates the
7
Without the equalizer, the sign function would be applied directly to the received signal, and
the result would bear little relationship to the transmitted signal.
298
Received signal
1.5
1
0.5
0
0.5
1
1.5
1000
2000
3000
4000
1.5
1
0.5
0
0.5
1
1.5
2
1000
2000
3000
4000
0.5
0
10
20
30
40
50
1000
2000
3000
4000
Figure 13.13 Trained least-squares equalizer for channel 2: time responses. Even for
this fairly severe channel, the equalizer is able to eectively undo the eects of the
channel as in Figures 13.9 and 13.11.
second major use of the equalizer; it is capable of removing uncorrelated interferences. Observe that the equalizer design is given no knowledge of the frequency
of the interference, nor even that any interference exists. Nonetheless, it automatically compensates for the narrowband interference by building a notch at
the oending frequency. The plot labeled Zeros of channel/equalizer combination shows the zeros of the convolution of the impulse response of the channel
and the impulse response of the optimal equalizer. Were the ring of zeros at
a uniform distance from the unit circle, then the magnitude of the frequency
response would be nearly at. But observe that one pair of zeros (at 1.4 radians) is considerably closer to the circle than all the others. Since the magnitude
of the frequency response is the product of the distances from the zeros to the
unit circle, this distance becomes small where the zero comes close. This causes
the notch.8
The eight plots for each of the other channels are displayed in similar fashion
in Figures 13.11 to 13.14.
Figures 13.1513.17 demonstrate equalizer design using the various recursive
methods of Sections 13.3 to 13.5 on the same problem. After running the leastsquares design in dae.m, the script asks whether you wish to simulate a recursive
solution. If yes, then you can choose
If this kind of argument relating the zeros of the transfer function to the frequency response
of the system seems unfamiliar, see Appendix F.
Linear Equalization
30
20
10
0
10
20
30
0
1
Real part
radians
Imaginary part
db
Imaginary part
299
1
2
3
4
Normalized frequency
Freq Resp Phase
0
5
10
15
20
25
30
35
1
2
3
4
Normalized frequency
Figure 13.14 Trained least-squares equalizer for channel 2: singularities and frequency
responses. The large circles show the locations of the zeros of the channel in the
upper-left plot and the locations of the zeros of the combined channelequalizer pair
in the lower-left plot. The dotted line represents the frequency response of the
channel, the dashed line is the frequency response of the equalizer, and the solid line
is the frequency response of the combined channelequalizer pair.
r the initialization: a scale factor species the size of the ball about the optimum
equalizer within which the initial value for the equalizer is randomly chosen.
As is apparent from Figures 13.1513.17, all three adaptive schemes are successful with the recommended default values, which were used in equalizing
channel 0. All three exhibit, in the upper-left plots of Figures 13.1513.17, decaying averaged squared parameter error relative to their respective trained leastsquares equalizer for the data block. This means that all are converging to the
vicinity of the trained least-squares equalizer about which dae.m initializes the
algorithms. The collapse of the squared prediction error is apparent from the
upper-right plot in each of these gures. An initially closed eye appears for a
short while in each of the lower-left plots of equalizer output history in the gures. The match of the magnitudes of the frequency responses of the trained
(block) least-squares equalizer (plotted with the solid line) and the last adaptive
equalizer setting (plotted with asterisks) from the data-block stream is quite
striking in the lower-right plots in these gures.
As expected, we nd the following.
r With modest noise, as in the cases here outside the frequency band occupied
by the single narrowband interferer, the magnitude of the frequency response
of the trained least-squares solution exhibits peaks (valleys) where the channel
response has valleys (peaks) so that the combined response is nearly at. The
phase of the trained least-squares equalizer adds with the channel phase so
100
101
101
2
1.5
1
0.5
0
0
1
10
2
3
3
2.5
dB
300
15
1
2
3
Normalized frequency
Figure 13.15 Trained LMS equalizer for channel 0. The dotted line represents the
achieved frequency response of the equalizer while the solid line represents the
frequency response of the desired (optimal) mean-square-error solution.
There are many ways in which the program dae.m can be used to investigate
and learn about equalization. Try to choose the various parameters to observe
the following
1. Increasing the power of the channel noise suppresses the frequency response of
the least-squares equalizer, with those frequency bands most suppressed being
those in which the channel has a null (and the equalizerwithout channel
noisewould have a peak).
2. Increasing the gain of a narrowband interferer results in a deepening of a
notch in the trained least-squares equalizer at the frequency of the interferer.
3. DMA is considered slower than trained LMS. Do you nd that DMA takes
longer to converge? Can you think of why it might be slower?
4. DMA typically accommodates larger initialization error than decision-directed
LMS. Can you nd cases where, with the same initialization, DMA converges
to an error-free solution but the decision-directed LMS does not? Do you think
there are cases in which the opposite holds?
100
101
101
2
1.5
1
0.5
0
1
0
1
10
2
3
301
dB
Linear Equalization
15
1
2
3
Normalized frequency
Figure 13.16 Decision-directed LMS equalizer for channel 0. The dotted line represents
101
100
4
3
2
1
0
2
1
0
5
dB
101
0
the achieved frequency response of the equalizer while the solid line represents the
frequency response of the desired (optimal) mean-square-error solution.
0
1
10
2
3
15
1
2
3
Normalized frequency
Figure 13.17 Blind DMA equalizer for channel 0. The dotted line represents the
achieved frequency response of the equalizer while the solid line represents the
frequency response of the desired (optimal) mean-square-error solution.
302
5. It is necessary to specify the delay for the trained LMS, whereas the blind
methods do not require the parameter . Rather, the selection of an appropriate delay is implicit in the initialization of the equalizer coecients. Can
you nd a case in which, with the delay poorly specied, DMA outperforms
trained LMS from the same initialization?
r W. A. Sethares, The LMS Family, in Ecient System Identication and Signal Processing Algorithms, Eds. N. Kalouptsidis and S. Theodoridis, PrenticeHall, 1993.
A copy of this paper can also be found on the accompanying website.
One of our favorite discussions of adaptive methods is
14 Coding
304
(Inherently redundant)
message to be
transmitted
Source
coding
Compressed
(redundancy
removed)
Structured
redundancy
added
Channel
coding
Transmitter
Structured
redundancy
removed
Noise
Channel
Receiver
Undo
channel
coding
Reconstructed
message
Undo
source
coding
Figure 14.1 Source and channel coding techniques manage redundancies in digital
example, one simple system would transmit each bit three times. Whenever a
single-bit error occurs in transmission, then the decoder at the receiver can gure
out by a simple voting rule that the error has occurred and what the bit should
have been. Schemes for nding and removing errors are called error-correcting
codes or channel codes, and are discussed in Section 14.6.
At rst glance, this appears paradoxical; source coding is used to remove
redundancy, while channel coding is used to add redundancy. But it is not really
self-defeating or contradictory because the redundancy that is removed by source
coding does not have a structure or pattern that a computer algorithm at the
receiver can exploit to detect or correct errors. The redundancy that is added in
channel coding is highly structured, and can be exploited by computer programs
implementing the appropriate decoding routines. Thus Figure 14.1 begins with
a message, and uses a source code to remove the redundancy. This is then coded
again by the channel encoder to add structured redundancy, and the resulting
signal provides the input to the transmitter of the previous chapters. One of the
triumphs of modern digital communications systems is that, by clever choice of
source and channel codes, it is possible to get close to the Shannon limits and
to utilize all the capacity of a channel.
14.1
What Is Information?
Like many common English words, information has many meanings. The American Heritage Dictionary catalogs six:
1.
2.
3.
4.
Coding
305
It would clearly be impossible to capture all of these senses in a technical denition that would be useful in transmission systems. The nal denition is closest
to our needs, though it does not specify exactly how the numerical measure
should be calculated. Shannon does. Shannons insight was that there is a simple relationship between the amount of information conveyed in a message and
the probability of the message being sent. This does not apply directly to messages such as sentences, images, or .wav les, but to the symbols of the alphabet
that are transmitted.
For instance, suppose that a fair coin has heads H on one side and tails T
on the other. The two outcomes are equally uncertain, and receiving either H
or T removes the same amount of uncertainty (conveys the same amount of
information). But suppose the coin is biased. The extreme case occurs when the
probability of H is 1. Then, when H is received, no information is conveyed,
because H is the only possible choice! Now suppose that the probability of sending H is 0.9 while the probability of sending T is 0.1. Then, if H is received, it
removes a little uncertainty, but not much. H is expected, since it usually occurs.
But if T is received, it is somewhat unusual, and hence conveys a lot of information. In general, events that occur with high probability give little information,
while events of low probability give considerable information.
To make this relationship between the probability of events and information
more plain, imagine a game in which you must guess a word chosen at random
from the dictionary. You are given the starting letter as a hint. If the hint is
that the rst letter is t, then this does not narrow down the possibilities very
much, since so many words start with t. But if the hint is that the rst letter
is x, then there are far fewer choices. The likely letter (the highly probable
t) conveys little information, while the unlikely letter (the improbable x)
conveys a lot more information by narrowing down the choices.
Heres another everyday example. Someone living in Ithaca (New York) would
be completely unsurprised that the weather forecast called for rain, and such
a prediction would convey little real information since it rains frequently. On
the other hand, to someone living in Reno (Nevada), a forecast of rain would
be very surprising, and would convey that very unusual meteorological events
were at hand. In short, it would convey considerable information. Again, the
amount of information conveyed is inversely proportional to the probabilities of
the events.
To transform this informal argument into a mathematical statement, consider
a set of N possible events xi , for i = 1, 2, . . . , N . Each event represents one possible outcome of an experiment, such as the ipping of a coin or the transmission
of a symbol across a communication channel. Let p(xi ) be the probability that
the ith event occurs, and suppose that some event must occur.1 This means that
1
When ipping the coin, it cannot roll into the corner and stand on its edge; each ip results
in either H or T .
306
N
i=1 p(xi ) = 1. The goal is to nd a function I(xi ) that represents the amount
of information conveyed by each outcome.
The following three qualitative conditions all relate the probabilities of events
with the amount of information they convey:
(14.1)
(14.2)
where p(xi and xj ) means that xi occurred in the rst trial and xj occurred
in the second. This additivity requirement for the amount of information conveyed by the occurrence of independent events is formally stated in terms of the
information function as
(iv) I(xi and xj ) = I(xi ) + I(xj )
when the events xi and xj are independent.
On combining the additivity in (iv) with the three conditions (i)(iii), there is
one (and only one) possibility for I(xi ):
1
= log(p(xi )).
I(xi ) = log
(14.3)
p(xi )
Coding
307
It is easy to see that (i)(iii) are fullled, and (iv) follows from the properties of
the log (recall that log(ab) = log(a) + log(b)). Therefore,
1
1
I(xi and xj ) = log
= log
p(xi and xj )
p(xi )p(xj )
1
1
+ log
= log
p(xi )
p(xj )
= I(xi ) + I(xj ).
The base of the logarithm can be any (positive) number. The most common
choice is base 2, in which case the measurement of information is called bits.
Unless otherwise stated explicitly, all logs in this chapter are assumed to be
base 2.
Example 14.1. Suppose there are N = 3 symbols in the alphabet, which are
transmitted with probabilities p(x1 ) = 1/2, p(x2 ) = 1/4, and p(x3 ) = 1/4. Then
the information conveyed by receiving x1 is 1 bit, since
1
= log(2) = 1.
I(x1 ) = log
p(x1 )
Similarly, the information conveyed by receiving either x2 or x3 is I(x2 ) =
I(x3 ) = log(4) = 2 bits.
308
14.2
Redundancy
All the examples in the previous section presume that there is no relationship
between successive symbols. (This was the independence assumption in (14.2).)
This section shows by example that real messages often have signicant correlation between symbols, which is a kind of redundancy. Consider the following
sentence from Shannons paper A Mathematical Theory of Communication:
It is clear, however, that by sending the
information in a redundant form the
probability of errors can be reduced.
This sentence contains 20 words and 115 characters, including the commas,
period, and spaces. It can be coded into the 8-bit binary ASCII character
set recognized by computers as the text format, which translates the character string (that is readable by humans) into a binary string containing 920
(= 8 115) bits.
Coding
309
Suppose that Shannons sentence is transmitted, but that errors occur so that
1% of the bits are ipped from one to zero (or from zero to one). Then about
3.5% of the letters have errors:
It is clea2, however, that by sendhng the
information in a redundaNt form the
probabilipy of errors can be reduced.
The message is comprehensible, although it appears to have been typed poorly.
With 2% bit error, about 7% of the letters have errors:
It is clear, howaver, thad by sending the
information in a redundan4 form phe
prkbability of errors cAf be reduced.
Still the underlying meaning is decipherable. A dedicated reader can often decipher text with up to about 3% bit error (10% symbol error). Thus, the message
has been conveyed, despite the presence of the errors. The reader, with an extensive familiarity with English words, sentences, and syntax, is able to recognize
the presence of the errors and to correct them.
As the bit error rate grows to 10%, about one third of the letters have errors,
and many words have become incomprehensible. Because space is represented
as an ASCII character just like all the other symbols, errors can transform spaces
into letters or letters into spaces, thus blurring the true boundaries between the
words.
Wt is ahear, h/wav3p, dhat by sending phc
)hformatIon if a rEdundaft fnre thd
prkba@)hity ob erropc can be reduaed.
With 20% bit error, about half of the letters have errors and the message is
completely illegible:
I4 "s Cdrq h+Ae&d"( (At by sjdafd th$
hfFoPmati/. )f a p(d5jdan fLbe thd
rab!DITy o& drkp1 aa& bE rd@u!ed.
These examples were all generated using the following Matlab program
redundant.m which takes the text textm, translates it into a binary string, and
then causes per percent of the bits to be ipped. The program then gathers
statistics on the resulting numbers of bit errors and symbol errors (how many
letters were changed).
Listing 14.1. redundant.m redundancy of written english in bits and letters
textm= It is clear , however , that by sending the ...
310
Exercise 14.5. Read in a large text le using the following Matlab code. (Use
one of your own or use one of the included text les.)2 Make a plot of the symbol
error rate as a function of the bit error rate by running redundant.m for a variety
of values of per. Examine the resulting text. At what value of per does the text
become unreadable? What is the corresponding symbol error rate?
Listing 14.2. readtext.m read in a text document and translate to character string
[ f i d , m e s s a g e i ] = fopen ( OZ . txt , r ) ;
f d a t a=fread ( f i d ) ;
text=c h a r ( f d a t a ) ;
% f i l e must be t e x t
% r ea d t e x t a s a v e c t o r
% to c h a r a c t e r s t r i n g
Through the Looking Glass by Lewis Carroll (carroll.txt) and The Wonderful Wizard of Oz
by Frank Baum (OZ.txt) are available on the website.
A more optimistic rendering of this sentence: Computers do not yet deal readily with meaning.
Coding
311
dent. How good an assumption is this for English text? It is a poor assumption.
As the preceding examples suggest, normal English is highly correlated.
It is easy to catalog the frequency of occurrence of the letters. The letter e
is the most common. In Frank Baums Wizard of Oz, for instance, e appears
20,345 times and t appears 14,811 times, but the letters q and x appear
only 131 and 139 times, respectively (z might be a bit more common in Baums
book than normal because of the title). The percentage occurrence for each letter
in the Wizard of Oz is
a
b
c
d
e
f
g
6.47
1.09
1.77
4.19
10.29
1.61
1.60
h
i
j
k
l
m
n
5.75
4.63
0.08
0.90
3.42
1.78
4.90
o
p
q
r
s
t
u
6.49
1.01
0.07
4.71
4.51
7.49
2.05
v
w
x
y
z
0.59
2.49
0.07
1.91
0.13
(14.4)
Space is the most frequent character, occurring 20% of the time. It was easier
to use the following Matlab code, in conjunction with readtext.m, than to
count the letters by hand.
Listing 14.3. freqtext.m frequency of occurrence of letters in text
l i t t l e =length ( find ( t e x t s t r i n g==t ) ) ;
b i g=length ( find ( t e x t s t r i n g==T ) ) ;
f r e q =( l i t t l e +b i g )/ length ( t e x t s t r i n g )
% how many t i m e s t o c c u r s
% how many t i m e s T o c c u r s
% percentage
312
Observe that most of the two-letter combinations are actual words, as well as
many three-letter words. Longer sets of symbols tend to wander improbably.
While, in principle, it would be possible to continue gathering probabilities of all
three-letter combinations, then four, etc., the table begins to get rather large (a
matrix with 26n elements would be needed to store all the n-letter probabilities).
Shannon5 suggests another way:
. . . one opens a book at random and selects a letter on the page. This letter is recorded.
The book is then opened to another page, and one reads until this letter is encountered.
The succeeding letter is then recorded. Turning to another page, this second letter is
searched for, and the succeeding letter recorded, etc.
Of course, Shannon did not have access to Matlab when he was writing in
1948. If he had, he might have written a program like textsim.m, which allows
specication of any text (with the default being The Wizard of Oz) and any number of terms for the probabilities. For instance, with m=1, the letters are chosen
completely independently; with m=2, the letters are chosen from successive pairs;
and with m=3, they are chosen from successive triplets. Thus, the probabilities
of clusters of letters are dened implicitly by the choice of the source text.
Listing 14.4. textsim.m use (large) text to simulate transition probabilities
m=1;
l i n e l e n g t h =60;
load OZ . mat
n=text ( 1 :m) ; n l i n e=n ; n l e t=x ;
f o r i =1:100
j =1;
while j <l i n e l e n g t h | n l e t =
k=f i n d s t r ( text , n ) ;
i n d=round ( ( length ( k ) 1) * rand )+1;
n l e t=text ( k ( i n d )+m) ;
i f abs ( n l e t )==13
n l e t= ;
end
n l i n e =[ n l i n e , n l e t ] ;
n=[n ( 2 :m) , n l e t ] ;
j=j +1;
end
disp ( [ n l i n e s e t s t r ( 1 3 ) ] )
n l i n e= ;
end
%
%
%
%
%
# terms f o r t r a n s i t i o n
# l e t t e r s i n each l i n e
f i l e f o r input
i n i t i a l i z e variables
# l i n e s i n o u tp u t
% s c a n th r o u g h f i l e
% a l l occurrences of seed
% p i c k one
% treat carriage returns
% as s p aces
% add n e x t l e t t e r
% new s e e d
% f o r m a t o u t p u t / add CRs
% i n i t i a l i z e next l i n e
Typical output of textsim.m depends heavily on the number of terms m used for
the transition probabilities. With m=1 or m=2, the results appear much as above.
When m=3,
Be end claime armed yes a bigged wenty for me
fearabbag girl Humagine ther mightmarkling the
5
Coding
313
Exercise 14.6. Run the program textsim.m using the input le carroll.mat,
which contains the text to Lewis Carrolls Through the Looking Glass, with m =
1, 2, . . ., 8. At what point does the output repeat large phrases from the input
text?
Exercise 14.7. Run the program textsim.m using the input le foreign.mat,
which contains a book that is not in English. Looking at the output for various
m, can you tell what language the input is? What is the smallest m (if any) at
which it becomes obvious?
The following two problems might not appeal to everyone.
Exercise 14.8. The program textsim.m operates at the level of letters and the
probabilities of transition between successive sets of m-length letter sequences.
Write an analogous program that operates at the level of words and the probabilities of transition between successive sets of m-length word sequences. Does
your program generate plausible-sounding phrases or sentences?
314
Coding
315
that seek to optimize performance. Section 14.5 will explore some practical ways
to attack this problem, but the next two sections establish a measure of performance such that it is possible to know how close to the optimal any given code
lies.
14.3
Entropy
This section extends the concept of information from a single symbol to a
sequence of symbols. As dened by Shannon,6 the information in a symbol is
inversely proportional to its probability of occurring. Since messages are composed of sequences of symbols, it is important to be able to talk concretely about
the average ow of information. This is called the entropy and is formally dened
as
H(x) =
N
p(xi )I(xi )
i=1
N
p(xi ) log
i=1
N
1
p(xi )
(14.5)
i=1
where the symbols are drawn from an alphabet xi , each with probability p(xi ).
H(x) sums the information in each symbol, weighted by the probability of that
symbol. Those familiar with probability and random variables will recognize
this as an expectation. Entropy7 is measured in bits per symbol, and so gives
a measure of the average amount of information transmitted by the symbols of
the source. Sources with dierent symbol sets and dierent probabilities have
dierent entropies. When the probabilities are known, the denition is easy to
apply.
Example 14.3. Consider the N = 3 symbol set dened in Example 14.1. The
entropy is
H(x) =
6
7
1
1
1
1 + 2 + 2 = 1.5 bits/symbol.
2
4
4
Actually, Hartley was the rst to use this as a measure of information in his 1928 paper in
the Bell System Technical Journal called Transmission of Information.
Warning: though the word is the same, this is not the same as the notion of entropy that is
familiar from physics since the units here are in bits per symbol while the units in physics
are energy per degree Kelvin.
316
Exercise 14.10. Reconsider the fair die of Exercise 14.1. What is its entropy?
1
1
1
1
2 + 2 + 2 + 2 = 2 bits/symbol.
4
4
4
4
In Example 14.4, messages of the same length from the rst source give less
information than those from the second source. Hence, sources with the same
number of symbols but dierent probabilities can have dierent entropies. The
key is to design a system to maximize entropy since this will have the largest
throughput, or largest average ow of information. But how can this be achieved?
First, consider the simple case in which there are two symbols in the alphabet,
x1 with probability p, and x2 with probability 1 p. (Think of a coin that is
weighted so as to give heads with higher probability than tails.) Applying the
denition (14.5) shows that the entropy is
H(x) =
Coding
317
H(p)
0.8
0.6
0.4
0.2
0
0.1
0.2
0.3
0.7
0.8
0.9
N
p(xi ) log
i=1
=
since
N
i=1
N
p(xi ) log
i=1
1
p(xi )
1
p(xi )
log(N )
N
p(xi ) log(N ),
i=1
and changing the base of the logarithm (using log(z) log2 (z) = log2 (e) ln(z),
where ln(z) loge (z)), gives
N
1
p(xi ) ln
H(x) log(N ) = log(e)
.
N p(xi )
i=1
If all symbols
are equally likely, p(xi ) = 1/N , then 1/(N p(xi )) = 1 and
1
=
ln(1)
= 0. Hence H(x) = log(N ). On the other hand, if the symln N p(x
i)
bols are not equally likely, then the inequality ln(z) z 1 (which holds for
z 0) implies that
N
1
1
N p(xi )
i=1
$N
%
N
1
= log(e)
p(xi )
N
i=1
i=1
p(xi )
= log(e) [1 1] = 0.
(14.6)
Rearranging (14.6) gives the desired bound on the entropy, namely that H(x)
log(N ). This says that, all else being equal, it is preferable to choose a code
318
in which each symbol occurs with the same probability. Indeed, Example 14.5
provides a concrete source for which the equal-probability case has higher entropy
than the unequal-probability case.
Section 14.2 showed how letters in the text of natural languages do not occur
with equal probability. Thus, naively using the letters will not lead to an ecient transmission. Rather, the letters must be carefully translated into equally
probable symbols in order to increase the entropy. A method for accomplishing
this translation is given in Section 14.5, but Section 14.4 examines the limits of
attainable performance when transmitting symbols across a noisy (but otherwise
perfect) channel.
14.4
Channel Capacity
Section 14.1 showed how much information (measured in bits) is contained in
a given symbol, and Section 14.3 generalized this to the average amount of
information contained in a sequence or set of symbols (measured in bits per
symbol). In order to be useful in a communication system, however, the data must
move from one place to another. What is the maximum amount of information
that can pass through a channel in a given amount of time? The main result of
this section is that the capacity of the channel denes the maximum possible ow
of information through the channel. The capacity is a function of the bandwidth
of the channel and of the amount of noise in the system, and it is measured in
bits per second.
If the data are encoded using N = 2 equally probable bits per symbol, and if
the symbols are independent, the entropy is H2 = 0.5 log(2) + 0.5 log(2) = 1 bit
per symbol. Why not increase the number of bits per symbol? This would allow
representing more information. On doubling to N = 4, the entropy increases to
H4 = 2. In general, when using N bits, the entropy is HN = log(N ). By increasing N without bound, the entropy can be increased without bound! But is it
really possible to send an innite amount of information?
When doubling the size of N , one of two things must happen. Either the distance between the levels must decrease, or the power must increase. For instance,
it is common to represent the binary signal as 1 and the four-level signal as
1, 3. In this representation, the distance between neighboring values is constant, but the power in the signal has increased. Recall that the power in a
discrete signal x[k] is
T
1 2
lim
x [k].
T T
k=1
For a binary signal with equal probabilities, this is P2 = 12 (12 + (1)2 ) = 1. The
four-level signal has power P4 = 14 (12 + (1)2 + 32 + (3)2 ) = 5. To normalize
the power to unity for the four-level signal, calculate the value x such that
Coding
319
Amplitude
1
0.5
0
0.5
1
1.5
2
2-level signal 4-level signal 8-level signal 16-level signal
*
+ (x)2 + (3x)2 + (3x)2 ) = 1, which is x = 1/5. Figure 14.3 shows how
the values of the N -level signal become closer together as N increases, when the
power is held constant.
Now it will be clearer why it is not really possible to send an innite amount
of information in a single symbol. For a given transmitter power, the amplitudes
become closer together for large N , and the sensitivity to noise increases. Thus,
when there is noise (and some is inevitable), the four-level signal is more prone to
errors than the two-level signal. Said another way, a higher signal-to-noise ratio8
(SNR) is needed to maintain the same probability of error in the four-level signal
as in the two-level signal.
Consider the situation in terms of the bandwidth required to transmit a given
set of data containing M bits of information. From the Nyquist sampling theorem of Section 6.1, data can be sent through a channel of bandwidth B at a
maximum rate of 2B symbols per second. If these symbols are coded into two
levels, then M symbols must be sent. If the data are transmitted with four levels
(by assigning pairs of binary digits to each four-level symbol), then only M/2
symbols are required. Thus the multilevel signal can operate at half the symbol
rate of the binary signal. Said another way, the four-level signal requires only
half the bandwidth of the two-level signal.
The previous two paragraphs show the trade-o between SNR and bandwidth.
To maintain the same probability of error, larger bandwidth allows smaller SNR;
larger SNR allows the use of a narrower frequency band. Quantifying this tradeo was one of Shannons greatest contributions.
While the details of a formal proof of the channel capacity are complex, the
result is believable when thought of in terms of the relationship between the
1
2
4 (x
As the term suggests, SNR is the ratio of the energy (or power) in the signal to the energy
(or power) in the noise.
320
distance between the levels in a source alphabet and the average amount of
noise that the system can tolerate. A digital signal with N levels has a maximum
information rate C = log(N )/T , where T is the time interval between transmitted
symbols. C is the capacity of the channel, and has units of bits per second.
This can be expressed in terms of the bandwidth B of the channel by recalling
Nyquists sampling theorem, which says that a maximum of 2B pulses per second
can pass through the channel. Thus the capacity can be rewritten
C = 2B log(N ) bits per second.
To include the eect of noise, observe that the power of the received signal is
S + P (where S is the power of the signal and P is the power
of the noise).
Accordingly, the average amplitude of the received signal is S + P and the
average amplitude of the noise is P. The average distance d between levels
is twice the
average amplitude divided by the number of levels (minus one),
and so d = 2 S + P/(N 1). Many errors will occur in the transmission unless
the distance between the signal levels is separated by at least twice the average
amplitude of the noise, that is, unless
2 S +P
> 2 P.
d=
N 1
= B log 1 +
(14.7)
C = 2B log
P
P
bits per second.
Observe that, if either the bandwidth or the SNR is increased, so is the channel capacity. For white noise, as the bandwidth increases, the power in the noise
increases, the SNR decreases, and so the channel capacity does not become innite. For a xed channel capacity, it is easy to trade o bandwidth against SNR.
For example, suppose a capacity of 1000 bits per second is required. Using a
bandwidth of 1 kHz, we nd that the signal and the noise can be of equal power.
As the allowed bandwidth is decreased, the ratio S/P increases rapidly:
Bandwidth
1000
500
250
125
100
Hz
Hz
Hz
Hz
Hz
S/P
1
3
15
255
1023
Shannons result can now be stated succinctly. Suppose that there is a source
producing information at a rate of R bits per second and a channel of capacity
C. If R < C (where C is dened as in (14.7)) then there exists a way to represent
Coding
321
(or code) the data so that it can be transmitted with arbitrarily small error.
Otherwise, the probability of error is strictly positive.
This is tantalizing and frustrating at the same time. The channel capacity
denes the ultimate goal beyond which transmission systems cannot go, yet it
provides no recipe for how to achieve the goal. The next sections describe various
methods of representing or coding the data that assist in approaching this limit
in practice.
The following Matlab program explores a noisy system. A sequence of fourlevel data is generated by calling the pam.m routine. Noise is then added with
power specied by p, and the number of errors caused by this amount of noise
is calculated in err.
Listing 14.5. noisychan.m generate 4-level data and add noise
m=1000;
p =1/15; s = 1 . 0 ;
x=pam (m, 4 , s ) ;
L=sqrt ( 1 / 5 ) ;
n=sqrt ( p ) * randn ( 1 ,m) ;
y=x+n ;
qy=q u a n t a l p h ( y , [ 3 * L, L , L , 3 * L ] ) ;
e r r=sum( abs ( sign ( qy x ) ) ) /m;
%
%
%
%
%
%
%
%
l e n g t h o f data s e q u e n c e
power o f n o i s e and s i g n a l
4PAM i n p u t with power 1 . . .
. . . with amp l e v e l s L
n o i s e with power p
o u t p u t adds n o i s e to data
q u a n t i z e to [ 3 * L, L , L , 3 * L ]
percent transmission er r or s
Typical outputs of noisychan.m are shown in Figure 14.4. Each plot shows the
input sequence (the four solid horizontal lines), the input plus the noise (the cloud
of small dots), and the error between the input and quantized output (the dark
stars). Thus the dark stars that are not at zero represent errors in transmission.
The noise P in the right-hand case is the maximum noise allowable in the
plausibility argument used to derive (14.7), which relates the average amplitudes
of the signal plus the noise to the number of levels in the signal. For S = 1 (the
same conditions as in Exercise 14.12(a)), the noise was chosento be independent
1
Amplitude
322
2000 4000
1/6 max noise
2000 4000
1/3 max noise
2000 4000
max noise
Figure 14.4 Each plot shows a four-level PAM signal (the four solid lines), the signal
plus noise (the scattered dots), and the error between the data and the quantized
output
stars). The noise in the right-hand plot was at the Shannon limit
(the dark
N S + P / P , the noise in the middle plot was at one-third the power, and the
noise in the left-hand plot was at one-sixth the power.
Coding
323
noise. When symbols encounter anything less than the average noise, then all is
well, since the average distance between levels is greater than the average noise.
But errors occur when symbols encounter more than the average amount of noise.
(This is why there are so many errors in the right-hand plot of Figure 14.4.) Good
coding schemes try to ensure that all symbols experience (roughly) the average
noise. This can be accomplished by grouping the symbols into clusters or blocks
that distribute the noise evenly among all the symbols in the block. Such error
coding is discussed in Section 14.6.
14.5
Source Coding
The results from Section 14.3 suggest that, all else being equal, it is preferable to
choose a code in which each symbol occurs with the same probability. But what if
the symbols occur with widely varying frequencies? Recall that this was shown
in Section 14.2 for English and other natural languages. There are two basic
approaches. The rst aggregates the letters into clusters, and provides a new
(longer) code word for each cluster. If properly chosen, the new code words can
occur with roughly the same probability. The second approach uses variablelength code words, assigning short codes to common letters like e and long
codes to infrequent letters like x. Perhaps the most common variable-length
code was that devised by Morse for telegraph operators, which used a sequence
of dots and dashes (along with silences of various lengths) to represent the
letters of the alphabet.
Before discussing how source codes can be constructed, consider an example
using the N = 4 code from Example 14.4(a) in which p(x1 ) = 0.5, p(x2 ) = 0.25,
and p(x3 ) = p(x4 ) = 0.125. As shown earlier, the entropy of this source is 1.75
bits/symbol, which means that there must be some way of coding the source so
that, on average, 1.75 bits are used for each symbol. The naive approach to this
source would use 2 bits for each symbol, perhaps assigning
x1 11, x2 10, x3 01, and x4 00.
(14.8)
An alternative representation is
x1 1, x2 01, x3 001, and x4 000,
(14.9)
where more-probable symbols use fewer bits, and less-probable symbols require
more. For instance, the string
x1 , x2 , x1 , x4 , x3 , x1 , x1 , x2
(in which each element appears with the expected frequency) is coded as
10110000011101.
This requires 14 bits to represent the eight symbols. The average is 14/8 = 1.75
bits per symbol, so this coding is as good as possible, since it equals the entropy.
324
In contrast, the naive code of (14.8) requires 16 bits to represent the eight symbols for an average of 2 bits per symbol. One feature of the variable-length
code in (14.9) is that there is never any ambiguity about where it starts,
since any occurrence of a 1 corresponds to the end of a symbol. The naive
code requires knowledge of where the rst symbol begins. For example, the
string 01 10 11 00 1 is very dierent from 0 11 01 10 01 even
though they contain the same bits in the same order. Codes for which the
start and end are immediately recognizable are called instantaneous or prex
codes.
Since the entropy denes the smallest number of bits that can be used to
encode a source, it can be used to dene the eciency of a code
eciency =
entropy
.
average # of bits per symbol
(14.10)
Thus the eciency of the naive code (14.8) is 1.75/2 = 0.875 while the eciency of the variable-rate code (14.9) is 1. Shannons source coding theorem
says that, if an independent source has entropy H, then there exists a prex code in which the average number of bits per symbol is between H and
H + 1. Moreover, there is no uniquely decodable code that has smaller average length. Thus, if N symbols (each with entropy H) are compressed into
fewer than N H bits, information is lost, while information need not be lost
if N (H + 1) bits are used. Shannon has dened the goal towards which all
codes aspire, but provides no way of nding good codes for any particular
case.
Fortunately, D. A. Human proposed an organized procedure to build variablelength codes that are as ecient as possible. Given a set of symbols and their
probabilities, the procedure is as follows.
1. List the symbols in order of decreasing probability. These are the original
nodes.
2. Find the two nodes with the smallest probabilities, and combine them into
one new node, with probability equal to the sum of the two. Connect the new
nodes to the old ones with branches (lines).
3. Continue combining the pairs of nodes with the smallest probabilities. (If
there are ties, pick any of the tied symbols.)
4. Place a 0 or a 1 along each branch. The path from the rightmost node to the
original symbol denes a binary list, which is the code word for that symbol.
This procedure is probably easiest to understand by working through an example.
Consider again the rst N = 4 code from Example 14.4 in which the symbols have
probabilities p(x1 ) = 0.5, p(x2 ) = 0.25, and p(x3 ) = p(x4 ) = 0.125. Following the
foregoing procedure leads to the chart shown in Figure 14.5. In the rst step, x3
and x4 are combined to form a new node with probability equal to 0.25 (the sum
p(x3 ) + p(x4 )). Then this new node is combined with x2 to form a new node with
probability 0.5. Finally, this is combined with x1 to form the rightmost node.
Coding
Symbol
Probability
x1
0.5
x2
x3
x4
1
0
1
0
0.25
0.125
325
1
0
0.5
0.25
0.125
Each branch is now labeled. The convention used in Figure 14.5 is to place a 1
on the top and a 0 on the bottom (assigning the binary digits in another order
just relabels the code). The Human code for this source can be read from the
chart. Reading from the right-hand side, x1 corresponds to 1, x2 to 01, x3 to
001, and x4 to 000. This is the same code as in (14.9).
The Human procedure with a consistent branch-labeling convention always
leads to a prex code because all the symbols end the same (except for the
maximal-length symbol x4 ). More importantly, it always leads to a code that
has average length very near the optimal.
Exercise 14.16. Consider the source with N = 5 symbols with probabilities
p(x1 ) = 1/16, p(x2 ) = 1/8, p(x3 ) = 1/4, p(x4 ) = 1/16, and p(x5 ) = 1/2.
a. What is the entropy of this source?
b. Build the Human chart.
c. Show that the Human code is
x1 0001, x2 001, x3 01, x4 0000, and x5 1.
d. What is the eciency of this code?
e. If this source were encoded naively, how many bits per symbol would be
needed? What is the eciency?
Exercise 14.17. Consider the source with N = 4 symbols with probabilities
p(x1 ) = 0.3, p(x2 ) = 0.3, p(x3 ) = 0.2, and p(x4 ) = 0.2.
a.
b.
c.
d.
Exercise 14.18. Build the Human chart for the source dened by the 26
English letters (plus space) and their frequency in the Wizard of Oz as given
in (14.4).
326
cx ( j
cx ( j
cx ( j
cx ( j
)=[1];
: j +1)=[0 ,1];
: j +2)=[0 ,0 ,1];
: j +2)=[0 ,0 ,0];
j=j +1;
j=j +2;
j=j +3;
j=j +3;
The third step carries out the decoding. Assuming the encoding and decoding
have been done properly, cx is transformed into the output y, which should be
the same as the original sequence x.
Listing 14.7. codex.m step 3: decode the variable-length sequence
j =1; i =1;
y=[];
while i<=length ( cx )
i f cx ( i : i ) = = [ 1 ] , . . .
y ( j )=+1; i=i +1; j=j +1;
e l s e i f cx ( i : i + 1 ) = = [ 0 , 1 ] , . . .
y ( j )= 1; i=i +2; j=j +1;
e l s e i f cx ( i : i + 2 ) = = [ 0 , 0 , 1 ] , . . .
y ( j )=+3; i=i +3; j=j +1;
e l s e i f cx ( i : i + 2 ) = = [ 0 , 0 , 0 ] , . . .
y ( j )= 3; i=i +3; j=j +1; end
end
Indeed, running the program codex.m (which contains all three steps) gives a
perfect decoding.
Exercise 14.19. Mimicking the code in codex.m, create a Human encoder and
decoder for the source dened in Example 14.16.
Exercise 14.20. Use codex.m to investigate what happens when the probabilities of the source alphabet change.
Coding
327
a. Modify step 1 of the program so that the elements of the input sequence have
probabilities
x1 0.1, x2 0.1, x3 0.1, and x4 0.7.
(14.11)
b. Without changing the Human encoding to account for these changed probabilities, compare the average length of the coded data vector cx with the
average length of the naive encoder (14.8). Which does a better job compressing the data?
c. Modify the program so that the elements of the input sequence all have the
same probability, and answer the same question.
d. Build the Human chart for the probabilities dened in (14.11).
e. Implement this new Human code and compare the average length of the
coded data cx with the previous results. Which does a better job compressing
the data?
Exercise 14.21. Using codex.m, implement the Human code from Exercise 14.18. What is the length of the resulting data when applied to the text
of the Wizard of Oz? What rate of data compression has been achieved?
Source coding is used to reduce the redundancy in the original data. If the
letters in the Wizard of Oz were independent, then the Human coding in Exercise 14.21 would be optimal: no other coding method could achieve a better compression ratio. But the letters are not independent. More sophisticated schemes
would consider not just the raw probabilities of the letters, but the probabilities
of pairs of letters, or of triplets, or more. As suggested by the redundancy studies in Section 14.2, there is a lot that can be gained by exploiting higher-order
relationships between the symbols.
Exercise 14.22. Zipped les (usually with a .zip extension) are a popular
form of data compression for text (and other data) on the web. Download a
handful of .zip les. Note the le size when the le is in its compressed form and
the le size after decompressing (unzipping) the le. How does this compare
with the compression ratio achieved in Exercise 14.21?
Exercise 14.23. Using the routine writetext.m (this le, which can be found
on the website, uses the Matlab command fwrite), write the Wizard of Oz
text to a le OZ.doc. Use a compression routine (uuencode on a Unix or Linux
machine, zip on a Windows machine, or stut on a Mac) to compress OZ.doc.
Note the le size when the le is in its compressed form, and the le size after
decompressing. How does this compare with the compression ratio achieved in
Exercise 14.21?
328
14.6
Channel Coding
The job of channel or error-correcting codes is to add some redundancy to a
signal before it is transmitted so that it becomes possible to detect when errors
have occurred and to correct them, when possible.
Perhaps the simplest technique is to send each bit three times. Thus, in order
to transmit a 0, the sequence 000 is sent. In order to transmit a 1, 111 is sent.
This is the encoder. At the receiver, there must be a decoder. There are eight
possible sequences that can be received, and a majority-rules decoder assigns
000 0
101 1
001 0
110 1
010 0
011 1
100 0
111 1.
(14.12)
This encoder/decoder can identify and correct any isolated single error and so
the transmission has smaller probability of error. For instance, assuming no more
than one error per block, if 101 was received, then the error must have occurred
in the middle bit, whereas if 110 was received, then the error must have been
in the third bit. But the majority-rules coding scheme is costly: three times the
number of symbols must be transmitted, which reduces the bit rate by a factor of
three. Over the years, many alternative schemes have been designed to reduce the
probability of error in the transmission without incurring such a heavy penalty.
Linear block codes are popular because they are easy to design, easy to implement, and have a number of useful properties. With n > k, an (n, k) linear
code operates on sets of k symbols, and transmits a length-n code word for each
set. Each code is dened by two matrices: the k by n generator matrix G, and
the n k by n parity-check matrix H. In outline, the operation of the code is
as follows.
1. Collect k symbols into a vector x = {x1 , x2 , . . . , xk }.
2. Transmit the length-n code word c = xG.
3. At the receiver, the vector y is received. Calculate yH T .
4. If yH T = 0, then no errors have occurred.
5. When yH T = 0, errors have occurred. Look up yH T in a table of syndromes, which contains a list of all possible received values and the most
likely code word to have been transmitted, given the error that occurred.
6. Translate the corrected code word back into the vector x.
The simplest way to understand this is to work through an example in detail.
14.6.1
Coding
329
+
0
1
0
0
1
0
1
1
1
0
0
0
0
1
0
1
1
0
HT =
1
0
0
01
1 1
0 0
.
1 0
(14.14)
01
This code bundles the bits into pairs, and the four corresponding code words are
x1 = 00 c1 = x1 G = 00000,
x2 = 01 c2 = x2 G = 01011,
x3 = 10 c3 = x3 G = 10101,
and
x4 = 11 c4 = x4 G = 11110.
There is one subtlety. The arithmetic used in the calculation of the code words
(and indeed throughout the linear-block-code method) is not standard. Because
the input source is binary, the arithmetic is also binary. Binary addition and
multiplication are shown in Table 14.1. The operations of binary arithmetic may
be more familiar as exclusive OR (binary addition) and logical AND (binary
multiplication).
In eect, at the end of every calculation, the answer is taken modulo 2. For
instance, in standard arithmetic, x4 G = 11112. The correct code word c4 is
found by reducing each calculation modulo 2. In Matlab, this is done with
mod(x4*g,2), where x4=[1,1] and g is dened as in (14.13). In modulo 2 arithmetic, 1 represents any odd number and 0 represents any even number. This is
also true for negative numbers so that, for instance, 1 = +1 and 4 = 0.
After transmission, the received signal y is multiplied by H T . If there were no
errors in transmission, then y is equal to one of the four code words ci . With H
dened as in (14.14), c1 H T = c2 H T = c3 H T = c4 H T = 0, where the arithmetic
is binary, and where 0 means the zero vector of size 1 by 3 (in general, 1 by
(n k)). Thus yH T = 0 and the received signal is one of the code words.
However, when there are errors, yH T = 0, and the value can be used to determine the most likely error to have occurred. To see how this works, rewrite
y = c + (y c) c + e,
330
Table 14.2. Syndrome table for the binary (5, 2) code with generator matrix (14.13) and
parity-check matrix (14.14)
Syndrome eH T
000
001
010
011
100
101
110
111
where e represents the error(s) that have occurred in the transmission. Note that
yH T = (c + e)H T = cH T + eH T = eH T ,
since cH T = 0. The value of eH T is used by looking in the syndrome table,
Table 14.2. For example, suppose that the symbol x2 = 01 is transmitted using
the code c2 = 01011. But an error occurs in transmission so that y = 11011 is
received. Multiplication by the parity-check matrix gives yH T = eH T = 101.
Looking this up in the syndrome table shows that the most likely error was
10000. Accordingly, the most likely code word to have been transmitted was
y e = 11011 10000 = 01011, which is indeed the correct code word c2 .
On the other hand, if more than one error occurred in a single symbol, then the
(5, 2) code cannot necessarily nd the correct code word. For example, suppose
that the symbol x2 = 01 is transmitted using the code c2 = 01011 but that two
errors occur in transmission so that y = 00111 is received. Multiplication by the
parity-check matrix gives yH T = eH T = 111. Looking this up in the syndrome
table shows that the most likely error was 10010. Accordingly, the most likely
symbol to have been transmitted was y e = 00111 + 10010 = 10101, which is
the code word c3 corresponding to the symbol x3 , and not c2 .
The syndrome table can be built as follows. First, take each possible single
error pattern, that is, each of the n = 5 es with exactly one 1, and calculate eH T
for each. As long as the columns of H are nonzero and distinct, each error pattern
corresponds to a dierent syndrome. To ll out the remainder of the table, take
each of the possible double errors (each of the es with exactly two 1s) and
calculate eH T . Pick two that correspond to the remaining unused syndromes.
Since there are many more possible double errors n(n 1) = 20 than there are
syndromes (2nk = 8), these are beyond the ability of the code to correct.
The Matlab program blockcode52.m shows details of how this encoding and
decoding proceeds. The rst part denes the relevant parameters of the (5, 2)
binary linear block code: the generator g, the parity-check matrix h, and the
Coding
331
syndrome table syn. The rows of syn are ordered so that the binary digits of
eH T can be used to directly index into the table.
Listing 14.8. blockcode52.m part 1: denition of (5, 2) binary linear block code, the
generator and parity-check matrices
g =[1 0 1 0 1 ;
0 1 0 1 1];
h=[1 0 1 0 0 ;
0 1 0 1 0;
1 1 0 0 1];
% th e f o u r code words cw=x * g (mod 2 )
x ( 1 , : ) = [ 0 0 ] ; cw ( 1 , : ) =mod ( x ( 1 , : ) * g , 2 ) ;
x ( 2 , : ) = [ 0 1 ] ; cw ( 2 , : ) =mod ( x ( 2 , : ) * g , 2 ) ;
x ( 3 , : ) = [ 1 0 ] ; cw ( 3 , : ) =mod ( x ( 3 , : ) * g , 2 ) ;
x ( 4 , : ) = [ 1 1 ] ; cw ( 4 , : ) =mod ( x ( 4 , : ) * g , 2 ) ;
% th e syndrome t a b l e
syn =[0 0 0 0 0 ;
0 0 0 0 1;
0 0 0 1 0;
0 1 0 0 0;
0 0 1 0 0;
1 0 0 0 0;
1 1 0 0 0;
1 0 0 1 0];
The second part carries out the encoding and decoding. The variable p species
the chance that bit errors will occur in the transmission. The code words c are
constructed using the generator matrix. The received signal is multiplied by the
parity-check matrix h to give the syndrome, which is then used as an index into
the syndrome table (matrix) syn. The resulting most likely error is subtracted
from the received signal, and this is the corrected code word that is translated
back into the message. Because the code is linear, code words can be translated
back into the message using an inverse matrix9 and there is no need to store
all the code words. This becomes important when there are millions of possible
code words, but when there are only four it is not crucial. The translation is
done in blockcode52.m in the for j loop by searching.
Listing 14.9. blockcode52.m part 2: encoding and decoding data
p=.1;
m=10000;
dat = 0 . 5 * ( sign ( rand ( 1 ,m) 0 . 5 ) + 1 ) ;
f o r i = 1 : 2 :m
c=mod ( [ dat ( i ) dat ( i + 1 )] * g , 2 ) ;
f o r j =1: length ( c )
i f rand<p , c ( j )=c ( j )+1; end
end
y=c ;
eh=mod ( y * h , 2 ) ;
e h i n d=eh (1) * 4+ eh (2) * 2+ eh ( 3 ) + 1 ;
e=syn ( ehind , : ) ;
y=mod ( ye , 2 ) ;
9
% pr obabi l i ty of bit f l i p
% l e n g t h o f message
% m random 0 s and 1 s
% b u i l d codeword
% flip
%
%
%
%
%
b i t s with prob p
received signal
m u l t i p l y by p a r i t y c h e c k h
tu r n syndrome i n t o i n d e x
e r r o r from syndrome t a b l e
add e to c o r r e c t e r r o r s
332
f o r j =1:max( s i z e ( x ) )
% g e t message from codewords
i f y==cw ( j , : ) , z ( i : i +1)=x ( j , : ) ; end
end
end
e r r=sum( abs ( zdat ) )
% how many e r r o r s o c c u r r e d
Running blockcode52.m with the default parameters of 10% bit errors and
length m=10000 will give about 400 errors, a rate of about 4%. Actually, as
will be shown in the next section, the performance of this code is slightly better
than these numbers suggest, because it is also capable of detecting certain errors
that it cannot correct, and this feature is not implemented in blockcode52.m.
Exercise 14.24. Use blockcode52.m to investigate the performance of the
binary (5, 2) code. Let p take on a variety of values p = 0.001, 0.01, 0.02, 0.05,
0.1, 0.2, and 0.5 and plot the percentage of errors as a function of the percentage
of bits ipped.
Exercise 14.25. This exercise compares the performance of the (5, 2) block
code in a more realistic setting and provides a good warm-up exercise for the
receiver to be built in Chapter 15. The program nocode52.m (all Matlab les are
available on the website) provides a template with which you can add the block
coding into a real transmitter and receiver pair. Observe, in particular, that
the block coding is placed after the translation of the text into binary but before
the translation into 4-PAM (for transmission). For eciency, the text is encoded
using text2bin.m (recall Example 8.2). At the receiver, the process is reversed:
the raw 4-PAM data are translated into binary, then decoded using the (5, 2)
block decoder, and nally translated back into text (using bin2text.m) where
you can read it. Your task in this problem is to experimentally verify the gains
possible when using the (5, 2) code. First, merge the programs blockcode52.m
and nocode52.m. Measure the number of errors that occur as noise is increased
(the variable varnoise scales the noise). Make a plot of the number of errors
as the variance increases. Compare this with the number of errors that occur as
the variance increases when no coding is used (i.e., running nocode52.m without
modication).
Exercise 14.26. Use the matrix ginv=[1 1;1 0 ;0 0;1 0;0 1]; to replace
the for j loop in blockcode52.m. Observe that this reverses the eect of constructing the code words from the x since cw*ginv=x (mod 2).
Exercise 14.27. Implement the simple majority-rules code described in (14.12).
a. Plot the percentage of errors after coding as a function of the number of
symbol errors.
b. Compare the performance of the majority-rules code to the (5, 2) block code.
c. Compare the data rate required by the majority-rules code with that required
by the (5, 2) code and with the naive (no coding) case.
Coding
14.6.2
333
Example 14.5. The code words of the (5, 2) binary code are 00000, 01011, 10101,
and 11110, which are assigned to the four input pairs 00, 01, 10, and 11, respectively. The Hamming distance10 between any two elements in C is equal to the
number of places in which they disagree. For instance, the distance between 00000
and 01011 is 3, which is written d(00000, 01011) = 3. The distance between 1001
and 1011 is d(1001, 1011) = 1. The minimum distance of a code C is the smallest
distance between any two code words. In symbols,
dmin = min d(ci , cj ),
i=j
where ci C.
Exercise 14.28. Show that the minimum distance of the (5, 2) binary linear
block code is dmin = 3.
Exercise 14.29. Write down all code words for the majority-rules code (14.12).
What is the minimum distance of this code?
Exercise 14.30. A code C has four elements {0000, 0101, 1010, 1111}. What
is the minimum distance of this code?
Let Di (t) be the decoding sets of all possible received signals that are less
than t away from ci . For instance, the majority-rules code has two code words,
and hence two decoding sets. With t = 1, these are
D1 (1) = {000, 001, 100, 010},
D2 (1) = {111, 110, 011, 101}.
10
(14.15)
Named after R. Hamming, who also created the Hamming blip as a windowing function.
Software Receiver Design adopted the blip in previous chapters as a convenient pulse
shape.
334
When any of the elements in D1 (1) are received, the code word c1 = 0 is used;
when any of the elements in D2 (1) are received, the code word c2 = 1 is used.
For t = 0, the decoding sets are
D1 (0) = {000} and D2 (0) = {111}.
(14.16)
In this case, when 000 is received, c1 is used; when 111 is received, c2 is used.
When the received bits are in neither of the Di , an error is detected, though it
cannot be corrected. When t > 1, the Di (t) are not disjoint and hence cannot be
used for decoding.
Exercise 14.31. What are the t = 0 decoding sets for the four-element code in
Exercise 14.30? Are the t = 1 decoding sets disjoint?
Exercise 14.32. Write down all possible disjoint decoding sets for the (5, 2)
linear binary block code.
One use of decoding sets lies in their relationship with dmin . If 2t < dmin , then
the decoding sets are disjoint. Suppose that the code word ci is transmitted over
a channel, but that c (which is obtained by changing at most t components of ci )
is received. Then c still belongs to the correct decoding set Di , and is correctly
decoded. This is an error-correction code that handles up to t errors.
Now suppose that the decoding sets are disjoint with 2t + s < dmin , but that
t < d(c, ci ) t + s. Then c is not a member of any decoding set. Such an error
cannot be corrected by the code, though it is detected. The following example
shows how the ability to detect errors and the ability to correct them can be
traded o.
Example 14.6. Consider again the majority-rules code C with two elements
{000, 111}. This code has dmin = 3 and can be used as follows.
1. t = 1, s = 0. In this mode, using decoding sets (14.15), code words could suer
any single error and still be correctly decoded. But, if two errors occurred,
the message would be incorrect.
2. t = 0, s = 2. In this mode, using decoding sets (14.16), the code word could
suer up to two errors and the error would be detected, but there would be
no way to correct it with certainty.
Example 14.7. Consider the code C with two elements {0000000, 1111111}.
Then, dmin = 7. This code can be used in the following ways.
1. t = 3, s = 0. In this mode, the code word could suer up to three errors and
still be correctly decoded. But, if four errors occurred, the message would be
incorrect.
Coding
335
Syndrome
eH T
0000
0001
0010
0100
1000
1101
1011
0111
0011
0110
1100
0101
1010
1001
1110
1111
Most likely
error e
0000000
0000001
0000010
0000100
0001000
0010000
0100000
1000000
0000011
0000110
0001100
0011000
0001010
0010100
0111000
0010010
336
was noted in the discussion of the (5, 2) code of the previous section. Moreover,
nding the minimum distance of a linear code is also easy, since dmin is equal
to the smallest number of nonzero coordinates in any code word (not counting
the zero code word). Thus dmin can be calculated directly from the denition
by nding the distances between all the code words, or by nding the code word
that has the smallest number of 1s. For instance, in the (5, 2) code, the two
elements 01011 and 10101 each have exactly three nonzero terms.
14.6.3
(14.17)
P
[Ik |P ] = 0,
(14.18)
Ink
where the 0 is the k by n k matrix of all zeros. Hence, dene H = [P |Ink ].
Observe that the (5, 2) code is of this form, since in binary arithmetic 1 = +1
and so P = P .
1000111
G = 0 1 0 1 0 1 1
0011101
and parity-check matrix
0 1
1 0
1 1
T
H =
1 0
0 1
0 0
0 0
1 1
1 1
0 1
.
0 0
0 0
1 0
0 1
The syndrome Table 14.3 is built by calculating which error pattern is most likely
(i.e., has the fewest bits ipped) for each given syndrome eH T . This code has
dmin = 4, and hence the code can correct any 1-bit errors, 7 (out of 21) possible
2-bit errors, and 1 of the many 3-bit errors.
Coding
337
+
0
1
2
3
4
0
0
1
2
3
4
1
1
2
3
4
0
2
2
3
4
0
1
3
3
4
0
1
2
4
4
0
1
2
3
0
1
2
3
4
0
0
0
0
0
0
1
0
1
2
3
4
2
0
2
4
1
3
3
0
3
1
4
2
4
0
4
3
2
1
Exercise 14.33. Using the code from blockcode52.m, implement the binary
(7, 3) linear block code. Compare its performance and eciency with the (5, 2)
code and the majority-rules code.
a. For each code, plot the percentage p of bit ips in the channel versus the
percentage of bit ips in the decoded output.
b. For each code, what is the average number of bits transmitted for each bit in
the message?
Sometimes, when the source alphabet is not binary, the elements of the code
words are also not binary. In this case, using the binary arithmetic of Table 14.1 is
inappropriate. For example, consider a source alphabet with ve symbols labeled
0, 1, 2, 3, 4. Arithmetic operations for these elements are addition and multiplication modulo 5, which are dened in Table 14.4. These can be implemented
in Matlab using the mod function. For some source alphabets, the appropriate
arithmetic operations are not modulo operations, and in these cases, it is normal
to simply dene the desired operations via tables like Tables 14.1 and 14.4.
Example 14.9. A (6, 4) code using a q = 5-element source alphabet has generator
matrix
100044
0 1 0 0 4 3
G=
0 0 1 0 4 2
000141
and parity-check matrix
1
4 4
4 3 1
4 2 1
T
H =
=
4 1 1
1 0 1
0
0 1
1
2
3
,
4
0
1
338
Table 14.5. Syndrome table for the q = 5 source alphabet (6, 4) code
Syndrome
eH T
00
01
10
14
13
12
11
02
20
23
21
24
22
03
30
32
34
31
33
04
40
41
42
43
44
Most likely
error e
000000
000001
000010
000100
001000
010000
100000
000002
000020
000200
002000
020000
200000
000003
000030
000300
003000
030000
300000
000004
000040
000400
004000
040000
400000
Coding
339
14.7
340
Music
A/D
CIRC
Encoder
ReedSolomon
Linear Block Codes
MUX
EFM
"Eight-to-Fourteen Module"
MUX
"Synchronization"
1.41 Mbps
1.88 Mbps
1.92 Mbps
4.32 Mbps
Optical media
into two separate codes so that an interleaver can be used between them. This
spreads out the information over a larger range and helps to spread out the errors
(making them easier to detect and/or correct).
The encoding process on the CD is completely specied, but each manufacturer
can implement the decoding as they wish. Accordingly, there are many choices.
For instance, the ReedSolomon codes can be used to correct two errors each,
or to detect up to ve errors. When errors are detected, a common strategy is
to interpolate the audio, which may be transparent to the listener as long as the
error rate is not too high. Manufacturers may also choose to mute the audio when
the error rate is too high. For data purposes, the controller can also ask that the
data be reread. This may allow correction of the error when it was caused by
mistracking or some other transitory phenomenon, but will not be eective if the
cause is a defect in the medium.
r C. E. Shannon, A Mathematical Theory of Communication, The Bell System Technical Journal, vol. 27, pp. 379423 and 623656, July and October,
1948.
The projects of Chapters 15 and 16 integrate all the xes of the fourth step
into the receiver structure of the third step to create fully functional digital
receivers. The well-fabricated receiver is robust with respect to distortions such
as those caused by noise, multipath interference, timing inaccuracies, and clock
mismatches.
After building the components, testing them, assembling them into a receiver,
and testing the full design, your receiver is ready. Congratulations. You have
earned the degree of Master of Digital Radio. You are now ready to conquer the
world!
Master
of
l
Digita
Radio
____
_____
_____ me here
a
n
your
15 Make It So
343
Make It So
15.1
Text
message Character Bits
Coding
to binary
conversion
Symbols
Scaling
si
Trigger
Baseband
signal
Pulse
shape
Transmitted
passband
signal
Modulation
Adjacent
users
Channel
Broadband
noise
Analog
received
signal
includes periodic i Tt + t
marker and training
sequence
Analog
received
signal
Bandpass
filter
Downconversion
to IF
Automatic
gain
control
Sampled
received
signal
the receiver.
kTs
344
+3
+1
1
3
(15.1)
as in Example 8.1. Thus, if there are n letters, there are 7n (uncoded) bits, 7n( 52 )
coded bits, and 7n( 25 )( 12 ) 4-PAM symbols. These mappings are familiar from Section 8.1, and are easy to use with the help of the Matlab functions bin2text.m
and text2bin.m. Exercise 14.25 provides several hints to help implement the M6
encoding, and the Matlab function nocode52.m outlines the necessary transformations from the original text into a sequence of 4-PAM symbols s[i].
In order to decode the message at the receiver, the recovered symbols must
be properly grouped and the start of each group must be located. To aid this
frame synchronization, a marker sequence is inserted into the symbol stream at
the start of every block of 100 letters (at the start of every 875 symbols). The
header/training sequence that starts each frame is given by the phrase
A0Oh well whatever Nevermind
(15.2)
which codes into 245 4-PAM symbols and is assumed to be known at the receiver.
This marker text string can be used as a training sequence by the adaptive
equalizer. The unknown message begins immediately after each training segment.
Thus, the M6 symbol stream is a coded message periodically interrupted by the
same marker/training clump.
As indicated in Figure 15.1, pulses are initiated at intervals of Tt seconds,
and each is scaled by the 4-PAM symbol value. This translates the discretetime symbol sequence s[i] (composed of the coded message interleaved with the
marker/training segments) into a continuous-time signal
s[i](t iTt t ).
s(t) =
i
Make It So
345
1, 3
2 MHz
6.4 s
[0.1, 0.3]
204 kHz
8 clock periods
See (15.2)
1120 symbols
Filtered white noise
Fixed, < 0.01%
Fixed
Fixed, < 0.01%
Max. delay spread = 7 symbols
850 kHz
The channel may be near ideal (i.e., a unit gain multisymbol delay) or it may
have signicant intersymbol interference. In either case, the impulse response of
the channel is unknown at the receiver, though an upper bound on its delay
spread may be available. There are also disturbances that may occur during the
transmission. These may be wideband noise with at power spectral density or
they may be narrowband interferers, or both. They are unknown at the receiver.
The achieved intermediate frequency is required to be within 0.01% of its
assigned value. The carrier phase (t) is unknown to the receiver and may vary
over time, albeit slowly. This means that the phase of the intermediate-frequency
signal presented to the receiver sampler may also vary.
The bandpass lter before the downconverter in the front end of the receiver
in Figure 15.2 partially attenuates adjacent 204-kHz-wide FDM user bands. The
automatic gain control is presumed locked and xed over each transmission.
The free-running sampler frequency of 850 kHz is well above twice the 102 kHz
baseband bandwidth of the user of interest. This is necessary for the baseband
analog signal interpolator used in the timer in the DSP portion of the receiver
in Figure 15.3. However, the sampler frequency is not above twice the highest
frequency of the IF signal. This means that the sampled received signal has
replicated the spectrum at the output of the front end analog downconverter
lowpass lter to frequencies between zero and IF.
15.2
346
Sampled
received
signal
Downconversion
Matched
filter
Carrier
recovery
Interpolator
downsampler
Timing
recovery
Adaptive layer
Equalizer
Training
segment
locator
Equalizer
adaptation
Decision
device
Recovered
source
Decoder
Frame
synchronization
1. Choose the order in which the basic operations of the receiver occur.
2. Select components and methods that can perform the basic operations in an
ideal setting.
3. Select adaptive elements that allow the receiver to continue functioning when
there are impairments.
4. Verify that the performance requirements are met.
While it may seem as though each stage requires that choices made in the preceding stages be xed, in reality, diculties encountered at one stage in the design
process may require a return to (and dierent choices to be made in) earlier
stages. As will soon become clear, the M6 problem specication has basically
(pre)resolved the design issues of the rst two stages.
15.2.1
If this sounds like a challenge, rest assured it is. Research continues worldwide, making
compilation of a complete handbook of receiver designs and algorithms a Sisyphean task.
The creation of new algorithms with minor variations that exploit a particular applicationspecic circumstance is a popular pastime of communication engineers. Perhaps you too will
come up with a unique approach!
Make It So
347
15.2.2
For instance, the company might have a patent on a particular method of timing recovery
and using any other method might require royalty payments.
For instance, in the QAM radio of A Digital Quadrature Amplitude Modulation Radio, available in the website, the blocks appear in a dierent order.
Indeed, changing parameters such as this allows an instructor to create new transmission
standards for each class!
348
xed lowpass lter in the downconverter and the xed matched lter preceding
the interpolator/downsampler) can be conrmed by simulations of the ISI-free
ideal/full-knowledge setting. Thus, the upper half of Figure 15.3 is specied by
stage-two activities.
15.2.3
15.2.4
Make It So
349
long as the sum of all the partial errors does not exceed the maximum allowable
error, there is a good chance that the complete receiver will work according to
its specications.
The approach is to choose a method of measuring the amount of error, for
instance, the average of the squared recovery error. Each individual component
can be assigned a threshold, and its parameters can be adjusted so that it does
not contribute more than its share to the total error. Assuming that the accumulation of the errors from various sources is additive, the complete receiver
will have no larger error than the concatenation of all its parts. This additivity
assumption is eectively an assumption that the individual pieces of the system
do not interact with each other. If they do (or when they do), then the threshold
allotments may need to be adjusted.
There are many factors that contribute to the recovery error, including the
following.
350
carrier phase, timing jitter, imperfections in the equalizer, tap jitter, and noise
gain. All of these are potentially present in the M6 software-dened digital radio.
In all of the cases in which error is due to the jiggling of the parameters in
adaptive elements (in the estimation of the sampling instants, the phase errors,
the equalizer taps), the errors are proportional to the stepsize used in the algorithm. Thus, the (asymptotic) recovery error can be made arbitrarily small by
reducing the appropriate stepsize. The problem is that, if the stepsize is too
small, the element takes longer to converge. If the time to convergence of the element is too long (for instance, longer than the complete message), then the error
is increased. Accordingly, there is some optimal stepsize that is large enough to
allow rapid convergence yet small enough to allow acceptable error. An analogous trade-o arises with the choice of the length of the equalizer. Increasing its
length reduces the size of the residual error. But as the length grows, so does the
amount of tap jitter.
Such trade-os are common in any engineering design task. The next section
suggests a method of quantifying the trade-os to help make concrete decisions.
15.2.5
Make It So
351
r Step 1: Tuning the Carrier Recovery As shown in Chapter 10, any of the
352
at its optimum answer; then average over all the test signals. The answer may
be aected by the various parameters of the algorithm: the that determines
the approximation to the derivative, the l parameter that species the time
support of the interpolation, and the stepsize (these variable names are from
the rst part of the timing-recovery algorithm clockrecDD.m on page 258.)
In operation, there may also be slight inaccuracies in the specication of the
clock period. When the clock period at the transmitter and that at the receiver
dier, the stepsize must be large enough that the timing estimates can follow
the changing period. (Recall the discussion surrounding Example 12.4.) Thus,
again, there is a tension between a large stepsize needed to track rapid changes
and a small stepsize to minimize the eect of the jitter on the mean squared
recovery error. In a more complex environment, in which clock phases might be
varying, it might be necessary to follow a procedure more like that considered
in step 1.
Step 3: Tuning the Equalizer After choosing the equalizer method (as specied
by the performance function), there are parameters that must be chosen and
decisions that must be made in order to implement the linear equalizer. These
are
the order of the equalizer (number of taps),
the initial values of the equalizer,
the training signal delay (if using the training signal), and
the stepsize.
As in the previous steps, it is a good idea to create a collection of test signals
using a simulation of the transmitter. To test the performance of the equalizer, the test signals should contain a variety of ISI channels and/or additive
interferences.
As suggested in Chapter 13, in a high-SNR scenario the T -spaced equalizer
tries to implement an approximation of the inverse of the ISI channel. If the
channel is mild, with all its roots well away from the unit circle, then its
inverse may be fairly short. But if the channel has zeros that are near the unit
circle, then its FIR inverse may need to be quite long. While much can be
said about this, a conservative guideline is that the equalizer should be from
two to ve times longer than the maximum anticipated channel delay spread.
One subtlety that arises in making this decision and in consequent testing is
that any channel ISI that is added into a simulation may appear dierently
at the receiver because of the sampling. This eect was discussed at length in
Section 13.1, where it was shown how the eective digital model of the channel
includes the timing oset. Thus (as mentioned in the previous step) assessing the actual channel to which the equalizer will adapt requires knowing
the timing oset that will be found by the timing recovery. Fortunately, in
the M6 receiver structure of Figure 15.3, the timing-recovery algorithm operates independently of the equalizer, and so the optimal value can be assessed
beforehand.
Make It So
353
For most of the adaptive equalizers in Chapter 13, the center-spike initialization is used. This was justied in Section 13.4 (see page 289) as a useful
method of initialization. Only if there is some concrete a priori knowledge of
the channel characteristics would other initializations be used.
The problem of nding an appropriate delay was discussed in Section 13.2.3,
where the least-squares solution was recomputed for each possible delay. The
delay with the smallest error was the best. In a real receiver, it will not be
possible to do an extensive search, and so it is necessary to pick some delay.
The M6 receiver uses correlation to locate the marker sequence and this can be
used to locate the time index corresponding to the rst training symbol. This
location plus half the length of the equalizer should correspond closely to the
desired delay. Of course, this value may change depending on the particular
ISI (and channel lengths) used in a given test signal. Choose a value that,
over the complete set of test signals, provides a reasonable answer.
The remaining designer-selected variable is stepsize. As with all adaptive
methods, there is a trade-o inherent in stepsize selection: making it too large
can result in excessive jitter or algorithm instability, while making it too small
can lead to an unacceptably long convergence time. A common technique is
to select the largest stepsize consistent with achievement of the components
assigned asymptotic performance threshold.
Step 4: Frame Synchronization Any error in locating the rst symbol of each
four-symbol block can completely garble the reconstructed text. The frame
synchronizer operates on the output of the quantizer, which should contain few
errors once the equalizer, timing recovery, and phase recovery have converged.
The success of frame synchronization relies on the peakiness of the correlation
of the marker/training sequence. The chosen marker/training sequence A0Oh
well whatever Nevermind should be long enough that there are few false
spikes when correlating to nd the start of the message within each block.
To test software written to locate the marker, feed it a sample symbol string
assembled according to the specications described in the previous section as
if the downconverter, clock timing, equalizer, and quantizer had recovered the
transmitted symbol sequence perfectly.
354
Exercise 15.2. The B 3IG transmitter can be used to implement the M6 transmission specications, as provided in m6params.m. Plot the received signal and
its spectrum. Use these plots to explain why your answers to Exercise 15.1 are
correct.
15.3
r
r
r
r
Make It So
355
r
r
r
r
rollo
initial
initial
initial
sion specication along with various impairments. This will enable you to test
your receiver (as described in the preceding section) over a wider range of
conditions than just the test signals available on the website.
Try to break your receiver. See how much noise can be present in the received
signal before accurate (e.g., less than 1% symbol errors) demodulation seems
impossible. Find the fastest change in the carrier phase that your receiver can
track, even with a bad initial guess.
In order to facilitate more eective debugging while building the project,
implementation of a debug mode in the receiver is recommended. The information of interest will be plots of the time histories of pertinent signals as well
as timing information (e.g., a graph of matched lter average output power
versus receiver symbol timing oset). One convenient way to add this feature
to your Matlab receiver would be to include a debug ag as an argument
that produces these plots when the ag is activated.
When debugging adaptive components, use a test with initialization at the
right answer and zero stepsize to determine whether the problem is in the
adaptation or in the xed component structure. An initialization very near
the desired answer with a small stepsize will reveal that the adaptive portion
is working properly if the adaptive parameter trajectory remains in the close
vicinity of the desired answer. A rapid divergence may indicate that the update
has the wrong sign or that the stepsize is way too large. An aimless wandering
that drifts away from the vicinity of the desired answer represents a more
subtle problem that requires reconsideration of the algorithm code and/or its
suitability for the circumstance at hand.
Several test les that contain a mystery signal with a quote from a
well-known book are available on the website. They are labeled easy.mat,
medium.mat, and hard.mat.5 These have been created with a variety of dierent
5
One student remarked that these should have been called hard.mat, harder.mat, and
completelyridiculous.mat. Nonetheless, a well-crafted M6 receiver can recover the hidden
messages.
356
rollo factors, carrier frequencies, phase noises, ISI, interferers, and symbol timing osets. We encourage the adventurous reader to try to receive these secret
signals. Solve the mystery. Break it down.
r B. Bing and N. Jayant, A Cellphone for All Standards, IEEE Spectrum, pp.
3439, May 2002.
The eld of software radio erupted with a special issue of the IEEE Communications Magazine in May 1995. This was called a landmark special issue in
an editorial in the more recent
r E. Buracchini, The Software Radio Concept, IEEE Communications Magazine, vol. 38, pp. 138143, September 2000
and papers from the (occasional) special section in the IEEE Communications
Magazine on topics in software and DSP in radio. For much more, see
r J. A. C. Bingham, The Theory and Practice of Modem Design, Wiley Interscience, 1988 (especially Chapter 5);
16.1
358
will a QAM radio. While the basic ideas of carrier recovery remain the same,
the details of the QAM protocol require changes in the operation of the adaptive
elements used to estimate the parameters. Similarly, the frequency of the carrier
at the transmitter and the frequency of the demodulating signal at the receiver
must be aligned. For example, Section 16.4.1 extends the Costas-loop idea to
4-QAM while Section 16.4.3 extends the PLL for 4-QAM.
Just as a PAM radio needs to align the sampling times and rates at the receiver
with the symbol times and rates, so will a QAM radio. While the basic ideas
of timing recovery remain the same, the details of the QAM protocol require
changes in the detailed operation of the adaptive elements. Section 16.6 extends
the timing-recovery methods of PAM in Chapter 12 to QAM.
Just as a PAM radio needs to build an equalizer to combat intersymbol interference, so will a QAM radio. While the basic ideas of equalization remain the
same as in Chapter 13, equalization of the two real signal streams of QAM is most
easily described in terms of a complex-valued adaptive equalizer as in Section
16.8.
An interesting feature of QAM is that the carrier recovery can be carried
out before the equalizer (as in Section 16.4) or after the equalizer. Such postequalization carrier recovery can be accomplished as in Section 16.7 by derotating
the complex-valued constellation at the output of the equalizer. This is just one
example of the remarkable variety of ways in which a QAM receiver can be
structured. Several dierent possible QAM constellations are discussed in Section
16.5 and several possible ways of ordering the receiver elements are drawn from
the technical literature in Section 16.9.
As is done throughout Software Receiver Design, exercises are structured
as mini-design exercises for individual pieces of the system. These pieces come
together at the end, with a description of (and Matlab code for) the Q3 AM
prototype receiver, which parallels the M6 receiver of Chapter 15, but for QAM.
A series of experiments with the Q3 AM receiver is intended to encourage exploration of a variety of alternative architectures for the radio. Exercises ask for
assessments of the practicality of the various extensions, and allow for experimentation, discovery, and perhaps even a small dose of frustration, as the importance of real-world impairments stresses the radio designs. The objective of this
chapter is to show the design process in action and to give the reader a feel for
how to generalize the original PAM system for new applications.
16.2
359
signals that are nonzero for frequencies between B and B while the spectrum
of the modulated signals is nonzero in the interval [fc B, fc + B] and in
the interval [fc B, fc + B]. Since bandwidth is a scarce resource, it would be
preferable to use a scheme such as quadrature modulation (QM, introduced in
Section 5.3), which provides a way to remove this redundancy. Since the spectrum
of the resulting signal is asymmetric in QM, such a system can be modeled using
complex-valued signals, though these can always be rewritten and realized as (a
pair of) real-valued signals.
As described in Equation (5.6) on page 91, QM sends two message signals
m1 (t) and m2 (t) simultaneously in the same 2B passband bandwidth using two
orthogonal carriers (cosine and sine) at the same frequency fc ,
v(t) = m1 (t) cos(2fc t + ) m2 (t) sin(2fc t + ).
(16.1)
is the xed oset of the carrier phase. Dene the complex-valued message
m(t) = m1 (t) + jm2 (t)
and the complex sinusoid ej(2fc t+) . Observe that the real part of the product
m(t)ej(2fc t+) = m1 (t) cos(2fc t + ) m2 (t) sin(2fc t + )
+ j[m2 (t) cos(2fc t + ) + m1 (t) sin(2fc t + )]
is precisely v(t) from (16.1), that is,
v(t) = Re{m(t)ej(2fc t+) },
(16.2)
where T is the interval between adjacent symbols and si [k], drawn from a nite
alphabet, is the ith message symbol at time k. The corresponding transmitted
signal is
v(t) =
p(t kT )[s1 [k] cos(2fc t + ) s2 [k] sin(2fc t + )]
k
= Re
#
p(t kT )s[k]e
j(2fc t+)
(16.4)
where
s[k] = s1 [k] + js2 [k]
is a complex-valued symbol obtained by combining the two real-valued messages.
The two data streams could arise from separate messages. For instance, one
user might send a binary 1 sequence s1 [k] while another user transmits a binary
360
11
s2
1
1
10
01
s1
1
1
(a)
00
01
s2
1
11
00
s1
1
1
10
(b)
1 sequence s2 [k]. Taken together, these can be thought of as the 4-QAM constellation 1 j. There are many ways in which two binary signals can be combined;
two are shown in Figure 16.1, which plots (s1 , s2 ) pairs in a two-dimensional plane
with s1 values on one axis and s2 values on the other.
Alternatively, the two messages could be a joint encoding of a single message. For example, a 1, 3 4-PAM coding could be recast as 4-QAM using an
assignment like
3 1 j
1 1 + j
+1 +1 j
+3 +1 + j
In either case, s1 [k] and s2 [k] are assumed to have zero average and to be uncorrelated so that their average product is zero.
The process of generating QAM signals such as (16.4) is demonstrated in
qamcompare.m, which draws on the PAM pulse-shaping routine pulrecsig.m
from page 194. qamcompare.m uses a simple Hamming pulse shape p(t) and random binary values for the messages s1 [k] and s2 [k]. The modulation is carried out
in two ways, with real sines and cosines (corresponding to the rst part of (16.4))
and with complex modulation (corresponding to the second part of (16.4)). The
two outputs can be compared by calculating max(abs(vcomp-vreal)), which
veries that the two are identical.
Listing 16.1. qamcompare.m compare real and complex QAM implementations
N=1000; M=20; Ts = . 0 0 0 1 ;
% # symbols , o v e r s a m p l i n g f a c t o r
time=Ts * (N*M 1 ) ; t =0: Ts : time ;
% s a m p l i n g i n t e r v a l and time
s 1=pam (N, 2 , 1 ) ; s 2=pam (N, 2 , 1 ) ;
% l e n g t h N r e a l 2 l e v e l s i g n a l s
ps=hamming (M) ;
% p u l s e shape o f width M
f c =1000; th = 1.0; j=sqrt ( 1 ) ;
% c a r r i e r f r e q and phase
s1up=zeros ( 1 ,N*M) ; s2up=zeros ( 1 ,N*M) ;
s1up ( 1 :M: end)= s 1 ;
% o v e r s a m p l e by M
s2up ( 1 :M: end)= s 2 ;
% o v e r s a m p l e by M
sp1=f i l t e r ( ps , 1 , s1up ) ;
% c o n v o l v e p u l s e shape with s 1
sp2=f i l t e r ( ps , 1 , s2up ) ;
% c o n v o l v e p u l s e shape with s 2
% make r e a l and complexv a l u e d v e r s i o n s and compare
v r e a l=sp1 . * cos (2 * pi * f c * t+th ) sp2 . * s i n (2 * pi * f c * t+th ) ;
vcomp = r e a l ( ( sp1+j * sp2 ) . * exp ( j * (2 * pi * f c * t+th ) ) ) ;
max( abs ( vcompv r e a l ) )
% v e r i f y t h a t they r e th e same
0000
0001
3
0100
0101
1
s2
0011
0010
0111
0110
1100
1
1101
1111
1110
1000
3
1001
1011
1010
361
s1
It is also possible to use larger QAM constellations. For example, Figure 16.2
shows a Gray-coded 16-QAM constellation that can be thought of as the set of
all possible s = s1 + js2 , where s1 and s2 take values in 1, 3. Various other
possibilities are discussed in Section 16.5.
The two message signals in QAM may also be built using a pulsed-phase
modulation (PPM) method rather than the pulsed-amplitude method described
above. Though they are implemented somewhat dierently, both can be written
in the same form as (16.4). A general PPM sequence can be written
p(t kT ) cos(2fc t + (t)),
(16.5)
v(t) = g
k
where g is a xed scaling gain and (t) is a time-varying phase signal dened by
the data to be transmitted. For example, a 4-PPM system might have
(t) = [k],
kT t < (k + 1)T,
(16.6)
where [k] is chosen from among the four possibilities /4, 3/4, 5/4, and
7/4. The four phase choices are associated with the four pairs 00, 10, 11, and
01 to convert from the bits of the message bits to the transmitted signal. This
particular phase modulation is sometimes called quadrature phase-shift keying
(QPSK) in the literature.
Using the cosine angle-sum formula (A.13),
cos(2fc t + (t)) = cos(2fc t) cos((t)) sin(2fc t) sin((t)).
With g = 2,
g cos([k]) = 1 and g sin([k]) = 1,
for all values of [k]. Hence
cos(2fc t + (t)) = cos(2fc t) sin(2fc t))
362
which is the same as (16.4) with si = 1 and with zero phase = 0. Thus, QPSK
and QAM are just dierent realizations of the same underlying process.
Exercise 16.1. Use qamcompare.m as a basis to implement a 4-PPM modulation.
Identify the values of si that correspond to the values of [k]. Demonstrate that
the two modulated signals are the same.
Exercise 16.2. Use qamcompare.m as a basis to implement a 16-QAM modulation as shown in Figure 16.2. Compare this system with 4-QAM in terms
of
a. amount of spectrum used, and
b. required power in the transmitted signal.
What other trade-os are made when moving from a 4-QAM to a 16-QAM
modulation scheme?
Exercise 16.3. Consider a complex-valued modulation system dened by
v(t) = Im{m(t)ej(2fc t+) },
where Im{a + jb} = b takes the imaginary part of its argument.
a. Find a modulation formula analogous to the left-hand side of (16.4) to show
that v(t) be implemented using only real-valued signals.
b. Demonstrate the operation of this imaginary modulation scheme in a simulation modeled on qamcompare.m.
Exercise 16.4. Consider the pulsed-phase modulation scheme in (16.5)
(16.6) with 16 elements, where the angle can take values = 2n/16 for
n = 0, 1, . . . , 15. How does this scheme dier from, and how is it similar to, the
16-QAM of Figure 16.2?
Exercise 16.5. In PAM, the data are modulated by a single sinusoid. In QAM,
two sets of data are modulated by a pair of sinusoids of the same frequency but
90 out of phase. Is it possible to build a communications protocol in which four
sets of data are modulated by four sinusoids 45 out of phase? If so, describe the
modulation procedure. If not, explain why not.
363
e j(2f0t+)
e j(2fct+)
m(t)
Re{ }
v(t)
x(t)
s(t)
LPF
Transmitter
Receiver
16.3
Demodulating QAM
Figure 5.10 on page 91 shows how a quadrature-modulated signal like (16.1) can
be demodulated using two mixers, one with a sin() and one with a cos(). The
underlying trigonometry (under the assumptions that the carrier frequency fc
is known exactly and that the phase term is zero) is written out in complete
detail in Section 5.3, and is also shown (in the context of nding the envelope
of a complex signal) in Appendix C. This section focuses on the more practical
case where there may be phase and frequency osets. The math is simplied by
using the complex-valued form where the received signal v(t) of (16.2) is mixed
with the complex sinusoid ej(2f0 t+) as in Figure 16.3.
Algebraically, this can be written
x(t) = ej(2f0 t+) v(t) = ej(2f0 t+) Re{m(t)ej(2fc t+) }
= ej(2f0 t+) (m1 (t) cos(2fc t + ) m2 (t) sin(2fc t + ))
=
ej()
(m1 (t)ej2(f0 +fc )t + m1 (t)ej2(f0 fc )t )
2
ej()
(m2 (t)ej2(f0 +fc )t + m2 (t)ej2(f0 fc )t ).
+j
2
Assuming fc f0 and that the cuto frequency of the LPF is less than 2fc (and
greater than fc ), the two high-frequency terms are removed by the LPF so that
s(t) = LPF{x(t)} =
=
ej()
(m1 (t)ej2(f0 fc )t + jm2 (t)ej2(f0 fc )t )
2
1 j2(f0 fc )t+j()
e
m(t),
2
(16.7)
where m(t) = m1 (t) + jm2 (t). When the demodulating frequency f0 is identical
to the modulating frequency fc and when the modulating phase is identical to
the demodulating phase , the output of the receiver s(t) is an attenuated copy
of the message m(t). The spectra of the various signals in the demodulation
process are shown in Figure 16.4. The transmitted signal v(t) is real-valued and
hence has a symmetric spectrum. This is shifted by the mixer so that one of the
(asymmetric) pieces of |X(f )| is near the origin and the other lies near 2fc.
The lowpass lter removes the high-frequency portion, leaving only the copy of
364
|V( f )|
|X( f )|
fc
2fc
fc
fc
|S( f )|
fc
fc
fc
Figure 16.3. Observe the asymmetry of the spectra |X(f )| and |S(f )|.
cos(2fct+)
cos(2f0t+)
m1(t)
x1(t)
LPF
s1(t)
Transmitter
m2(t)
sin(2fct+)
v(t)
Receiver
x2(t)
LPF
s2(t)
sin(2f0t+)
m(t) near the origin. Though the calculations use complex-valued signals, the
same procedure can be implemented purely with real signals as shown in Figure
16.5.
When f0 = fc but = , s(t) of (16.7) simplies to ej() m(t)/2. This can be
interpreted geometrically by observing that multiplication by a complex exponential ej is a rotation (in the complex plane) through an angle . In terms of
the pulsed data sequences s1 and s2 shown in Figures 16.1 and 16.2, the constellations become rotated about the origin through an angle given by . This
is the dierence between the actual and the estimated phase. In order to recover
the transmitted data properly (to deduce the correct sequence of symbols), it is
necessary to derotate s(t). This can be accomplished by estimating the unknown
values using techniques that are analogous to the phase-locked loop, the Costas
loop, and decision-directed methods, as will be discussed in Section 16.4. The
details will change in order to account for the dierences in the problem setting,
but the general techniques for carrier recovery will be familiar from the PAM
setting in Chapter 10.
When f0 = fc and = , the output of the demodulator in (16.7) is s(t) =
1
j2(f0 fc )t
. This is a time-varying rotation of the constellation: the points
2 m(t)e
s1 and s2 spin as a function of time at a rate proportional to the frequency
dierence between the carrier frequency fc and the estimate f0 . Again, it is
necessary to estimate this dierence using carrier-recovery techniques.
365
%
%
%
%
%
%
%
%
%
%
%
%
%
# symbols , o v er s a m p l e M
sampling times
s i g na l s of length N
p u l s e shape o f width M
c a r r i e r f r e q and phase
o v e r s a m p l e by M
c o n v o l v e p u l s e shape & data
complex c a r r i e r
f r e q and phase o f demod
demodulate v
s p e c i f y f i l t e r p a r a m e te r s
design f i l t e r
s=LPF{ x }
Exercise 16.6. qamdemod.m shows that when fc = f0 and = the reconstruction of the message is exact. The symbols in m can be recovered if the real and
imaginary parts of s are sampled at the correct time instants.
a. Find the correct timing oset tau so that s[k+tau] = m[k] for all k.
b. Examine the consequences of a phase oset. Let = 0 (th=0) and examine
the output when (ph) is 10 , 20 , 45 , 90 , 180 , and 270 . Explain what
you see in terms of (16.7).
c. Examine the consequences of a frequency oset. Let fc=1000, f0=1000.1, and
th=ph=0. What is the correct timing oset tau for this case? Is it possible to
reconstruct m from s? Explain what you see in terms of (16.7).
Exercise 16.7. Implement the demodulation shown in Figure 16.5 using realvalued sines and cosines to carry out the same task as in qamdemod.m. (Hint:
begin with vreal of qamcompare.m and ensure that the message can be recovered
without use of complex-valued signals.)
Exercise 16.8. Exercise 16.2 generates a 16-QAM signal. What needs to be
changed in qamdemod.m to successfully demodulate this 16-QAM signal?
Exercise 16.9. Design a complex-valued demodulation for the imaginary
method of Exercise 16.3. Show that the demodulation can also be carried out
using purely real signals.
366
ej(2f0t+)
v(t)
phase
splitter
x(t)
s(t)
16.4
367
16.4.1
(16.9)
368
(16.10)
= + (/2)
for integers , as desired. The objective is to adjust the receiver mixer phase (t)
so as to maximize JC . The result will be the correct phase or a 90 , 180 , or
270 rotation of .
The adaptive update to maximize JCQ is
JC
.
(16.11)
[k + 1] = [k] +
=[k]
In order to implement this, it is necessary to generate
JC
|=[k] ,
JC
= 2 sin(4 4).
which is
(16.12)
,
x3 (t) = LPF v(t) cos 2f0 t + +
2
3
.
x4 (t) = LPF v(t) cos 2f0 t + +
4
369
m2 (t)[sin( ) + sin(4fc t + + )]
1
[m1 (t) cos( ) m2 (t) sin( )].
2
Similarly,
1
[m1 (t) cos( /4) m2 (t) sin( /4)] ,
2
1
x3 (t) = [m1 (t) sin( ) + m2 (t) cos( )] ,
2
1
x4 (t) = [m1 (t) cos( 3/4) m2 (t) sin( 3/4)] .
2
Now form the product of the four xi (t)s and simplify to obtain
x2 (t) =
1
[4m1 (t)m2 (t)(m22 (t) m21 (t)) cos(4 4) (16.13)
128
(m41 (t) 6m21 (t)m22 (t) + m42 (t)) sin(4 4)].
For a pulse shape p(t) such as a rectangle or the Hamming blip that is timelimited to within one T -second symbol interval, p(t) = 0 for t < 0 or t > T .
Squaring both sides of the QAM pulse train (16.3) gives
m2i (t) =
s2i [k]p2 (t kT )
k
p2 (t kT ) (t)
for 4-QAM, where si [k] = 1 and (t) is some periodic function with period T .
Thus,
m21 (t) m22 (t) = 0,
m41 (t) = m42 (t) = m21 (t)m22 (t) = 2 (t).
Accordingly, the four-term product simplies to
x1 (t)x2 (t)x3 (t)x4 (t) = 42 (t) sin(4 4),
which is directly proportional to the desired derivative (16.12).
In this special case (where the pulse shape is time-limited to a single symbol
interval), of (16.11) becomes
[k + 1] = [k] + x1 (t)x2 (t)x3 (t)x4 (t) t=kTs ,=[k] ,
(16.14)
where Ts denes the time between successive updates (which is typically less
than the symbol period T ).
370
LPF
x1[k]
cos(2f0kTs +[k])
x2[k]
v(kTs)
LPF
x3[k]
[k]
x4[k]
371
Phase offset
4
0
0.2
0.4
0.6
Time
l p f 1=f l i p l r ( h ) * z1 ;
l p f 2=f l i p l r ( h ) * z2 ;
l p f 3=f l i p l r ( h ) * z3 ;
l p f 4=f l i p l r ( h ) * z4 ;
th ( k+1)= th ( k)+mu* l p f 1 * l p f 2 * l p f 3 * l p f 4 ;
end
%
%
%
%
%
output o f f i l t e r
output o f f i l t e r
output o f f i l t e r
output o f f i l t e r
a l g o r i t h m update
1
2
3
4
Exercise 16.16. How does the lter h inuence the performance of the Costas
loop?
2
Phase offset
372
6
0
0.2
0.4
0.6
Time
a. Try fl = 1000, 30, 10, 3. In each case, use freqz to verify that the lter has
been properly designed.
b. Remove the LPFs completely from costasloop.m. How does this aect the
convergent values? The tracking performance?
Exercise 16.17. What changes are needed to qamcostasloop.m to enable it to
function with 16-QAM? (Recall Exercises 16.2 and 16.8.)
Exercise 16.18. Exercise 10.21 shows an alternative implementation of the PAM
Costas loop that uses cheaper xed-phase oscillators rather than adjustablephase oscillators. Refer to Figure 10.12 on page 211. Design an analogous QAM
implementation and write a simulation (or modify qamcostasloop.m) to demonstrate its operation.
Exercise 16.19. Figure 16.10 shows a high-level block diagram of a dual-loop
system for tracking a frequency oset in a QAM system.
a. Draw a detailed block diagram labeling all signals and blocks. For comparison,
the PAM equivalent (using PLLs) is shown in Figure 10.18.
b. Implement the dual-loop frequency tracker and verify that small frequency
osets can be tracked. For comparison, the PAM equivalent is implemented
in dualplls.m on page 219.
c. How large can the frequency oset be before the tracking fails?
The previous discussion focused on the special case where the pulse shape is
limited to a single symbol interval. In fact, the same algorithm functions for more
v[k]
Carrier
Recovery
Carrier
Recovery
373
1[k]
2[k]
[k]
general pulse shapes. The key is to nd conditions under which the update term
(16.13) remains proportional to the derivative of the objective function (16.12).
The generic eect of any small-stepsize adaptive element like (16.14) is to
average the update term over time. Observe that the four-term product (16.13)
has two parts: one is proportional to cos(4 4) and the other is proportional
to sin(4 4). Two things must happen for the algorithm to work: the average
of the cos term must be zero and the average of the sin term must always have
the same sign. The average of the rst term is
avg{4m1 (t)m32 (t) 4m2 (t)m31 (t)}
while the average of the second is
avg{m41 (t) 6m21 (t)m22 (t) + m42 (t)}.
In QAM, the messages mi (t) are built as the product of the data si [k] and a
pulse shape as in (16.3). Even assuming that the average of the data values
is zero (which implies that the average of the messages is also zero), nding
these by hand for various pulse shapes is not easy. But they are straightforward
to nd numerically. The following program calculates the desired quantities by
averaging over N symbols. The default pulse shape is the Hamming blip, but
others can be tested by redening the variable unp=srrc(10,0.3,M,0) for a
square-root raised cosine pulse or unp=ones(1,M) for a rectangular pulse shape.
In all cases, the cosine term cterm is near zero while the sine term sterm is a
negative constant. Since the term appears in (16.13) with a negative sign, the
sine term is proportional to the derivative sin(4 4). Thus it is possible to
approximate all the terms that enter into the algorithm (16.14).
Listing 16.4. qamconstants.m calculate constants for avg{x1 x2 x3 x4}
N=2000; M=50;
% # o f symbols , o v er s a m p l e M
s 1=pam (N, 2 , 1 ) ; s 2=pam (N, 2 , 1 ) ;
% r e a l 2 l e v e l s i g n a l s
mup1=zeros ( 1 ,N*M) ; mup2=zeros ( 1 ,N*M) ;
mup1 ( 1 :M: end)= s 1 ;
% z e r o pad Ts p a c e d s e q u e n c e
mup2 ( 1 :M: end)= s 2 ;
% o v e r s a m p l e by M
unp=hamming (M) ;
% u n n o r m a l i z e d p u l s e shape
p=sqrt (M) * unp / sqrt (sum( unp . 2 ) ) ;
% n o r m a l i z e d p u l s e shape
m1=f i l t e r ( p , 1 , mup1 ) ;
% c o n v o l v e p u l s e shape & data
m2=f i l t e r ( p , 1 , mup2 ) ;
% c o n v o l v e p u l s e shape & data
sterm=sum( ( m1. 4 ) 6 * (m1 . 2 ) . * ( m2. 2 ) + (m2 . 4 ) ) / (N*M)
cterm=sum(4 * m1 . * m2.3 4 * m1 . 3 . * m2) / (N*M)
374
Exercise 16.20. Find a pulse shape p(t) and a set of symbol values s1 and s2
that will cause the QAM Costas loop to fail. Hint: nd values so that the average
of the sinusoidal term is near zero. Redo the simulation qamcostasloop.m with
these values and verify that the system does not achieve convergence.
Exercise 16.21. Suppose that si [k] are binary 1 and that avg{s1 [k]} =
avg{s2 [k]} = 0. The message sequences mi (t) are generated as in (16.3). Show
that avg{m1 (t)} = avg{m2 (t)} = 0 for any pulse shape p(t).
Exercise 16.22. Suppose that avg{m1 (t)} = avg{m2 (t)} = 0. Which of the
following are true?
a.
b.
c.
d.
e.
f.
16.4.2
375
16.4.3
376
lter (as in Figure 10.3 on page 197) passes a strong sinusoid at twice the frequency and twice the phase of the carrier. This double-frequency surrogate can
then be used as an input to a phase-locked loop for carrier recovery as in Section
10.3.
In QAM, the carrier is better hidden because it is generated as in (16.1) by
combining two dierent signals modulated by both sin() and cos() or, equivalently, by the real and imaginary parts of a complex modulating wave as in
(16.2). What kind of preprocessing can bring the carrier into the foreground?
An analogy with the processing in the Costas loop suggests using the fourth
power of the received signal. This will quadruple (rather than double) the frequency of the underlying carrier, and so the fourth power needs to be followed
by a narrow-bandpass lter centered at (about) four times the carrier frequency.
This quadruple-frequency surrogate can then be used as an input to a standard
phase-locked loop for carrier recovery.
The rst step is to verify that using the square really is futile. With v(t) dened
in (16.1), it is straightforward (though tedious) to show that
v 2 (t) =
1 2
[m (t) + m22 (t) + (m21 (t) m22 (t)) cos(4fc t + 2)
2 1
2m1 (t)m2 (t) sin(4fc t + 2)].
A bandpass lter with center frequency at 2fc removes the constant DC term,
and this cannot be used (as in PAM) to extract the carrier since avg{m21 (t)
m22 (t)} = avg{m1 (t)m2 (t)} = 0. Nothing is left after passing v 2 (t) through a
narrow-bandpass lter.
The fourth power of v(t) has three kinds of terms: DC terms, terms near
2fc , and terms near 4fc . All but the latter are removed by a BPF with center
frequency near 4fc . The remaining terms are
BPF{v 4 (t)} =
1
[4m1 (t)m2 (t)(m22 (t) m21 (t)) sin(8fc t + 4)
8
(m41 (t) 6m21 (t)m22 (t) + m42 (t)) cos(8fc t + 4)].
What is amazing about this equation is that the two terms 4m1 m2 (m22 m21 )
and m41 6m21 m22 + m42 are identical to the two terms in (16.13). Accordingly,
the former averages to zero while the latter has a nonzero average. Thus
BPF{v 4 (t)} cos(8fc t + 4)
and this signal can be used to identify (four times) the frequency and (four times)
the phase of the carrier.
In typical application, the carrier frequency is known only approximately, that
is, the BPF must use the center frequency f0 rather than fc itself. In order to
make sure that the lter passes the needed sinusoid, it is wise to make sure that
the bandwidth is not too narrrow. On the other hand, if the bandwidth of the
BPF is too wide, unwanted extraneous noises will also be passed. This tension
v(kTs)
X4
BPF
centered
at ~ 4fc
LPF
377
[k]
sin(8f0kTs +4[k])
Figure 16.11 The sampled QAM input v(kTs ) is raised to the fourth power and passed
through a BPF. This extracts a sinusoid with frequency 4fc and phase 4. A
standard PLL extracts 2 for use in carrier recovery.
suggests a design trade-o between the uncertainty in fc and the desire for a
narrow BPF.
Exercise 16.25. Generate a complex 4-QAM signal v(t) with phase shift as in
qamcompare.m. Imitate the code in pllpreprocess.m on page 196, but raise the
signal to the fourth power and choose the center frequency of the BPF to be 4fc.
Verify that the output is (approximately) a cos wave of the desired frequency
4fc and phase 4. This may be more obvious in the frequency domain.
Exercise 16.26. What happens on raising v(t) to the eighth power? Can this
be used to recover (eight times) the carrier frequency at (eight times) the phase?
Explain why or why not.
The output BPF{v4 (t)} of the preprocessor is presumed to be a sinusoid that
can be applied to a phase-tracking element such as the digital phase-locked loop
(PLL) from Section 10.3. The preprocessor plus PLL are shown in Figure 16.11,
which is the same as the PLL derived for PAM in Figure 10.7, except that it
must operate at 4fc (instead of 2fc ) and extract a phase equal to 4 (instead
of 2). Observe that this requires that the digital signal be sampled at a rate
sucient to operate at 4fc in order to avoid aliasing. In practice, such a rapid
sampling rate can be a tall order.
Though this section has focused on a fourth-power method of carrier recovery
for 4-QAM, the methods are also applicable to larger constellations such as 16QAM. The literature oers some encouraging comments. For instance, Anderson
(1999) on page 149 states:
When the . . . modulation is, for instance 16-QAM instead of QPSK, the PLL reference signal is not a steady cos(40 t + 40 ) and the phase dierence signal has other
components besides sin(40 40 ). Nonetheless, the synchronizer still works passably
well.
378
decisions and equalizer convergence that this forward-acting method oers outweighs
the problems of such a narrow-band PLL remains to be seen.
Exercise 16.27. Implement the 4-QAM PLL system shown in Figure 16.11.
Begin with the preprocessor from Exercise 16.25 and combine this with a modied version of pllconverge.m from page 204.
Exercise 16.28. What changes need to be made to the 4-QAM preprocessor of
Exercise 16.25 and the corresponding PLL of Exercise 16.27 in order to operate
with a 16-QAM constellation?
16.5
10
10
10
10
16-QAM
10
379
256-QAM
64-QAM
4-QAM
0
10
15
20
SNR in dB
25
30
r e a l e r r=q u a n ta l p h ( r e a l ( r ) , c o n s t )==q u a n ta l p h ( r e a l ( s ) , c o n s t ) ;
i m a g e r r=q u a n t a l p h ( imag( r ) , c o n s t )==q u a n ta l p h ( imag( s ) , c o n s t ) ;
SER=1mean( r e a l e r r . * i m a g e r r ) ;
% d e t e r m i n e SER by c o u n t i n g
a l l s e r s ( i )=SER ;
% # symbols w/ RE+IM c o r r e c t
end
When the percentage of errors is plotted against the SNR, the result is a
waterfall plot such as Figure 16.12. Large noises (small SNR) imply large
error rates while small noises cause few errors. Thus each constellation shows a
characteristic drop-o as the SNR increases. On the other hand, for a given SNR,
the constellations with the most widely distributed points have fewer errors.
For Gaussian noises (as generated by randn), soft errors in recovering the message pairs are circularly distributed about each constellation point. Accordingly,
it is wise to try to keep the points as far apart as possible, under the constraint
of equal power. Thus any four-point constellation should be a square in order to
avoid one pair of symbol errors becoming more likely.
The simulation qamser.m can be run with any noise distribution and with
any conceivable constellation. For regular QAM constellations and independent
Gaussian noise, there is a formula that predicts the theoretical shape of the
waterfall curve. Let a2 be the variance of the Gaussian noise and s2 the variance
of the symbol sequence. Proakis and Salehi (2002), on page 422, show that the
probability of an incorrect decision for an M -QAM system is
'%2
&
$
3s2
1
erfc
,
(16.15)
1 1 1
2(M 1)a2
M
where the erfc is the complementary error function (see help erfc in Matlab).
This formula is superimposed on the simulations for 4-, 16-, 64-, and 256-QAM
in Figure 16.12 and obviously agrees closely with the simulated results. This plot
was generated by the routine sersnr.m which is available on the website.
Of course, there is no need to restrict a constellation to a regular grid of points,
though rectangular grids will tend to have better noise rejection. For example,
380
a system designer could choose to omit the four corner points in a square QAM
constellation. This would reduce the signal power range over which analog electronics of the system must retain linearity. Nonsquare QAM constellations can
also be easier to synchronize, though they will tend to have higher SER (for
the same SNR) than square constellations because there is a smaller minimum
distance between points in constellations of the same total power. For example, Figure 16.13 shows an irregular constellation called the V.29 constellation.
Anderson (1999) comments on page 97 that the V.29 modem standard
has worse error performance in AWGN than does . . . [square] 16-QAM, but it is easier
to synchronize.
16.6
381
sampled signals are not unrelated to each other. Though the messages themselves
are typically considered to be uncorrelated, the two signals have been modulated
and demodulated simultaneously, and so they are tightly synchronized with each
other. A better approach is to adapt a single parameter that species when to
sample both signals.
The problem is approached by nding performance or objective functions that
have maxima (or minima) at the optimal point (i.e., at the correct sampling
instants). The performance functions are then used to dene adaptive elements
that iteratively estimate the correct sampling times. As usual in Software
Receiver Design, all other aspects of the system are presumed to operate
awlessly: the upconversions and downconversions are ideal, the pulse-matched
lters are well designed, there is no interference, and the channel is benign. Moreover, both baseband signals are assumed to occupy the same bandwidth and the
sampling is fast enough to avoid problems with aliasing.
The oversampled sequences are ltered by matched lters that correspond to
the pulse shape at the transmitter. The output of the matched lters is sent into
interpolators that extract the two baud-spaced sequences. When all goes well,
these can be decoded into the original messages s1 and s2 . For PAM signals as in
Chapter 12, the baud-timing rate can be found by optimizing the average of the
rst, second, or fourth power of the absolute values of the baud-spaced sequence
values. For some pulse shapes and powers, it is necessary to minimize, whereas
others require maximization.
The demodulated QAM signal contains two independent signals s1 and s2 with
the same timing oset, or, equivalently, it is a single complex-valued signal s. By
analogy with PAM, it is reasonable to consider optimizing the average of powers
of s, that is, to maximize or minimize
JQ ( ) = avg{(|s1 |p + |s2 |p )q }
(16.16)
%
%
%
%
n data p o i n t s , m+1 t a u s
p u l s e shape
matched f i l t e r
normalize
% f o r each o f f s e t
% c r e a t e 4QAM s e q u e n c e
% z e r o pad and upsample
382
(c)
(e)
(b)
(d)
(a)
0
0.2
0.4
0.6
Timing offset
0.8
[k + 1] = [k]
= [k]
= [k]
(m31 (kT + ) + m32 (kT + ))
(m1 (kT + ) + m2 (kT + ))
.
= [k]
383
384
Exercise 16.32. Mimic clockrecOP.m on page 262 to implement the timingrecovery algorithm for [k] using objective function (e).
a. Derive the adaptive-element update for objective function (a).
b. Implement the adaptive element for objective (a).
c. Choose stepsizes so that the two methods converge in approximately the
same number of iterations.
d. Add noise to the two methods. Which of the methods is more resilient to the
added noise?
Exercise 16.33. State a dispersion-based objective function for timing recovery
of QAM analogous to that in Figure 12.11.
a. Plot the value of the objective function against the timing oset .
b. Derive the corresponding adaptive element, i.e., the update equation for [k].
c. Implement the adaptive element (mimicking clockrecOP.m on page 262).
16.7
Baseband Derotation
Carrier recovery identies the phase and frequency dierences between the modulating sinusoids at the transmitter and the demodulating sinusoids at the
receiver. Standard approaches such as the PLL or Costas loop of Section 16.4
operate at passband, that is, the iteration that identies the phases and frequencies operates at the sampling rate of the receiver, which is typically higher
than the symbol rate.
As observed in Section 16.3, a phase oset can be pictured as a rotation of
the constellation and a frequency oset can be interpreted as a spinning of the
constellation diagram. Of course these are baseband diagrams, which show
the symbol values after the timing recovery has downsampled the signal to the
symbol rate. This suggests that it is also possible to approach carrier recovery
at baseband, by constructing an adaptive element that can derotate a skewed
constellation diagram. This section shows how carefully designed adaptive elements can derotate a QAM constellation. These are essentially single-parameter
equalizers that operate on the two real data streams by treating the signal and
equalizer as complex-valued quantities.
Bingham (1988), on page 231, motivates the post-equalization carrier-recovery
process for QAM:
A complex equalizer . . . can compensate for any demodulating carrier phase, but it
is easier to deal with frequency oset by using a separate circuit or algorithm that,
because it deals with only one variable, carrier phase, can move faster without causing
jitter.
385
s(t)
e j
r(t)
e j
x(t)
The situation is this: some kind of (passband) carrier recovery has been done,
but it is imperfect and a slow residual rotation of the constellation remains.
Binghams rst sentence observes that a complex-valued equalizer (such as those
detailed in Section 16.8) can accomplish the derotation at the same time that it
equalizes, by multiplying all of the (complex) equalizer coecients by the same
complex factor ej . But equalizers have many parameters: real-valued equalizers
such as those in Chapter 13 can have dozens (and some real-world equalizers
have hundreds) of parameters. It takes longer to adjust a dozen parameters than
to adjust one. A dozen parameters introduce more jitter than a single parameter.
Even worse, consider a situation where a multitap equalizer has adapted to
perfectly equalize a complex channel. If the carrier now begins to develop a
rotational oset, all of the coecients of the equalizer will move (multiplied by
the factor ej ). Thus all of the otherwise well-set equalizer gains move in order
to accomplish a task that could be dealt with by a single parameter (the value
of the rotation ). Never send a dozen parameters to do a job when one will do!
To see how this works, model the (downsampled) received signal as r(t) =
ej s(t), where represents the carrier phase oset. A one-tap equalizer
is the system ej as shown in Figure 16.15. Clearly, if the parameter can
be adjusted to be equal to the unknown , the carrier oset is corrected and
x(t) = s(t).
As in the design of any adaptive element, it is necessary to choose an objective
function. There are several possibilities, and the remainder of this section details
two: a decision-directed strategy and a dispersion-minimization strategy. At the
end of the day, the derotated signals x1 and x2 will be sampled and quantized
to give the hard decisions s1 = sign(x1 ) and s2 = sign(x2 ), which can be written
more compactly as s = sign(x) with s = s1 + j
s2 .
Consider as objective function the average of
JBD () = (1/2)(s x)(s x) ,
where the superscript indicates complex conjugation. An element that adapts
so as to minimize this objective is
(s x)(s x)
[k + 1] = [k]
.
2
=[k]
The objective can be rewritten
(s x)(s x) = (s1 x1 )2 + (s2 x2 )2
since the imaginary parts cancel out. Hence
x1
x2
JBD ()
= (s1 x1 )
(s2 x2 )
.
386
x2
= r2 sin() + r1 cos() = x1 .
Thus
JBD ()
= (s1 x1 )x2 (s2 x2 )x1 = s1 x2 s2 x1
(16.17)
which can be compared directly to Figure 16-6 in Barry, Lee, and Messerschmitt.
Implementation of (16.17) requires access to the signals s1 [k] and s2 [k]. This
can be accomplished using a training sequence, or more commonly by using a
decision-directed variation that replaces s1 [k] with s1 [k] and s2 [k] with s2 [k].
The adaptive derotator element can be examined in operation in
qamderotate.m, where the 4-QAM message is rotated by an angle -phi. After
the derotator, the x (and the hard decisions shat1 and shat2) restore the constellation to its proper orientation.
Listing 16.7. qamderotate.m derotate a complex-valued QAM signal
N=1000; j=sqrt ( 1 ) ;
% # symbols , time b a s e
s=pam (N, 2 , 1 ) + j * pam (N, 2 , 1 ) ;
% s i g na l s of length N
p h i = 0.1;
% a n g l e to r o t a t e
r=s . * exp( j * p h i ) ;
% rotation
mu= 0 . 0 1 ; t h e t a =0; t h e t a=zeros ( 1 ,N ) ;
% i n i t i a l i z e variables
f o r i =1:N1
% adapt th r o u g h a l l data
x=exp ( j * t h e t a ( i ) ) * r ( i ) ;
% x=r o t a t e d ( r )
x1=r e a l ( x ) ; x2=imag( x ) ;
% r e a l and i m a g i n a r y p a r t s
s h a t 1=sign ( x1 ) ; s h a t 2=sign ( x2 ) ;
% hard d e c i s i o n s
t h e t a ( i +1)= t h e t a ( i )mu* ( s h a t 1 * x2s h a t 2 * x1 ) ; % i t e r a t i o n
end
(16.18)
where is a real constant. This objective function can be viewed as the projection
onto the real axis of a rotated, but otherwise perfect, symbol constellation. Since
the real parts of the 4-QAM symbols cluster around 1, choosing = 1 allows
JDM () to be zero when = . For other constellations, JDM ()|= will, on
387
(16.19)
Exercise 16.34. Rewrite the system in Figure 16.15 in its real (implementable)
form by letting s(t) = s1 (t) + js2 (t) and ejz = cos(z) + j sin(z). Express x(t)
directly as a function of the real-valued signals s1 (t) and s2 (t). Show that =
implies x(t) = s(t).
Exercise 16.35. Reimplement the qamderotate.m routine without using any
complex numbers.
Exercise 16.36. Calculate the derivative of JDM () of (16.18) with respect to
, which is used to implement the algorithm (16.19).
Exercise 16.37. Implement the dispersion-minimization derotator by mimicking qamderotate.m.
Exercise 16.38. Formulate a DD derotator for use with 16-QAM. Implement
it in imitation of qamderotate.m. Is the convergence faster or slower than with
4-QAM?
Exercise 16.39. Formulate a dispersion-minimization derotator for use with
16-QAM.
Exercise 16.40. Formulate a derotator for use with 16-QAM that uses only the
four corner points of the constellation, those with the highest SNR.
16.8
388
operation of the equalizer can be pictured in the frequency domain. For example,
Figures 13.10, 13.12, and 13.14 (on pages 296299) show frequency responses of
a channel and its converged equalizer. The product of the two is near unity:
that is, the product has magnitude response (approximately) equal to unity at
all frequencies. This is the sense in which the equalizer undoes the eect of the
channel. With complex-valued QAM, the signal has a frequency response that
is not necessarily symmetric about zero. The equalizer can thus be pictured
in exactly the same way (with the goal of attaining a unity product) but the
frequency response of the equalizer may also need to be asymmetric in order to
achieve this goal. Thus the equalizer must be complex-valued in order to achieve
an asymmetric frequency response.
The rst step in the design of any adaptive element is to choose an objective
function. One approach, analogous to the LMS equalizer of Section 13.3, is to
presume that a (complex-valued) training sequence d[k] is available. The output
of the equalizer can be written as an inner product of a set of n + 1 (complexvalued) lter coecients fi with a vector of (complex-valued) received signals
r[k i] as
f1
n
f2
y[k] =
fi r[k i] = (r[k], r[k 1], . . . , r[k n])T . = X T [k]f. (16.20)
..
i=1
fn
Let e[k] be the dierence between the training signal d and the output of the
equalizer
e[k] = d[k] X T [k]f,
(16.21)
,
[e[k]e [k]]
+j
[e[k]e [k]]
f [k + 1] = f [k]
fR
fI
fR =fR [k]
fI =fI [k]
389
Note that
e[k]e [k] = e2R [k] + e2I [k],
which can be expanded using (16.21) as
T
eR [k] = Re{e[k]} = Re{d[k]} Re{X T [k]f } = dR [k] XR
[k]fR + XIT [k]fI ,
T
[k]fI .
eI [k] = Im{e[k]} = Im{d[k]} Im{X T [k]f } = dI [k] XIT [k]fR XR
(16.22)
Compare this with the real version of trained LMS for PAM in (13.27). Except
for the notation (the present version is written with vectors), the only dierence
is the complex conjugation.
The complex-valued 4-QAM equalizer LMSequalizerQAM.m passes a 4-QAM
signal through an arbitrary (complex) channel to simulate the occurrence of ISI.
The equalizer f adapts, and, with luck, converges to a lter that is roughly
the inverse of the channel. The equalizer can be tested by generating a new
set of data ltered through the same channel and then ltered through the
equalizer. If it is working, the doubly ltered signal should be almost equal to
the original, though it will likely be shifted in time as it passes through the two
390
%
%
%
%
%
%
%
%
%
%
%
d e f i n e complex c h a n n e l
how many data p o i n t s
4QAM s o u r c e o f l e n g t h m
output o f channel
i n i t i a l i z e e q u a l i z e r at 0
s t e p s i z e and d e l a y d e l t a
p l ace to s t o r e output
iterate
output o f e q u a l i z e r
c a l c u l a t e e r r o r term
update e q u a l i z e r c o e f f i c i e n t s
There are several ways to test how well the equalizer is working. One simple
way is to look at the convolution of the channel with the nal converged equalizer;
if this is close to a pure (possibly multisample) delay (i.e., an impulse response
with a 1 in the ith location and zeros elsewhere), all is well. For example, with
the default channel b above, the converged equalizer f is approximately
0.31 0.019j, 0.66 0.15j, 0.34 + 0.01j, 0.14 + 0.03j.
and the convolution of b and f is
0.15 0.07j, 0.05 + 0.04j, 1.01 0.01j,
0.02 + 0.01j, 0.06 0.04j, 0.08 0.05j,
which is reasonably close to 0, 0, 1, 0, 0, 0.
The test routine LMSequalizerQAMTest.m uses the nal converged value f of
the equalizer and the denition of the channel b from LMSequalizerQAM.m. A
new set of data is generated, passed through the equalizer, and then quantized
to form the hard decisions dec. The vector err counts up the number of errors
that have occurred for each delay. If one of the entries is zero then the equalizer
has done its job perfectly for that delay. The loop in Listing 16.9 searches over
a number of dierent time shifts (the terms sh) because the output will be a
delayed version of the input and the best delay might not be known beforehand.
In practice, a typical equalizer uses only one delay.
Listing 16.9. LMSequalizerQAMTest.m tests nal equalizer lter
f i n a l e q=f ;
% test final f i l t e r f
m=1000;
% new data p o i n t s
s=pam (m, 2 , 1 ) + j * pam (m, 2 , 1 ) ;
% new 4QAM s o u r c e o f l e n g t h m
r=f i l t e r ( b , 1 , s ) ;
% output o f channel
y t=f i l t e r ( f , 1 , r ) ;
% u s e f i n a l f i l t e r f to t e s t
dec=sign ( r e a l ( y t ))+ j * sign ( imag( y t ) ) ; % q u a n t i z a t i o n
f o r sh =0: n
% i f e q u a l i z e r working , one
e r r ( sh +1)=0.5 *sum( abs ( dec ( sh +1:end) s ( 1 : endsh ) ) ) ;
end
% of these delays = zero error
391
16.9
and timing recovery are done before the sampling into digital form. The decision
blocks quantize to the points of the QAM constellation.
The most interesting feature of Binghams second receiver, shown in Figure
16.17, is the decision-directed carrier recovery. The outputs of the quantizer are
assumed to be correct and are fed back to adjust the phase of the sinusoids in
the mixers, as discussed in Section 16.4.2.
The third of Binghams receiver structures is the nearly-all-digital receiver
of Figure 16.18. This uses a free-running sampler and digital interpolation to estimate the value of the signals at the desired sampling times, as is familiar from
Chapter 12. There is a free-running downconversion before the equalizer and
post-equalization carrier recovery (as described in Section 16.4.2) that operates
on the hard decisions. The equalization element is also decision-directed. Interestingly, the AGC also incorporates feedback from the same signals entering the
carrier recovery.
The nal architecture from Bingham is the all-digital receiver of Figure
16.19. The initial sampling is accomplished by a free-running sampler that operates at a sub-Nyquist rate (compared with the RF of the carrier). Again, the
AGC incorporates feedback on the magnitude of the error between the output of
the equalizer and the hard decisions. The control of the timing recovery is purely
digital and requires an interpolator. The downconversion is accomplished in two
stages: a xed free-running oscillator followed by a decision-directed derotation.
The decision-feedback equalizer is a nite-impulse-response lter that operates
in the feedback loop. It is adapted using a decision-directed objective function.
BPF
Carrier
Recovery
cos(2f0t)
Timing
Recovery
sin(2f0t)
Decoder
LPF
LPF
Figure 16.16 Binghams analog receiver for QAM carries out the bulk of the processing
LPF
BPF
AGC
cos(2f0t)
sin(2f0t)
DD Carrier
Recovery
LPF
Timing
Recovery
Decoder
392
393
Magnitude
Error
interpolation
filter
Phase
AGC ADC
BPF Splitter LPF
Timing
Recovery
Rotator
Equalizer
e j
e j2fckTs
Carrier
Recovery
e j
Derotator
Figure 16.18 Binghams third receiver digitizes near the start of the signal chain and
adapts many of its elements using feedback from the hard decisions. Redrawn from
c
Figure 5.3 of Bingham (1988). The gure is 1988
John Wiley & Sons, Inc., and is
reprinted with permission.
ADC
BPF
Phase
AGC Splitter
Interpolator
Timing
Recovery
Allpass
Filter
e j2fckTs
e j
e j
Equalizer
+
Carrier
Recovery
Magnitude
Error
Figure 16.19 Binghams all-digital receiver structure is a redrawing of Figure 5.4 of
Bingham (1988). The receiver samples at the start of the signal chain and carries out
c
all processes in the digital domain. The gure is 1988
John Wiley & Sons, Inc., and
is reprinted with permission.
The receiver structures in Figures 16.16 to 16.19 follow the development of the
generic receivers in Figure 12.2 on page 252 which progress from mostly analog
to completely digital. Many of the details in the structures can be rearranged
without undue concern: for instance, a decision-feedback equalizer could replace
a feedforward equalizer, the adaptive elements could operate by optimizing a dispersion objective rather than a decision-directed objective, etc. The possibilities
are staggering!
A typical digital QAM receiver is presented in Figure 4-2 of Meyr,
Moeneclaey, and Fechtel (1998), and is shown here in Figure 16.20. The front
end uses an analog mixer for coarse downconversion and a digital derotation (in
the block labeled phase estimator) fed back from after the downsampler. The
free-running sampling is done at a rate Ts faster than the symbol rate T , and
uses digital interpolation from the timing recovery. Observe that the matched
lter occurs after the interpolation but before the timing element. This helps to
394
f=1/Ts
r(t)
Analog
Prefilter
ej(0+)t
rf (t)
rf (kTs)
unTs
Interpolator
Filter
Frequency
Error
Detection
mn
z(nT + T)
Matched
Prefilter
Symbol an
Detection
mnTs
e j(mnTs)
Frequency
Integrator
Frequency
Synthesizer
Timing
Recovery
Phase
Estimator
Frequency
Integrator
Coarse
Frequency
Correction
Figure 16.20 This typical digital QAM receiver is adopted from Figure 4-2 in Meyr,
Moeneclaey, and Fechtel (1998). Two sampling rates are shown, the bulk of the
processing uses a sampling period Ts that is faster than the symbol rate T . The gure
c
is 1998
John Wiley & Sons, Inc., and is reprinted with permission.
smooth the signal for the timing recovery, which also feeds forward to control
the downsampling to the symbol rate.
Figure 16.21 shows a generic equalized data demodulator from Treichler,
Larimore, and Harp (1998). The most prominent feature of this design is the
control-loop architecture, which emphasizes how tightly coupled the various components are. As in previous structures, the mixing is accomplished by a local
oscillator that has feedback from the output of the decision device. A second
local oscillator down-modulates again after the equalizer, which is working faster
than the symbol rate. Two equalizers are shown, a feedforward equalizer and a
decision-feedback equalizer.
The generic blind demodulator for QAM shown in Figure 16.22 is also taken
from Treichler, Larimore, and Harp (1998). The control sequencer amalgamates signals from various places in the receiver and uses them to create a more
centralized control structure, embedding various elements within the loops of others. As before, the analog AGC uses feedback correction from the free-running
sampler output. The quadrature free-running downconversion is trimmed by the
hard decisions and the resampler uses a timing-recovery method that adapts
using only the largest values in the constellation. The objective function of the
equalizer is selected dynamically from either LMS (with a training sequence) or
CMA, which uses the dispersion minimization for blind adaptation.
The multipoint network modem of Jablon (1992) is shown in Figure 16.23.
The design uses a sampler with an adjustable clock rate, a passband equalizer
with de-spun error, and a post-equalization carrier recovery.
The nal architecture of this section is Lee and Messerschmitts typical passband QAM receiver that begins with an analog bandpass lter and uses a
395
Soft
Decisions
Forward
Error
Correction
Hard
Decisions
(w/ FEC)
DFE
BPF
AGC
Hard
Decisions
(no FEC)
Equalizer
Timing
Recovery
Power
Estimation
Equalizer
Adjustment
Carrier
Recovery
Control-Loop Bus
Figure 16.21 This generic equalized data demodulator, redrawn from Figure 4 in
Treichler, Larimore, and Harp (1998), emphasizes the degree of coordination in the
processing of the receiver. Signals are fed back from the output of the hard decisions
and from the decision-directed carrier recovery. Many of the loops include signicant
(and complicated) portions of the receiver such as the feedforward equalizer and the
decision-feedback equalizer. Such nesting of adaptive elements is a tricky business
c
since they must must not interfere with each other. The gure is 1998
IEEE and is
used with permission.
Soft
Decisions
BPF
AGC
A/D
QDC
Hard
Decisions
Equalizer
CMA
Power
Estimation
Timing
Recovery
Equalizer
Adjustment
LMS
Carrier
Recovery
Control Sequencer
Figure 16.22 This receiver can switch between two equalizers: LMS for faster
396
A/D
AGC
Decoding
Equalizer
PLL
Sampling
Clock
Timing
Recovery
e j[k]
e j[k]
Error
Computation
Figure 16.23 This QAM receiver, simplied from the original Figure 2 in Jablon
(1992), uses a passband equalizer before the demodulation and trimming by the PLL.
c
The gure is 1992
IEEE and is used with permission.
Timing Recovery
Nyquist-rate
sampling
BPF
Twice
symbol-rate
sampling
Symbol-rate
sampling
Fractionally
Spaced
Precursor
Equalizer
Phase
Splitter
e j2fckTs
Preliminary
demodulation
Carrier
Recovery
Hard
Decisions
+
+
Postcursor
Equalizer
Figure 16.24 This typical passband QAM receiver is redrawn from Figure 5-21 of
c
Barry, Lee, and Messerschmitt (2004). The gure is 2004
Kluwer Academic, and is
used with the kind permission of Springer Science and Business Media.
Why are there so many receiver architectures? Why not gure out once and
for all which is the best, and stick with it? One reason is that some structures are
more suited to particular operating circumstances than others: some components,
some objective functions, and some ordering of the elements may be better in
certain situations. For example, Barry, Lee, and Messerschmitt (2004) state the
following on page 733:
One practical diculty arises when an adaptive equalizer is used in conjunction with a
decision-directed carrier recovery loop. Baseband adaptive equalizers assume that the
input has been demodulated. The solution to this diculty . . . is to use a passband
equalizer. . . . By placing the forward equalizer before the carrier recovery demodulation,
we avoid having the equalizer inside the carrier recovery loop. By contrast, a baseband
equalizer would follow the demodulator and precede the slicer. This means that it is
inside the carrier recovery loop. Consequently, the loop transfer function of the carrier
recovery includes the time-varying equalizer, causing considerable complication. At
the very least, the long delay (several symbol intervals) associated with the baseband
equalizer would force the loop gain of the carrier recovery to be reduced to ensure
stability, impairing its ability to track rapidly varying carrier phase. The passband
equalizer . . . mitigates this problem by equalizing prior to demodulation.
397
These represent only a handful of the many possible architectures for a QAM
radio. The next section asks you to explore some alternatives.
16.10
Chapter 15 asked you to code the complete M6 receiver using only the tiny
building blocks from the homework and book chapters. The task with the QuasiQuixotic QAM receiver (Q3 AM for short) is somewhat dierent. A complete
(working) prototype was coded by a crack team of students at Cornell University
in winter of 2002.1 The routine qpskRx.m can be found on the website, and the
transmission protocol and receiver architecture are described in the next two
sections. Your job, should you choose to accept it, is to make changes to this
receiver: to improve the radio by using better parts (such as a PLL in place of
a Costas loop), to explore alternative structures (such as those of the previous
section), and to adapt it to work with bigger constellations (such as 16-QAM).
As Section 16.9 showed, there are many ways to structure a QAM receiver.
Exploring various rearrangements of the modules and submodules should provide
insight into the inner working of the radio at a slightly higher level than when
designing the M6 radio. There are a variety of disturbances and impairments
that the Q3 AM receiver will be asked to handle, including
r
r
r
r
r
r
r
r
398
3. lowpass ltering for downconversion, matched lter, and interpolation all provided by a matched lter with adjusted timing oset adapted with maximization of the fourth power of downsampled signals in dual-loop conguration
4. correlation used to resolve phase ambiguity and to locate the start of the
training sequence in the equalizer input
5. linear equalizer adaptation via LMS; switched to decision-directed LMS adaptation during the data (i.e. non-training) portion
6. frame-synchronized descrambler and (5, 2) linear block-code decoder
16.11
16.11.1
Oversampled
Carrier Synchronized
Signal
Carrier Recovery
Baud-Spaced
Clock-Synchronized
Signal
Timing Recovery
training
data
Trained LMS
Equalization
initial
equalizer
Correlation
Oversampled
Output from
Analog Front End
Decision-Directed
Equalization
Equalized and
Quantized Message
Comparison
and BER calculation
Original
Message
Receiver Inputs
Recovered
Message
Descrambling
and Decoding
Receiver Output
399
Phase Noise: The carrier phase noise is modeled as a random walk, such that
k+1 = k + k ,
(16.23)
where k is a white noise whose variance is dictated when running the software.
(See Section 16.11.3.)
Timing Oset Noise: The timing oset noise is modeled in the same manner
as the phase noise, only with a white noise of a dierent variance, which is
specied when running the software.
Carrier Oscillator Frequency and Phase Oset: The frequency oset between
the transmitter and receiver carrier oscillators is specied as a ratio, of f ,
such that fact = (1 of f )fc . The phase oset can be specied in any region
from 0 to 2.
Baud Oscillator Frequency and Phase Oset: The frequency oset between the
transmitter and receiver baud oscillators (aka clocks) is also specied as a
ratio, of f , such that Tsact = Ts of f /(1 of f ). The baud oscillator phase
oset, which is also known as the xed timing oset, may also be specied.
Multipath Channels: The software has the ability to simulate transmission
through a xed multipath channel specied at run time.
Time-Varying Multipath: It is possible to study the receivers ability to track
timing-varying multipath by turning on a ag in the software and specifying
the speed of time variation for a particular built-in time-varying multipath
channel. (See Section 16.11.3.)
Wideband Additive Channel Noise The received signal includes additive noise,
which is modeled as a white Gaussian random process. This noise is added in
the channel, and its variance can be specied by specifying the channel SNR
when running the software.
16.11.2
The Receiver
Carrier Recovery and Downconversion
The input to the receiver from the channel and transmitter is an upconverted
signal centered in frequency at fc , and oversampled by a factor of four. The
rst block this data enters is the carrier-recovery unit, which uses a quadriphase
Costas loop. The estimates, est [k], from the adaptive Costas loop are then used
to demodulate the signal by multiplication by exp(j(2fc Ts k + est [k]). The
lowpass ltering done in the timing-recovery unit by the matched lter completes
the demodulation.
Timing Recovery
The oversampled signal is then sent to the baud-timing-recovery unit, which
interpolates the signal using a pulse shape with nonzero timing oset (with the
timing oset estimated adaptively) matched to the transmitter pulse shape. This
is slightly dierent from sinc-interpolation, because it uses the time-shifted pulse
400
Table 16.1. The parameters which must be set in the rst structure, b, passed into the
transmitter portion of the software suite. See the example in Section 16.11.3 for more
details.
Name
debugFlag
ph off
f off
t off
SNR
channel
tNoiseVar
bfo
pNoiseVar
TVChan
alpha
c
g
Description
Flag to indicate whether or not to generate plots
Phase oset between the transmitter and receiver carrier
Frequency oset between the transmitter and receiver carrier
Timing oset between the transmitter and receiver baud
Signal-to-noise ratio in the channel
Fixed channel impulse response (ignored if TVChan = 1)
Variance of noise in the receiver baud timing
Frequency oset between the transmitter and receiver baud
Variance of phase noise in receiver and transmitter carrier
= 0, use static channel dened by channel parameter
= 1, use [1, 0, 0, 0, c + g cos(2fc kTs )]
Controls parameter variation in time-varying channel
Mean value c of the time-varying channel tap
Variation g about mean value of time-varying channel tap
Table 16.2. The parameters which must be specied in the second structure, specs, when
running the transmitter portion of the the software suite. See the example in Section 16.11.3
for more details.
Name
v
codingF
scrambleF1
beta
scrambleF2
OverSamp
Description
Square QAM constellation has 22v points (v = 1 for QPSK)
Whether or not to use coding (same as for transmitter)
Whether or not to generate diagnostic plots when scrambling
The rollo factor used in the SRRC matched lter
Whether or not to scramble (same as for transmitter)
Oversampling factor, usually set to 4
Correlation
Correlation must be performed to nd the segment used to train the equalizer,
thus this block correlates the signal with the pre-arranged training data. Once
the training segment is found, the correlation block passes the starting location
on to the equalizer along with the training data.
Equalization
Equalization is performed rst using an adaptive trained LMS algorithm, and
then, when the training runs out, using the adaptive decision-directed LMS
401
algorithm. Step sizes for this algorithm (along with those mentioned above) may
be specied as inputs to the software.
Performance Evaluation
After the receiver has nished processing the received signal, its soft decisions
(data at the equalizer output) are compared with the original sent symbols
in order to determine the mean-squared error at the equalizer output. It is
then assumed that the dispersion around the decisions is due to additive circularly Gaussian noise, and a probability of symbol error is determined using
this assumption and the average of the squared error over all data after the
training phase. Also, the hard decisions on the equalized, pre-decoding data
are compared with the original coded message symbols to give an empirical
SER. Furthermore, the hard decisions are descrambled and decoded, and the bit
error rate is measured by comparing the transmitted (uncoded) data. Thus, an
uncoded SER based on the mean-squared error, a measured pre-decoder SER,
and an empirical coded BER are determined. If the coded BER is suciently low
and the errors are sparsely distributed so that there is no more than one error
per symbol, the coded SER can be approximated by multiplying the BER (units:
errors/bit) by the number of bits/symbol (i.e., 2 for 4-QAM). When there is only
a small amount of data running through the system, the rst method with its
MSE-based approximation will be capable of more accurately estimating smaller
probabilities of error, because the MSE becomes substantial before the SER does.
16.11.3
Table 16.3. The parameters to specify when running the receiver portion of the software
suite. These parameters are all within a structure that is passed to the receiver port of the
software when running a simulation. See the example of Section 16.11.3.
Name
Costas Mu1
Costas Mu2
Time mu1
Time mu2
EqMu
ddEqMu
debugFlag
scrambleF
codingFlag
OverSamp
Description
First step size to use in the type-II Costas loop
Second step size to use in the type-II Costas loop
First step size to use in the dual timing recovery
Second step size to use in the dual timing recovery
Step size to use with the trained LMS equalizer
Step size to use with the decision-directed equalizer
Flag that indicates whether or not to generate plots
(If debugFlag = 1, the plots are drawn)
Flag that turns on and o the scrambling of the signal
Flag that turns on and o the coding of the signal
Oversampling factor, usually set to 4
The code to run a performance study that shows how the symbol error rate of
the scheme varies with the SNR in the channel, as plotted in Figure 16.26, can
be found in snrTest.m.
10
10
SER
402
10
10
Approximate
Measured
10
15
20
SNR
References
The following papers and books were utilized in preparing this chapter and are
recommended as more comprehensive sources on QAM radio.
J. B. Anderson, Digital Transmission Engineering, Prentice-Hall, 1999.
J. R. Barry, E. A. Lee, and D. G. Messerschmitt, Digital Communication, 3rd
edition, Kluwer Academic, 2004.
J. A. C. Bingham, The Theory and Practice of Modem Design, Wiley, 1988.
403
This appendix gathers together all of the math facts used in the text. They are
divided into six categories:
r
r
r
r
r
r
Trigonometric identities
Fourier transforms and properties
Energy and power
Z-transforms and properties
Integral and derivative formulas
Matrix algebra
A.1
Trigonometric Identities
r Eulers relation
ejx = cos(x) j sin(x)
(A.1)
1 jx
e + ejx
2
(A.2)
sin(x) =
1 jx
e ejx
2j
(A.3)
cos2 (x) =
1
(1 + cos(2x))
2
(A.4)
sin2 (x) =
1
(1 cos(2x))
2
(A.5)
cos(x) =
405
x = cos x
2
2
x = sin x
cos(x) = sin
2
2
Sinecosine product
sin(x) = cos
(A.8)
1
[cos(x y) + cos(x + y)]
2
(A.9)
1
[cos(x y) cos(x + y)]
2
(A.10)
r Cosinecosine product
cos(x) cos(y) =
r Sinesine product
r Odd symmetry of the sine
(A.7)
1
[sin(x y) + sin(x + y)]
2
sin(x) cos(y) =
sin(x) sin(y) =
(A.6)
sin(x) = sin(x)
(A.11)
(A.12)
(A.13)
(A.14)
A.2
W (f ) =
w(t)ej2f t dt
(A.15)
w(t) =
A j
e (f f0 ) + ej (f + f0 )
2
Fourier transform of a cosine
A j
e (f f0 ) + ej (f + f0 )
F {A cos(2f0 t + )} =
2
F {A sin(2f0 t + )} = j
W (f )ej2f t df
(A.16)
(A.17)
(A.18)
406
(A.19)
(t) =
T /2 t T /2
otherwise,
(A.20)
sin(f T )
T sinc(f T ).
f T
(A.21)
1
0
F {(t)} = T
F {sinc(2W t)} =
2W
f
2W
(A.22)
w(t) = 2f0
sin(2f0 t)
2f0 t
cos(2f t)
,
1 (4f t)2
F {w(t)} = 1 1 + cos (|f | f1 )
2
2f
(A.23)
|f | < f1
f1 < |f | < B
(A.24)
|f | > B,
t = 0, (T /4)
(t/T )(1 (4t/T )2 )
T
1
(1 + (4/))
t=0
T
+2
sin
+
cos
t = T /(4),
4
2T
1/2
1
(|f | f1 )
F {w(t)} =
1 + cos
2f
2
0
|f | < f1
f1 < |f | < B
|f | > B.
(A.25)
(A.26)
407
and
ws (t) = w(t)
F {ws (t)} =
1
Ts
(t kTs ),
k=
W (f (n/Ts )).
(A.27)
(A.28)
n=
A t>0
0
t < 0,
1
(f )
+
.
F {w(t)} = A
2
j2f
w(t) =
(A.29)
w(t) =
F {w(t)} =
1/(t)
0
t>0
t < 0,
j
j
f > 0,
f < 0.
(A.30)
r Linearity property
With F {wi (t)} = Wi (f ),
F {aw1 (t) + bw2 (t)} = aW1 (f ) + bW2 (f ).
(A.31)
r Duality property
With F {w(t)} = W (f ),
F {W (t)} = w(f ).
(A.32)
F {w(t)ej2f0 t } = W (f f0 ).
(A.33)
(A.34)
(A.35)
408
(A.36)
r Time-shift property
With F {w(t)} = W (f ),
F {w(t t0 )} = W (f )ej2f t0 .
(A.37)
1
W
a
f
.
a
(A.38)
r Dierentiation property
With F {w(t)} = W (f ),
dw(t)
= j2f W (f ).
dt
Convolution multiplication property
With F {wi (t)} = Wi (f ),
(A.39)
(A.40)
(A.41)
and
(A.42)
r Parsevals theorem
r Final-value theorem
W1 (f )W2 (f )df.
(A.43)
where F {w(t)} = W (f ).
f 0
(A.44)
A.3
409
s2 (t)dt
E(s) =
(A.45)
1
T
T /2
s2 (t)dt
(A.46)
T /2
s2 [k]
(A.47)
P (s) = lim
(A.48)
k=N
(A.49)
Px (f ) = lim
(Watts/Hz),
(A.50)
t
,
xT (t) = x(t)
T
(A.51)
A.4
k=
x[k]z k
(A.52)
410
r Time-shift property
With Z{x[k]} = X(z),
Z{x[k ]} = z X(z).
(A.53)
(A.54)
r Linearity property
With Z{xi [k]} = Xi (z),
A.5
(A.55)
z1
r Schwarzs inequality
2
a(x)b(x)dx
|a(x)| dx
(A.56)
|b(x)| dx
2
(A.57)
and equality occurs only when a(x) = kb (x), where superscript indicates
complex conjugation (i.e., (a + jb) = a jb).
Leibnizs rule
$
%
b(x)
d
f (, x)d
a(x)
db(x)
da(x)
= f (b(x), x)
f (a(x), x)
dx
dx
dx
b(x)
f (, x)
d
(A.58)
+
x
a(x)
(A.59)
d
dy
dw
(wy) = w
+y
dx
dx
dx
(A.60)
r Derivative of a product
411
(A.61)
d
dy
(cos(y)) = (sin(y))
dx
dx
(A.62)
dy
d
(sin(y)) = (cos(y))
dx
dx
(A.63)
(AT )T = A
(A.64)
(AB)T = B T AT
(A.65)
r Derivative of cosine
r Derivative of sine
A.6
Matrix Algebra
r Transpose transposed
r Transpose of a product
r Transpose and inverse commutativity
If A1 exists,
T
= A1 .
(A.66)
A1 A = AA1 = I.
(A.67)
AT
r Inverse identity
If A1 exists,
Simulating Noise
413
Simulating Noise
Amplitude
10
20
30
40
50
(a) Time in seconds
60
Magnitude
5
0
1000
800
600
400
200
0
400
200
0
200
(b) Frequency in Hz
400
the function randn to create a vector with N normally distributed (or Gaussian)
random numbers.
Listing B.1. randspec.m spectrum of random numbers
N=216;
Ts = 0 . 0 0 1 ; t=Ts * ( 1 :N ) ;
x=randn ( 1 ,N ) ;
p l o t s p e c ( x , Ts ) ;
%
%
%
%
Running randspec.m gives a plot much like that shown in Figure B.1, though
details may change because the random numbers are dierent each time the
program is run.
The random numbers themselves fall mainly between 4, though most are less
than 2. The average (or mean) value is
m=
N
1
x[k]
N
(B.1)
k=1
N
1
(x[k] m)2
N
(B.2)
k=1
For randn, this is very close to 1.0. When the mean is zero, this variance is the
same as the power. Hence, if m=0, v=pow(x) also gives the variance.
The spectrum of a numerically generated white-noise sequence typically
appears as in the bottom plot of Figure B.1. Observe the symmetry in the spectrum (which occurs because the random numbers are real-valued). In principle,
the spectrum is at (all frequencies are represented equally), but in reality, any
414
given time the program is run, some frequencies appear slightly larger than others. In Figure B.1, there is such a spurious peak near 275 Hz, and a couple more
near 440 Hz. Verify that these spurious peaks occur at dierent frequencies each
time the program is run.
Exercise B.1. Use randspec.m to investigate the spectrum when dierent numbers of random values are chosen. Try N = 10, 100, 210, 218 . For each of the values
N, locate any spurious peaks. When the same program is run again, do they occur
at the same frequencies?1
Exercise B.2. Matlabs randn function is designed so that the mean is always
(approximately) zero and the variance is (approximately) unity. Consider a signal
dened by w = a randn + b; that is, the output of randn is scaled and oset.
What are the mean and variance of w? Hint: use (B.1) and (B.2). What values
must a and b have to create a signal that has mean 1.0 and variance 5.0?
Exercise B.3. Another Matlab function to generate random numbers is rand,
which creates numbers between 0 and 1. Try the code x=rand(1,N)-0.5 in
randspec.m, where the 0.5 causes x to have zero mean. What are the mean
and the variance of x? What does the spectrum of rand look like? Is it also
white? What happens if the 0.5 is removed? Explain what you see.
Exercise B.4. Create two dierent white signals w[k] and v[k] that are at least
N = 216 elements long.
a. For each j between 100 and +100, nd the cross-correlation Rwv [j] between
w[k] and v[k].
b. Find the autocorrelations Rw [j] and Rv [j]. What value(s) of j give the largest
autocorrelation?
Though many types of noise may have a wide bandwidth, few are truly white.
A common way to generate random sequences with (more or less) any desired
spectrum is to pass white noise through a linear lter with a specied passband.
The output then has a spectrum that coincides with the passband of the lter.
For example, the following program creates such colored noise by passing white
noise through a bandpass lter that attenuates all frequencies but those between
100 and 200 Hz:
Listing B.2. randcolor.m generating a colored noise spectrum
N=216;
Ts = 0 . 0 0 1 ; nyq =0.5/ Ts ;
s s f =(N/ 2 :N/2 1)/( Ts *N ) ;
1
Matlab allows control over whether the random numbers are the same each time using
the seed option in the calls to the random-number generator. Details can be found in the
help les for rand and randn.
Magnitude
Simulating Noise
800
600
400
200
0
415
600
400
200
0
400
200
0
200
400
(b) Spectrum of output random numbers (Frequency in Hz)
x=randn ( 1 ,N ) ;
f b e =[0 100 110 190 200 nyq ] / nyq ;
damps=[0 0 1 1 0 0 ] ;
f l =70;
b=f i r p m ( f l , f b e , damps ) ;
y=f i l t e r ( b , 1 , x ) ;
%
%
%
%
%
%
N random numbers
define desired f i l t e r
des i r ed amplitudes
f i l t er size
design impulse response
f i l t e r x with b
Plots from a typical run of randcolor.m are shown in Figure B.2, which illustrates the spectrum of the white input and the spectrum of the colored output.
Clearly, the bandwidth of the output noise is (roughly) between 100 and 200 Hz.
Exercise B.5. Create a noisy signal that has no energy below 100 Hz. It should
then have (linearly) increasing energy from 100 Hz to the Nyquist rate at 500 Hz.
a. Design an appropriate lter using firpm. Verify its frequency response by
using freqz.
b. Generate a white noise and pass it through the lter. Plot the spectrum of
the input and the spectrum of the output.
Exercise B.6. Create two noisy signals w[k] and v[k] that are N = 216 elements
long. The bandwidths of both w[k] and v[k] should lie between 100 and 200 Hz
as in randcolor.m.
a. For each j between 100 and +100, nd the cross-correlation Rwv [j] between
w[k] and v[k].
b. Find the autocorrelations Rw [j] and Rv [j]. What value(s) of j give the largest
autocorrelation?
c. Are there any similarities between the two autocorrelations?
d. Are there any similarities between these autocorrelations and the impulse
response b of the bandpass lter?
The envelope of a signal is a curve that smoothly encloses the signal, as shown in
Figure C.1. An envelope detector is a circuit (or computer program) that outputs
the envelope when the signal is applied at its input.
In early analog radios, envelope detectors were used to help recover the message from the modulated carrier, as discussed in Section 5.1. One simple design
includes a diode, capacitor, and resistor arranged as in Figure C.2. The oscillating signal arrives from an antenna. When the voltage is positive, current passes
through the diode, and charges the capacitor. When the voltage is negative,
the diode blocks the current, and the capacitor discharges through the resistor.
The time constants are chosen so that the charging of the capacitor is quick (so
that the output follows the upward motion of the signal), but the discharging is
relatively slow (so that the output decays slowly from its peak value). Typical
output of such a circuit is shown by the jagged line in Figure C.1, a reasonable
approximation to the actual envelope.
It is easy to approximate the action of an envelope detector. The essence
of the method is to apply a static nonlinearity (analogous to the diode in the
circuit) followed by a lowpass lter (the capacitor and resistor). For example, the
Matlab code in AMlarge.m on page 83 extracted the envelope using an absolutevalue nonlinearity and an LPF, and this method is also used in envsig.m.
Listing C.1. envsig.m envelope of a bandpass signal
time = . 3 3 ; Ts =1/10000;
t =0:Ts : time ; l e n t=length ( t ) ;
f c =1000; c=cos (2 * pi * f c * t ) ;
fm=10;
w=cos (2 * pi * fm * t ) . * exp(5 * t ) + 0 . 5 ;
x=c . * w ;
f b e =[0 0 . 0 5 0 . 1 1 ] ; damps=[1 1 0 0 ] ;
f l =100; b=f i r p m ( f l , f b e , damps ) ;
envx=(pi / 2 ) * f i l t e r ( b , 1 , abs ( x ) ) ;
%
%
%
%
%
%
%
%
%
Suppose that a pure sine wave is input into this envelope detector. Then the
output of the LPF would be the average of the absolute value of the sine wave
(the integral of the absolute value of a sine wave over a period is /2). The factor
417
Approximation of
envelope using
analog circuit
Upper
envelope
Signal
Lower
envelope
Signal
Envelope
/2 in the denition of envx accounts for this factor so that the output rides
on crests of the wave. The output of envsig.m is shown in Figure C.3(a), where
the envelope signal envx follows the outline of the narrow-bandwidth passband
signal x, though with a slight delay. This delay is caused by the linear lter, and
can be removed by shifting the envelope curve by the group delay of the lter.
This is fl/2, half the length of the lowpass lter when designed using the firpm
command.
A more formal denition of envelope uses the notion of in-phase and quadrature components of signals to reexpress the original bandpass signal x(t) as the
product of a complex sinusoid and a slowly varying envelope function,
x(t) = Re{g(t)ej2fc t }.
(C.1)
The function g(t) is called the complex envelope of x(t), and fc is the carrier
frequency in Hz.
To see that this is always possible, consider Figure C.4. The input x(t) is
assumed to be a narrowband signal centered near fc (with support between
fc B and fc + B for some small B). Multiplication by the two sine waves
modulates this to a pair of signals centered at baseband and at 2fc . The LPF
removes all but the baseband, and so the spectra of both xc (t) and xs (t) are
contained between B to B. Modulation by the nal two sinusoids returns the
baseband signals to a region around fc , and adding them together gives exactly
the signal x(t). Thus, Figure C.4 represents an identity. It is useful because it
allows any passband signal to be expressed in terms of two baseband signals,
which are called the in-phase and quadrature components of the signal.
Amplitude
Amplitude
418
1.5
1
0.5
0
0.5
1
1.5
1.5
1
0.5
0
0.5
1
1.5
0.05
0.1
0.05
0.1
0.15
0.2
(a)
Time
0.25
0.3
0.15
0.2
Time
0.25
0.3
(b)
2 cos(2f0kT)
cos(2f0kT)
LPF
xc(t)
+
x(t)
LPF
2 sin(2f0kT)
xs(t)
sin(2f0kT)
x(t)
(C.2)
(C.3)
Applying Eulers identity (A.1) then shows that the envelope g(t) can be
expressed in terms of the in-phase and quadrature components as
*
g(t) = x2c (t) + x2s (t).
Any physical (real-valued) bandlimited waveform can be represented as in
(C.1) and so it is possible to represent many of the standard modulation schemes
in a unied notation.
419
For example, consider the case in which the complex envelope is a scaled
version of the message waveform (i.e., g(t) = Ac w(t)). Then
x(t) = Re{Ac w(t)ej2fc t }.
Using ejx = cos(x) j sin(x),
x(t) = Re{w(t)[Ac cos(2fc t) + jAc sin(2fc t)]}
= w(t)Ac cos(2fc t),
which is the same as AM with a suppressed carrier from Section 5.2.
AM with a large carrier can also be written in the form of (C.1) with g(t) =
Ac [1 + w(t)]. Then
x(t) = Re{Ac [1 + w(t)]ej2fc t }
= Re{Ac ej2fc t + Ac w(t)ej2fc t }
= Ac cos(2fc t) + w(t)Ac cos(2fc t).
The envelope g(t) is real in both of these cases when w(t) is real.
When the envelope g(t) = x(t) + jy(t) is complex-valued, x(t) in (C.1)
becomes
x(t) = Re{(x(t) + jy(t))ej2fc t }.
With ejx = cos(x) + j sin(x),
x(t) = Re{x(t) cos(2fc t) + jx(t) sin(2fc t) + jy(t) cos(2fc t) + j 2 y(t) sin(2fc t)}
= x(t) cos(2fc t) y(t) sin(2fc t).
This is the same as the quadrature modulation of Section 5.3.
Exercise C.1. Replace the filter command with the filtfilt command and
rerun envsig.m. Observe the eect of the delay. Read the Matlab help le for
filtfilt, and try to adjust the programs so that the outputs coincide. Hint:
you will need to change the lter parameters as well as the decay of the output.
Exercise C.2. Replace the absolute-value nonlinearity with a rectifying nonlinearity
x(t) t 0
x(t) =
0
t < 0,
which more closely simulates the action of a diode. Mimic the code in envsig.m
to create an envelope detector. What is the appropriate constant that must be
used to make the output smoothly touch the peaks of the signal?
Exercise C.3. Use envsig.m and the following code to nd the envelope of a
signal. Can you see how to write these three lines of code in one (complex-valued)
line?
420
xc=f i l t e r ( b , 1 , 2 * x . * cos (2 * pi * f c * t ) ) ;
x s=f i l t e r ( b , 1 , 2 * x . * s i n (2 * pi * f c * t ) ) ;
envx=abs ( xc+sqrt ( 1) * x s ) ;
% in phase component
% q u a d r a t u r e component
% envelope of s i g n a l
Exercise C.4. For those who have access to the Matlab signal-processing toolbox, an even simpler syntax for the complex envelope is
envx=abs(hilbert(x));
Can you gure out why the Hilbert transform is useful for calculating the
envelope?
Exercise C.5. Find a signal x(t) for which all the methods of envelope detection
fail to provide a convincing envelope. Hint: try signals that are not narrowband.
Most people are quite familiar with time-domain thinking: a plot of voltage
versus time, how stock prices vary as the days pass, a function that grows (or
shrinks) over time. One of the most useful tools in the arsenal of an electrical
engineer is the idea of transforming a problem into the frequency domain. Sometimes this transformation works wonders; what at rst seemed intractable is now
obvious at a glance. Much of this appendix is about the process of making the
transformation from time into frequency, and back again from frequency into
time. The primary mathematical tool is the Fourier transform (and its discretetime counterparts).
D.1
(D.1)
Observe that the transform is an integral over all time, while the inverse transform is an integral over all frequency; the transform converts a signal from time
into frequency, while the inverse converts from frequency into time. Because the
transform is invertible, it does not create or destroy information. Everything
about the time signal w(t) is contained in the frequency signal W (f ) and vice
versa.
The integrals (D.1) and (D.2) do not always exist; they may fail to converge
or they may become innite if the signal is bizarre enough. Mathematicians
have catalogued exact conditions under which the transforms exist, and it is a
422
w(t)ej2f t dt + b
v(t)ej2f t dt
=a
= aW (f ) + bV (f ).
What does the transform mean? Unfortunately, this is not immediately apparent from the denition. One common interpretation is to think of W (f ) as
describing how to build the time signal w(t) out of sine waves (more accurately,
out of complex exponentials). Conversely, w(t) can be thought of as the unique
time waveform that has the frequency content specied by W (f ).
Even though the time signal is usually a real-valued function, the transform
W (f ) is, in general, complex-valued due to the complex exponential ej2f t
appearing in the denition. Thus W (f ) is a complex number for each frequency
f . The magnitude spectrum is a plot of the magnitude of the complex numbers
W (f ) as a function of f , and the phase spectrum is a plot of the angle of the
complex numbers W (f ) as a function of f .
D.2
t=0
423
w(kt)ej2(n/T )k(T /N ) t
0
f =n/T
k=0
= t
N
1
w(kt)ej(2/N )nk ,
k=0
W (f ) =
2
(f + f0 )Td
(f f0 )Td
(D.3)
424
1
60
0.5
40
0
0.5
1
4
20
2
0
2
4
Time/seconds
(a) Switched sinusoid
0.5
0.5
0.4
0.4
0.3
0.3
0.2
0.2
0.1
0.1
500
1000 1500
Bin number
(b) Raw DFT magnitude
0
0
0
50 100 40 20
0
20
40
100 50
Frequency/Hz
Frequency/Hz
(c) Magnitude spectrum (d) Zoom into magnitude spectrum
Plots of the key variables are shown in Figure D.1. The switched sinusoid w
is shown plotted against time, and the raw spectrum dftmag is plotted as
a function of its index. The proper magnitude spectrum spec is plotted as a
function of frequency, and the nal plot shows a zoom into the low-frequency
region. In this case, the time resolution is t = T /N = 0.0078 s and the frequency
resolution is f = 1/T = 0.125 Hz. The largest allowable f0 without aliasing is
N/(2T ) = 64 Hz.
Exercise D.1. Rerun the preceding program with T=16, Td=2, and f=5. Comment on the location and the width of the two spectral lines. Can you nd
particular values so that the peaks are extremely narrow? Can you relate the
locations of these narrow peaks to (D.3)?
One way of classifying and measuring signals and systems is by their power (or
energy), and the amount of power (or energy) in various frequency regions. This
section denes the power spectral density, and shows how it can be used to
measure the power in signals, to measure the correlation within a signal, and to
talk about the gain of a linear system. In Software Receiver Design, power
spectral density is used mainly in Chapter 11 in the discussion of the design of
matched ltering.
The (time) energy of a signal was dened in (A.45) as the integral of the signal
squared, and Parsevals theorem (A.43) guarantees that this is the same as the
total energy measured in frequency
|W (f )|2 df,
E=
426
Pw (f ) = lim
(Watts/Hz),
(E.2)
f =
Observe that the PSD is always real and nonnegative. When w(t) is real-valued,
then the PSD is symmetric, Pw (f ) = Pw (f ).
The PSD can be used to reexpress the autocorrelation function (the correlation
of w(t) with itself),
1 T /2
Rw ( ) = lim
w(t)w(t + )dt,
T T T /2
in the frequency domain. This is the continuous-time counterpart of the crosscorrelation (8.3) with w = v. First, replace with . Now the integrand is a
convolution, and so the Fourier transform is the product of the spectra. Hence,
1
w(t) w(t)
F {Rw ( )} = F {Rw ( )} = F lim
T T
1
1
= lim
F {w(t) w(t)} = lim
|W (f )|2 = Pw (f ).
T T
T T
Thus, the Fourier transform of the autocorrelation function of w(t) is equal to
the power spectral density of w(t),1 and it follows that
P =
Pw (f )df = Rw (0),
1
1
|YT (f )|2 = lim
|XT (f )|2 |H(f )|2 = Px (f )|H(f )|2 ,
T T
T
(E.3)
This
( is known as the WienerKhintchine theorem, and it formally requires that
Rw ( )d be nite; that is, the correlation between w(t) and w(t + ) must die away
as gets large.
427
where yT (t) = y(t)(t/T ) and xT (t) = x(t)(t/T ) are truncated versions of y(t)
and x(t). Thus, the PSD of the output is precisely the PSD of the input times
the magnitude of the frequency response (squared), and the power gain of the
linear system is exactly |H(f )|2 for each frequency f .
The Z -Transform
This appendix presents background material that is useful when designing equalizers and when analyzing feedback systems such as the loop structures that occur
in many adaptive elements. The Z and the s play more than an orthographic
role since the Z-transform (the discrete-time counterpart of the s-domain Laplace
transform) can be used to represent a linear system such as a channel model or
a lter in a concise way. The frequency response of these models can easily be
derived using a simple graphical technique that also provides insight into the
inverse model. This can be useful in visualizing equalizer design as in Chapter
13, and the same techniques are useful in the analysis of systems such as the
PLLs of Chapter 10. The open-eye criterion provides a way of determining
how good the design is.
F.1
Z-Transforms
Fundamental to any digital signal is the idea of the unit delay, a time delay T of
exactly one sample interval. There are several ways to represent this mathematically, and this section uses the Z-transform, which is closely related to a discrete
version of the Fourier transform. Dene the variable z to represent a (forward)
time shift of one sample interval. Thus, zu(kT ) u((k + 1)T ). The inverse is the
backward time shift z 1 u(kT ) u((k 1)T ). These are most commonly written
without explicit reference to the sampling rate as
zu[k] = u[k + 1] and z 1 u[k] = u[k 1].
For example, the FIR lter with input u[k] and output
y[k] = u[k] + 0.6u[k 1] 0.91u[k 2]
can be rewritten in terms of the time-delay operator z as
y[k] = (1 + 0.6z 1 0.91z 2)u[k].
The Z -Transform
429
Y (z) = Z{y[k]} =
y[k]z k .
(F.1)
k=
y[k ]z k .
k=
y[j]z (j+) = z
y[j]z j = z Y (z). (F.2)
Z{y[k ]} =
j+=
j+=
(F.3)
430
Y (z)
zb
= 1 bz 1 =
.
U (z)
z
(F.4)
The Z -Transform
431
H(z) =
(F.5)
An interesting (and sometimes useful) feature of the Z-transform is the relationship between the asymptotic value of the sequence in time and a limit of the
transfer function.
Final-Value Theorem for Z-transforms: If X(z) converges for |z| > 1 and
all poles of (z 1)X(z) are inside the unit circle, then
lim x[k] = lim (z 1)X(z).
z1
(F.6)
Exercise F.1. Use the denition of the Z-transform to show that the transform
is linear; that is, show that Z{ax[k] + bu[k]} = aX(z) + bU (z).
Exercise F.2. Find the z-domain transfer function of the system dened by
y[k] = b1 u[k] + b2 u[k 1].
a.
b.
c.
d.
e.
f.
transfer function?
Exercise F.3. Find the z-domain transfer function of the system dened by
y[k] = ay[k 1] + bu[k 1].
a.
b.
c.
d.
e.
f.
Exercise F.4. Find the z-domain transfer function of the lter dened by y[k] =
y[k 1] 2u[k] + (2 )u[k 1].
a.
b.
c.
d.
432
F.2
| + |
Re()Re()
Im()Im()
Re
The Z -Transform
180o = radians
Nyquist sampling
rate
Frequency of
test points given
in radians
z2
b1
Zeros
b3
b2
a3
a1
a2
z1
DC or zero
frequency
433
(F.7)
Accordingly, the magnitude of this FIR transfer function at any value z is the
product of the magnitudes of the distances from z to the zeros. For any test
point on the unit circle, the magnitude is equal to the product of all the distances
from the test point to the zeros. An example is shown in Figure F.2, where a
transfer function has three zeros. Two test points are shown at frequencies
corresponding to (approximately) 15 and 80 . The magnitude at the rst test
point is equal to the product of the lengths a1 , a2 , and a3 , while the magnitude at
the second is b1 b2 b3 . Qualitatively, the frequency response begins at some value
and slowly decreases in magnitude until it nears the second test point. After this,
it rises. Accordingly, this transfer function is a notch lter.
Exercise F.5. Consider the transfer function (z a)(z b) with 1 > a > 0 and
0 > b > 1. Sketch the magnitude of the frequency response, and show that it
has a bandpass shape over the range of frequencies between 0 and radians.
As another example, consider a ring of equally spaced zeros in the complex-z
plane. The resulting frequency-response magnitude will be relatively at because,
no matter where the test point is taken on the unit circle, the distance to the
zeros in the ring of zeros is roughly the same. As the number of zeros in the ring
decreases (increases), scallops in the frequency-response magnitude will become
more (less) pronounced. This is true irrespective of whether the ring of transferfunction zeros is inside or outside the unit circle. Of course, the phase curves will
be dierent in the two cases.
Exercise F.6. Sketch the frequency response of H(z) = z a when a = 2.
Sketch the frequency response of H(z) = z a when a = 2.
Exercise F.7. Sketch the frequency responses of
434
a.
b.
c.
d.
Exercise F.8. A second-order FIR lter has two zeros, both with positive real
parts. TRUE or FALSE: The lter is a highpass lter.
Exercise F.9. TRUE or FALSE: The linear, time-invariant lter with impulse
response
f [k] =
[k j]
j=
is a highpass lter.
Of course, these frequency responses can also be evaluated numerically. For
instance, the impulse response of the system described by H(z) = 1 + 0.6z 1
0.91z 2 is the vector h=[1 0.6 -0.91]. Using the command freqz(h) draws
the frequency response.
Exercise F.10. Draw the frequency response for each of the systems H(z) in
Problem F.7 using Matlab.
Exercise F.11. Develop a formula analogous to (F.7) that holds when H(z)
contains both poles and zeroes as in (F.5).
a. Sketch the frequency response for the system of Exercise F.3 when a = 0.5
and b = 1.
b. Sketch the frequency response for the system of Exercise F.3 when a = 0.98
and b = 1.
c. Sketch the frequency response for the system of Exercise F.3 when a = 1 and
b = 1.
If the transfer function includes nite-valued poles, the gain of the transfer
function is divided by the product of the distances from a test point on the unit
circle to the poles. The counterclockwise angle from the positive horizontal at
each pole location to the vector pointing from there to the test point on the unit
circle is subtracted in the overall phase formula. The point of this technique is
not to carry out complex calculations better left to computers, but to learn to
reason qualitatively using plots of the singularities of transfer functions.
The Z -Transform
F.3
435
Channel
Source
s
b0 + b1
z1 +
b2
z2
Decision
device
sign(.)
Reconstructed
source
estimate
y
436
Furthermore, y[k] = s[k] and y[k] = s[k 2] across the same set of choices. The
eye is still open.
Now consider b0 = 0.5, b1 = 1, and b2 = 0.6. The resulting r[k] are 0.9, 2.1,
1.1, 0.1, 0.1, 1.1, 2.1, and 0.9, with s[k 1] = 1, 1, 1, 1, 1, 1, 1, and
1. Out of these eight possibilities, two cause sign{r[k]} = s[k 1]. (Neither s[k]
nor s[k 2] does better.) The eye is closed.
This can be explored in Matlab using the program openclosed.m, which
denes the channel in b and implements it using the filter command. After
passing through the channel, the binary source becomes multivalued, taking on
values b1 b2 b3 . Typical outputs of openclosed.m are shown in Figure F.4
for channels b=[0.4 1 -0.2] and [0.5 1 -0.6]. In the rst case, four of the
possible values are above zero (when b2 is positive) and four are below (when
b2 is negative). In the second case, there is no universal correspondence between
the sign of the input data and the sign of the received data y. This is the purpose
of the nal for statement, which counts the number of errors that occur at each
delay. In the rst case, there is a delay that causes no errors at all. In the second
case, there are always errors.
Listing F.1. openclosed.m draw eye diagrams
b=[0.4 1 0.2];
% def i ne channel
m=1000; s=sign ( randn ( 1 ,m) ) ;
% binary input of length m
r=f i l t e r ( b , 1 , s ) ;
% output o f channel
y=sign ( r ) ;
% quantization
f o r sh =0:5
% e r r o r at d i f f e r e n t d el ay s
e r r ( sh +1)=0.5 *sum( abs ( y ( sh +1:m) s ( 1 :msh ) ) ) ;
end
then such incorrect decisions cannot occur. The greatest distortion occurs at the
boundary between the open and closed eyes. Let be the index at which the
impulse response has its largest coecient (in magnitude), so |b | |bi | for all
i. Dene the open-eye measure for a binary 1 input
i= |bi |
.
OEM = 1
|b |
For b0 = 0.4, b1 = 1, and b2 = 0.2, OEM = 1 (0.6/1) = 0.4. This value is
how far from zero (i.e., crossing over to the other source-alphabet value) the
equalizer output is in the worst case (as can be seen in Figure F.4). Thus, errorfree behavior could be assured as long as all other sources of error are smaller
than this OEM. For the channel [0.5, 1, 0.6], the OEM is negative, and the
eye is closed.
The Z -Transform
437
Amplitude
2
1
0
1
2
100 200 300 400 500 600 700 800 900 1000
Amplitude
100 200 300 400 500 600 700 800 900 1000
Symbol number
If the source is not binary, but instead takes on maximum (smax ) and minimum
(smin ) magnitudes, then, as a worst-case measure,
( i= |bi |)smax
OEM = 1
.
|b |smin
As dened, OEM is always less than unity, with this value achieved only in the
trivial case that all |bi | are zero for i = and |b | > 0. Thus,
438
0.1, 10, 0.1] have an open eye? Hint: use 2*s*(rand-0.5) to generate the
noise.
Exercise F.14. Modify openclosed.m so that the input uses the source alphabet
1, 3. Are any of the channels in Problem F.12 open eye? Is the channel b=
[0.1, 0.1, 10, 0.1] open eye? What is the OEM measure in each case?
When a channel has an open eye, all the intersymbol interference can be
removed by the quantizer. But when the eye is closed, something more must
be done. Opening a closed eye is the job of an equalizer, and is discussed at
length in Chapter 13.
Exercise F.15. The sampled impulse response from symbol values to the output of the downsampler in the receiver depends on the baud timing of the
downsampler. For example, let h(t) be the impulse response from symbol values
m(kT ) to downsampler output y(kT ). The sampled impulse response sequence
is h(t)|t=kT + for integers k and symbol period T , where is the selected baudtiming oset. Consider the nonzero impulse response values for two dierent
choices for ,
h(t)|t=kT +1 = {0.04, 1.00, 0.52, 0.32, 0.18},
h(t)|t=kT +2 = {0.01, 0.94, 0.50, 0.26, 0.06}
for k = 0, 1, 2, 3, 4.
a. With = 1 and a binary source alphabet 1, is the system from the source
symbols to the downsampler output open-eye? Clearly justify your answer.
b. With = 2 and a binary source alphabet 1, is the system from the source
symbols to the downsampler output open-eye? Clearly justify your answer.
c. Consider ltering the downsampler output with an equalizer with transfer
function F (z) = (z )/z to produce soft decisions y[k]. Thus, the discretetime impulse response from the symbols m[k] to the soft decisions y[k] is the
convolution of the sampled impulse response from the symbol values to the
downsampler output with the equalizer impulse response. With = 1 and a
four-element source alphabet {1, 3} can the system from the source symbols to the equalizer output be made open-eye by selecting = 0.6? Explain.
F.4
The Z -Transform
439
G(z) = B(z)/A(z), the loop can track both step inputs (which correspond to
phase osets in the carrier) and ramp inputs (which correspond to frequency
osets in the carrier). This provides analytical justication of the assertions in
Chapter 10 on the tracking capabilities of the loops.
As discussed in Section 10.6.3, Figure 10.22 is the linearization of Figure 10.20.
The input to the linearized system is 2 and the goal is to choose the LPF G(z) so
that 2 converges to 2. This can be rewritten as the desire to drive e = 2 2
to zero. Observe that a phase oset in the carrier corresponds to a nonzero and
a step input applied to the linearized system. A frequency oset in the carrier
corresponds to a ramp input (i.e., a line with slope proportional to the frequency
oset) applied to the linearized system.
Accordingly, the behavior of the system can be studied by nding the transfer
function E(z)/(z) from to e. The asymptotic value of E(z)/(z) can be
found using the nal-value theorem with (z) equal to a step and with (z)
equal to a ramp. If these are zero, the linearized system converges to the input,
i.e., e converges to zero and so converges to . This demonstrates the desired
tracking behavior.
is /(z 1) and
The transfer function from the output of the block G(z) to [k]
is G(z)/(z 1). With G(z) = B(z)/A(z)
so the transfer function from e to [k]
expressed as a ratio of two polynomials in z, the transfer function from to e is
E(z)
(z 1)A(z)
=
.
(z)
(z 1)A(z) + 2B(z)
(F.8)
zA(z)
(z 1)A(z)
(z) =
.
(z 1)A(z) + 2B(z)
(z 1)A(z) + 2B(z)
(F.9)
are strictly inside the unit circle. Since the numerator is zero, limk e[k] = 0.
In other words, as time k increases, the estimated phase converges to [k]. Thus
the system can track a phase oset in the carrier.
When [k] is a ramp with slope ,
0
k<0
[k] =
k k 0,
440
zA(z)
(z 1)((z 1)A(z) + 2B(z))
z1
A(1)
z1
A(z)
E(z) = lim
=
z1 (z 1)A(z) + 2B(z)
z
2B(1)
as long as B(1) = 0 and the roots of (F.9) are strictly inside the unit circle.
If A(1) = 0, limk e[k] is nonzero and decreases with larger . If A(1) = 0,
converges to the ramp [k]. This means that the
limk e[k] is zero and [k]
loop can also asymptotically track frequency osets in the carrier.
Changing shifts the closed-loop poles in (F.9). This impacts both the stabil locks
ity of the roots of (z) and the decay rate of the transient response as [k]
onto and tracks [k]. Poles closer to the origin of the z-plane correspond to faster
decay of the transient repsonse. Poles closer to the origin of the z-plane than to
z = 1 tend to de-emphasize the lowpass nature of the G(z), thereby weakening the suppression of any high-frequency disturbances from the input. Thus,
the location of the closed-loop poles compromises between improved removal of
broadband noises and a faster decay of the transient error.
The choice of G(z) which includes a pole at z = 1 (i.e., an integrator) results
in a PLL with type-II tracking capability, a designation commonly used in
feedback control systems where polynomial tracking is a frequent task. The name
arises from the ability to track a type-I polynomial (i = 1 in input ki with k
the time index) with zero error asymptotically and a type-II polynomial (k 2 )
with asymptotically constant (and nite) oset.
Exercise F.16. Suppose that a loop such as Figure 10.20 has G(z) = b/(z a).
a.
b.
c.
d.
Exercise F.17. Suppose that a loop such as Figure 10.20 has G(z) = b(z
c)/(z 1).
a.
b.
c.
d.
The Z -Transform
441
Exercise F.18. Suppose that a loop such as Figure 10.20 has G(z) = b(z
1)2 /(z 1 ).
a. What is the corresponding (z) of (F.9)?
b. Does this loop track phase osets? Does it track frequency osets?
c. For what value of does (z) become unstable?
Exercise F.19. The general loop in Figure 10.20 is simulated in pllgeneral.m.
a. Implement the lter G(z) from Exercise F.16 and verify that it behaves as
predicted.
b. Implement the lter G(z) from Exercise F.17 and verify that it behaves as
predicted.
c. Implement the lter G(z) from Exercise F.19 and verify that it behaves as
predicted.
There are two results in this appendix. The rst section argues that averages
(whether implemented as a simple sum, as a moving average, or in recursive form)
have an essentially lowpass character. This is used repeatedly in Chapters
6, 10, 12, and 13 to study the behavior of adaptive elements by simplifying
the objective function to remove extraneous high-frequency signals. The second
result is that the derivative of an average (or an LPF) is almost the same as
the average (or LPF) of the derivative. This approximation is formalized in
(G.12) and is used throughout Software Receiver Design to calculate the
derivatives that occur in adaptive elements such as the phase-locked loop, the
automatic gain control, output energy maximization for timing recovery, and
various equalization algorithms.
G.1
N
1
[i].
N i=1
(G.1)
For instance, the average temperature last year can be calculated by adding up
the temperature on each day, and then dividing by the number of days.
When talking about averages over time, it is common to emphasize recent
data and to de-emphasize data from the distant past. This can be done using a
moving average of length P , which has a value at time k of
1
[k] = avg{[i]} =
P
k
i=kP +1
[i].
(G.2)
443
(G.4)
which adds up each new element of the input sequence [i], scaled by . Indeed,
if the recursive lter (G.4) has = 1/N and is initialized with [0] = 0, then
[N ] is identical to the simple average in (G.1).
Writing these averages in the form of the lters (G.4) and (G.3) suggests the
following question: what kind of lters are these? The impulse response h[k] of
the moving average lter is
k<0
0
1
h[k] =
0k<P
P
0
k P,
which is essentially a rectangle shape in time. Accordingly, the frequency
response is sinc-shaped, from (A.20). Thus, the averaging lter passes very
low frequencies and attenuates high frequencies. It thus has a lowpass character,
though it is far from an ideal LPF.
The impulse response for the simple recursive lter (G.4) is
0
k<0
h[k] =
k 0.
This is also a rectangle that widens as k increases, which again represents a
lter with a lowpass character. This can be seen using the techniques of Appendix
F by observing that the transfer function of (G.4) has a single pole at 1 which
causes the magnitude of the frequency response to decrease as the frequency
increases. Thus, averages such as (G.1), moving-average lters such as (G.3),
and recursive lters such as (G.4) all have a lowpass character.
G.2
444
Chapter 12, and the equalizers of Chapter 13 all involve LPFs, averages, or both.
Finding the correct form for the adaptive updates requires taking the derivative
of ltered and averaged signals. This section shows when it is possible to commute the two operations, that is, when the derivative of the ltered (averaged)
signal is the same as a ltering (averaging) of the derivative. The derivative is
taken with respect to some variable , and the key to the commutativity is how
enters the ltering operation. Sometimes the derivative is taken with respect
to time, sometimes it is taken with respect to a coecient of the lter, and
sometimes it appears as a parameter within the signal.
When the derivative is taken with respect to time, the LPF and/or average
commute with the derivative; that is,
d
d
=
LPF{}
(G.5)
LPF
d
d
and
avg
d
d
d
avg{},
d
(G.6)
where is the signal and represents time. This is a direct consequence of linearity; the LPF and the derivative are both linear operations. Since linear operations commute, so do the lters (averages) and the derivatives. This is demonstrated using the code in dlpf.m in which a random signal s is passed through
an arbitrary linear system dened by the impulse response h. The derivative is
approximated in dlpf.m using the diff function, and the calculation is done two
ways: rst by taking the derivative of the ltered signal, and then by ltering the
derivative. Observe that the two methods give the same output after the lters
have settled.
Listing G.1. dlpf.m dierentiation and ltering commute
s=randn ( 1 , 1 0 0 ) ;
h=randn ( 1 , 1 0 ) ;
d l p f s=d i f f ( f i l t e r ( h , 1 , s ) ) ;
l p f d s=f i l t e r ( h , 1 , d i f f ( s ) ) ;
d l p f s l p f d s
%
%
%
%
%
g e n e r a t e random data
an a r b i t r a r y i m p u l s e r e s p o n s e
take deriv of f i l t e r e d input
f i l t e r th e d e r i v o f i n p u t
compare th e two
When the derivative is taken with respect to a coecient (tap weight) of the
lter, then (G.5) does not hold. For example, consider the time-invariant linear
lter
[k] =
P
1
bi [k i],
i=0
which has impulse response [bP 1 , . . . , b1 , b0 ]. If the bi are chosen so that [k]
represents a lowpass ltering of the [k], then the notation
[k] = LPF{[k]}
445
(G.7)
Since all the terms bi [k i] are independent of bj for i = j, all of the derivatives
dbi [k i]/dbj are zero. For i = j,
dbj
dbj [k j]
= [k j]
= [k j],
dbj
dbj
so
d[k]
dLPF{[k]}
=
= [k j].
dbj
dbj
(G.8)
P
1
bi (, k i).
i=0
446
P 1
d
bi (a0 u[k i] + a1 u[k i 1] + a2 u[k i 2])
da1 i=0
P
1
d
(a0 u[k i] + a1 u[k i 1] + a2 u[k i 2])
da1
i=0
P
1
d(a1 , k)
bi u[k i 1] = LPF
=
.
da1
=
bi
i=0
The transition between the second and third equality mimics the transition from
(G.7) to (G.8), with u playing the role of and a1 playing the role of bj .
G.3
P
1
bi ([k i], k i)
i=0
447
Only the rst term in the sum has the form of (G.10). All others are of the form
d([k i], k i)
,
d[k]
with i = 0. If there were no functional relationship between [k] and [k i],
this derivative would be zero, and
d(, k)
d[k]
= b0
.
d[k]
d =[k]
But, of course, there generally is a functional relationship between at dierent
times, and proper evaluation of the derivative requires that this relationship be
taken into account.
The situation that is encountered repeatedly throughout Software Receiver
Design occurs when [k] is dened by a small-stepsize iteration; that is,
[k] = [k 1] + ([k 1], k 1),
(G.11)
where ([k 1], k 1) is some bounded signal (with bounded derivative) which
may itself be a function of time k 1 and the state [k 1]. A key feature of
(G.11) is that is a user-choosable stepsize parameter. As will be shown, when
a suciently small is chosen, the derivative d[k]/d[k] can be approximated
eciently as
P
1
P
1
d([k i], k i)
d([k i], k i)
dLPF{([k], k)}
=
bi
bi
d[k]
d[k]
d[k i]
i=0
i=0
#
d(, k)
,
(G.12)
= LPF
d =[k]
which nicely recaptures the commutativity of the LPF and the derivative as in
(G.5). A special case of (G.12) is to replace LPF with avg.
The remainder of this section provides a detailed justication for this approximation and provides two detailed examples. Other examples appear throughout
Software Receiver Design.
As a rst step, consider the derivative which appears in the second term of
the sum in (G.12). This can be rewritten using the chain rule (A.59) as
d([k 1], k 1)
d([k 1], k 1) d[k 1]
=
.
d[k]
d[k 1]
d[k]
Rewriting (G.11) as [k 1] = [k] ([k 1], k 1) yields
d([k 1], k 1) d([k] ([k 1], k 1))
d[k 1]
d[k]
d(, k 1)
d([k 1], k 1)
=
.
1
d
d[k]
=[k1]
(G.13)
448
,
=
d(, k 1)
d[k]
1 + 0
1+
d
(G.14)
=[k1]
where
d(, k 1)
.
0 =
d
=[k1]
(G.15)
.
d[k]
d
=[k1]
Following the same basic steps for the general delay term in (G.12) shows that
d(, k n)
d([k n], k n)
(1 n ),
=
d[k]
d
=[kn]
where
n1
0
n =
j
1
1 + 0
j=1
(G.16)
d[k]
d
=[kn]
449
Example G.3. Example G.1 assumes that the phase angle is xed, even though
the purpose of the adaptation in a phase-tracking algorithm is to allow to follow
a changing phase. To investigate the time-varying situation, let [k] = [k] and
([k], k) = ([k], k) = sin(2f kT + [k]). Suppose also that the dynamics of
are given by
[k] = [k 1] + ([k 1], k 1).
Using the approximation (G.16) yields
P 1
d
dLPF{([k], k)}
=
bi ([k i], k i)
d[k]
d[k] i=0
=
=
P 1
d
bi sin(2(k i)T + [k i])
d[k]
P
1
i=0
P
1
i=0
bi
d
sin(2(k i)T + [k i])
d[k]
bi
d
sin(2(k i)T + [k i])
d[k i]
i=0
P
1
(G.17)
Example G.4. Example G.2 assumes that the parameter a1 of the linear lter
is xed, even though the purpose of the adaptation is to allow a1 to change
in response to the behavior of the signal. Let ([k], k) be formed by ltering
a signal u[k] that is independent of [k]. To be precise, let [k] = a1 [k] and
([k], k) = (a1 [k], k) = a0 [k]u[k] + a1 [k]u[k 1] + a2 [k]u[k 2]. Suppose also
that the dynamics of a1 [k] are given by
a1 [k] = a1 [k 1] + (a1 [k 1], k 1).
450
P 1
d
bi (a0 [k i]u[k i] + + a2 [k i]u[k i 2])
da1 [k] i=0
P
1
bi
i=0
P
1
d
(a0 [k i]u[k i] + + a2 [k i]u[k i 2])
da1 [k]
P 1
da1 [k i]u[k i 1]
da1 [k i]u[k i 1]
bi
da1 [k]
da1 [k i]
i=0
i=0
#
P
1
d(a1 , k)
bi u[k i 1] = LPF
=
.
da1
i=0
bi
a1 =a1 [k]
In Chapter 9, the Basic Black Box Impairment Generator of Figure 9.22 (on page
187) was described as a routine that transforms a Matlab script specifying the
operation of the transmitter into the (received) signal that appears at the input of
the receiver. This appendix opens up the black box, shining light on the internal
operation of the B 3IG.
The B 3IG is implemented in Matlab as the routine BigTransmitter.m, and
it allows straightforward modeling of any (or all) of the possible impairments
discussed throughout Software Receiver Design, including carrier-frequency
oset, baud-timing osets, and frequency-selective and time-varying channels,
as well as channel noise. Since many of the impairments and nonidealities that
arise in a communication system occur in the channel and RF front end, B 3IG
is more than a transmitter: it includes the communication channel and receiver
RF front end as well. An overview of the B 3IG is shown in Figure H.1.
The B 3IG architecture expands on the simplied communication system of
Chapter 9 and has more options than the M6 transmitter of Chapter 15. Some
of the additional features are as follows.
Support for multiple users. The transmitter generates a signal that may contain
information intended for more than one receiver.
Message for
User 1
Message for
Transmitter
User 2
...
Channel Between
Base Station
and User n
Sampled IF
Receiver
for User n
Received
Digital
Signal
Message for
User K
Figure H.1 The B 3IG picture: an overview of the transmission system which can be
used with multiple users, and has numerous ways to model impairments of the
received signal.
452
Assumption that the receiver employs a sampled intermediate-frequency architecture. Section 6.2 presented several choices for performing downsampling in
a receiver. In modern communication systems, where carrier frequencies can
be on the order of several gigahertz, it is rarely feasible to build a receiver
front end that samples at the Nyquist rate. The B 3IG transmitter generates a
received signal that has been brought down to a lower, intermediate frequency
(IF) and then sampled at some specied rate assumed to be lower than the
Nyquist rate of the IF.
Insertion of periodic preamble data. In practice, transmission of some known
preamble data is required so that the receiver can learn how to combat the
various impairments and nonidealities. In addition, the preamble permits the
receiver to identify the start of a frame or transmission.
The B 3IG is intended to mimic the base station in a cellular system in which
the geographical coverage area is split into hexagonally shaped cells as in Figure H.2. Thus there are many users in the same geographical region all wishing
to transmit and receive simultaneously. How is a given receiver able to separate its message from the composite received signal? The key is to separate the
transmission either in time or in frequency (or using a mixture of time and
frequency called the code space). These separation techniques are called timedivision multiple access (TDMA), frequency-division multiple access (FDMA),
and code-division multiple access (CDMA).
Within a single cell, the transmitter implements multiple users that send messages by sequencing them in time. In TDMA, where the signal intended for each
user is transmitted during a designated time slot, all users employ the same band
of frequencies. The frame structure for the B 3IG TDMA is shown in Figure H.3.
This may be contrasted with the FDMA situation where users each employ their
own frequency range, as was discussed in Figure 2.3 on page 22.
Typically, adjacent cells transmit on dierent frequencies, though frequencies
may be reused in cells that are suciently far away. Adjacent cells may use
frequencies that are close to each otherand may even overlap slightly due to
relaxed spectral masks. Consequently, it is not unreasonable to expect some
... User K Preamble User 1 User 2 ... User K Preamble User 1 ...
Np Characters
in Preamble
Ns Characters
per User Slot
453
interference from adjacent cells. The B 3IG makes it easy to study the eects of
this kind of interference.
In code-division multiple access (CDMA), each user is assigned a code that is
mutually orthogonal to all of the other users. All users transmit at the same time
and in the same frequency range, and the decoding relies on the orthogonality of
the codes. The B 3IG does not currently implement a CDMA protocol. Adding a
CDMA component to the receiver would make a great course project!
H.1
Bits
Text
message Characterto-binary
conversion
Symbols
s[i]
Scaling
TDMA user
multiplexing
Trigger
Baseband
signal
s(t)
Pulse
shape
P( f )
Transmitted
passband
signal
Modulation
including
phase noise
Channel
Adjacent Broadband
users
noise
Analog
received
signal
1
iTt + t
Figure H.4 The signal-ow diagram of the B 3IG transmitter closely follows that of the
454
mixer
Preselect
Filter
r[k]
IF Filter
AGC
kTs
oscillator
which converts each letter into a 7-bit binary string, thus assigning seven 4-PAM
symbols to every pair of letters. This mapping is familiar from Example 8.2.
In order to decode the message at the receiver, the recovered symbols must be
properly grouped, the start of each group must be located, and the desired user
data must be extracted. To aid this TDMA frame synchronization, a preamble
is inserted in the symbol stream at the start of every frame. The preamble is
a short text message that starts each frame and it is assumed to be known at
the receiver. Like the message, it is encoded in 4-PAM symbols. The unknown
messages for each user are placed in sequence after the preamble, as in Figure
H.3.
As indicated in Figure H.4, pulses are initiated at intervals of Tt seconds,
and each is scaled by the 4-PAM symbol value. This translates the discrete-time
symbol sequence s[i] (composed of the messages interleaved with the preamble)
into a continuous time signal
s[i](t iTt t ).
s(t) =
i
455
The channel may be near ideal, i.e., a unit gain multi-symbol delay, or it may
have signicant intersymbol interference. In addition it can be time-varying, and
the B 3IG code allows two ways to introduce time variation. The rst permits
specication of the channel impulse response c1 at the start of the transmission
and the channel impulse response c2 at the end of the transmission. At any
time in between, the actual impulse response moves linearly from c1 to c2 . The
second method of introducing time variation is to model the channel variation
as a random walk. The variance of the random-walk process can be specied.
In either case, the impulse response of the channel is unknown at the receiver,
though an upper bound on its delay spread may be available in practice. There
are also other disturbances that may be present, including interference from
adjacent channels and narrowband interferers. These disturbances can also be
controlled using the B 3IG transmitter, and they are assumed to be unknown at
the receiver.
The achieved intermediate frequency is required to be within some userspecied tolerance of its assigned value. The carrier phase (t) is unknown to the
receiver and may vary over time, albeit slowly, due to phase noise. This means
that the phase of the intermediate-frequency signal presented to the receiver
sampler may also vary.
The front end of the sampled IF receiver, as shown in Figure H.5, consists
of a low-noise amplier, a preselect lter, an AGC, a mixer for downconversion
to IF, and the sampler. The preselect lter partially attenuates adjacent FDM
user bands. The automatic gain control is presumed locked and xed over each
transmission, and outputs a signal whose average power is unity. The free-running
sampler frequency fs needs to be well above twice the baseband bandwidth of
the user of interest to allow proper functioning of the baseband analog signal
interpolator in the DSP timer in the receiver. However, fs need not be twice
the highest frequency of the IF signal. This implies that the sampled received
signal has replicated the spectrum of the user transmission at the output of the
front-end analog downconverter lowpass lter to frequencies between zero and
IF.
H.2
H.2.1
Function Call
To generate the received signal, the B 3IG transmitter is called by
[r, s]=BigTransmitter(m, frameParams, rfParams, chanParams);
where m is the message (or messages, in the case of multiple users) to be
transmitted, frameParams is a structure containing the parameters relating to
the frame structure, rfParams contains the analog/RF-related parameters, and
456
chanParams contains the channel parameters. There are two output arguments:
r is the received sampled signal and s is the 4-PAM symbols which were transmitted. Thus, the length of s is approximately equal to the length of r times the
eective oversampling factor.
H.2.2
rfParams.SRRCrolloff
Figure H.6 B 3IG parameters passed via the stuctures frameParams, rfParams, and
chanParams.
457
458
H.2.3
459
Amplitude
Magnitude (x104)
0.004
0.008
(a) Seconds
0.012
8
6
4
2
0
0
1
(b) Frequency (x107)
three parameters have been left incomplete, as indicated by the question marks
in BigEx2.m. Determine the intermediate frequencies of the desired user and
adjacent interfering user, and the sampling frequency fs in order to generate the
signal in Figure H.7. Plot the spectrum of the signal you generate.
Exercise H.2. The script in BigEx3.m generates an ideal received signal much
like idsys.m from Chapter 9. This time, however, the transmitter sends signals
for two users using TDMA, where frameParams.userDataLength = 5. Mimic
the receiver code in BigIdeal.m to accurately decode the signal for each user.
Write your receiver code so that it stores the message for the rst user in a
variable called decoded1, and the message for the second user in a variable
called decoded2.
H.3
r Use the debugging capabilities of Matlab, including breakpoints, step execution, etc.
Index
460
Index
461
462
Index
Hamming
blip, 156, 169, 194, 228, 233
distance, 333
wide blip, 230
hard decision, 174
Haykin, S., 39, 56
HDTV, 102
header, 158, 344, 454
high-side injection, 93
highpass lter, see HPF
Hilbert transform, 407, 420
hill climbing, 115
HPF, 24, 46, 141
Human code, 37, 324
human hearing, 102
ideal
channel, 5
receiver, 4, 5, 13, 58, 165
transmitter, 165
Lathi, B. P., 39
least mean square algorithm, 285, 388
least squares, 277
Lee, E. A., 375, 386, 395, 402
Leibniz rule, 410
letters to bits, 4, 153
linear, 20, 23, 407, 422
linear block codes, 37
linear lters, 59, 65, 70, 130151
linear vs nonlinear codes, 335
LMS, see least mean squares
local minima, 118
logical AND, 329
lookfor, see Matlab lookfor
low-side injection, 93
lowpass lter, see LPF
LPF, 23, 141, 171
LPF and averaging, 442
M6 receiver, 342356
majority rules, 328, 332
marker, 162, 172, 178, 344, 454
matched lter, 242249
mathematical prerequisites, v
Index
Matlab
AGC, 124
averaging, 124
block code, 331
clock recovery, 258, 262
convolution, 70, 237
correlation, 158
DMA equalizer, 292
envelope, 416
equalizer
DD, 289
LMS, 286
LS, 278
error surface, 125, 213, 259
eye diagrams, 233
FFT, 135
lter, 47, 48, 70, 142, 237
rpm, vii, 47, 77, 146, 415
frequency response, 74
frequency tracking, 219
freqz, 143
help, 42
ideal receiver, 169
ideal transmitter, 168
interpolation, 112
lookfor, 42
matched lter, 244
mod, 329
noise, 413
phase tracking, 198, 204, 208, 212
plotspec, 42, 51
quantalph, 53, 161
rand vs randn, 414
random, 43
random sentences, 312
remez, 47
resample, 113
reshape, 233
sampling, 98, 108
source code, 326
spectrum of a pulse sequence, 228
timing recovery, 258, 262
toeplitz, 276
maximum phase, 430
maximum-length pseudo-noise sequence, 162
McClellan, J. H., 56, 151
mean, 413
Meyr, H., 268, 356, 394, 403
minimum distance, 333, 338
minimum phase, 430
Mitola, J. et al., 356
Mitra, S., 57
mixers, 5354
mixing, 81
mod, see Matlab mod
modular arithmetic, 329, 337
463
modulation, 9, 17, 20
complex-valued, 359
large carrier, 81
quadrature, 9093, 283, 417
quadrature amplitude, 357403
single sideband, 81
small carrier, 8490
vestigal sideband, 81
Morse code, 323
moving average, 442
mp3 compression, 327
multipath, 10, 27, 34, 61, 179, 182, 270,
272273, 435
mystery signal, 355
Nahin, P. J., 97
naive receiver, 12
Nevermind, 344
noise, 42, 77, 179
broadband, 60, 76, 180, 242, 412
colored, 414
in-band, 10, 60
narrowband, 61, 270, 412
out-of-band, 10, 60
simulating, 412415
spectrum of, 413
thermal, 60, 76
white, 245, 412
nonlinear, 20
nonlinear vs linear codes, 335
nonlinearities, 5253, 196, 197, 376, 416
nonreturn to zero, 236
number of particles in the Universe, 336
numerical approximation to derivative, 256,
262
Nyquist
frequency, 50
pulse, 237242, 247
rate, 101
sampling theorem, 28, 101
open eye, 185, 232, 266, 278, 287, 290, 435
open-eye measure, 436
Oppenheim, A. V., 56
optimization, 34, 114
oscillators, 4446, 192, 210
other users, 60, 270
output power, 251, 254
oversampling, 109, 156, 168, 194, 228, 236
PAM, 5
parity check, 328, 330
Parsevals theorem, 133, 408, 425
passband, 141
pedagogical method, iv
performance function, 114, 263, 293, 381
464
Index
Index
465