208
Sinais e Sistemas
UFRJ
586
Sinais e Sistemas
UFRJ
1
Sinais e Sistemas
UFRJ
1
Sinais e Sistemas
UFRJ
1
Sinais e Sistemas
UFRJ
1
Sinais e Sistemas
UFRJ
1
Sinais e Sistemas
UMG
3
Sinais e Sistemas
PUC
1
Sinais e Sistemas
UMG
1
Sinais e Sistemas
FPAS
Texto de pré-visualização
i Software Receiver Design Build Your Own Digital Communications System in Five Easy Steps Have you ever wanted to understand how modern digital communication systems work What is inside your cell phone or HDTV How it is possible for grandmas voice and face to be converted into ones and zeroes transmitted across the planet through wires and through the air received in your home and reconstructed at your fingertips Chapter by chapter Software Receiver Design helps you create a Matlab R realization of the various pieces of a communications system that make this possible exploring the key ideas along the way In the final chapters you can put it all together to build fully functional software receivers 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 and immediacy to the study of communication systems Johnson Sethares and Klein have been learning researching and teaching about signals information flow and data transmission for a long time At the end of the last century they began working with engineers in the telecommuni cations industry on some problems in the transmission and reception of digital TV systems In the course of solving these problems they designed built and coded a software version of the receiver that was key in locating the source of the problems and in testing eventual solutions When it was over the authors had a startling revelation the process of building the software receiver had taught them an enormous amount Why not take this idea and use it to help others learn Software Receiver Design is the result The authors teach at Cornell University the University of Wisconsin and Worcester Polytechnic Institute and you can find out more about them if interested on the web For instance pt may be the rectangular pulse pt 1 when 0 t T 0 otherwise 12 which is plotted in Figure 12a The transmitter of Figure 11 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 11 is illustrated in Figure 12b using the rectangular pulse shape Thus the first pulse begins at some time τ and it is scaled by s0 producing s0pt τ The second pulse begins at time τ T and is scaled by s1 resulting in s1pt τ T The third pulse gives s2pt τ 2T and so on The complete output of the transmitter is the sum of all these scaled pulses yt i sipt τ iT 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 11 it is called 4PAM 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 finite 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 12b is as shown in Figure 12c 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 reflected from mountains or buildings It may be diffracted 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 different city Noises may enter and change the shape of the waveform There are two compelling reasons to consider the telecommunication system in the simplified 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 refine 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 12c and to recover the original text message This can be accomplished by an idealized receiver such as that shown in Figure 13 The first task this receiver must accomplish is to sample the signal to turn it into computerfriendly digital Software Receiver Design Build Your Own Digital Communications System in Five Easy Steps C Richard Johnson Jr William A Sethares and Andrew G Klein July 19 2011 iv cambridge university press Cambridge New York Melbourne Madrid Cape Town Singapore Sao Paulo Cambridge University Press The Edinburgh Building Cambridge CB2 2RU UK Published in the United States of America by Cambridge University Press New York wwwcambridgeorg Information on this title wwwcambridgeorg9780521XXXXXX C Cambridge university Press 2011 This publication is in copyright Subject to statutory exception and to the provisions of relevant collective licensing agreements no reproduction of any part may take place without the written permission of Cambridge University Press First published 2011 Printed in the United Kingdom at the University Press Cambridge A catalogue record for this publication is available from the British Library Library of Congress Cataloguing in Publication data ISBN13 9780521XXXXXX hardback ISBN10 0521XXXXXX hardback Cambridge University Press has no responsibility for the persistence or accuracy of URLs for external or thirdparty internet websites referred to in this publication and does not guarantee that any content on such websites is or will remain accurate or appropriate To the Instructor though its OK for the student to listen in Software Receiver Design helps the reader build a complete digital radio that includes each part of a typical digital communication system Chapter by chapter the reader creates a Matlab R realization of the various pieces of the system exploring the key ideas along the way In the final 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 empha size some topics that are often covered only superficially 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 mul tiplexing 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 finish than to halflearn the properties of many Whole Lotta Radio Our approach to building the components of the digital radio is consistent throughout Software Receiver Design For many of the tasks we define a performance function and an algorithm that optimizes this function This vi To the Instructor approach provides a unified framework for deriving the AGC clock recovery car rier 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 fine texts cited for further reading in Section 38 would be fine Software Receiver Design emphasizes two ways to assess the behavior of the components of a communication system by studying the performance func tions 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 ana lytical 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 final project challenges the digital radio that the student has built by adding many different kinds of imperfections includ ing 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 handson 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 find that the order of presentation of topics in the five easy steps is different from that used by other books Section 13 provides an overview of the flow of topics and our reasons for structuring the course as we have Finally we believe that Software Receiver Design may be of use to non traditional students Besides the many standard kinds of exercises there are many problems in the text that are selfchecking in the sense that the reader will know whenwhether they have found the correct answer These may also be useful to the selfmotivated design engineer who is using Software Receiver Design to learn about digital radio To the Instructor vii How Weve Used Software Receiver Design The authors have taught from various versions of this text for a number of years exploring different ways to fit coverage of digital radio into a standard electrical engineering elective sequence Perhaps the simplest way is via a standalone course one semester long in which the student works through the chapters and ends with the final project as outlined in Chapter 15 Students who have graduated tell us that when they get to the workplace where softwaredefined digital radio is increasingly impor tant the preparation of this course has been invaluable After having completed this course plus a rigorous course in probability other students have reported that they are well prepared for the typical introductory graduatelevel class in communications offered at research universities At Cornell University the University of Wisconsin and Worcester Polytechnic Institute the home institutions of the authors there is a twosemester sequence in communications available for advanced undergraduates We have integrated the text into this curriculum in three ways 1 Teach from a traditional text for the first semester and use Software Receiver Design in the second 2 Teach from Software Receiver Design in the first semester and use a tra ditional text in the second 3 Teach from Software Receiver Design in the first semester and teach a projectoriented extension in the second All three work well When following the first approach students often comment that by reading Software Receiver Design they finally understand what they had been doing the previous semester Because there is no probability prerequisite for Software Receiver Design the second approach can be moved earlier in the curriculum Of course we encourage students to take probability at the same time In the third approach the students were asked to extend the basic pulse amplitude modulation PAM and quadrature amplitude modulation QAM digital radios to incorporate code division multiplexing to use more advanced equalization techniques etc We believe that the increasing market penetration of broadband communica tions is the driving force behind the continuing redesign of radios wireless communications devices Digital devices continue to penetrate the market for merly occupied by analog for instance digital television has now supplanted analog television in the USA and the area of digital and softwaredefined radio is regularly reported in the mass media Accordingly it is easy for the instructor to emphasize the social and economic aspects of the wireless revolution The impact of digital radio is vast and it is an exciting time to get involved viii To the Instructor Some Extras The course website contains extra material of interest especially to the instruc tor First we have assembled a complete collection of slides in pdf format that may help in lesson planning The final 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 exploration1 Mathematical Prerequisites r G B Thomas and R L Finney Calculus and Analytic Geometry 8th edition AddisonWesley 1992 r B Kolman and D R Hill Elementary Linear Algebra 8th edition Prentice Hall 2003 r J H McClellan R W Schafer and M A Yoder Signal Processing First PrenticeHall 2003 1 The m scripts will run with either Matlab or GNU Octave which is freely available at httpwwwgnuorgsoftwareoctave When using the scripts with Matlab the Signal Pro cessing Toolbox is required all scripts have been tested with Matlab v710R2010a but are expected to work with older versions of Matlab For Octave the scripts were tested with Octave v323 and the required OctaveForge toolboxes signal v1011 specfun v109 optim v1012 miscellaneous v109 and audio v114 When using Octave the script firpm octavem can be renamed firpmm so that identical code will run in the two plat forms Contents To the Instructor page v Step 1 The Big Picture 1 1 A Digital Radio 2 11 What Is a Digital Radio 2 12 An Illustrative Design 3 13 Walk This Way 12 Step 2 The Basic Components 15 2 A Telecommunication System 16 21 Electromagnetic Transmission of Analog Waveforms 16 22 Bandwidth 18 23 Upconversion at the Transmitter 20 24 Frequency Division Multiplexing 22 25 Filters that Remove Frequencies 23 26 Analog Downconversion 24 27 Analog Core of a Digital Communication System 26 28 Sampling at the Receiver 28 29 Digital Communications Around an Analog Core 29 210 Pulse Shaping 30 211 Synchronization Good Times Bad Times 33 212 Equalization 34 213 Decisions and Error Measures 35 214 Coding and Decoding 37 215 A Telecommunication System 38 216 Stairway to Radio 38 3 The Six Elements 40 31 Finding the Spectrum of a Signal 41 32 The First Element Oscillators 44 33 The Second Element Linear Filters 46 x Contents 34 The Third Element Samplers 49 35 The Fourth Element Static Nonlinearities 52 36 The Fifth Element Mixers 53 37 The Sixth Element Adaptation 55 38 Summary 56 Step 3 The Idealized System 58 4 Modeling Corruption 59 41 When Bad Things Happen to Good Signals 59 42 Linear Systems Linear Filters 65 43 The Delta Function 65 44 Convolution in Time Its What Linear Systems Do 70 45 Convolution Multiplication 72 46 Improving SNR 76 5 Analog Demodulation 80 51 Amplitude Modulation with Large Carrier 81 52 Amplitude Modulation with Suppressed Carrier 84 53 Quadrature Modulation 90 54 Injection to Intermediate Frequency 93 6 Sampling with Automatic Gain Control 98 61 Sampling and Aliasing 99 62 Downconversion via Sampling 103 63 Exploring Sampling in MATLAB 108 64 Interpolation and Reconstruction 110 65 Iteration and Optimization 114 66 An Example of Optimization Polynomial Minimization 115 67 Automatic Gain Control 120 68 Using an AGC to Combat Fading 127 69 Summary 129 7 Digital Filtering and the DFT 130 71 Discrete Time and Discrete Frequency 130 72 Practical Filtering 141 8 Bits to Symbols to Signals 152 81 Bits to Symbols 152 82 Symbols to Signals 155 83 Correlation 157 84 Receive Filtering From Signals to Symbols 160 85 Frame Synchronization From Symbols to Bits 161 Contents xi 9 Stuff Happens 165 91 An Ideal Digital Communication System 166 92 Simulating the Ideal System 167 93 Flat Fading A Simple Impairment and a Simple Fix 175 94 Other Impairments More What Ifs 178 95 A B3IG Deal 187 Step 4 The Adaptive Components 191 10 Carrier Recovery 192 101 Phase and Frequency Estimation via an FFT 194 102 Squared Difference Loop 197 103 The PhaseLocked Loop 202 104 The Costas Loop 206 105 DecisionDirected Phase Tracking 210 106 Frequency Tracking 216 11 Pulse Shaping and Receive Filtering 226 111 Spectrum of the Pulse Spectrum of the Signal 227 112 Intersymbol Interference 229 113 Eye Diagrams 231 114 Nyquist Pulses 237 115 Matched Filtering 242 116 Matched Transmit and Receive Filters 247 12 Timing Recovery 250 121 The Problem of Timing Recovery 251 122 An Example 252 123 DecisionDirected Timing Recovery 256 124 Timing Recovery via Output Power Maximization 261 125 Two Examples 266 13 Linear Equalization 270 131 Multipath Interference 272 132 Trained LeastSquares Linear Equalization 273 133 An Adaptive Approach to Trained Equalization 284 134 DecisionDirected Linear Equalization 288 135 DispersionMinimizing Linear Equalization 290 136 Examples and Observations 294 14 Coding 303 141 What Is Information 304 142 Redundancy 308 xii Contents 143 Entropy 315 144 Channel Capacity 318 145 Source Coding 323 146 Channel Coding 328 147 Encoding a Compact Disc 339 Step 5 Putting It All Together 341 15 Make It So 342 151 How the Received Signal Is Constructed 343 152 A Design Methodology for the M6 Receiver 345 153 No Soap Radio The M6 Receiver Design Challenge 354 16 A Digital Quadrature Amplitude Modulation Radio 357 161 The Song Remains the Same 357 162 Quadrature Amplitude Modulation QAM 358 163 Demodulating QAM 363 164 Carrier Recovery for QAM 367 165 Designing QAM Constellations 378 166 Timing Recovery for QAM 380 167 Baseband Derotation 384 168 Equalization for QAM 387 169 Alternative Receiver Architectures for QAM 391 1610 The Q3AM Prototype Receiver 397 1611 Q3AM Prototype Receiver Users Manual 398 Appendices 404 A Transforms Identities and Formulas 404 A1 Trigonometric Identities 404 A2 Fourier Transforms and Properties 405 A3 Energy and Power 409 A4 ZTransforms and Properties 409 A5 Integral and Derivative Formulas 410 A6 Matrix Algebra 411 B Simulating Noise 412 C Envelope of a Bandpass Signal 416 D Relating the Fourier Transform to the DFT 421 D1 The Fourier Transform and Its Inverse 421 D2 The DFT and the Fourier Transform 422 Contents xiii E Power Spectral Density 425 F The ZTransform 428 F1 ZTransforms 428 F2 Sketching the Frequency Response from the ZTransform 432 F3 Measuring Intersymbol Interference 435 F4 Analysis of Loop Structures 438 G Averages and Averaging 442 G1 Averages and Filters 442 G2 Derivatives and Filters 443 G3 Differentiation Is a Technique Approximation Is an Art 446 H The B3IG Transmitter 451 H1 Constructing the Received Signal 453 H2 Matlab Code for the Notorious B3IG 455 H3 Notes on Debugging and Signal Measurement 459 Index 460 xiv Contents With thanks to Tom Robbins for his foresight encouragement and perseverance The professors who have taught from earlier versions of this book Mark Ander sland Marc Buchner Brian Evans Edward Doering Tom Fuja Brian Sadler Michael Thompson and Mark Yoder The classes of students who have learned from earlier versions of this book ECE436 and ECE437 at the University of Wisconsin EE467 and EE468 at Cornell University and ECE 3311 at Worcester Polytechnic Institute Teaching assistants and graduate students who have helped refine this mate rial Jai Balkrishnan Rick Brown Wonzoo Chung Qingxiong Deng Matt Gaubatz Jarvis Haupt Sean Leventhal Yizheng Liao Katie Orlicki Jason Pagnotta Adam Pierce Johnson Smith Charles Tibenderana and Nick Xenias The companies that have provided data or access to engineers and joined us in the field Applied Signal Technology Aware Fox Digital Iberium Lucent Technologies and NxtWave Communications now AMD The many talented academics and engineers who have helped hone this mate rial Raul Casas Tom Endres John Gubner Rod Kennedy Mike Larimore Rick Martin Phil Schniter John Treichler John Walsh Evans Wetmore and Robert Williamson The staff of talented editors at Cambridge University Press Phil Meyler Sarah Finlay Sarah Matthews Steven Holt and Joanna EndellCooper Where would we have been without LATEX guru Sehar Tahir Those with a welldeveloped sense of humor Ann Bell and Betty Johnson Dread Zeppelin whose 1999 performance in Palo Alto inspired the title Telecom munication Breakdown In this new improved expanded and more reveal ingly titled version the legacy continues how many malapropic Led Zeppelin song titles are there Dedicated to Samantha and Franklin Step 1 The Big Picture Software Receiver Design Build Your Own Digital Communications System in Five Easy Steps is structured like a staircase with five simple steps The first chapter presents a naive digital communications system a sketch of the digital radio as the first step The second chapter ascends one step to fill in details and demystify various pieces of the design Successive chapters then revisit the same ideas each step adding depth and precision The first functional though idealized receiver appears in Chapter 9 Then the idealizing assumptions are stripped away one by one throughout the remaining chapters culminating in sophisticated receiver designs in the final chapters Section 13 on page 12 outlines the five steps in the construction of the receiver and provides an overview of the order in which topics are discussed 1 A Digital Radio 11 What Is a Digital Radio The fundamental principles of telecommunications have remained much the same since Shannons time What has changed and is continuing to change is how those principles are deployed in technology One of the major ongoing changes is the shift from hardware to softwareand Software Receiver Design reflects this trend by focusing on the design of a digital softwaredefined radio that you will implement in Matlab Radio does not literally mean the AMFM radio in your car it represents any throughtheair transmission such as television cell phone or wireless com puter data though many of the same ideas are also relevant to wired systems such as modems cable TV and telephones Softwaredefined means that key elements of the radio are implemented in software Taking a softwaredefined approach mirrors the trend in modern receiver design in which more and more of the system is designed and built in reconfigurable software rather than in fixed hardware The fundamental concepts behind the transmission are introduced demonstrated and we hope understood through simulation For example when talking about how to translate the frequency of a signal the procedures are presented mathematically in equations pictorially in block diagrams and then concretely as short Matlab programs Our educational philosophy is that it is better to learn by doing to motivate study with experiments to reinforce mathematics with simulated examples to integrate concepts by playing with the pieces of the system Accordingly each of the later chapters is devoted to understanding one component of the transmis sion system and each culminates in a series of tasks that ask you to build a particular version of that part of the communication system In the final chapter the parts are combined to form a full receiver We try to present the essence of each system component in the simplest possi ble form We do not intend to show all the most recent innovations though our A Digital Radio 3 presentation and viewpoint are modern nor do we intend to provide a complete analysis of the various methods Rather we ask you to investigate the perfor mance of the subsystems partly through analysis and partly using the software code that you have created and that we have provided We do offer insight into all pieces of a complete transmission system We present the major ideas of com munications via a small number of unifying principles such as transforms to teach modulation and recursive techniques to teach synchronization and equalization We believe that these basic principles have application far beyond receiver design and so the time spent mastering them is well worth the effort Though far from optimal the receiver that you will build contains all the elements of a fully functional receiver It provides a simple way to ask and answer what if questions What if there is noise in the system What if the modulation frequencies are not exactly as specified What if there are errors in the received digits What if the data rate is not high enough What if there are distortion reflections or echoes in the transmission channel What if the receiver is moving The first step begins with a sketch of a digital radio 12 An Illustrative Design The first 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 refine the ideas The design is shown in Figures 11 through 15 While talking about these figures it will become clear that some ideas are being oversimplified 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 files jpg photos snippets of speech rasterscanned 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 difference between a string of zeros and no transmission at 4 Chapter 1 A Digital Radio Coder 1 τ kT Text Symbols sk Scaling factor Initiation trigger Twide analog pulse shape pt generator Baseband signal yt Figure 11 An idealized baseband transmitter all A common remedy is to send a pulse with a positive amplitude to represent a one and a pulse of the same shape but negative amplitude to represent a zero In fact if the receiver could distinguish pulses of different sizes then it would be possible to send two bits with each symbol for example by associating the amplitudes1 of 1 1 3 and 3 with the four choices 10 01 11 and 00 The four symbols 1 3 are called the alphabet and the conversion from the original message the text into the symbol alphabet is accomplished by the coder in the transmitter diagram Figure 11 The first few letters the standard ASCII binary representation of these letters and their coding into symbols are as follows letter binary ASCII code symbol string a 01 10 00 01 1 1 3 1 b 01 10 00 10 1 1 3 1 c 01 10 00 11 1 1 3 3 d 01 10 01 00 1 1 1 3 11 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 r the symbol interval T be the time between successive symbols and r the pulse shape pt be the shape of the pulse that will be transmitted 1 Many such choices are possible These particular values were chosen because they are equidis tant and so noise would be no more likely to flip a 3 into a 1 than to flip a 1 into a 1 6 Chapter 1 A Digital Radio rt τδ τδT 3g g g 3g τδ2T τδ3T τδ4T yt τ τT 3 1 1 3 τ2T τ3T τ4T pt 1 0 T a b c Figure 12 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 offset in time by τ and scaled in magnitude by the symbols sk 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 δ Decoder Quantizer Reconstructed text Reconstructed symbols Received signal η kT Sampler Figure 13 An idealized baseband receiver form But when should the samples be taken On comparing Figures 12b and 12c 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 1g 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 11 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 first pulse begins Let δ be the time it takes for the signal to move from the transmitter to the receiver Thus the k 1st 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 δ T2 As indicated in Figure 13 the receiver begins sampling at time η and then samples regularly at η kT for all integers k If η were chosen so that η τ δ T2 13 A Digital Radio 7 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 figure out when to sample Basically some extra synchronization procedure is needed in order to satisfy 13 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 trans mitter call it Ttrans is created by a separate oscillator from that creating the symbol period at the receiver call it Trec they will inevitably differ 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 andor 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 13 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 11 and 13 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 syn chronization that is needed Imagine joining a broadcast in progress or one in which the first 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 letterstosymbol code of 11 each letter of the alphabet is translated into a sequence of four symbols If the start of the frame is off by even a single sym 2 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 Thus proper decoding requires locating where the frame starts a step called frame synchronization Frame synchronization is implicit in Figure 13 in the choice of η which sets the time t η with k 0 of the first symbol of the first character frame of the message of interest How to find 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 11 require Consider transmitting a single Tsecondwide rectangular pulse Fourier transform theory shows that any such timelimited pulse cannot be truly bandlimited that is cannot have its frequency content restricted to a finite range Indeed the Fourier transform of a rectangular pulse in time is a sinc function in frequency see Equation A20 in Appendix A The magnitude of this sinc is overbounded by a function that decays as the inverse of frequency peek ahead to Figure 211 Thus to accommodate this singlepulse transmission all other transmitters must have negligible energy below some factor of B 1T For the sake of argument suppose that a factor of 5 is safe that is all other transmitters must have no significant 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 111 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 tradeoff 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 9 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 highfrequency content Similarly if other transmitters operated at high frequencies outside 5B Hz it would be sen sible to add a lowpass filter at the front end of the receiver Rejecting frequencies outside the protected 5B baseband turf also removes a bit of the higherfrequency content of the rectangular pulse The effect 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 transmit ter of Figure 11 and the receiver of Figure 13 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 simul taneously 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 different pulse shape other than the rectangle that has no lowfrequency content but the most common approach is to modulate change frequency by multiplying the pulseshaped signal by a highfrequency sinusoid Such a radiofrequency RF transmitter is shown in Figure 14 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 demod ulated by multiplying by another highfrequency sinusoid and then lowpass filtering These frequency translations are described in more detail in Section 26 where it is shown that the modulating sinusoid and the demodulating sinu soid 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 11 and 13 produces the transmitter in Figure 14 and the associated receiver in Figure 15 The new block in the transmitter is an analog component that effectively 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 Chapter 1 A Digital Radio Frequency translator Pulse shape filter Coder Passband signal Baseband signal Symbols Text Figure 14 Radiofrequency transmitter Decoder Quantizer Reconstructed text Baseband signal Sampler Frequency translator Received signal Figure 15 Radiofrequency receiver block in the receiver of Figure 15 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 13 This process of translating the spectrum of the transmitted signal to higher frequencies allows many transmitters to operate simultaneously in the same geo graphical area But there is a price Since the signals are not completely band limited to within their assigned 5Bwide 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 fix cost In fact there are many other ways in which the transmission channel can devi ate from the ideal and these will be discussed in detail later on for instance in Section 41 and throughout Chapter 9 Typically the cluttered electromagnetic spectrum results in a variety of distortions and interferences r inband within the frequency band allocated to the user of interest r outofband frequency components outside the allocated band such as the signals of other transmitters r narrowband spurious sinusoidallike components r broadband with components at frequencies across the allocated band and beyond including thermal noise introduced by the analog electronics in the receiver r fading when the strength of the received signal fluctuates r multipath when the environment contains many reflective and absorptive objects at different distances the transmission delay will differ across different paths smearing the received signal and attenuating some frequencies more than others A Digital Radio 11 Gain with delay Multipath Selfinterference Transmitted signal Interference from other sources Received signal Broadband noises Figure 16 A channel model admitting various kinds of interferences These channel imperfections are all incorporated in the channel model shown in Figure 16 which sits in the communication system between Figures 14 and 15 Many of these imperfections in the channel can be mitigated by clever use of filtering at the receiver Narrowband interference can be removed with a notch filter that rejects frequency components in the narrow range of the interferer without removing too much of the broadband signal Outofband interference and broadband noise can be reduced using a bandpass filter that suppresses the signal in the outofband frequency range and passes the inband frequency components without distortion With regard to Figure 15 it is reasonable to wonder whether it is better to perform such filtering before or after the sampler ie by an analog or a digital filter In modern receivers the trend is to minimize the amount of analog processing since digital methods are often cheaper and usually more flexible since they can be implemented as reconfigurable software rather than fixed 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 61 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 freerunning sampler Interpola tion can be used to figure out values of the signal at any desired intermediate instant such as at time η kT recall 13 for a particular η that is not an integer multiple of T Thus the timing synchronization can be incorporated into the postsampler digital signal processing box which is shown generically in Figure 17 Observe that Figure 15 is one particular version of 17 How exactly does interpolation work 12 Chapter 1 A Digital Radio Digital signal processing Analog signal processing Recovered source Received signal η kT Figure 17 A generic modern receiver using both analog signal processing ASP and digital signal processing DSP However sometimes it is more cost effective to perform certain tasks in analog circuitry For example if the transmitter modulates to a very high frequency then it may cost too much to sample fast enough Currently it is common practice to perform some frequency translation and some outofband signal reduction in the analog portion of the receiver Sometimes the analog portion may translate the received signal all the way back to baseband Other times the analog portion translates to some intermediate frequency and then the digital portion finishes the translation The advantage of this seemingly redundant approach is that the analog part can be made crudely and hence cheaply The digital processing finishes the job and simultaneously compensates for inaccuracies and flaws in the inexpensive analog circuits Thus the digital signal processing portion of the receiver may need to correct for signal impairments arising in the analog portion of the receiver as well as from impairments caused by the channel Use DSP when possible The digital signal processing portion of the receiver can perform the following tasks r downconvert the sampled signal to baseband r track any changes in the phase or frequency of the modulating sinusoid r adjust the symbol timing by interpolation r compensate for channel imperfections by filtering r convert modestly inaccurate recovered samples into symbols r perform frame synchronization via correlation r decode groups of symbols into message characters A central task in Software Receiver Design is to elaborate on the system structure in Figures 1416 to create a working softwaredefined radio that can perform these tasks This concludes the illustrative design at the first most superficial step of the radio stairway Use DSP to compensate for cheap ASP 13 Walk This Way This section provides a whirlwind tour of the complete structure of Software Receiver Design Each step presents the digital transmission system in greater depth and detail Step 1 The Naive Digital Communications System As we have just seen the first step introduced the digital transmission of data and discussed how bits of information may be coded into waveforms sent across space to the receiver and then decoded back into bits Since there is no universal clock issues of timing become important and some of the most complex issues in digital receiver design involve the synchronization of the received signal The system can be viewed as consisting of three parts 1 a transmitter as in Figure 14 2 a transmission channel 3 a receiver as in Figure 15 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 briefly 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 fixed 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 reflections diffractions or diffusions 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 Channel impairments and linear systems Chapter 4 Frequency translation and modulation Chapter 5 Sampling and gain control Chapter 6 Receive digital filtering Chapter 7 Symbols to bits to signals Chapter 8 14 Chapter 1 A Digital Radio Chapter 9 provides a complete though idealized softwaredefined digital radio system r Step 4 The Adaptive Components The fourth step describes all the practical fixes that are required in order to create a workable radio One by one the various problems are studied and solutions are proposed implemented and tested These include fixes for additive noise for timing offset problems for clock frequency mismatches and jitter and for multipath reflections Again the order in which topics are discussed is the order in which they appear in the receiver Carrier recovery Chapter 10 the timing of frequency translation Receive filtering Chapter 11 the design of pulse shapes Clock recovery Chapter 12 the timing of sampling Equalization Chapter 13 filters that adapt to the channel Coding Chapter 14 making data resilient to noise r Step 5 Putting It All Together The final steps are the projects of Chapters 15 and 16 which integrate all the fixes of the fourth step into the receiver structure of the third step to create a fully functional digital receiver The well fabricated receiver is robust with respect to distortions such as those caused by noise multipath interference timing inaccuracies and clock mismatches 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 briefly 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 fixed the ordering of the blocks in the system diagram has stabilized 2 A Telecommunication System Telecommunications technologies using electromagnetic transmission surround us television images flicker radios chatter cell phones and telephones ring allowing us to see and hear each other anywhere on the planet Email and the Internet link us via our computers and a large variety of common devices such as CDs DVDs and hard disks augment the traditional pencil and paper storage and transmittal of information People have always wished to communicate over long distances to speak with someone in another country to watch a distant sporting event to listen to music performed in another place or another time to send and receive data remotely using a personal computer In order to imple ment these desires a signal a sound wave a signal from a TV camera or a sequence of computer bits needs to be encoded stored transmitted received and decoded Why Consider the problem of voice or music transmission Send ing sound directly is futile because sound waves dissipate very quickly in air But if the sound is first transformed into electromagnetic waves then they can be beamed over great distances very efficiently Similarly the TV signal and computer data can be transformed into electromagnetic waves 21 Electromagnetic Transmission of Analog Waveforms There are some experimental physical facts that cause transmission systems to be constructed as they are First for efficient wireless broadcasting of electro magnetic energy an antenna needs to be longer than about 110 of a wavelength of the frequency being transmitted The antenna at the receiver should also be proportionally sized The wavelength λ and the frequency f of a sinusoid are inversely propor tional For an electrical signal travelling at the speed of light c 3 108 ms the relationship between wavelength and frequency is λ c f A Telecommunication System 17 For instance if the frequency of an electromagnetic wave is f 10 kHz then the length of each wave is λ 3 108 ms 104s 3 104 m Efficient transmission requires an antenna longer than 01λ which is 3 km Sinu soids 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 AM radio f 6001500 kHz λ 500200 m 01λ 20 m r VHF TV f 30300 MHz λ 101 m 01λ 01 m r UHF TV f 033 GHz λ 101 m 01λ 001 m r Cell phones USA f 824894 MHz λ 036033 m 01λ 003 m r PCS f 1819 GHz λ 01670158 m 01λ 0015 m r GSM Europe f 890960 MHz λ 03370313 m 01λ 003 m r LEO satellites f 16 GHz λ 0188 m 01λ 00188 m 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 different behaviors depending on the frequency of the waves r Below 2 MHz electromagnetic waves follow the contour of the Earth This is why shortwave and other radios can sometimes be heard hundreds or thousands of miles from their source r Between 2 and 30 MHz skywave propagation occurs with multiple bounces from refractive atmospheric layers r Above 30 MHz lineofsight propagation occurs with straightline travel between two terrestrial towers or through the atmosphere to satellites r Above 30 MHz atmospheric scattering also occurs which can be exploited for longdistance terrestrial communication Humanmade media in wired systems also exhibit frequencydependent behav ior 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 longdistance communica tions Because of its role as a carrier the AMUHFVHFPCS 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 form and its discrete counterparts the DFT and the FFT1 Fourier transforms are useful in assessing energy or power at particular frequencies The Fourier transform of a signal wt is defined as W f t wt e j 2 π f t dt F w t 21 where j 1 and f is given in Hz ie cycless or 1s Speaking mathematically W f is a function of the frequency f Thus for each f W f is a complex number and so can be plotted in several ways For instance it is possible to plot the real part of W f as a function of f and to plot the imaginary part of W f as a function of f Alternatively it is possible to plot the real part of W f versus the imaginary part of W f The most common plots of the Fourier transform of a signal are done in two parts the first graph shows the magnitude W f versus f this is called the magnitude spectrum and the second graph shows the phase angle of W f versus f this is called the phase spectrum Often just the magnitude is plotted though this inevitably leaves out information Perhaps the best way to understand the Fourier transform is to look closely at the inverse function w t f W f e j 2 π f t d f 22 The complex exponential e j 2 π f t can be interpreted as a complexvalued sinusoidal wave since it is the sum of a sine term and a cosine term both of frequency f via Eulers formula Since Wf is a complex number at each f 22 can be interpreted as describing or decomposing wt into sinusoidal elements of frequencies f weighted by the Wf 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 22 Bandwidth If at any particular frequency f0 the magnitude spectrum is strictly positive Wf0 0 then the frequency f0 is said to be present in wt 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 telephonequality speech with maximum frequency 4 kHz and audible music with maximum frequency 20 kHz 1 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 efficient method of calculating the DFT A Telecommunication System 19 f W f Halfpower BW Nulltonull BW Power BW Absolute BW 1 2 0707 2 Figure 21 Various ways to define bandwidth BW for a realvalued signal But realworld signals are never completely bandlimited and there is almost always some energy at every frequency Several alternative definitions of band width are in common use these try to capture the idea that most of the energy is contained in a specified frequency region Usually these are applied across positive frequencies with the presumption that the underlying signals are realvalued and hence have symmetric spectra Here are some of the alternative definitions 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 3dB or halfpower bandwidth is f2 f1 where for frequencies outside f1 f f2 Hf is never greater than 1 2 times its maximum value 3 Nulltonull or zerocrossing bandwidth is f2 f1 where f2 is the first null in Hf above f0 and for bandpass systems f1 is the first null in the enve lope below f0 where f0 is the frequency of maximum Hf For baseband systems f1 is usually zero 4 Power bandwidth is f2 f1 where f1 f f2 defines the frequency band in which 99 of the total power resides Occupied bandwidth is such that 05 of power is above f2 and 05 below f1 These definitions are illustrated in Figure 21 The various definitions of bandwidth refer directly to the frequency content of a signal Since the frequency response of a linear filter is the transform of its impulse response bandwidth is also used to talk about the frequency range over which a linear system or filter operates Exercise 21 TRUE or FALSE Absolute bandwidth is never less than 3dB power bandwidth Exercise 22 Suppose that a signal is complexvalued and hence has a spectrum that is not symmetric about zero frequency State versions of the various definitions of bandwidth that make sense in this situation Illustrate your definitions as in Figure 21 23 Upconversion at the Transmitter Suppose that the signal wt contains important information that must be transmitted There are many kinds of operations that can be applied to wt Linear time invariant LTI operations are those for which superposition applies but LTI operations cannot augment the frequency content of a signalno sine wave can appear at the output of a linear operation if it was not already present in the input Thus the process of modulation or upconversion which requires a change of frequencies must be either nonlinear or time varying or both One useful way to modulate is with multiplication consider the product of the message waveform wt with a cosine wave st wt cos2πf₀t 23 where f₀ 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 f₀ Hz Using one of Eulers identities A2 cos2πf₀t 12 ej2πf₀t ej2πf₀t 24 one can calculate the spectrum or frequency content of the signal st from the definition of the Fourier transform given in 21 In complete detail this is Sf Fst Fwt cos2πf₀t F wt 12 ej2πf₀t ej2πf₀t from to wt 12 ej2πf₀t ej2πf₀t ej2πft dt 12 from to wt ej2πf f₀t ej2πf f₀t dt 12 from to wtej2πf f₀t dt 12 from to wtej2πf f₀t dt 12 Wf f₀ 12 Wf f₀ 25 A Telecommunication System 21 f f f W f S f 1 f0 f0 f f0 f 05 f0 f0 f f0 f b a Figure 22 Action of a modulator If the message signal wt has the magnitude spectrum shown in part a then the modulated signal st has the magnitude spectrum shown in part b Thus the spectrum of st consists of two copies of the spectrum of wt each shifted in frequency by f0 one up and one down and each half as large This is sometimes called the frequencyshifting property of the Fourier trans form and sometimes called the modulation property Figure 22 shows how the spectra relate If wt 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 st appears as in part b This kind of modulation or upconversion or frequency shift is ideal for translating speech music or other lowfrequency signals into much higher frequencies for instance f0 might be in the AM or UHF bands so that they can be transmit ted efficiently It can also be used to convert a highfrequency signal back down to baseband when needed as will be discussed in Section 26 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 23 where the message wt is multiplied by a high frequency sinusoid with fixed 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 23 Referring to Figure 22 find which frequencies are present in Wf and not in Sf Which frequencies are present in Sf but not in Wf Exercise 24 Using 25 draw analogous pictures for the phase spectrum of st as it relates to the phase spectrum of wt Exercise 25 Suppose that st is modulated again this time via multiplication with a cosine of frequency f1 What is the resulting magnitude spectrum Hint let rt st cos2πf1t and apply 25 to find Rf 22 Chapter 2 A Telecommunication System 24 Frequency Division Multiplexing When a signal is modulated the width in Hz of the replicas is the same as the width in Hz of the original signal This is a direct consequence of Equation 25 For instance if the message is bandlimited to f and the carrier frequency is fc then the modulated signal has energy in the range from f fc to f fc and from f fc to f fc If f fc then several messages can be transmitted simultaneously by using different carrier frequencies This situation is depicted in Figure 23 where three different messages are represented by the triangular rectangular and halfoval spectra each bandlim ited to f Each of these is modulated by a different carrier f1 f2 and f3 which are chosen so that they are further apart than the width of the messages In general as long as the carrier frequencies are separated by more than 2f there will be no overlap in the spectrum of the combined signal This process of combining many different signals together is called multiplexing and because the frequencies are divided up among the users the approach of Figure 23 is called frequencydivision multiplexing FDM Whenever FDM is used the receiver must separate the signal of interest from all the other signals present This can be accomplished with a bandpass filter as in Figure 24 which shows a filter designed to isolate the middle user from the others Exercise 26 Suppose that two carrier frequencies are separated by 1 kHz Draw the magnitude spectra if a the bandwidth of each message is 200 Hz and b the bandwidth of each message is 2 kHz Comment on the ability of the bandpass filter at the receiver to separate the two signals Another kind of multiplexing is called timedivision multiplexing TDM in which two or more messages use the same carrier frequency but at alternating time instants More complex multiplexing schemes such as code division mul tiplexing overlap the messages in both time and frequency in such a way that they can be demultiplexed efficiently by appropriate filtering f3 f f2 f1 f1 f2 f3 f2 f f2 f f3 f f3 f W f Figure 23 Three different upconverted signals are assigned different frequency bands This is called frequencydivision multiplexing A Telecommunication System 23 f3 f f2 f1 f2 f f2 f Bandpass filter W f Figure 24 Separation of a single FDM transmission using a bandpass filter 25 Filters that Remove Frequencies Each time the signal is modulated an extra copy or replica of the spectrum appears When multiple modulations are needed for instance at the transmitter to convert up to the carrier frequency and at the receiver to convert back down to the original frequency of the message copies of the spectrum may proliferate There must be a way to remove extra copies in order to isolate the original message This is one of the things that linear filters do very well There are several ways of describing the action of a linear timeinvariant filter In the time domain the most common method of implementation the filter is characterized by its impulse response which is defined to be the output of the filter when the input is an impulse function Because of the linearity the output of the filter in response to any arbitrary input is the superposition of weighted copies of a timeshifted version of the impulse response a procedure known as convolution Since convolution may be difficult to understand directly in the time domain the action of a linear filter is often described in the frequency domain Perhaps the most important property of the Fourier transform is the duality between convolution and multiplication which says that r convolution in time multiplication in frequency and r multiplication in time convolution in frequency This is discussed in detail in Section 45 Thus the convolution of a linear filter can readily be viewed in the frequency Fourier domain as a pointbypoint multiplication For instance an ideal lowpass filter LPF passes all frequencies below fl which is called the cutoff frequency This is commonly plotted in a curve called the frequency response of the filter which describes the action of the filter2 If this filter is applied to a signal wt then all energy above fl is removed from wt Figure 25 shows this pictorially If wt has the magnitude spectrum shown in part a and the frequency response of the lowpass filter with cutoff frequency fl is as shown in part b then the magnitude spectrum of the output appears in part c 2 Formally the frequency response can be calculated as the Fourier transform of the impulse response of the filter 24 Chapter 2 A Telecommunication System fl fl f a fl fl f b fl fl f c W f H f Y f H f W f Figure 25 Action of a lowpass filter a shows the magnitude spectrum of the message which is input into an ideal lowpass filter with frequency response b c shows the pointbypoint multiplication of a and b which gives the spectrum of the output of the filter Exercise 27 An ideal highpass filter passes all frequencies above some given fh and removes all frequencies below Show the result of applying a highpass filter to the signal in Figure 25 with fh fl Exercise 28 An ideal bandpass filter passes all frequencies between an upper limit f and a lower limit f Show the result of applying a bandpass filter to the signal in Figure 25 with f 2fl3 and f fl3 The problem of how to design and implement such filters is considered in detail in Chapter 7 26 Analog Downconversion Because transmitters typically modulate the message signal with a high frequency carrier the receiver must somehow remove the carrier from the mes sage 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 highfrequency replicas A lowpass filter can then remove everything but the scaled copy of the original message This is how the box labelled frequency translator in Figure 15 is typically implemented To see this procedure in detail suppose that st wt cos2πf0t arrives at the receiver which multiplies st by another cosine wave of exactly the same frequency and phase to get the demodulated signal dt st cos2πf₀t wt cos22πf₀t Using the trigonometric identity A4 namely cos2x 12 12 cos2x this can be rewritten as dt wt 12 12 cos4πf₀t 12 wt 12 wt cos2π2f₀t The spectrum of the demodulated signal can be calculated to be Fdt F 12 wt 12 wt cos2π2f₀t 12 Fwt 12 Fwt cos2π2f₀t by linearity Now the frequencyshifting property 25 can be applied to show that Fdt 12 Wf 14 Wf 2f₀ 14 Wf 2f₀ 26 Thus the spectrum of this downconverted received signal has the original baseband component scaled to 50 and two matching pieces each scaled to 25 centered around twice the carrier frequency f₀ and twice its negative A lowpass filter can now be used to extract Wf and hence to recover the original message wt This procedure is shown diagrammatically in Figure 26 The spectrum of the original message is shown in a and the spectrum of the message modulated by the carrier appears in b When downconversion is done as just described the demodulated signal dt has the spectrum shown in c Filtering by a lowpass filter as in part c removes all but a scaled version of the message Now consider the FDM transmitted signal spectrum of Figure 23 This can be demodulateddownconverted similarly The frequencyshifting rule 25 with a shift of f₀ f₃ ensures that the downconverted spectrum in Figure 27 matches 26 and the lowpass filter removes all but the desired message from the downconverted signal This is the basic principle of a transmitter and receiver pair But there are some practical issues that arise What happens if the oscillator at the receiver is not completely accurate in either frequency or phase The downconverted received signal becomes st cos2πf₀ αt β This can have serious consequences for the demodulated message What happens if one of the antennas is moving The Doppler effect suggests that this corresponds to a small nonzero value of α What happens if the transmitter antenna wobbles due to the wind over a range equivalent to several wavelengths of the transmitted signal This can alter β In effect the baseband component is perturbed from 12Wf and 26 Chapter 2 A Telecommunication System f 0 f a 0 b f0 f0 c 2f0 2f0 Lowpass filter stcos2πf0t W f S f Figure 26 The message can be recovered by downconversion and lowpass filtering 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 f3f1 f3f2 2f3 f1f3 f3f2 2f3 f3f1 f2f3 f3f1 f3f2 Figure 27 The signal containing the three messages of Figure 23 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 simply lowpass filtering the downconverted signal results in distortion Carrier synchronization schemes which attempt to identify and track the phase and fre quency of the carrier are routinely used in practice to counteract such problems These are discussed in detail in Chapters 5 and 10 27 Analog Core of a Digital Communication System The signal flow in the AM communication system described in the preceding sections is shown in Figure 28 The message is upconverted for efficient trans mission summed with other FDM users for efficient use of the electromag netic spectrum subjected to possible channel noises such as thermal noise A Telecommunication System 27 Other FDM users Upconversion Message waveform Bandpass filter for FDM user selection Lowpass filter Received signal Other interference Carrier specification Downconversion Carrier synchronization Figure 28 Analog AM communication system bandpass filtered to extract the desired user downconverted requiring carrier synchronization and lowpass filtered to recover the actual message But no transmission system operates perfectly Each of the blocks in Figure 28 may be noisy may have components which are inaccurate and may be subject to fundamental limitations For instance r the bandwidth of a filter may be different from its specification eg the shoulders might not drop off fast enough to avoid passing some of the adjacent signal r the frequency of an oscillator might not be exact and hence the modulation andor demodulation might not be exact r the phase of the carrier is unknown at the receiver since it depends on the time of travel between the transmitter and the receiver r perfect filters are impossible even in principle r no oscillator is perfectly regular there is always some jitter in frequency Even within the frequency range of the message signal the medium can affect different frequencies in different ways These are called frequency selective effects For example a signal may arrive at the receiver and a moment later a copy of the same signal might arrive after having bounced off 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 difficult to reassemble the original message A special filter called the equalizer is often added to the receiver to help improve the situation An equalizer is a kind of deghosting circuit3 and equalization is addressed in detail in Chapter 13 3 We refrain from calling these ghost busters 28 Chapter 2 A Telecommunication System 28 Sampling at the Receiver Because of the proliferation of inexpensive and capable digital processors receivers often contain chips that are essentially specialpurpose comput ers In such receivers many of the functions that are traditionally han dled by discrete components such as analog oscillators and filters can be handled digitally Of course this requires that the analog received sig nal be turned into digital information a series of numbers that a com puter can process This analogtodigital conversion AD is known as sampling Sampling measures the amplitude of the waveform at regular intervals and then stores these measurements in memory Two of the chief design issues in a digital receiver are the following r Where should the signal be sampled r How often should the sampling be done The answers to these questions are intimately related to each other When taking samples of a signal they must be taken fast enough that impor tant information is not lost Suppose that a signal has no frequency content above f Hz The widely known Nyquist reconstruction principle see Section 61 says that if sampling occurs at a rate greater than 2f samples per second it is pos sible to reconstruct the original signal from the samples alone Thus as long as the samples are taken rapidly enough no information is lost On the other hand when samples are taken too slowly the signal cannot be reconstructed exactly from the samples and the resulting distortion is called aliasing Accordingly in the receiver it is necessary to sample at least twice as fast as the highest frequency present in the analog signal being sampled in order to avoid aliasing Because the receiver contains modulators that change the frequencies of the signals different parts of the system have different highest frequencies Hence the answer to the question of how fast to sample is dependent on where the samples will be taken The sampling 1 could be done at the input to the receiver at a rate proportional to the carrier frequency 2 could be done after the downconversion at a rate proportional to the rate of the symbols or 3 could be done at some intermediate rate Each of these is appropriate in certain situations For the first case consider Figure 23 which shows the spectrum of the FDM signal prior to downconversion Let f3 f be the frequency of the upper edge of the user spectrum near the carrier at f3 According to the Nyquist principle the upconverted received signal must be sampled at a rate of at least 2f3 f to avoid aliasing For highfrequency carriers this exceeds the rate of reasonably A Telecommunication System 29 f3 fI f3 fI f3 fI f3 fI Figure 29 FDM downconversion to an intermediate frequency priced AD 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 softwarebased receiver In the second case the downconversion and subsequent lowpass filtering are done in analog circuitry and the samples are taken at the output of the lowpass filter 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 29 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 filter extracts the whole FDM band at an intermediate frequency IF and then it is only necessary to sample at a rate greater than 2f3 f fI Downconversion to an intermediate frequency is common since the analog circuitry can be fixed 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 29 Digital Communications Around an Analog Core The discussion so far in this chapter has concentrated on the classical core of telecommunication systems the transmission and reception of analog waveforms In digital systems as considered in the previous chapter the original signal consists of a stream of data and the goal is to send the data from one location to another The data may be a computer program ASCII text pixels of a picture a digitized MP3 file or sampled speech from a cell phone Data consist of a 30 Chapter 2 A Telecommunication System sequence of numbers which can always be converted to a sequence of zeros and ones called bits How can a sequence of bits be transmitted The basic idea is that since transmission media such as air phone lines the ocean are analog the bits are converted into an analog signal Then this analog signal can be transmitted exactly as before Thus at the core of every digital communication system lies an analog system The output of the transmitter the transmission medium and the front end of the receiver are necessarily analog Digital methods are not new Morsecode telegraphy which consists of a sequence of dashes and dots coded into long and short tone bursts became widespread in the 1850s The early telephone systems of the 1900s were analog with digitization beginning in the 1960s Digital relative to fully analog communications have the following advan tages r digital circuits are relatively inexpensive r data encryption can be used to enhance privacy r digital realization tends to support greater dynamic range r signals from voice video and data sources can be merged for transmission over a common system r digital signals can be easily compressed r noise does not accumulate from repeater to repeater over long distances r low error rates are possible even with substantial noise r errors can be corrected via coding In addition digital receivers can easily be reconfigured or upgraded because they are essentially softwaredriven For instance a receiver built for one broadcast standard say for the American market could be transformed into a receiver for the European market with little additional hardware But there are also some disadvantages of digital relative to fully analog communications including the following r more bandwidth is generally required than with analog r synchronization is required 210 Pulse Shaping In order to transmit a digital data stream it must be turned into an analog signal The first 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 4PAM symbols 1 3 was given explicitly in 11 This was converted into an analog waveform using the rectangular pulse shape 12 which results in signals that look like Figure 210 The rectangular pulse Πt of 28 is T time units wide and centered at the origin Figure 12 In general such signals can be written yt k skpt kT 27 where the sk are the values of the symbols and the function pt is the pulse shape Thus each member of the 4PAM 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 noisefree 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 difficult to avoid having different messages interfere with each other To see this define the rectangular pulse Πt 1 if T2 t T2 0 otherwise 28 as shown in Figure 210 The shifted pulses 28 are sometimes easier to work with than 12 and their magnitude spectra are the same by virtue of the timeshifting property A37 The Fourier transform can be calculated directly from the definition 21 Wf from to Πt ej2πft dt from tT2 to T2 1 ej2πft dt ej2πft j2πf T2tT2 ejπfT ejπfTj2πf T sinπfT πfT T sincfT 29 The sinc function is illustrated in Figure 211 Thus the Fourier transform of a rectangular pulse in the time domain is a sinc function in the frequency domain Since the sinc function dies away with an envelope of 1πx the frequency content of the rectangular pulse shape is in principle infinite It is not possible to separate messages into different nonoverlapping frequency regions as is required for an FDM implementation as in Figure 23 Alternatives to the rectangular pulse are essential Consider what is really required of a pulse shape The pulse is transmitted at time kT and again at time k 1T and again at k 2T The received signal is the sum of all these 32 Chapter 2 A Telecommunication System 8 6 4 2 0 2 4 6 8 0 05 1 sincx Envelope 1πx Figure 211 The sinc function sincx sinπxπx has zeros at every integer except zero and dies away with an envelope of 1πx 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 satisfies 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 211 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 27 the shifted pulse shape is multiplied by each member of the data sequence and then added together If the channel is perfect distortionless and noisefree 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 synchroniza tion 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 A22 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 infinite 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 outofband content in fre quency and an impulse response that falls off rapidly enough to allow reason able truncation in the time domain Commonly used pulse shapes such as the squareroot 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 33 1 1 T2 T p1t 1 1 T2 T p3t 1 1 T2 T p2t Figure 212 Some alternative pulse shapes Exercise 29 Consider the three pulse shapes sketched in Figure 212 for a T spaced PAM system a Which of the three pulse shapes in Figure 212 has the largest baseband power bandwidth Justify your answer b Which of the three pulse shapes in Figure 212 has the smallest baseband power bandwidth Justify your answer Exercise 210 TRUE or FALSE The flatter the top of the pulse shape the less sensitive the receiver is to small timing offsets Explain your reasoning 211 Synchronization Good Times Bad Times Synchronization may occur in several places in the digital receiver r Symbol phase synchronizationchoosing when within each interval T to sample r Symbol frequency synchronizationaccounting for different clock oscillator rates at the transmitter and receiver r Carrier phase synchronizationaligning the phase of the carrier at the receiver with the phase of the carrier at the transmitter r Carrier frequency synchronizationaligning the frequency of the carrier at the receiver with the frequency of the carrier at the transmitter r Frame synchronizationfinding the start of each message data block In digital receivers it is important to sample the received signal at the appro priate time instants Moreover these time instants are not known beforehand rather they must be determined from the signal itself This is the problem of clock recovery A typical strategy samples several times per pulse and then uses some criterion to pick the best one to estimate the optimal time or to interpo late an appropriate value There must also be a way to deal with the situation when the oscillator defining the symbol clock at the transmitter differs from the oscillator defining the symbol clock at the receiver Similarly carrier synchroniza tion is the process of recovering the carrier in both frequency and phase from the received signal This is the same task in a digital receiver as in an analog 34 Chapter 2 A Telecommunication System design recall that the cosine wave used to demodulate the received signal in 26 was aligned in both phase and frequency with the modulating sinusoid at the transmitter though the details of implementation may differ In many applications such as cell phones messages come in clusters called packets and each packet has a header that is located in some agreedupon 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 finding a timing offset τ to maximize the energy of the received signal Solving this optimization problem via a gradient technique leads to a standard algorithm for timing recovery r The problem of carrier phase synchronization can be stated as that of finding a phase offset θ to minimize a particular function of the modulated received signal Solving this optimization problem via a gradient technique leads to the phaselocked loop a standard method of carrier recovery r Carrier phase synchronization can also be stated using an alternative per formance function that leads directly to the Costas loop another standard method of carrier recovery Our presentation focuses on solving problems using simple recursive gradient methods Once the synchronization problems are correctly stated techniques for their solution become obvious With the exception of frame synchroniza tion which is approached via correlational methods the problem of designing synchronizers is unified via one simple concept that of the minimization or maximization of an appropriate performance function Chapters 6 10 and 12 contain details 212 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 differently to arrive at the receiver at different times This intersymbol interference can garble the data The channel may also attenuate different frequencies by different amounts Thus frequency selectivity can render the data indecipherable The solution to both of these problems is to build a filter in the receiver that attempts to undo the effects of the channel This filter called an equalizer cannot be fixed in advance by the system designer however because it must be different in order to compensate for different channel paths that are encountered when the system is operating The problem of equalizer design can be stated as a simple optimization problem that of finding a set of filter parameters to minimize an appropriate function of the error given only the received data and perhaps a training sequence This problem is investigated in detail in Chapter 13 where the same kinds of adaptive techniques that are used to solve the synchronization problems can also be applied to solve the equalization problem 213 Decisions and Error Measures In analog systems the transmitted waveform can attain any value but in a digital implementation the transmitted message must be one of a small number of values defined by the symbol alphabet Consequently the received waveform in an analog system can attain any value but in a digital implementation the recovered message is meant to be one of a small number of values from the source alphabet Thus when a signal is demodulated to a symbol and it is not a member of the alphabet the difference between the demodulated value called a soft decision and the nearest element of the alphabet the hard decision can provide valuable information about the performance of the system To be concrete label the signals at various points as shown in Figure 213 The binary input message b The coded signal w is a discretetime sequence drawn from a finite alphabet The signal m at the output of the filter and equalizer is continuousvalued at discrete times is a version of that is quantized to the nearest member of the alphabet The decoded signal is the final 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 differs 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 measures the difference between the message and the soft decision The average squared error 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 difference between the message and the quantized output of the receiver can be used to measure the harddecision error The decisiondirected error replaces this with the error between the soft decisions and the associated hard decisions This error is used in Section 134 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 105 and as a way of adjusting the symbol timing in Section 123 There are other useful indicators of the performance of digital communication receivers Let be the bit duration when there are two bits per symbol 2 The indicator counts how many bits have been incorrectly received and the bit error rate is Similarly the symbol error rate sums the indicators counting the number of alphabet symbols that were transmitted incorrectly More subjective or contextdependent measures are also possible such as the 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 efficient transmission of the message 214 Coding and Decoding What is information How much can move across a particular channel in a given amount of time Claude Shannon proposed a method of measuring information in terms of bits and a measure of the capacity of the channel in terms of the bit ratethe number of bits transmitted per second This is defined quantitatively by the channel capacity which is dependent on the bandwidth of the channel and on the power of the noise in comparison with the power of the signal For most receivers however the reality is far from the capacity and this is caused by two factors First the data to be transmitted are often redundant and the redundancy squanders the capacity of the channel Second the noise can be unevenly distributed among the symbols When large noises disrupt the signal then excessive errors occur The problem of redundancy is addressed in Chapter 14 by source coding which strives to represent the data in the most concise manner possible After demon strating the redundancy and correlation of English text Chapter 14 introduces the Huffman code which is a variablelength code that assigns short bit strings to frequent symbols and longer bit strings to infrequent symbols Like Morse code this will encode the letter e with a short code word and the letter z with a long code word When correctly applied the Huffman procedure can be applied to any symbol set not just the letters of the alphabet and is nearly optimal that is it approaches the limits set by Shannon The problem of reducing the sensitivity to noise is addressed in Chapter 14 using the idea of linear block codes which cluster a number of symbols together and then add extra bits A simple example is the binary parity check which adds an extra bit to each character If there is an even number of ones then a 1 is added and if there is an odd number of ones a 0 is added The receiver can always detect that a single error has occurred by counting the number of ones received If the sum is even then an error has occurred while if the sum is odd then no single error can have occurred More sophisticated versions can not only detect errors but also correct them Like good equalization and proper synchronization coding is an essential part of the operation of digital receivers 38 Chapter 2 A Telecommunication System 215 A Telecommunication System The complete system diagram including the digital receiver that will be built in this text is shown in Figure 213 This system includes the following r A source coding that reduces the redundancy of the message r An error coding that allows detection andor correction of errors that may occur during the transmission r A message sequence of T spaced symbols drawn from a finite alphabet r Pulse shaping of the message designed in part to conserve bandwidth r Analog upconversion to the carrier frequency within a specified tolerance r Channel distortion of transmitted signal r Summation with other FDM users channel noise and other interferers r Analog downconversion to intermediate frequency including bandpass pre filtering around the desired segment of the FDM passband r AD impulse sampling preceded by antialiasing filter at a rate of 1Ts with arbitrary start time The sampling rate is assumed to be at least as fast as the symbol rate 1T r Downconversion to baseband requiring carrierphase and frequency synchro nization r Lowpass or pulseshapematched filtering for the suppression of outofband users and channel noise r Downsampling with timing adjustment to T spaced symbol estimates r Equalization filtering to combat intersymbol interference and narrowband interferers r A decision device quantizing softdecision outputs of the equalizer to the near est member of the source alphabet ie the hard decision r Source and error decoders Of course permutations and variations of this system are possible but we believe that Figure 213 captures the essence of many modern transmission sys tems 216 Stairway to Radio The path taken by Software Receiver Design is to break down the telecommu nication system into its constituent elements the modulators and demodulators the samplers and filters the coders and decoders In the various tasks within each chapter you are asked to build a simulation of the relevant piece of the sys tem 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 reflection and activity will be useful in enlarging your understanding and in training your intuition For Further Reading There are many books about various aspects of communication systems Here are some of our favorites Three basic texts that utilize probability from the outset and that also pay substantial attention to pragmatic design issues such as synchronization are the following r J B Anderson Digital Transmission Engineering IEEE Press 1999 r J G Proakis and M Salehi Digital Communications 5th edition McGraw Hill 2007 This text also has a Matlabbased companion J G Proakis M Salehi and G Bauch Contemporary Communication Systems Using Matlab 2nd edition Cengage Learning 2004 r S Haykin Communication Systems 4th edition John Wiley and Sons 2001 Three introductory texts that delay the introduction of probability until the latter chapters are the following r L W Couch III Digital and Analog Communication Systems 6th edition PrenticeHall 2001 r B P Lathi Modern Digital and Analog Communication Systems 3rd edition Oxford University Press 1998 r F G Stremler Introduction to Communication Systems 3rd edition Addison Wesley 1990 These final three references are probably the most compatible with Software Receiver Design in terms of the assumed mathematical background 3 The Six Elements At first glance block diagrams such as the communication system shown in Fig ure 213 probably appear complex and intimidating There are so many different 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 timeinvariant filters which augment or diminish the amplitude of par ticular frequencies or frequency ranges in a signal r samplers which change analog continuoustime signals into discretetime signals r static nonlinearities such as squarers and quantizers which can add frequency content to a signal r linear timevarying systems such as mixers that shift frequencies around in useful and understandable ways and 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 modified 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 213 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 The Six Elements 41 Time Amplitude Time Amplitude Frequency The magnitude spectrum shows the frequency context of the input signal Magnitude Frequency The magnitude spectrum shows the frequency content of the output signal Magnitude Input signal as a function of time Output signal as a function of time Input signal as a function of frequency Output signal as a function of frequency xt X f yt Y f Element Figure 31 The element transforms the input signal x into the output signal y The action of an element can be thought of in terms of its effect on the signals in time or via the Fourier transform in terms of its effect on the spectra of the signals by how the frequency content of the input relates to the frequency content of the output Figure 31 illustrates these two complementary ways of viewing the elements Understanding both the timedomain and frequencydomain 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 elec trical engineering degrees will recognize that the timedomain representation of a signal and its frequencydomain representation are related by the Fourier transform which is briefly reviewed in the next section 31 Finding the Spectrum of a Signal A signal st can often be expressed in analytical form as a function of time t and the Fourier transform is defined as in 21 as the integral of ste2πjft The resulting transform Sf is a function of frequency Sf is called the spectrum of the signal st and describes the frequencies present in the signal For example if the time signal is created as a sum of three sine waves the spectrum will have spikes corresponding to each of the constituent sines If the time signal contains only frequencies between 100 and 200 Hz the spectrum will be zero for all frequencies outside of this range A brief guide to Fourier transforms appears in Appendix D and a summary of all the transforms and properties that are used throughout Software Receiver Design appears in Appendix A Often however there is no analytical expression for a signal that is there is no known equation that represents the value of the signal over time Instead 42 Chapter 3 The Six Elements the signal is defined 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 filter or a sound waveform encoded as an MP3 file In all these cases it is not possible to find 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 com putable fast Fourier transform or FFT can be used to find the spectrum or fre quency content of a measured signal The Matlab function plotspecm which plots the spectrum of a signal is available on the website Its help file1 notes pl ots pec x Ts pl ots the spectrum of x Tstime in s ecs between adjacent samples The function plotspecm is easy to use For instance the spectrum of a square wave can be found using the following sequence Listing 31 specsquarem plot the spectrum of a square wave f 10 frequency of square wave time 2 length of time Ts11000 time i n t e r v a l between samples tTs Ts time cr eate a time vector xsign cos 2 pi f t square wave sign of cos wave pl ots pec x Ts c a l l pl ots pec to draw spectrum The output of specsquarem is shown2 in Figure 32 The top plot shows time2 seconds of a square wave with f10 cycles per second The bottom plot shows a series of spikes that define the frequency content In this case the largest spike occurs at 10 Hz followed by smaller spikes at all the oddinteger multiples ie at 30 50 70 etc Similarly the spectrum of a noise signal can be calculated as Listing 32 specnoisem plot the spectrum of a noise signal time 1 length of time Ts110000 time i n t e r v a l between samples xrandn 1 time Ts Ts points of noi s e f o r time seconds pl ots pec x Ts c a l l pl ots pec to draw spectrum A typical run of specnoisem is shown in Figure 33 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 specnoisem produces plots that are qualitatively similar though the details will differ 1 You can view the help file 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 appli cation If you dont know what the proper command to do a job is then use lookfor For instance to find the command that inverts a matrix type lookfor inverse You will find the desired command inv 2 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 The Six Elements 43 1 05 0 Amplitude 05 400 300 200 100 0 Frequency 100 200 300 400 1 02 04 06 08 1 Seconds 12 14 16 18 2 0 1200 800 400 0 Magnitude Figure 32 A square wave and its spectrum as calculated by using plotspecm Exercise 31 Use specsquarem to investigate the relationship between the time behavior of the square wave and its spectrum The Matlab command zoom on is often helpful for viewing details of the plots a Try square waves with different frequencies f20 40 100 300 Hz How do the time plots change How do the spectra change b Try square waves of different lengths time1 10 100 seconds How does the spectrum change in each case c Try different sampling times Ts1100 110000 seconds How does the spectrum change in each case Exercise 32 In your signals and systems course you probably calculated ana lytically the spectrum of a square wave by using the Fourier series How does this calculation compare with the discrete data version found by specsquarem Exercise 33 Mimic the code in specsquarem to find the spectrum of a an exponential pulse st et for 0 t 10 b a scaled exponential pulse st 5et for 0 t 10 c a Gaussian pulse st et2 for 2 t 2 d a Gaussian pulse st et2 for 20 t 20 e the sinusoids st sin2πft φ for f 20 100 1000 with φ 0 π4 π2 and 0 t 10 Exercise 34 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 specnoisem b Use rand and the sign function to create a signal that is 1 with probability 12 and 1 with probability 12 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 Chapter 3 The Six Elements 4 2 0 4 2 Amplitude 0 02 04 06 08 1 Seconds 300 200 100 0 Magnitude 4000 2000 0 2000 4000 Frequency Figure 33 A noise signal and its spectrum as calculated using plotspecm Exercise 35 Modify the code in plotspecm 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 differ b Plot the phase spectrum of the random signal created in Exercise 34a While plotspecm can be quite useful ultimately it will be necessary to have more flexibility which in turn requires one to understand how the FFT function inside plotspecm works This will be discussed at length in Chapter 7 The next six sections describe the six elements that are at the heart of communica tions systems The elements are described both in the time domain and in the frequency domain 32 The First Element Oscillators The Latin word oscillare means to ride in a swing It is the origin of oscillate which means to move back and forth in steady unvarying rhythm Thus a device that creates a signal that moves back and forth in a steady unvarying rhythm is called an oscillator An electronic oscillator is a device that produces a repetitive electronic signal usually a sinusoidal wave A basic oscillator is diagrammed in Figure 34 Oscillators are typically designed to operate at a specified frequency f0 and the input specifies the phase φt of the output st cos2πf0t φt The input may be a fixed number but it may also be a signal that is it may change over time In this case the output is no longer a pure sinusoid of frequency f0 For instance suppose the phase is a ramp or line with slope 2πc that is φt 2πct Then st cos2πf0t 2πct cos2πf0 ct and the actual frequency of oscillation is f0 c The Six Elements 45 cos2πf0tφt φt Figure 34 An oscillator creates a sinusoidal oscillation with a specified frequency f0 and input φt 05 0 05 1 1 0 02 04 06 08 1 12 14 16 18 2 Seconds Amplitude 80 40 0 120 50 40 30 20 10 0 10 20 30 40 50 Frequency Magnitude Figure 35 A sinusoidal oscillator creates a signal that can be viewed in the time domain as in the top plot or in the frequency domain as in the bottom plot There are many ways to build oscillators from analog components Generally there is an amplifier and a feedback circuit that returns a portion of the amplified 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 ampli fier or feedback is needed For example a digital sine wave of frequency f Hz and a phase of φ radians can be represented mathematically as skTs cos2πfkTs φ 31 where Ts is the time between samples and where k is an integer counter k 1 2 3 Equation 31 can be directly implemented in Matlab Listing 33 speccosm plot the spectrum of a cosine wave f 10 phi 0 s p e c i f y frequency and phase time 2 length of time Ts1100 time i n t e r v a l between samples tTs Ts time cr eate a time vector xcos2 pi f tphi cr eate cos wave pl ots pec x Ts draw waveform and spectrum The output of speccosm is shown in Figure 35 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 A18 The two spikes of Figure 35 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 A2 The spikes of Figure 35 represent the magnitudes of these two complexvalued exponentials 46 Chapter 3 The Six Elements Exercise 36 Mimic the code in speccosm to find the spectrum of a cosine wave a for different frequencies f1 2 20 30 Hz b for different phases φ 0 01 π8 π2 radians c for different sampling rates Ts110 11000 1100000 Exercise 37 Let x1t be a cosine wave of frequency f 10 x2t be a cosine wave of frequency f 18 and x3t be a cosine wave of frequency f 33 Let xt x1t 05 x2t 2 x3t Find the spectrum of xt What property of the Fourier transform does this illustrate Exercise 38 Find the spectrum of a cosine wave in the following cases a φ is a function of time Try φt 10πt b φ is a function of time Try φt πt2 c f is a function of time Try ft sin2πt d f is a function of time Try ft t2 33 The Second Element Linear Filters Linear timeinvariant filters shape the spectrum of a signal If the signal has too much energy in the low frequencies a highpass filter can remove them If the signal has too much highfrequency noise a lowpass filter can reject it If a signal of interest resides only between f and f then a bandpass filter tuned to pass frequencies between f and f can remove outofband interference and noise More generally suppose that a signal has frequency bands in which the magnitude of the spectrum is lower than desired and other bands in which the magnitude is greater than desired Then a linear filter can compensate by increas ing or decreasing the magnitude This section provides an overview of how to implement simple filters in Matlab More thorough treatments of the theory design use and implementation of filters are given in Chapter 7 While the calculations of a linear filter are usually carried out in the time domain filters are often specified in the frequency domain Indeed the words used to specify filters such as lowpass highpass and bandpass describe how the filter acts on the frequency content of its input Figure 36 for instance shows a noisy input entering three different filters The frequency response of the LPF shows that it allows low frequencies those below the cutoff frequency f to pass while removing all frequencies above the cutoff Similarly the HPF passes all the high frequencies and rejects those below its cutoff f The frequency response of the BPF is specified by two frequencies It will remove all frequencies below f and all frequencies above f leaving only the region between The Six Elements 47 Mag Freq White input f f f f f f f f f LPF Y1 f y1t xt Y2 f Y3 f y2t y3t BPF HPF ff f f f f f X f Figure 36 A white signal containing all frequencies is passed through a lowpass filter LPF leaving only the low frequencies a bandpass filter BPF leaving only the middle frequencies and a highpass filter HPF leaving only the high frequencies Figure 36 shows the action of ideal filters How close are actual implementa tions The Matlab code in filternoisem shows that it is possible to create digital filters that reliably and accurately carry out these tasks Listing 34 filternoisem filter a noisy signal three ways time 3 length of time Ts110000 time i n t e r v a l between samples xrandn 1 time Ts generate noi s e s i g n a l figure 1 pl ots pec x Ts draw spectrum of input f r e q s 0 02 021 1 amps1 1 0 0 bfirpm 100 freqs amps s p e c i f y the LP f i l t e r ylpf i l t e r b 1 x do the f i l t e r i n g figure 2 pl ots pec ylp Ts pl ot the output spectrum f r e q s 0 024 026 05 051 1 amps0 0 1 1 0 0 bfirpm 100 freqs amps BP f i l t e r ybpf i l t e r b 1 x do the f i l t e r i n g figure 3 pl ots pec ybp Ts pl ot the output spectrum f r e q s 0 074 076 1 amps0 0 1 1 bfirpm 100 freqs amps s p e c i f y the HP f i l t e r yhpf i l t e r b 1 x do the f i l t e r i n g figure 4 pl ots pec yhp Ts pl ot the output spectrum The output of filternoisem is shown in Figure 37 Observe that the spec tra at the output of the filters are close approximations to the ideals shown in Figure 36 There are some differences however While the idealized spectra are completely flat in the passband the actual ones are rippled While the idealized spectra completely reject the outofband frequencies the actual ones have small but nonzero energy at all frequencies Two new Matlab commands are used in filternoisem The firpm command specifies the contour of the filter as a line graph Octave and early versions of Matlab call this command remez For instance typing plot 0 024 026 05 051 1 0 0 1 1 0 0 48 Chapter 3 The Six Elements Magnitude spectrum at input Magnitude spectrum at output of lowpass filter Magnitude spectrum at output of bandpass filter 4000 2000 0 2000 4000 Magnitude spectrum at output of highpass filter Figure 37 The spectrum of a white signal containing all frequencies is shown in the top figure This is passed through three filters a lowpass a bandpass and a highpass The spectra at the outputs of these three filters are shown in the second third and bottom plots The actual filters behave much like their idealized counterparts in Figure 36 at the Matlab prompt draws a box that represents the action of the BPF designed in filternoisem over the positive frequencies The frequencies are specified as percentages of fNY Q 12Ts which in this case is equal to 5000 Hz fNY Q is discussed further in the next section Thus the BPF in filternoisem passes frequencies between 0265000 Hz and 055000 Hz and rejects all others The filter command uses the output of firpm to carry out the filtering operation on the vector specified in its third argument More details about these commands are given in the section on practical filtering in Chapter 7 Exercise 39 Mimic the code in filternoisem to create a filter 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 310 Change the sampling rate to Ts120000 Redesign the three filters from Exercise 39 Exercise 311 Let x1t be a cosine wave of frequency f 800 x2t be a cosine wave of frequency f 2000 and x3t be a cosine wave of frequency f 4500 Let xt x1t 05 x2t 2 x3t Use xt as input to each of the three filters in filternoisem Plot the spectra and explain what you see Exercise 312 TRUE or FALSE A linear timeinvariant system exists that has input a cosbt and output c sindt with a c and b d Explain Exercise 313 TRUE or FALSE Filtering a passband signal with absolute bandwidth B through certain fixed linear filters can result in an absolute band width of the filter output greater than B Explain The Six Elements 49 Exercise 314 TRUE or FALSE A linear timeinvariant finiteimpulse response filter with a frequency response having unit magnitude over all fre quencies and a straightline sloped phase curve has as its transfer function a pure delay Explain Exercise 315 TRUE or FALSE Processing a bandlimited signal through a linear timeinvariant filter can increase its halfpower bandwidth Explain 34 The Third Element Samplers Since part of any digital transmission system is analog transmissions through the air across a cable or along a wire are inherently analog and part of the system is digital there must be a way to translate the continuoustime signal into a discretetime signal and vice versa The process of sampling an analog sig nal sometimes called analogtodigital conversion is easy to visualize in the time domain Figure 38 shows how sampling can be viewed as the process of evalu ating a continuoustime signal at a sequence of uniformly spaced time intervals thus transforming the analog signal xt into the discretetime signal xkTs One of the key ideas in signals and systems is the Fourier series a signal is periodic in time it repeats every P seconds if and only if the spectrum can be written as a sum of complex sinusoids with frequencies at integer multiples of a fundamental frequency f Moreover this fundamental frequency can be written in terms of the period as f 1P Thus if a signal repeats 100 times every second P 001 s then its spectrum consists of a sum of sinusoids with frequencies 100 200 300 Hz Conversely if a spectrum is built from a sum of sinusoids with frequencies 100 200 300 Hz then it must represent a periodic signal in time that has period P 001 s Said another way the nonzero portions of the spectrum are uniformly spaced f 100 Hz apart This uniform spacing can be interpreted as a sampling in frequency of an underlying continuousvalued spectrum This is xt xkTs xk Ts a b xt Ts 2Ts 3Ts 4Ts t xTs x1 x2Ts x2 x4Ts x4 x3Ts x3 Figure 38 The sampling process is shown in b as an evaluation of the signal xt at times 2Ts Ts 0 Ts 2Ts This procedure is schematized in a as an element that has the continuoustime signal xt as input and the discretetime signal xkTs as output 50 Chapter 3 The Six Elements P f fs Ts Periodic in time Uniform sampling in frequency f 1 P fs 1 Ts 3fs 2 3fs 2 fs 2 0 fs 2 f 2f 3f 4f 5f Fourier Transform Inverse Fourier Transform Uniform sampling in time Periodic in frequency Figure 39 Fouriers result says that any signal that is periodic in time has a spectrum that consists of a collection of spikes uniformly spaced in frequency Analogously any signal whose spectrum is periodic in frequency can be represented in time as a collection of spikes uniformly spaced in time and vice versa illustrated in the top portion of Figure 39 which shows the timedomain repre sentation on the left and the corresponding frequencydomain 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 1Ts 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 fs2 to fs2 rather than from 0 to fs This makes sense because the spectra of individual realvalued sinusoidal components contain two spikes symmetrically located around 0 Hz as we saw in Section 32 Accordingly the highest frequency that can be represented unam biguously is fs2 and this frequency is often called the Nyquist frequency fNY 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 The Six Elements 51 yi xk m Figure 310 The discrete signal xk is downsampled by a factor of m by removing all but one of every m samples The resulting signal is yi which takes on values yi xk whenever k im n in the bottom right diagram of Figure 39 where the spectrum between 3fs2 and fs2 is the same as the spectrum between fs2 and 3fs2 In fact we have been observing this convention throughout Sections 32 and 33 since all of the figures of spectra Figures 32 33 35 and 37 show just one period of the complete spectrum Perhaps you noticed that plotspecm changes the frequency axis when the sampling interval Ts is changed If not go back and redo Exercise 31c By the second convention plotspecm shows exactly one period of the complete spectrum By the first convention the plots are labeled from fNY Q to fNY 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 inves tigated by simulation in the problems below Aliasing and other samplingrelated 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 yi xim n where n is an integer between 0 and m 1 For example with m 3 and n 1 yi is the sequence that consists of every third value of xk y0 x1 y1 x4 y2 x7 y3 x10 etc This is commonly drawn in block form as in Figure 310 If the spectrum of xk is bandlimited to 1m of the Nyquist rate then downsampling by m loses no information Otherwise aliasing occurs Like analogtodigital sampling down sampling is a timevarying operation Exercise 316 Mimicking the code in speccosm with the sampling interval Ts1100 find the spectrum of a cosine wave cos2πft when f30 40 49 50 51 60 Hz Which of these show aliasing Exercise 317 Create a cosine wave with frequency 50 Hz Plot the spec trum when this wave is sampled at Ts150 190 1100 1110 and 1200 Which of these show aliasing Exercise 318 Mimic the code in speccosm with sampling interval Ts1100 to find the spectrum of a square wave with fundamental f10 20 30 33 52 Chapter 3 The Six Elements 43 Hz Can you predict where the spikes will occur in each case Which of the square waves show aliasing 35 The Fourth Element Static Nonlinearities Linear systems3 such as filters cannot add new frequencies to a signal though they can remove unwanted frequencies Nonlinearities such as squaring and quan tizing can and will add new frequencies These can be useful in the communica tion system in a variety of ways Perhaps the simplest memoryless nonlinearity is the square which takes the input at each time instant and multiplies it by itself Suppose the input is a sinusoid at frequency f that is xt cos2πft Then the output is the sinusoid squared which can be rewritten using the cosinecosine product A4 as yt x2t cos22πft 1 2 1 2 cos2π2ft The spectrum of yt has a spike at 0 Hz due to the constant and a spike at 2f Hz from the doublefrequency term Unfortunately the action of a squaring element is not always as simple as this example might suggest The following exercises encourage you to explore the kinds of changes that occur in the spectra when using a variety of simple nonlinear elements Exercise 319 Mimic the code in speccosm with Ts11000 to find the spectrum of the output yt of a squaring block when the input is a xt cos2πft for f 100 Hz b xt cos2πf1t cos2πf2t for f1 100 and f2 150 Hz c a filtered noise sequence with nonzero spectrum between f1 100 and f2 300 Hz Hint generate the input by modifying filternoisem d Can you explain the large DC zerofrequency component Exercise 320 TRUE or FALSE The bandwidth of x4t cannot be greater than that of xt Explain Exercise 321 Try different values of f1 and f2 in Exercise 319 Can you predict what frequencies will occur in the output When is aliasing an issue Exercise 322 Repeat Exercise 321 when the input is a sum of three sinusoids 3 To be accurate these systems must be exponentially stable and timeinvariant Exercise 323 Suppose that the output of a nonlinear block is the rectification absolute value of the input Find the spectrum of the output when the input is a for 100 Hz b for 100 and 125 Hz c Repeat b for 110 and 200 Hz Can you predict what frequencies will be present for any and d What frequencies will be present if is the sum of three sinusoids and Exercise 324 Suppose that the output of a nonlinear block is where 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 for 100 Hz b for 100 and 150 Hz Exercise 325 Quantization of an input is another kind of common nonlinearity The MATLAB function quantalphm available on the website quantizes a signal to the nearest element of a desired set Its help file reads yquantalphxalphabet quantize the input signal x to the alphabet using nearest neighbor method input x vector to be quantized alphabet vector of discrete values that y can assume sorted in ascending order output y quantized vector Let be a random vector xrandn1n of length n Quantize to the nearest a What percentage of the outputs are 1s 3s b Plot the magnitude spectrum of and the magnitude spectrum of the output c Now let x3randn1n and answer the same questions 36 The Fifth Element Mixers One feature of most telecommunications systems is the ability to change the frequency of the signal without changing its information content For example 54 Chapter 3 The Six Elements speech occurs in the range below about 8 kHz In order to transmit this it is upconverted as in Section 23 to radio frequencies at which the energy can easily propagate over long distances At the receiver it is downconverted as in Section 26 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 311 The following Matlab code implements a simple modulation Listing 35 modulatem change the frequency of the input time 5 Ts110000 time and sampling i n t e r v a l tTs Ts time def i ne a time vector f c 1000 cmodcos 2 pi f c t cr eate cos of f r eq f c f i 100 xcos 2 pi f i t input i s cos of f r eq f i ycmod x multiply input by cmod figure 1 pl ots pec cmod Ts f i nd s pectr a and pl ot figure 2 pl ots pec x Ts figure 3 pl ots pec y Ts The first three lines of the code create the modulating sinusoid ie an oscillator The next line specifies the input in this case another cosine wave The Matlab syntax calculates a pointbypoint multiplication of the two vectors cmod and x The output of modulatem is shown in Figure 312 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 326 Mimic the code in modulatem to find the spectrum of the output yt of a modulator block with modulation frequency fc 1000 Hz when a the input is xt cos2πf1t cos2πf2t for f1 100 and f2 150 Hz b the input is a square wave with fundamental f 150 Hz c the input is a noise signal with all energy below 300 Hz d the input is a noise signal bandlimited to between 2000 and 2300 Hz e the input is a noise signal with all energy below 1500 Hz cos2πf0tφ xtcos2πf0tφ xt φ X Figure 311 The mixing operation shifts all frequencies of a signal xt by an amount defined by the frequency f0 of the modulating sinusoidal wave The Six Elements 55 Magnitude spectrum at input Magnitude spectrum of the oscillator 3000 2000 1000 0 1000 2000 3000 Magnitude spectrum at output Figure 312 The spectrum of the input sinusoid is shown in the top figure The middle figure shows the spectrum of the modulating wave The bottom shows the spectrum of the pointbypoint multiplication in time of the two which is the same as their convolution in frequency 37 The Sixth Element Adaptation Adaptation is a primitive form of learning Adaptive elements in telecommuni cation systems find approximate values for unknown parameters in an attempt to compensate for changing conditions or to improve performance A common strategy in parameterestimation problems is to guess a value assess how good the guess is and refine the guess over time With luck the guesses converge to a useful estimate of the unknown value Figure 313 shows an adaptive element containing two parts The adaptive subsystem parameterized by a changes the input into the output The quality assessment mechanism monitors the output and other relevant signals and tries to determine whether a should be increased or decreased The arrow through the system indicates that the a value is then adjusted accordingly Adaptive elements occur in a number of places in the communication system including the following r In an automatic gain control the adaptive subsystem is multiplication by a constant a The qualityassessment mechanism gauges whether the power at the output of the AGC is too large or too small and adjusts a accordingly a Input Output Quality Assessment Figure 313 The adaptive element is a subsystem that transforms the input into the output parameterized by a and a qualityassessment mechanism that evaluates how to alter a in this case whether to increase or decrease a 56 Chapter 3 The Six Elements r In a phaselocked loop the adaptive subsystem contains a sinusoid with an unknown phase shift a The qualityassessment mechanism adjusts a to maximize a filtered version of the product of the sinusoid and its input r In a timing recovery setting the adaptive subsystem is a fractional delay given by a One mechanism for assessing quality monitors the power of the output and adjusts a to maximize this power r In an equalizer the adaptive subsystem is a linear filter parameterized by a set of as The qualityassessment mechanism monitors the deviation of the output of the system from a target set and adapts the as accordingly Chapter 6 provides an introduction to adaptive elements in communication systems and a detailed discussion of their implementation is postponed until then 38 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 filters 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 howto aspects by providing a series of Matlab exercises which will be useful when creating simulations of the various parts of a receiver For Further Reading The intellectual background of the material presented here is often called signals and systems One of the most accessible books is r J H McClellan R W Schafer and M A Yoder Signal Processing First Pearson PrenticeHall 2003 Other books provide greater depth and detail about the theory and uses of Fourier transforms We recommend these as both background and supplementary reading r A V Oppenheim A S Willsky and S H Nawab Signals and Systems 2nd edition PrenticeHall 1997 r S Haykin and B Van Veen Signals and Systems Wiley 2002 4 Assuming a sixfingered hand The Six Elements 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 filter design Some of the best are the following r A V Oppenheim R W Schafer and J R Buck DiscreteTime Signal Pro cessing PrenticeHall 1999 r B Porat A Course in Digital Signal Processing Wiley 1997 r S Mitra Digital Signal Processing A ComputerBased Approach McGraw Hill 2005 Finally since Matlab is fundamental to our presentation it is worth mentioning some books that describe the uses and abuses of the Matlab language r A Gilat MATLAB An Introduction with Applications Wiley 2007 r B Littlefield and D Hanselman Mastering Matlab 7 PrenticeHall 2004 Step 3 The Idealized System 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 reflections diffractions or diffusions 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 channel frequency translation sampling Chapter 4 Chapter 5 Chapter 6 receive filtering equalization decision device decoding Chapter 7 Chapter 8 Chapter 9 provides a complete though idealized softwaredefined digital radio system 4 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 41 More important than locating the sources of the problems is fixing them The received signal can be processed using linear filters to help reduce the interferences and to undo to some extent the effects of the degradations The central question is how to specify filters that can successfully mitigate these problems and answering this requires a fairly detailed understanding of filtering Thus a discussion of linear filters occupies the bulk of this chapter which also provides a background for other uses of filters throughout the receiver such as the lowpass filters used in the demodulators of Chapter 5 the pulseshaping and matched filters of Chapter 11 and the equalizing filters of Chapter 13 41 When Bad Things Happen to Good Signals The path from the transmitter to the receiver is not simple as Figure 41 sug gests Before the signal reaches the receiver it may be subject to a series of strange events that can corrupt the signal and degrade the functioning of the receiver This section discusses five kinds of corruption that are used throughout the chapter to motivate and explain the various purposes that linear filters may serve in the receiver 60 Chapter 4 Modeling Corruption Multipath Changing gain Transmitted signal Signals from other users Broadband noise Narrowband noise Received signal Types of corruption Figure 41 Sources of corruption include multipath interference changing channel gains interference from other users broadband noise and narrowband interferences 411 Other Users Many different 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 different frequency bands to each user This was called frequencydivision multiplexing FDM in Chapter 2 and was shown diagrammatically in Figure 23 on page 22 The signals from the different users can be separated using a bandpass filter as in Figure 24 on page 23 Of course practical filters do not completely remove outofband signals nor do they pass inband signals completely without distortions Recall the three filters in Figure 37 on page 48 412 Broadband Noise When the signal arrives at the receiver it is small and must be amplified While it is possible to build highgain amplifiers the noises and interferences will also be amplified along with the signal In particular any noise in the amplifier 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 filter is applied at the front end of the receiver By applying a suitable filter the total power in the noise compared with the total power in the signal can often be reduced Figure 42 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 flat region and its power is the shaded area After applying the bandpass filter the power in the signal remains more or less unchanged while the power in the noise is greatly reduced Thus the signaltonoise ratio SNR improves Modeling Corruption 61 Power in signal Power in noise Power in signal is unchanged fc B fc B fc B fc B fc B fc B fc B fc B a b c Total power in noise is decreased fc B fc B fc B fc B 0 Figure 42 The signaltonoise ratio is depicted graphically as the ratio of the power of the signal the area under the triangles to the power in the noise the shaded area After the bandpass filter the power in the noise decreases so the SNR increases 413 Narrowband Noise Noises are not always white that is the spectrum need not always be flat Stray sine waves and other signals with narrow spectra may also impinge on the receiver These may be caused by errant transmitters that accidentally broad cast in the frequency range of the signal or they may be harmonics of a lower frequency wave as it experiences nonlinear distortion If these narrowband distur bances occur out of band they will automatically be attenuated by the bandpass filter 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 filter one designed to remove just the offending frequency can be an effective tool Figure 43 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 filter BPF the two pairs of outofband spikes are removed but the inband pair remains Applying a narrow notch filter tuned to the frequency of the interferer allows its removal although this cannot be done without also affecting the signal somewhat 414 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 trans mitted 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 reflects refracts or diffracts and the signal arriving is quite different from the one that was sent 62 Chapter 4 Modeling Corruption Signal plus three narrowband interferers Removal of outofband interferers Removal of inband interferers also modifier signals Notch filter BPF Figure 43 Three narrowband interferers are shown in the top figure the three pairs of spikes The BPF cannot remove the inband interferer though a narrow notch filter can at the expense of changing the signal in the region where the narrowband noise occurred These distortions can be thought of as a combination of scaled and delayed reflections of the transmitted signal which occur when there are different prop agation paths from the transmitter to the receiver Between two transmission towers for instance the paths may include one along the line of sight reflections from the atmosphere reflections from nearby hills and bounces from a field or lake between the towers For indoor digital TV reception there are many local timevarying reflectors including people in the receiving room nearby vehicles and the buildings of an urban environment Figure 44 for instance shows mul tiple reflections that arrive after bouncing off a cloud and off a mountain and others that are scattered by multiple bounces from nearby buildings The strength of the reflections depends on the physical properties of the reflect ing surface while the delay of the reflections is primarily determined by the length of the transmission path Let st be the transmitted signal If N delays are represented by 1 2 N and the strengths of the reflections are h1 h2 hN then the received signal rt is rt h1st 1 h2st 2 hNst N 41 As will become clear in Section 44 this model of the channel has the form of a linear filter since the expression on the righthand side is a convolution of the transmitted signal and the his This is shown in part a of Figure 45 Since this channel model is a linear filter 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 Transmitter Cloud Receiver Buildings Mountain Line of sight Figure 44 The received signal may be a combination of several copies of the original transmitted signal each with a different attenuation and delay ht Transmitted signal Received signal Fourier Transform H f Frequency a b c d Figure 45 a The channel model 41 as a filter b The frequency response of the filter c An idealized BPF and the spectrum of the signal The product of b and c gives d the distorted spectrum at the receiver If the kinds of distortions introduced by the channel are known or can some how be determined then the bandpass filter at the receiver can be modified in order to undo the effects of the channel This can be seen most clearly in the frequency domain as in Figure 46 Observe that the BPF is shaped part d to approximately invert the debilitating effects of the channel part a in the frequency band of the signal and to remove all the outofband 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 45 where no shaping was attempted 64 Chapter 4 Modeling Corruption Frequency response of channel Spectrum of signal Product of a b Product of c d BPF with shaping a b c d e Figure 46 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 filter that has been shaped to undo the effect 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 filtering in the receiver can be used to reshape the received signal within the frequency band of the transmission as well as to remove unwanted outof band frequencies 415 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 reflection from a cloud might disappear when the cloud dissipates an additional reflection 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 reflections Fading may also occur when the transmitter andor the receiver are moving The Doppler effect shifts the frequencies slightly causing interferences that may slowly change Such timevarying problems cannot be fixed by a single fixed filter rather the filter must somehow compensate differently at different times This is an ideal application for the adaptive elements of Section 37 though results from the study of linear filters will be crucial in understanding how the time variations Modeling Corruption 65 in the frequency response can be represented as timevarying coefficients in the filter that represents the channel 42 Linear Systems Linear Filters Linear systems appear in many places in communication systems The trans mission channel is often modeled as a linear system as in 41 The bandpass filters used in the front end to remove other users and to remove noises are linear Lowpass filters are crucial to the operation of the demodulators of Chap ter 5 The equalizers of Chapter 13 are linear filters that are designed during the operation of the receiver on the basis of certain characteristics of the received signal Timeinvariant linear systems can be described in any one of three equivalent ways r The impulse response ht is a function of time that defines 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 r The frequency response Hf is a function of frequency that defines how the spectrum of the input is changed into the spectrum of the output The fre quency response and the impulse response are intimately related Hf is the Fourier transform of ht r A linear difference equation with constant coefficients such as 41 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 define 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 final step is to show how the action of the linear system can be redescribed in the time domain as a difference or as a differential equation This is postponed to Chapter 7 and is also discussed in some detail in Appendix F 43 The Delta Function One way to see how a system behaves is to kick it and see how it responds Some systems react sluggishly barely moving away from their resting state while others respond quickly and vigorously Defining exactly what is meant mathematically by a kick is trickier than it seems because the kick must occur over a very short amount of time yet must be energetic in order to have any effect This section defines 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 δtdt1 42 The criterion that it occur over a very short time span is translated to the statement that for every positive ϵ δt0 tϵ 0 tϵ 43 Thus the impulse δt is explicitly defined to be equal to zero for all t0 On the other hand δt is implicitly defined when t0 by the requirement that its integral be unity Together these guarantee that δt is no ordinary function¹ The most important consequence of the definitions 42 and 43 is the sifting property wtδtt₀dtwttt₀wt₀ 44 which says that the delta function picks out the value of the function wt from under the integral at exactly the time when the argument of the δ function is zero that is when tt₀ To see this observe that δtt₀ is zero whenever tt₀ and hence wtδtt₀ is zero whenever tt₀ Thus wtδtt₀dt wt₀δtt₀dt wt₀ δtt₀dtwt₀1wt₀ Sometimes it is helpful to think of the impulse as a limit For instance define the rectangular pulse of width 1n and height n by δₙt0 t12n n 12n t 12n 0 t12n Then δtlimn δₙt fulfills both criteria 42 and 43 Informally it is not unreasonable to think of δt as being zero everywhere except at t0 where it is infinite While it is not really possible to plot the delta function δtt₀ it can be represented in graphical form as zero everywhere except for an uppointing arrow at t₀ 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 ¹ The impulse is called a distribution and is the subject of considerable mathematical investigation Figure 47 The function wtδt10 2δt1 3δt5 consisting of three weighted δ functions is represented graphically as three weighted arrows at t1015 weighted by the appropriate constants is negative the arrow is drawn pointing down For instance Figure 47 shows a graphical representation of the function wtδt102δt13δt5 What is the spectrum Fourier transform of δt This can be calculated directly from the definition by replacing wt in 21 with δt ℱδt δtej2πftdt 45 Apply the sifting property 44 with wtej2πft and t₀0 Thus ℱδtej2πftt01 Alternatively suppose that δ is a function of frequency that is a spike at zero frequency The corresponding timedomain function can be calculated analogously using the definition of the inverse Fourier transform that is by substituting δf for Wf in A16 and integrating ℱ¹δf δfej2πftdfej2πftf01 Thus a spike at frequency zero is a DC signal a constant in time The discrete time counterpart of δt is the discrete delta function δk1 k0 0 k0 While there are a few subtle differences between δt and δk for the most part δt and δk act analogously For example the program specdeltam calculates the spectrum of the discrete delta function Listing 41 specdeltam plots the spectrum of a delta function time2 length of time Ts1100 time interval between samples tTsTstime create time vector xzerossizet create signal of all zeros x11 delta function plotspecxTs draw waveform and spectrum The output of specdeltam is shown in Figure 48 As expected from 45 the magnitude spectrum of the delta function is equal to 1 at all frequencies Exercise 41 Calculate the Fourier transform of δtt₀ from the definition Now calculate it using the timeshift property A37 Are they the same Hint they had better be A discrete delta function at time 0 has a magnitude spectrum equal to 1 for all frequencies Exercise 42 Use the definition of the IFT A16 to show that δf f0 ej2πf0t Exercise 43 Mimic the code in specdeltam to find the magnitude spectrum of the discrete delta function in the following cases a The delta does not occur at the start of x Try x10 1 x100 1 and x110 1 How do the spectra differ Can you use the timeshift property A37 to explain what you see b The delta changes magnitude x Try x1 10 x10 3 and x110 01 How do the spectra differ Can you use the linearity property A31 to explain what you see Exercise 44 Modify the code in specdeltam to find the phase spectrum of a signal that consists of a delta function when the nonzero term is located at the start x1 1 in the middle x100 1 and at the end x200 1 Exercise 45 Mimic the code in specdeltam to find the spectrum of a train of equally spaced pulses For instance x120end 1 spaces the pulses 20 samples apart and x125end 1 places the pulses 25 samples apart a Can you predict how far apart the resulting pulses in the spectrum will be b Show that from k to δt kTs 1Ts from n to δf nfs where fs 1Ts Hint let wt 1 in A27 and A28 c Now can you predict how far apart the pulses in the spectrum are Your answer should be in terms of how far apart the pulses are in the time signal In Section 32 the spectrum of a sinusoid was shown to consist of two symmetric spikes in the frequency domain recall Figure 35 on page 45 The next example shows why this is true by explicitly taking the Fourier transform to find the spectrum of a sinusoid The magnitude spectrum of a sinusoid with frequency f0 and amplitude A contains two δfunction spikes one at f f0 and the other at f f0 Example 41 Let wt A sin2πf0t and use Eulers identity A3 to rewrite wt as wt A2jej2πf0t ej2πf0t Applying the linearity property A31 and the result of Exercise 42 gives 𝓕wt A2j𝓕ej2πf0t 𝓕ej2πf0t j A2δf f0 δf f0 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 49 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 410a shows the magnitude spectrum Wf of a realvalued signal wt This can be interpreted as saying that wt 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 st in Figure 410b contains all positive frequencies between fc B and fc B and no others Note that the Fourier transform in 47 is purely imaginary as it must be because wt is odd see A37 The phase spectrum is a flat line at 90 because of the factor j Exercise 46 What is the magnitude spectrum of sin2πf0t θ Hint use the frequencyshift property A34 Show that the spectrum of cos2πf0t is 12δf f0 δf f0 Compare this analytical result with the numerical results from Exercise 36 Exercise 47 Let wit ai sin2πfi t for i 1 2 3 Without doing any calculations write down the spectrum of vt w1t w2t w3t Hint use linearity Graph the magnitude spectrum of vt in the same manner as in Figure 49 Verify your results with a simulation mimicking that in Exercise 37 The magnitude spectrum of a message signal wt is shown in a When wt is modulated by a cosine at frequency fc the spectrum of the resulting signal st wt cos2πfc t ϕ is shown in b Exercise 48 Let Wf sin2πf t0 What is the corresponding time function 44 Convolution in Time Its What Linear Systems Do Suppose that a system has impulse response ht and that the input consists of a sum of three impulses occurring at times t0 t1 and t2 with amplitudes a0 a1 and a2 for example the signal wt of Figure 47 Because of the linearity of the Fourier transform property A31 the output is a superposition of the outputs due to each of the input pulses The output due to the first impulse is a0 ht t0 which is the impulse response scaled by the size of the input and shifted to begin when the first input pulse arrives Similarly the outputs to the second and third input impulses are a1 ht t1 and a2 ht t2 respectively and the complete output is the sum a0 ht t0 a1 ht t1 a2 ht t2 Now suppose that the input is a continuous function xt At any time instant λ the input can be thought of as consisting of an impulse scaled by the amplitude xλ and the corresponding output will be xλ ht λ which is the impulse response scaled by the size of the input and shifted to begin at time λ The complete output is then given by integrating over all λ yt from to xλ ht λ dλ xt ht This integral defines the convolution operator and provides a way of finding the output yt of any linear system given its impulse response ht and the input xt Matlab has several functions that simplify the numerical evaluation of convolutions The most obvious of these is conv which is used in convoleXm 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 42 convoleXm example of numerical convolution Ts1100 time10 sampling interval and total time t0Tstime create time vector hexpt define impulse response xzerossizet input sum of two delta functions Figure 411 The convolution of the input the top plot with the impulse response of the system the middle plot gives the output in the bottom plot x1Ts3 x3Ts2 at times t1 and t3 yconvhx do convolution subplot311 plottx and plot subplot312 plotth subplot313 plotty1lengtht Figure 411 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 t1 and the output is zero When the first spike occurs the system responds by jumping to 3 and then decaying slowly at a rate dictated by the shape of ht The decay continues smoothly until time t3 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 first spike Since there are no more inputs the output slowly dies away Exercise 49 Suppose that the impulse response ht of a linear system is the exponential pulse htet t0 0 t0 49 Suppose that the input to the system is 3δt12δt3 Use the definition of convolution 48 to show that the output is 3ht12ht3 where htt0ett0 t t0 0 tt0 How does your answer compare with Figure 411 72 Chapter 4 Modeling Corruption Exercise 410 Suppose that a system has an impulse response that is an expo nential pulse Mimic the code in convolexm to find its output when the input is a white noise recall specnoisem on page 42 Exercise 411 Mimic the code in convolexm to find 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 filters commute with differentiation and with each other Exercise 412 Use the definition to show that convolution is commutative ie that w1t w2t w2t w1t Hint apply the change of variables τ t λ in 48 Exercise 413 Suppose a filter has impulse response ht When the input is xt the output is yt If the input is xdt xtt the output is ydt Show that ydt is the derivative of yt Hint use 48 and the result of Exercise 412 Exercise 414 Let wt Πt be the rectangular pulse of 28 What is wt wt Hint a pulse shaped like a triangle Exercise 415 Redo Exercise 414 numerically by suitably modifying convolexm Let T 15 s Exercise 416 Suppose that a system has an impulse response that is a sinc function as shown in Figure 211 and that the input to the system is a white noise as in specnoisem on page 42 a Mimic convolexm to numerically find the output b Plot the spectrum of the input and the spectrum of the output using plotspecm What kind of filter would you call this 45 Convolution Multiplication While the convolution operator 48 describes mathematically how a linear sys tem acts on a given input timedomain approaches are often not particularly revealing about the general behavior of the system Who would guess for instance in Exercises 411 and 416 that convolution with exponentials and sinc functions would act like lowpass filters By working in the frequency domain however the convolution operator is transformed into a simpler pointbypoint multiplication and the generic behavior of the system becomes clearer The first step is to understand the relationship between convolution in time and multiplication in frequency Suppose that the two time signals w1t and w2t have Fourier transforms W1f and W2f Then Fw1tw2tW1fW2f 410 To justify this property begin with the definition of the Fourier transform 21 and apply the definition of convolution 48 to obtain Fw1tw2tintt w1tw2tej2πftdt intt intλ w1λw2tλdλ ej2πft dt Reversing the order of integration and using the timeshift property A37 produces Fw1tw2tintλ w1λ intt w2tλej2πft dt dλ intλ w1λ W2fej2πfλ dλ W2f intλ w1λ ej2πfλdλ W1fW2f Thus convolution in the time domain is the same as multiplication in the frequency domain See A40 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 A41 that is Fw1tw2tW1fW2fint W1λW2fλdλ 411 The usefulness of these convolution properties is apparent when applying them to linear systems Suppose that Hf is the Fourier transform of the impulse response ht Suppose that Xf is the Fourier transform of the input xt that is applied to the system Then 48 and 410 show that the Fourier transform of the output is exactly equal to the product of the transforms of the input and the impulse response that is YfFytFxthtFhtFxtHfXf This can be rearranged to solve for HfYfXf 412 which is called the frequency response of the system because it shows for each frequency f how the system responds For instance suppose that Hf13 at some frequency f1 Then whenever a sinusoid of frequency f1 is input into the system it will be amplified by a factor of 3 Alternatively suppose that Hf20 at some frequency f2 Then whenever a sinusoid of frequency f2 is input into 74 Chapter 4 Modeling Corruption 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 filters For example the filters of Figures 24 25 and 26 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 filter affects the input and how the frequency content of the output relates to that of the input Sometimes the frequency response Hf is called the transfer function of the system since it transfers the input xt with transform Xf into the output yt 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 72 to design filters for the manipulation augmentation or removal of specified frequencies Example 42 In Exercise 416 a system was defined 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 A22 Hence the frequency response of the system is a rectangle that passes all frequencies below fc 1T and removes all frequencies above ie the system is a lowpass filter Matlab can help to visualize the relationship between the impulse response and the frequency response For instance the system in convolexm is defined via its impulse response which is a decaying exponential Figure 411 shows its output when the input is a simple sum of delta functions and Exercise 410 explores the output when the input is a white noise In freqrespm the behavior of this system is explained by looking at its frequency response Listing 43 freqrespm numerical example of impulse and frequency response Ts1100 time 10 sampling i n t e r v a l and t o t a l time t 0Ts time cr eate time vector hexpt def i ne impulse response pl ots pec h Ts f i nd and pl ot frequency response The output of freqrespm is shown in Figure 412 The frequency response of the system which is just the magnitude spectrum of the impulse response is found using plotspecm In this case the frequency response amplifies low frequencies and attenuates other frequencies more as the frequency increases This explains for instance why the output of the convolution in Exercise 410 contained primarily lower frequencies as evidenced by the slower undulations in time Modeling Corruption 75 0 0 0 2 4 6 8 10 1 Amplitude Seconds 40 30 20 10 0 10 30 20 40 100 Magnitude Frequency Figure 412 The action of a system in time is defined by its impulse response in the top plot The action of the system in frequency is defined by its frequency response in the bottom plot a kind of lowpass filter Exercise 417 Suppose a system has an impulse response that is a sinc func tion Using freqrespm find the frequency response of the system What kind of filter does this represent Hint center the sinc in time for instance use hsinc10ttime2 Exercise 418 Suppose a system has an impulse response that is a sin func tion Using freqrespm find the frequency response of the system What kind of filter does this represent Can you predict the relationship between the fre quency of the sine wave and the location of the peaks in the spectrum Hint try hsin25t Exercise 419 Create a simulation analogous to convolexm that inputs white noise into a system with an impulse response that is a sinc function as in Exercise 417 Calculate the spectra of the input and output using plotspecm Verify that the system behaves as suggested by the frequency response in Exer cise 417 Exercise 420 Create a simulation analogous to convolexm that inputs white noise into a system with an impulse response that is a sin function as in Exercise 418 Calculate the spectra of the input and output using plotspecm Verify that the system behaves as suggested by the frequency response in Exer cise 418 So far Section 45 has emphasized the idea of finding 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 filter with some special characteristic in the frequency domain for instance in order to accomplish one of the goals of bandpass filtering in Section 41 It is easy to specify the filter in the fre quency domain Its impulse response can then be found by taking the inverse Fourier transform and the filter can be implemented using convolution Thus 76 Chapter 4 Modeling Corruption the relationship between impulse response and frequency response can be used both to study and to design systems In general this method of designing filters is not optimal in the sense that other design methods can lead to more efficient designs but it does show clearly what the filter is doing and why Whatever the design procedure the represen tation of the filter in the time domain and its representation in the frequency domain are related by nothing more than a Fourier transform 46 Improving SNR Section 41 described several kinds of corruption that a signal may encounter as it travels from the transmitter to the receiver This section shows how linear filters can help Perhaps the simplest way a linear bandpass filter can be used is to remove broadband noise from a signal Recall Section 412 and especially Figure 42 A common way to quantify noise is the signaltonoise 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 first 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 413 The signal at the input rt in part a is composed of the message signal xt and the noise signal nt and the SNR at the input is therefore SNRinput power in xt power in nt Similarly the output yt is composed of a filtered version of the message yxt in part b and a filtered version of the noise ynt in part b The SNR at the output can therefore be calculated as SNRoutput power in yxt power in ynt Observe that the SNR at the output cannot be calculated directly from yt since the two components are scrambled together But since the filter is linear yt BPFxt nt BPFxt BPFnt yx yn which effectively shows the equivalence of parts a and b of Figure 413 The Matlab program improvesnrm 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 Modeling Corruption 77 xt rt nt BPF yt a b yxt ynt yt nt xt BPF BPF Figure 413 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 xn The BPF is created using the firpm command just like the bandpass filter in filternoisem 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 413 Thus yx and yn represent the signal x filtered 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 powm available on the website Listing 44 improvesnrm using a linear filter to improve SNR time 3 Ts120000 time and sampling i n t e r v a l f r e q s 0 029 03 04 041 1 f i l t e r design bandlimited amps0 0 1 1 0 0 between 3K and 4K bfirpm 100 freqs amps BP f i l t e r n025randn 1 time Ts generate white noi s e s i g n a l xf i l t e r b 1 2randn 1 time Ts do the f i l t e r i n g yf i l t e r b 1 xn a f i l t e r the s i g n a lnoi s e yxf i l t e r b 1 x or b f i l t e r s i g n a l ynf i l t e r b 1 n and noi s e s epar atel y zyxyn add them d i f f z ymax abs zy and make sure y z snrinppow xpown SNR at input snroutpow yx pow yn SNR at output Since the data generated in improvesnrm are random the numbers are slightly different each time the program is run Using the default values the SNR at the input is about 78 while the SNR at the output is about 61 This is certainly a noticeable improvement The variable diffzy shows the largest dif ference between the two ways of calculating the output that is between parts a and b of Figure 413 This is on the order of 1015 which is effectively the numerical resolution of Matlab calculations indicating that the two are effectively the same Figure 414 plots the spectra of the input and the output of a typical run of improvesnrm Observe the large noise floor 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 effect there 78 Chapter 4 Modeling Corruption Magnitude spectrum of signal plus noise Magnitude spectrum after filtering Figure 414 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 The program improvesnrm can be thought of as a simulation of the effect of having a BPF at the receiver for the purposes of improving the SNR when the signal is corrupted by broadband noise as was described in Section 412 The following problems ask you to mimic the code in improvesnrm to simulate the benefit of applying filters to the other problems presented in Section 41 Exercise 421 Suppose that the noise in improvesnrm is replaced with nar rowband noise as discussed in Section 413 Investigate the improvements in SNR a when the narrowband interference occurs outside the 3000 to 4000 Hz pass band b when the narrowband interference occurs inside the 3000 to 4000 Hz passband Exercise 422 Suppose that the noise in improvesnrm is replaced with other users who occupy different frequency bands as discussed in Section 411 Are there improvements in the SNR Exercise 423 Consider the interference between two users x1 and x2 occupying the same frequency band as shown in Figure 415 The phases of the two mixers at the transmitter are unequal with 5π6 φ θ π3 The lowpass filter LPF has a cutoff frequency of fc a passband gain of 15 a stopband gain of zero and zero phase at zero frequency LPF cos2πfctθ cos2πfctα cos2πfctφ x2t x1t yt receiver transmitter Figure 415 The multiuser transmission system of Exercise 423 Modeling Corruption 79 a For this system Y f c1X1f c2X2f Determine c1 and c2 as functions of fc φ θ and α b With α set to maximize c1c22 find c1 and c2 as functions of fc φ and θ c With α set to minimize c1c22 find c1 and c2 as functions of fc φ and θ The other two problems posed in Section 41 were multipath interference and fading These require more sophisticated processing because the design of the filters depends on the operating circumstances of the system These situations will be discussed in detail in Chapters 6 and 13 For Further Reading An early description of the linearity of communication channels can be found in r P A Bello Characterization of Randomly TimeVariant Linear Channels IEEE Transactions on Communication Systems vol 11 no 4 pp 360393 Dec 1963 5 Analog Demodulation 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 wkT in Figure 51 is a discretetime sequence drawn from a finite alphabet The ultimate output mkT produced by the decision device or quantizer is also discretetime 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 pulseshaping filter of the transmitter to the sampler at the receiver At the transmitter in Figure 51 the digital message has already been turned into an analog signal by the pulse shaping which was discussed briefly in Section 210 and is considered in detail in Chapter 11 For efficient 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 twostep procedure is shown in Figure 51 There are many ways in which signals can be modulated Perhaps the sim plest is amplitude modulation AM which is discussed in two forms large and small carrier in the next two sections This is generalized to the simultane ous transmission of two signals using quadrature modulation in Section 53 and it is shown that quadrature modulation uses bandwidth more efficiently than amplitude modulation This gain in efficiency can also be obtained using single sideband and vestigialsideband methods which are discussed in the document Analog Demodulation 81 Analog conversion to IF Carrier synchronization Analog upconversion Interferers Noise Pulse shaping Digital down conversion to baseband f Ts Decision Reconstructed message mkT δ 3 1 1 3 Message wkT 3 1 1 3 θ Figure 51 A complete digital communication system has many parts This chapter focuses on the upconversion and the downconversion which can done in many ways including largecarrier AM as in Section 51 suppressedcarrier AM as in Section 52 and quadrature modulation as in Section 53 titled Other Modulations available on the website Demodulation can also be accomplished using sampling as discussed in Section 62 and amplitude modu lation can also be accomplished with a simple squaring and filtering operation as in Exercise 59 Throughout the chapter contains a series of exercises that prepare readers to create their own modulation and demodulation routines in Matlab These lie at the heart of the software receiver that will be assembled in Chapters 9 and 15 51 Amplitude Modulation with Large Carrier Perhaps the simplest form of analog transmission system modulates the mes sage signal by a highfrequency carrier in a twostep procedure multiply the message by the carrier then add the product to the carrier At the receiver the message can be demodulated by extracting the envelope of the received signal Consider the transmittedmodulated signal vt Acwt cos2πfct Ac cos2πfct Acwt 1 cos2πfct diagrammed in Figure 52 The process of multiplying the signal in time by a cosinusoid is called mixing This can be rewritten in the frequency domain by mimicking the development from 23 to 25 on page 20 Using the convolution property of Fourier transforms 410 the transform of vt is V f FAcwt 1 cos2πfct AcFwt 1 Fcos2πfct 51 The spectra of Fwt 1 and V f are sketched in Figure 53 a and b The vertical arrows in b represent the transform of the cosine carrier at frequency fc ie a pair of delta functions at fc and the scaling by Ac2 is indicated next to the arrowheads If wt 1 the envelope of vt is the same as wt and an envelope detector can be used as a demodulator envelopes are discussed in detail in Appendix C One way to find the envelope of a signal is to lowpass filter the absolute value 82 Chapter 5 Analog Demodulation wt Ac cos2πfct vt vt LPF mt a Transmitter b Receiver envelope detector Figure 52 A communications system using amplitude modulation with a large carrier In the transmitter a the message signal wt is modulated by a carrier wave at frequency fc and then added to the carrier to give the transmitted signal vt In b the received signal is passed through an envelope detector consisting of an absolutevalue nonlinearity followed by a lowpass filter When all goes well the output mt of the receiver is approximately equal to the original message V f f fc b fc Ac2 Ac2 Fwt1 f B a B Ac Fcos2πfct f 2fc 4fc c 2fc 4fc Fvt f 2fc 4fc d 2fc 4fc Figure 53 Spectra of the signals in the largecarrier AM system of Figure 52 Lowpass filtering d gives a scaled version of a To see this analytically observe that Fvt FAcwt 1 cos2πfct AcFwt 1 cos2πfct AcFwt 1 F cos2πfct where the absolute value can be removed from wt 1 because wt 1 0 by assumption The spectrum of Fcos2πfct shown in Figure 53c may be familiar from Exercise 323 Accordingly Fvt is the convolution shown in Figure 53d Lowpass filtering this returns wt 1 which is the envelope of vt offset by the constant unity Analog Demodulation 83 An example is given in the following Matlab program The message signal is a sinusoid with a drift in the DC offset and the carrier wave is at a much higher frequency Listing 51 AMlargem largecarrier AM demodulated with envelope time 033 Ts110000 sampling i n t e r v a l time t 0Ts time l entlength t def i ne a time vector fm20 f c 1000 ccos 2 pi f c t def i ne c a r r i e r at f r eq f c w10 l ent 1 l ent cos 2 pifm t cr eate message 1 vc wc modulate w l ar ge c a r r i e r fbe 0 005 01 1 LPF design damps1 1 0 0 f l 100 bfirpm f l fbe damps impulse response of LPF envvpi 2 f i l t e r b 1 absv f i nd envelope The output of this program is shown in Figure 54 The slowly increasing sinusoidal message wt is modulated by the carrier ct at fc 1000 Hz The heart of the modulation is the pointbypoint multiplication of the message and the carrier in the fifth line This product vt is shown in Figure 54c The enveloping operation is accomplished by applying a lowpass filter to the real part of 2vtej2πfct as discussed in Appendix C This recovers the original message signal though it is offset by 1 and delayed by the linear filter Exercise 51 Using AMlargem plot the spectrum of the message wt the spectrum of the carrier ct and the spectrum of the received signal vt What is the spectrum of the envelope How close are your results to the theoretical predictions in 51 Exercise 52 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 AMlargem a Change the phase of the transmitted signal for instance let ccos2pi fctphase with phase01 05 pi3 pi2 pi and verify that the recovered envelope remains unchanged b Change the frequency of the transmitted signal for instance let ccos2 pifcgt with g10 10 100 100 and verify that the recovered envelope remains unchanged Can g be too large Exercise 53 Create your own message signal wt and rerun AMlargem Repeat Exercise 51 with this new message What differences do you see Exercise 54 In AMlargem verify that the original message w and the recovered envelope envv are offset by 1 except at the end points where the filter does not have enough data Hint the delay induced by the linear filter is approximately fl2 84 Chapter 5 Analog Demodulation Seconds d output of envelope detector 007 006 005 004 003 002 001 0 0 2 4 b carrier 1 0 1 Amplitude c modulated signal 2 0 2 4 a message signal 0 2 4 Amplitude Amplitude Amplitude Figure 54 An undulating message top is modulated by a carrier b The composite signal is shown in c and the output of an envelope detector is shown in d The principal advantage of transmission systems that use AM with a large carrier is that exact synchronization is not needed the phase and frequency of the transmitter need not be known at the receiver as was demonstrated in Exer cise 52 This means that the receiver can be simpler than when synchronization circuitry is required The main disadvantage is that adding the carrier into the signal increases the power needed for transmission but does not increase the amount of useful information transmitted Here is a clear engineering tradeoff the value of the wasted signal strength must be balanced against the cost of the receiver 52 Amplitude Modulation with Suppressed Carrier It is also possible to use AM without adding the carrier Consider the transmit tedmodulated signal vt Acwtcos2πfct diagrammed in Figure 55a in which the message wt is mixed with the cosine carrier Direct application of the frequencyshift property of Fourier transforms A33 shows that the spectrum of the received signal is V f 1 2AcWf fc 1 2AcWf fc As with AM with a large carrier the upconverted signal vt for AM with a suppressed carrier has twice the bandwidth of the original message signal If the Analog Demodulation 85 vt cos2πfc γt φ b a xt LPF mt wt Ac cos2πfct vt Transmitter Receiver Figure 55 A communications system using amplitude modulation with a suppressed carrier In the transmitter a the message signal wt is modulated by a carrier wave at frequency fc to give the transmitted signal vt In b the received signal is demodulated by a wave with frequency fc γ and phase φ and then lowpass filtered When all goes well the output of the receiver mt 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 410 on page 70 As illustrated in 26 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 filtering 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 55b shows this downconverter which can be described by xt vt cos2πfc γt φ 52 and mt LPFxt where LPF represents a lowpass filtering of the demodulated signal xt in an attempt to recover the message Thus the downconversion described in 52 acknowledges that the receivers local oscillator might not have the same fre quency 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 significantly 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 frequencyshift property of Fourier transforms 53 on xt in 52 produces the Fourier transform Xf Ac4ejφWffcfcγWffcfcγ ejφWffcfcγWffcfcγ Ac4ejφWfγejφWf2fcγ ejφ Wf2fcγ ejφWfγ 53 If there is no frequency offset ie if γ0 then Xf Ac4ejφ ejφWfejφWf2fcejφWf2fc Because cosx12ejxejx from A2 this can be rewritten XfAc2Wfcosφ Ac4ejφWf2fcejφWf2fc Thus a perfect lowpass filtering of xt with cutoff below 2fc removes the highfrequency portions of the signal near 2fc to produce mtAc2wtcosφ 54 The factor cosφ attenuates the received signal except for the special case when φ0 2πk for integers k If φ were sufficiently close to 0 2πk 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 11 The worst case occurs as φ approaches π2 when the message is attenuated to zero A scheme for carrierphase 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 carrierphase offset is zero ie φ0 but that the frequency offset γ is not Then the spectrum of xt from 53 is XfAc4WfγWf2fcγWf2fcγWfγ and the lowpass filtering of xt produces MfAc4WfγWfγ This is shown in Figure 56 Recognizing this spectrum as a frequencyshifted version of wt it can be translated back into the time domain using A33 to give mtAc2wtcos2πγt 55 Instead of recovering the message wt the frequency offset causes the receiver to recover a lowfrequency amplitudemodulated version of it This is bad with Analog Demodulation 87 f M f W f γ W f γ 0 Ac 4 Figure 56 When there is a carrierfrequency offset in the receiver oscillator the two images of W do not align properly Their sum is not equal to Ac2W f even a small carrierfrequency offset While cosφ in 54 is a fixed scal ing cos2πγt in 55 is a timevarying scaling that will alternately recover mt when cos2πγt 1 and make recovery impossible when cos2πγt 0 Transmitters are typically expected to maintain suitable accuracy to a nominal carrierfrequency setting known to the receiver Ways of automatically tracking inevitable small frequency deviations are discussed at length in Chapter 10 The following code AMm generates a message wt and modulates it with a carrier at frequency fc The demodulation is done with a cosine of frequency fc γ and a phase offset 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 filter Figure 57 shows four plots the message wt on top followed by the upconverted signal vt wtcos2πfct followed in turn by the downconverted signal xt The lowpassfiltered version is shown in the bottom plot observe that it is nearly identical to the original message albeit with a slight delay Listing 52 AMm suppressed carrier with possible freq and phase offset time 03 Ts110000 sampling i n t e r v a l time tTs Ts time l entlength t def i ne a time vector fm20 f c 1000 ccos 2 pi f c t c a r r i e r at f r eq f c w5 l ent 1 l ent cos 2 pifm t cr eate message vc w modulate with c a r r i e r gam0 phi 0 f r eq phase o f f s e t c2cos 2 pi f cgam tphi cr eate cos i ne f o r demod xv c2 demod r ecei ved s i g n a l fbe 0 01 02 1 damps1 1 0 0 LPF design f l 100 bfirpm f l fbe damps impulse response of LPF m2 f i l t e r b 1 x LPF the demodulated s i g n a l Exercise 55 Using AMm as a starting point plot the spectra of wt vt xt and mt Exercise 56 Try different phase offsets φ π π2 π3 π6 0 π6 π3 π2 π How well does the recovered message mt match the actual message wt For each case what is the spectrum of mt Exercise 57 TRUE or FALSE A small fixed phase offset in the receiver demodulating AM with suppressed carrier produces an undesirable lowfrequency modulated version of the analog message 88 Chapter 5 Analog Demodulation Amplitude a message signal b message after modulation d recovered message is a LPF applied to c 1 0 002 004 006 008 1 3 1 1 3 1 1 3 2 c demodulated signal 2 0 Figure 57 The message signal in the top frame is modulated to produce the signal in the second plot Demodulation gives the signal in the third plot and the LPF recovers the original message with delay in the bottom plot 2 Bandpass filter Centered at fc Addition Squarelaw device A0 cos2πfct wt 2A0wtcos2πfct Figure 58 The squarelaw mixing transmitter of Exercises 59 through 511 Exercise 58 Try different frequency offsets gam 0014 01 10 10 How well does the recovered message mt match the actual message wt For each case what is the spectrum of mt Hint look over more than just the first 01 s to see the effect Exercise 59 Consider the system shown in Figure 58 Show that the output of the system is 2A0wt cos2πfct as indicated Exercise 510 Create a Matlab routine to implement the squarelaw mixing modulator of Figure 58 a Create a signal wt that has bandwidth 100 Hz b Modulate the signal to 1000 Hz c Demodulate using the AM demodulator from AMm to recover the original wt Analog Demodulation 89 wt a b c d cos2πf1t φ1 BPF xt xt rt lower cutoff f2 upper cutoff f3 rt cos2πf8t φ2 sin2πf4t cos2πf5t lower cutoff f6 cutoff f9 upper cutoff f7 BPF yt LPF BPF W f f 300 2000 300 2000 2 Figure 59 The transmission system for Exercise 512 a the magnitude spectrum of the message b the transmitter c the channel and d the receiver Exercise 511 Exercise 510 essentially creates a transmitter and receiver based on the squarelaw 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 filter is not centered at the specified frequency Exercise 512 Consider the transmission system of Figure 59 The message signal wt has the magnitude spectrum shown in part a The transmitter in part b produces the transmitted signal xt which passes through the chan nel in part c The channel scales the signal and adds narrowband interferers to create the received signal rt The transmitter and channel parameters are φ1 03 radians f1 241 kHz f2 239 kHz f3 275 kHz f4 293 kHz and f5 226 kHz The receiver processing rt is shown in Figure 59d All bandpass and lowpass filters are considered ideal with a gain of unity in the passband and zero in the stopband a Sketch Rf 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 yt and reflects the value of φ1 and the delays imposed by the two ideal bandpass filters that form the received signal rt Select the receiver parameters f6 f7 f8 and f9 so the receiver output yt is a scaled version of wt Exercise 513 An analog baseband message signal wt has all energy between B and B Hz It is upconverted to the transmitted passband signal xt via AM 90 Chapter 5 Analog Demodulation with suppressed carrier xt wt cos2πfct φc where the carrier frequency fc 10B The channel is a pure delay and the received signal r is rt xt d where the delay d nTc Tcα is an integer multiple n 0 of the carrier period Tc 1fc plus a fraction of Tc given by α 1 The mixer at the receiver is perfectly synchronized to the transmitter so that the mixer output yt is yt rt cos2πfct φr The receiver mixer phase need not match the transmitter mixer phase φc The receiver lowpass filters y to produce vt LPFyt where the lowpass filter is ideal with unity passband gain linear passband phase with zero phase at zero frequency and cutoff frequency 12B a Write a formula for the receiver mixer output yt as a function of fc φc d α φr and wt without use of x r n or Tc b Determine the amplitude of the minimum and maximum values of yt for α 4 c For α 6 n 42 φc 02 radians and Tc 20 µs determine the value of φr that maximizes the magnitude of the maximum and minimum values of vt 53 Quadrature Modulation In AM transmission where the baseband signal and its modulated passband ver sion are realvalued the spectrum of the modulated signal has twice the band width of the baseband signal As pictured in Figure 410 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 inefficiency 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 efficiently To see how this can work suppose that there are two message streams m1t and m2t Modulate one message with a cosine to create the inphase signal and the other with the negative of a sine to form the quadrature signal These Analog Demodulation 91 m1t sin2πfct cos2πfct cos2πfct Transmitter Receiver m2t x1t x2t s1t s2t LPF LPF sin2πfct Figure 510 In a quadrature modulation system two messages m1t and m2t are modulated by two sinusoids of the same frequency sin2πfct and cos2πfct The receiver then demodulates twice and recovers the original messages after lowpass filtering are summed1 to form vt m1t cos2πfct m2t sin2πfct 56 which is then transmitted A receiver structure that can recover the two messages is shown in Figure 510 The signal s1t at the output of the receiver is intended to recover the first message m1t Similarly the signal s2t at the output of the receiver is intended to recover the negative of the second message m2t To examine the recovered signals s1t and s2t in Figure 510 first evaluate the signals before the lowpass filtering Using the trigonometric identities A4 and A8 x1t becomes x1t vt cos2πfct m1t cos22πfct m2t sin2πfct cos2πfct m1t 2 1 cos4πfct m2t 2 sin4πfct Lowpass filtering x1t produces s1t m1t 2 Similarly x2t can be rewritten using A5 and A8 as x2t vt sin2πfct m1t cos2πfct sin2πfct m2t sin22πfct m1t 2 sin4πfct m2t 2 1 cos4πfct and lowpass filtering x2t produces s2t m2t 2 Thus in the ideal situation in which the phases and frequencies of the modu lation and the demodulation are identical both messages can be recovered But if the frequencies andor phases are not exact then problems analogous to those 1 These are also sometimes modeled as the real and the imaginary parts of a single complexvalued signal This complex representation is explored more fully in Appendix C 92 Chapter 5 Analog Demodulation x2t x3t x4t x5t x6t x1t cos2πf5t φ cos2πf1t cos2πf2t lower cutoff f3 cutoff f6 upper cutoff f4 BPF LPF Figure 511 The transmission system of Exercise 516 encountered with AM will occur in the quadrature modulation For instance if the phase of say the demodulator x1t is not correct then there will be some distortion or attenuation in s1t However problems in the demodulation of s1t may also cause problems in the demodulation of s2t This is called crossinterference between the two messages Exercise 514 Use AMm as a starting point to create a quadrature modulation system that implements the block diagram of Figure 510 a Examine the effect of a phase offset in the demodulating sinusoids of the receiver so that x1t vt cos2πfct φ and x2t vt sin2πfct φ for a variety of φ Refer to Exercise 56 b Examine the effect of a frequency offset in the demodulating sinusoids of the receiver so that x1t vt cos2πfc γt and x2t vt sin2πfc γt for a variety of γ Refer to Exercise 58 c Confirm that a 1 phase error in the receiver oscillator corresponds to more than 1 crossinterference Exercise 515 TRUE or FALSE Quadrature amplitude modulation can com bine two real baseband messages of absolute bandwidth B in a radiofrequency signal of absolute bandwidth B Exercise 516 Consider the scheme shown in Figure 511 The absolute band width of the baseband signal x1 is 6 MHz and that of the baseband signal x2t is 4 MHz f1 164 MHz f2 154 MHz f3 148 MHz f4 160 MHz f5 80 MHz φ π2 and f6 82 MHz a What is the absolute bandwidth of x3t b What is the absolute bandwidth of x5t c What is the absolute bandwidth of x6t d What is the maximum frequency in x3t e What is the maximum frequency in x5t Thus the inefficiency of realvalued doublesided AM transmission can be reduced using complexvalued quadrature modulation which recaptures the lost bandwidth by sending two messages simultaneously For simplicity and clarity Analog Demodulation 93 the bulk of Software Receiver Design focuses on the real PAM case and the complexvalued quadrature case is postponed until Chapter 16 There are also other ways of recapturing the lost bandwidth both singlesideband and vestigial sideband discussed in the document Other Modulations on the website send a single message but use only half the bandwidth 54 Injection to Intermediate Frequency All the modulators and demodulators discussed in the previous sections down convert to baseband in a single step that is the spectrum of the received signal is shifted by mixing with a cosine of frequency fc that matches the transmission frequency fc As suggested in Section 28 it is also possible to downconvert to some desired intermediate frequency IF fI as depicted in Figure 29 and to then later downconvert to baseband by mixing with a cosine of the intermediate frequency fI There are several advantages to such a twostep procedure r all frequency bands can be downconverted to the same IF which allows use of standardized amplifiers modulators and filters 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 filtering to extract the passband around the IF can be accomplished in two ways by a local oscillator modulating from above the carrier frequency called highside injection or from below lowside injection To see this consider the double sideband modulation from Section 52 that creates the transmitted signal vt 2wtcos2πfct from the message signal wt and the downconversion to IF via xt 2vt ntcos2πfIt where nt represents interference such as noise and spurious signals from other users By virtue of the frequencyshifting property A33 V f Wf fc Wf fc 57 and the spectrum of the IF signal is Xf V f fI V f fI Nf fI Nf fI Wf fc fI Wf fc fI Wf fc fI Wf fc fI Nf fI Nf fI 58 94 Chapter 5 Analog Demodulation 850 1780 105 a 105 850 1780 V f N f X f f kHz f kHz f kHz 1245 1385 290 1245 1385 2175 b 2175 455 290 500 500 455 455 1410 1200 2156 3085 c 475 475 2156 1410 1200 3085 455 X f Figure 512 Example of highside and lowside injection to an IF at fI 455 kHz a transmitted spectrum b lowside injected spectrum and c highside injected spectrum Example 51 Consider a message spectrum Wf that has a bandwidth of 200 kHz an upconversion carrier frequency fc 850 kHz and an objective to downconvert to an intermediate frequency of fI 455 kHz For lowside injec tion where the frequency of the local oscillator is fℓ fc the goal is to cen ter Wf fc fℓ in 58 at fI so that fℓ fc 455 395 For highside injection with fℓ fc the goal is to center Wf fc fℓ at fI so that fℓ fc 455 1305 For illustrative purposes Figure 512 supposes that the interference Nf consists of a pair of delta functions at 105 and 1780 kHz Figure 512 sketches V f and Xf for both highside and lowside injection In this example both methods end up with unwanted narrowband interferences in the passband Observe the following r Lowside injection results in symmetry in the translated message spectrum about fc on each of the positive and negative halfaxes r Highside injection separates the undesired images further from the lower frequency portion which will ultimately be retained to reconstruct the mes sage This eases the requirements on the bandpass filter r Both highside and lowside injection can place frequency interferers in unde sirable places This highlights the need for adequate outofband rejection by a bandpass filter before downconversion to IF Analog Demodulation 95 wt rt xt cos2πfct cos2πfrt nt W f f kHz 22 22 Figure 513 Transmission system for Exercise 517 Exercise 517 Consider the system described in Figure 513 The message wt 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 xt by a mixer with frequency fr a With nt 0 fr 36 kHz and fc 83 kHz indicate all frequency ranges ix that include any part of the IF passband signal xt 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 ix 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 xt c With fr 84 kHz and fc 62 kHz indicate every range ix 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 xt Exercise 518 A transmitter operates as a standard AM with suppressed carrier transmitter as in AMm Create a demodulation routine that operates in two steps by mixing with a cosine of frequency 3fc4 and subsequently mixing with a cosine of frequency fc4 Where must passreject filters be placed in order to ensure reconstruction of the message Let fc 2000 Exercise 519 Consider the scheme shown in Figure 514 The absolute band width of the baseband signal x1 is 4 kHz f1 28 kHz f2 20 kHz and f3 26 kHz a What is the absolute bandwidth of x2t b What is the absolute bandwidth of x3t c What is the absolute bandwidth of x4t d What is the maximum frequency in x2t e What is the maximum frequency in x3t Exercise 520 Using your Matlab code from Exercise 518 investigate the effect of a sinusoidal interference 96 Chapter 5 Analog Demodulation X2 Squaring nonlinearity x4t x3t x2t x1t cos2πf1t BPF lower cutoff f2 upper cutoff f3 Figure 514 Transmission system for Exercise 519 X1 f f f1 f1 1 x1t x2t x3t x4t cos2πf2t lower cutoff f5 upper cutoff f6 BPF cos2πf3t cos2πf4t x5kTs x6kTs x7kTs x8kT x4t cos2πf8t LPF M Ts1f7 cutoff f9 Figure 515 Transmission system for Exercise 521 a at frequency fc6 b at frequency fc3 c at frequency 3fc Exercise 521 Consider the PAM communication system in Figure 515 The input x1t has a triangular baseband magnitude spectrum The frequency spec ifications 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 X5f between 3000 kHz Be certain to give specific 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 522 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 yt ut cos2πfct and carrier frequencies fc of 12 MHz and 50 MHz b two linear bandpass filters 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 Figure 516 Spectrum of the received signal for Exercise 522 c two impulse samplers with input u and output y related by yt sum from k to of utδt kTs with sample periods of 115 and 112 μs d one squarelaw device with input u and output y related by yt u²t e three summers with inputs u1 and u2 and output y related by yt u1t u2t The spectrum of the received signal is illustrated in Figure 516 The desired baseband output of the receiver should be a scaled version of the triangular portion centered at zero frequency with no other signals in the range between 8 and 8 MHz Using no more than four parts from the ten available build a receiver that produces the desired baseband signal Draw its block diagram Sketch the magnitude spectrum of the output of each part in the receiver For Further Reading A friendly and readable introduction to analog transmission systems can be found in P J Nahin On the Science of Radio AIP Press 1996 6 Sampling with Automatic Gain Control As foreshadowed in Section 28 transmission systems cannot be fully digital because the medium through which the signal propagates is analog Hence whether the signal begins as analog such as voice or music or whether it begins as digital such as mpeg jpeg or wav files it will be converted into a high frequency analog signal when it is transmitted In a digital receiver the received signal must be transformed into a discretetime signal in order to allow subse quent digital processing This chapter begins by considering the sampling process both in the time domain and in the frequency domain Then Section 63 discusses how Matlab can be used to simulate the sampling process This is not completely obvious because analog signals cannot be represented exactly in the computer Two sim ple tricks are suggested The first expresses the analog signal in functional form and takes samples at the desired times The second oversamples the analog signal so that it is represented at a high data rate the sampling can then be done on the oversampled signal Sampling and quantization are important because they translate the signal from analog to digital It is equally important to be able to translate from digital back into analog and the celebrated Nyquist sampling theorem shows that this is possible for any bandlimited signal assuming the sampling rate is fast enough When the goal of this translation is to rebuild a copy of the transmitted signal this is called reconstruction When the goal is to determine the value of the signal at some particular point it is called interpolation Techniques and Matlab code for both reconstruction and interpolation appear in Section 64 Figure 61 shows the received signal passing through a BPF which removes outofband interference and isolates the desired frequency range followed by a fixed demodulation to the intermediate frequency IF at which sampling takes place The automatic gain control AGC accounts for changes in the strength of the received signal When the received signal is powerful the gain a is small when the signal strength is low the gain a is high The goal is to guarantee that the analogtodigital converter does not saturate the signal does not routinely Sampling with Automatic Gain Control 99 Analog received signal Antenna Sampler Quantizer rt skTs sk AGC a Analog conversion to IF BPF Quality Assessment Figure 61 The front end of the receiver After filtering and demodulation the signal is sampled An automatic gain control AGC is needed to utilize the full dynamic range of the quantizer 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 fifth element of Chapter 3 How can such elements be designed Software Receiver Design suggests a general method based on gradientdirected optimization First a goal and an associ ated 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 defined 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 accord ing 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 65 through 67 will also be useful in designing other adaptive elements such as the phase tracking loops of Chapter 10 the clock recovery algorithms of Chapter 12 and the equalization schemes of Chapter 13 61 Sampling and Aliasing Sampling can be modeled as a pointbypoint multiplication in the time domain by a pulse train a sequence of impulses Recall Figure 38 on page 49 While this is intuitively plausible it is not terribly insightful The effects of sampling become apparent when viewed in the frequency domain When the sampling is done correctly no information is lost However if the sampling is done too slowly aliasing artifacts are inevitable This section shows the how and why of sampling Figure 62 An analog signal wt is multiplied pointbypoint by a pulse train This effectively samples the analog signal at a rate Ts Suppose an analog waveform wt is to be sampled every Ts seconds to yield a discretetime sequence wk wkTs wt tkTs for all integers k1 This is called point sampling because it picks off the value of the function wt at the points kTs One way to model point sampling is to create a continuousvalued function that consists of a train of pulses that are scaled by the values wkTs The impulse sampling function is wst wt sum from k to of δt kTs sum from k to of wkTsδt kTs and it is illustrated in Figure 62 The effect of multiplication by the pulse train is clear in the time domain But the relationship between wst and wt is clearer in the frequency domain which can be understood by writing Wsf as a function of Wf The transform Wsf is given in A27 and A28 With fs 1Ts this is Wsf fs sum from n to of Wf nfs Thus the spectrum of the sampled signal wst differs from the spectrum of the original wt in two ways Amplitude scalingeach term in the spectrum Wsf is multiplied by the factor fs Replicasfor each n Wsf contains a copy of Wf shifted to f nfs Sampling creates an infinite sequence of replicas each separated by fs Hz Said another way the process of sampling in time creates a periodicity in frequency 1 Observe that the notation wkTs means wt evaluated at the time t kTs This is also notated wk with the square brackets where the sampling rate Ts is implicit Sampling with Automatic Gain Control 101 2fs fs B B fsB fsB B B fs 0 0 0 b a B B fs 2 fs 2 fs fs W f Ws f f f 0 B B fs 2 fs 2 W f Ws f f f fsB fsB Figure 63 The spectrum of a sampled signal is periodic with period equal to fs In case a the original spectrum W f is bandlimited to less than fs2 and there is no overlapping of the replicas When W f is not bandlimited to less than fs2 as in b the overlap of the replicas is called aliasing where the period is defined 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 62 shows why the relationships in Figure 39 on page 50 hold Figure 63 shows these replicas in two possible cases In a fs 2B where B is the bandwidth of wt and the replicas do not overlap Hence it is possible to extract the one replica centered at zero by using a lowpass filter Assuming that the filtering is without error Wf is recovered from the sampled version Wsf Since the transform is invertible this means that wt can be recovered from wst Therefore no loss of information occurs in the sampling process2 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 wt is sampled to give wst which is nonzero only at the sampling instants kTs If wst is then input into a perfect analog lowpass filter its output is the same as the original wt Such filtering cannot be done with any digital filter operating at the sampling rate fs In terms of Figure 63 the digital filter can remove and reshape the frequencies between the bumps but can never remove the periodic bumps 102 Chapter 6 Sampling with Automatic Gain Control Nyquist Sampling Theorem If the signal wt is bandlimited to B Wf 0 for all f B and the sampling rate is faster than fs 2B then wt can be reconstructed exactly from its samples wkTs On the other hand in part b of Figure 63 the replicas overlap because the repetitions are narrower than the width of the spectrum Wf In this case it is impossible to recover the original spectrum perfectly from the sampled spectrum and hence it is impossible to exactly recover the original waveform from the sampled version The overlapping of the replicas and the resulting distortions in the reconstructed waveform are called aliasing Bandwidth can also be thought of as limiting the rate at which data can flow over a channel When a channel is constrained to a bandwidth 2B then the output of the channel is a signal with bandwidth no greater than 2B Accordingly the output can contain no frequencies above fs and symbols can be transmitted no faster than one every Ts seconds where 1Ts fs Exercise 61 Human hearing extends up to about 20 kHz What is the min imum sampling rate needed to fully capture a musical performance Compare this with the CD sampling rate of 441 kHz Some animal sounds such as the singing of dolphins and the chirping of bats occur at frequencies up to about 50 kHz What does this imply about CD recordings of dolphin or bat sounds Exercise 62 US highdefinition digital television HDTV is transmitted in the same frequency bands as conventional television for instance Channel 2 is at 54 MHz and each channel has a bandwidth of about 6 MHz What is the minimum sampling rate needed to fully capture the HDTV signal once it has been demodulated to baseband Exercise 63 An analog signal has nonzero values in its magnitude spectrum at every frequency between B and B This signal is sampled with period T where 1T B TRUE or FALSE The discretetime signal can have components in its spectrum at frequencies between B and 1T Exercise 64 The triangularly shaped magnitude spectrum of a real message signal wt is shown in Figure 64 where B 02 MHz The received signal rt 015wt cos2πft is modulated by an AM with suppressed carrier with f 145 MHz and atten tuated With 1f T1 12B select T1 T2 T3 and β so that the magnitude spectrum of x3k matches the magnitude spectrum of T1spaced samples of wt Justify your answer by drawing the magnitude spectra of x1 x2 and x3 between f and f Sampling with Automatic Gain Control 103 W f f B B 4 x1k x2k x3k rt β cos2πkT2 LPF kT1 cutoff frequency 1T3 passband gain 1 stopband gain 0 Figure 64 The triangularly shaped magnitude spectrum of the real message signal wt is shown on the left The receiver structure in Exercise 64 is shown on the right X f f v2kTs v3kTs v4kTs v1t xt cos400πkTs LPF Ts 0001 s 450 400 350 350 400 450 X2 square law Figure 65 The signal xt with spectrum Xf is input into this communication system Exercise 65 asks for the absolute bandwidth of the signal at each point as it moves through the system Exercise 65 The signal xt with magnitude spectrum shown in the left part of Figure 65 is input to the transmission system on the right The lowpass filter with output v4kTs has a cutoff 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 V1f V2f V3f and V4f have nonzero values 62 Downconversion via Sampling The processes of modulation and demodulation which shift the frequencies of a signal can be accomplished by mixing with a cosine wave that has a fre quency equal to the amount of the desired shift as was demonstrated repeatedly throughout Chapter 5 But this is not the only way Since sampling creates a collection of replicas of the spectrum of a waveform it changes the frequencies of the signal When the message signal is analog and bandlimited to B sampling can be used as a step in the demodulation process Suppose that the signal is transmitted with a carrier at frequency fc Direct sampling of this signal creates a collection of replicas one near DC This procedure is shown in Figure 66 for fs fc2 though beware when fs and fc are not simply related the replica might not land exactly at DC This demodulation by sampling is diagrammed in Figure 67 with fs fcn where n is a small positive integer and can be thought of as an alternative to mixing with a cosine that must be synchronized in frequency and phase with the transmitter oscillator The magnitude spectrum Wf of a message wt Figure 66 Spectra in a sampling downconverter such as Figure 67 The bandlimited analog signal Wf shown in a is upconverted to the transmitted signal in b Directly sampling this at a rate equal to fs fc2 results in the spectrum shown in the bottom plot is shown in Figure 66a and the spectrum after upconversion is shown in part b this is the transmitted signal st At the receiver st is sampled which can be modeled as a multiplication with a train of delta functions in time yt st sum from n to of δt nTs where Ts is the sample period Using 62 this can be transformed into the frequency domain as Yf 1Ts sum from n to of Sf nfs where fs 1Ts The magnitude spectrum of Yf is illustrated in Figure 66c for the particular choice fs fc2 and Ts 2fc with B fc4 fs2 There are three ways in which the sampling can proceed 1 sample faster than the Nyquist rate of the IF frequency 2 sample slower than the Nyquist rate of the IF frequency and then downconvert the replica closest to DC and 3 sample so that one of the replicas is directly centered at DC The first is a direct imitation of the analog situation where no aliasing will occur This may be expensive because of the high sample rates required to achieve Nyquist sampling The third is the situation depicted in Figures 66 and 67 which permit downconversion to baseband without an additional oscillator This may be sensitive to small deviations in frequency for instance when fs is not Sampling with Automatic Gain Control 105 LPF wt st yt cos2πfct mt Ts fcutoff B Figure 67 System diagram showing how sampling can be used to downconvert a signal The spectra corresponding to wt st and yt are shown in Figure 66 The output of the LPF contains only the Mshaped portion nearest zero exactly fc2 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 66 Create a simulation of a samplingbased 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 reflects 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 sine100hzsampm What choices have you made for these two sampling rates Exercise 67 Implement the procedure diagrammed in Figure 67 Comment on the choice of sampling rates How have you specified the LPF Exercise 68 Using your code from Exercise 67 examine the effect of incor rect 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 54 Exercise 69 Consider the part of a communication system shown in Figure 68 a Sketch the magnitude spectrum X1f of x1t wtcos1500πt Be certain to give specific values of frequency and magnitude at all significant points in the sketch b Draw the magnitude spectrum X2f of x2t wtx1t Be certain to give specific values of frequency and magnitude at all significant points in the sketch Chapter 6 Sampling with Automatic Gain Control Wf 02 220 220 f cos1500πt Figure 68 Input spectrum and system diagram for Exercise 69 wt x1t x2k x3k LPF x4k kTs cutoff frequency f2 cos2πfct cos2πfIt cos2πfIkTs Figure 69 The digital receiver used in Exercise 610 c Between 3750 Hz and 3750 Hz draw the magnitude spectrum X3f of x3t x2t k δtkTs for Ts 400 μs Be certain to give specific values of frequency and magnitude at all significant points in the sketch Exercise 610 Consider the digital receiver shown in Figure 69 The baseband signal wt 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 filter has a cutoff frequency of f2 For the following designs you are to decide whether they are successful ie whether or not the magnitude spectrum of the lowpass filter output x4 is the same up to a scale factor as the magnitude spectrum of the sampled wt with a sample period of Ts a Candidate System A B 7 kHz fc 34 kHz fI 49 kHz Ts 134 ms f1 0 and f2 16 kHz b Candidate System B B 11 kHz fc 39 kHz fI 130 kHz Ts 152 ms f1 13 kHz and f2 12 kHz Sampling with Automatic Gain Control Rf 15 15 6 4 2 2 4 6 fMHz rt BPF yt Ts cos2πfo t Figure 610 The digital receiver used in Exercise 611 four ideal linear bandpass filters with passband fL fU of 05 MHz 6 MHz 12 MHz 62 MHz 34 MHz 72 MHz and 42 MHz 83 MHz four impulse samplers with input u and output y related by yt k ut δtkTs with sample periods of 17 15 14 and 135 microseconds The magnitude spectrum Rf of the received signal rt is shown on the left in Figure 610 The objective is to specify the bandpass filter sampler and mixer so that the Mshaped segment of the magnitude spectrum is centered at f 0 in the output Yf with no other signals within 15 MHz of the upper and lower edges a Specify the three parts from the 12 provided i bandpass filter passband range fL fU in MHz ii sampler period Ts in μs iii mixer oscillator frequency fo in MHz b For the three components selected in part a sketch the magnitude spectrum of the sampler output between 20 and 20 MHz Be certain to give specific values of frequency and magnitude at all significant points in the spectra c For the three components selected in part a sketch the magnitude spectrum of yt between between the frequencies 12 and 12 MHz for your design Be certain to give specific values of frequency and magnitude at all significant points in the spectra d Is the magnitude spectrum of yt identical to the Mshaped segment of Rf first downconverted to baseband and then sampled Exercise 612 The message signal ut and additive interferer wt with magnitude spectra shown in Figure 611a are applied to the system in Figure 611b The analog mixer frequencies are fc 1600 kHz and fd 1240 kHz The BPF with output xt is assumed ideal is centered at fc and has lower cutoff frequency fL upper cutoff frequency fU and zero phase at fc The period of the sampler is Ts 17 104 s The phase β of the discretetime mixer is assumed to be adjusted to the value that maximizes the ratio of signal to interferer noise power in ykTs The LPF with output ykTs is assumed ideal with cutoff frequency 108 Chapter 6 Sampling with Automatic Gain Control W f 860 720 720 860 U f f kHz f kHz 40 40 ykTs ut wt xt cos2παkTsβ cos2πfdt LPF cos2πfct BPF Ts a b c Figure 611 Magnitude spectra of a the message and b the interference signals considered in Exercise 612 The receiver structure is shown schematically in c ykTs rt xt cos2πfckTs cos2πfct LPF kTs Figure 612 Digital receiver considered in Exercise 613 γ The design objective is for the spectrum of ykTs to estimate the spectrum of a sampled ut You are to select the upper and lower cutoff frequencies of the BPF the frequency α of the discretetime mixer and the cutoff frequency of the LPF in order to meet this objective a Design the desired BPF by specifying its upper fU and lower fL cutoff fre quencies b Compute the desired discretetime mixer frequency α c Design the desired LPF by specifying its cutoff frequency γ Exercise 613 Consider the digital receiver in Figure 612 producing ykTs which is intended to match the input xt sampled every Ts seconds The abso lute bandwidth of xt is B The carrier frequency fc is 10 times B The sample frequency 1Ts is 25 times fc Note that the sample frequency 1Ts is above the Nyquist frequency of the received signal rt Determine the maximum cutoff frequency as a function of the input bandwidth B for the lowpass filter produc ing ykTs so the design objective of matching samples of xt with a sample frequency of 1Ts is achieved 63 Exploring Sampling in MATLAB It is not possible to capture all of the complexities of analogtodigital conversion inside a computer program because all signals within a digital computer are already sampled Nonetheless most of the key ideas can be illustrated by using two tricks to simulate the sampling process Sampling with Automatic Gain Control 109 r evaluate a function at appropriate values or times r represent a data waveform by a large number of samples and then reduce the number of samples The first is useful when the signal can be described by a known function while the second is necessary whenever the procedure is datadriven that is when no functional form is available This section explores both approaches via a series of Matlab experiments Consider representing a sine wave of frequency f 100 Hz The sampling theorem asserts that the sampling rate must be greater than the Nyquist rate of 200 samples per second But in order to visualize the wave clearly it is often useful to sample considerably faster The following Matlab code calculates and plots the first 110 second of a 100 Hz sine wave with a sampling rate of fs 1Ts 10000 samples per second Listing 61 sine100hzm generate 100 Hz sine wave with sampling rate fs1Ts f 100 frequency of wave time 01 t o t a l time in seconds Ts110000 sampling i n t e r v a l tTs Ts time def i ne a time vector wsin 2 pi f t def i ne the s i ne wave plot t w pl ot the s i ne vs time xlabel seconds ylabel amplitude Running sine100hzm plots the first 10 periods of the sine wave Each period lasts 001 s and each period contains 100 points as can be verified by looking at w1100 Changing the variable time or Ts displays different numbers of cycles of the same sine wave while changing f plots sine waves with different underlying frequencies Exercise 614 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 615 Let Ts1500 How does the plot of the sine wave appear Let Ts1100 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 different When the sampling is rapid compared with the underlying frequency of the sig nal for instance the program sine100hzm 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 discretetime 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 310 on page 51 110 Chapter 6 Sampling with Automatic Gain Control Amplitude Seconds 1 0 1 0 001 002 003 004 Figure 613 Removing all but one of each N points from an oversampled waveform simulates the sampling process Listing 62 sine100hzsampm simulated sampling of the 100 Hz sine wave f 100 time 005 Ts110000 tTs Ts time s et time vector s wsin 2 pi f t cr eate s i ne wave w t s s 10 take 1 in s s samples wkw 1 s s end the sampled sequence wszeros size w ws 1 s s endwk sampled waveform ws t plot t w pl ot the waveform hold on plot t ws r hold o f f pl ot sampled wave Running sine100hzsampm results in the plot shown in Figure 613 where the continuous sine wave w is downsampled by a factor of ss10 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 effective sampling interval ssTs The spiky signal ws corresponds to the sampled signal wst while the sequence wk contains just the amplitude values at the tips of the spikes Exercise 616 Modify sine100hzsampm to create an oversampled sinc wave and then sample this with ss10 Repeat this exercise with ss30 ss100 and ss200 Comment on what is happening Hint in each case what is the effective sampling interval Exercise 617 Plot the spectrum of the 100 Hz sine wave when it is created with different downsampling rates ss10 ss11 ss30 and ss200 Explain what you see 64 Interpolation and Reconstruction The previous sections explored how to convert analog signals into digital signals The central result is that if the sampling is done faster than the Nyquist rate then no information is lost In other words the complete analog signal wt can be recovered from its discrete samples wk When the goal is to find the complete waveform this is called reconstruction when the goal is to find values of the waveform at particular points between the sampling instants it is called interpolation This section explores bandlimited interpolation and reconstruction in theory and practice The samples wkTs form a sequence of numbers that represent an underlying continuousvalued function wt at the time instants t kTs The sampling interval Ts is presumed to have been chosen so that the sampling rate fs 2B where B is the highest frequency present in wt The Nyquist sampling theorem presented in Section 61 states that the values of wt can be recovered exactly at any time τ The formula which is justified subsequently for recovering wτ from the samples wkTs is wτ t wst sinc τt dt where wst defined in 61 is zero everywhere except at the sampling instants t kTs Substituting 61 into wτ shows that this integral is identical to the sum wτ k wkTs sinc τkTsTs 63 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 finite time window To see why interpolation works note that the formula 63 is a convolution in time of the signal wkTs and the sinc function Since convolution in time is the same as multiplication in frequency by A40 the transform of wτ is equal to the product of FwskTs and the transform of the sinc By A22 the transform of the sinc function in time is a rect function in frequency This rect function is a lowpass filter since it passes all frequencies below fs2 and removes all frequencies above Since the process of sampling a continuoustime signal generates replicas of the spectrum at integer multiples of fs by 62 the lowpass filter removes all but one of these replicas In effect the sampled data are passed through an analog lowpass filter to create a continuoustime 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 63 combines them to recover wτ To see how 63 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 five 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 sininterpm shows that it is also possible in practice The plot in Figure 614 shows the original wave which appears choppy because it is sampled only five times per period and the reconstructed or smoothed waveform which looks just like a sine wave The variable intfac specifies how many extra Figure 614 A convincing sine wave can be reconstructed from its samples using sinc interpolation The choppy wave represents the samples and the smooth wave shows the reconstruction Sampling with Automatic Gain Control 113 it is a lowpass filter since the frequency response is a rect function The delay τ is proportional to the phase of the frequency response Exercise 618 In sininterpm 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 619 In sininterpm what happens when the window is reduced Make over smaller and find out What happens when too few points are inter polated Make intfac smaller and find out Exercise 620 Create a more interesting more complex wave wt Answer the above questions for this wt Exercise 621 Let wt be a sum of five sinusoids for t between 10 and 10 s Let wkT represent samples of wt with T 001 s Use interpsincm to inter polate the values w0011 w0013 and w0015 Compare the interpolated values with the actual values Explain any discrepancies Observe that sinct 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 convo lution ie why the variable over is large A simple way to reduce the num ber of terms is to use a function that dies away more quickly than the sinc a common choice is the squareroot 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 118 The SRRC can easily be incorporated into the interpolation code by replacing the code interpsincwtnowiover with interpsincwtnowioverbeta Exercise 622 With beta0 the SRRC is exactly the sinc Redo the above exercises trying various values of beta between 0 and 1 The function srrcm is available on the website Its help file is ss r r c syms beta P t o f f Generate a SquareRoot Raised Cosine Pulse syms i s 12 the length of s r r c pulse in symbol durations beta i s the r o l l o f f f a c t o r beta0 gi ves the s i nc f uncti on P i s the oversampling f a c t o r t o f f i s the phase or timing o f f s e t Matlab also has a builtin function called resample which has the following help file Change the sampling r ate of a s i g n a l Y resample XPQ resamples the sequence in vector X at PQ times the o r i g i n a l sample 114 Chapter 6 Sampling with Automatic Gain Control r ate using a polyphase implementation Y i s PQ times the length of 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 different from that used in 63 It is more efficient numer ically at reconstructing entire waveforms but it works only when the desired resampling rate is rationally related to the original The method of 63 is far more efficient when isolated not necessarily evenly spaced interpolating points are required which is crucial for synchronization tasks in Chapter 12 65 Iteration and Optimization An important practical part of the sampling procedure is that the dynamic range of the signal at the input to the sampler must remain within bounds This can be accomplished using an automatic gain control which is depicted in Figure 61 as multiplication by a scalar a along with a quality assessment block that adjusts a in response to the power at the output of the sampler This section discusses the background needed to understand how the quality assessment works The essential idea is to state the goal of the assessment mechanism as an optimization problem Many problems in communications and throughout engineering can be framed in terms of an optimization problem Solving such problems requires three basic steps 1 setting a goalchoosing a performance or objective function 2 choosing a method of achieving the goalminimizing or maximizing the objec tive function and 3 testing to make sure the method works as anticipated Setting the goal usually consists of finding a function that can be minimized or maximized and for which locating the minimum or maximum value pro vides useful information about the problem at hand Moreover the function must be chosen carefully so that it and its derivative can be calculated from quantities that are known or that can be derived from signals that are easily obtainable Sometimes the goal is obvious and sometimes it is not There are many ways of carrying out the minimization or maximization pro cedure Some of these are direct For instance if the problem is to find the point at which a polynomial function achieves its minimum value this can be solved directly by finding the derivative and setting it equal to zero Often however such direct solutions are impossible and even when they are possible recursive or adaptive approaches often have better properties when the signals are noisy This chapter focuses on a recursive method called steepest descent which is the basis of many adaptive elements used in communications systems and of all the elements used in Software Receiver Design Sampling with Automatic Gain Control 115 The final 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 con tour 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 mathemat ically where the mountainside is defined 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 66 An Example of Optimization Polynomial Minimization This first example is too simple to be of practical use but it does show many of the ideas starkly Suppose that the goal is to find the value at which the polynomial Jx x2 4x 4 64 achieves its minimum value Thus step 1 is set As any calculus book will suggest the direct way to find the minimum is to take the derivative set it equal to zero and solve for x Thus dJxdx 2x 4 0 is solved when x 2 This is indeed the value of x for which the parabola Jx 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 Jx are extremely nonlinear Or maybe the derivative of Jx 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 loca tion of the minimum evaluates which direction from this estimate is most steeply downhill and then makes a new estimate along the downhill direction Simi larly 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 Figure 615 Steepest descent finds the minimum of a function by always pointing in the direction that leads downhill Sampling with Automatic Gain Control 117 2 1 0 1 2 3 4 5 0 50 100 150 200 250 300 350 400 Starting values Time Figure 616 The program polyconvergem attempts to locate the smallest value of Jx x2 4x 4 by descending the gradient Fifty different starting values all converge to the same minimum at x 2 mu01 algorithm s t e p s i z e xzeros 1 N i n i t i a l i z e x to zero x13 s t a r t i n g point x 1 for k1N1 xk112mu x k4mu update equation end Figure 616 shows the output of polyconvergem for 50 different x1 starting values superimposed all converge smoothly to the minimum at x 2 Exercise 623 Explore the behavior of steepest descent by running polyconvergem with different parameters a Try mu 001 0 00001 002 003 005 10 100 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 x1 Can x1 be too large or too small As an alternative to simulation observe that the process 66 is itself a linear timeinvariant system of the general form xk 1 axk b 67 which is stable as long as a 1 For a constant input the finalvalue theorem of ztransforms see A55 can be used to show that the asymptotic convergent output value is limk xk b1 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 xk 1 xk x so 67 implies that x ax b which implies that x b1 a This holds assuming that a 1 For example for 66 x 4µ1 1 2µ 2 which is indeed the minimum Thus both simulation and analysis suggest that the iteration 66 is a viable way to find the minimum of the function Jx 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 Jx is differentiable Similarly it is usually quite straightforward to simulate the algorithm to examine its behavior in specific cases though it is not always so easy to carry out a theoretical analysis By their nature steepestdescent and hillclimbing methods use only local information This is because the update from a point xk depends only on the value of xk and on the value of its derivative evaluated at that point This can be a problem since if the objective function has many minima the steepestdescent algorithm may become trapped at a minimum that is not globally the smallest These are called local minima To see how this can happen consider the problem of finding the value of x that minimizes the function Jx e01x sinx Applying the chain rule the derivative is e01x cosx 01e01x sinx signx where signx 1 for x0 1 for x0 is the formal derivative of x Solving directly for the minimum point is nontrivial try it Yet implementing a steepestdescent search for the minimum can be done in a straightforward manner using the iteration xk1 xk μe01xk cosxk 01 sinxksignx To be concrete replace the update equation in polyconvergem with xk1 xk mu exp01 absxk cosxk 01 sinxk signxk Exercise 624 Implement the steepestdescent strategy to find the minimum of Jx in 68 modeling the program after polyconvergem Run the program for different values of mu N and x1 and answer the same questions as in Exercise 623 One way to understand the behavior of steepestdescent algorithms is to plot the error surface which is basically a plot of the objective as a function of the variable that is being optimized Figure 617a displays clearly the single global minimum of the objective function 64 while Figure 617b shows the many minima of the objective function defined by 68 As will be clear to anyone who has attempted Exercise 624 initializing within any one of the valleys causes the algorithm to descend to the bottom of that valley Although true steepestdescent algorithms can never climb over a peak to enter another valley even if the minimum there is lower it can sometimes happen in practice when there is a significant amount of noise in the measurement of the downhill direction Essentially the algorithm gradually descends the error surface by moving in the locally downhill direction and different initial estimates may lead to Sampling with Automatic Gain Control 119 20 15 10 5 0 5 10 15 20 05 05 0 10 20 30 40 4 2 0 2 4 6 8 Jx Jx x x Figure 617 Error surfaces corresponding to a the objective function 64 and b the objective function 68 different minima This underscores one of the limitations of steepestdescent methodsif there are many minima then it is important to initialize near an acceptable one In some problems such prior information may easily be obtained while in others it may be truly unknown The examples of this section are somewhat simple because they involve static functions Most applications in communication systems deal with signals that evolve over time and the next section applies the steepestdescent idea in a dynamic setting to the problem of automatic gain control AGC The AGC provides a simple setting in which all three of the major issues in optimization must be addressed setting the goal choosing a method of solution and verifying that the method is successful Exercise 625 Consider performing an iterative maximization of Jx 8 6x 6 cos6x via 65 with the sign on the update reversed so that the algorithm will maxi mize rather than minimize Suppose the initialization is x0 07 a Assuming the use of a suitably small stepsize µ determine the convergent value of x b Is the convergent value of x in part a the global maximum of Jx Justify your answer by sketching the error surface Exercise 626 Suppose that a unimodal singlevariable performance function has only one point with zero derivative and that all points have a positive second derivative TRUE or FALSE A gradientdescent method will converge to the global minimum from any initialization Exercise 627 Consider the modulated signal rt wt cos2πfct φ where the absolute bandwidth of the baseband message waveform wt is less than fc2 The signals x and y are generated via xt LPFrt cos2pi fc t heta yt LPFrt sin2pi fc t heta where the LPF cutoff frequency is fc2 a Determine xt in terms of wt fc phi and heta b Show that fracdd heta leftfrac12 x2tright xt yt using the fact that derivatives and filters commute as in G5 c Determine the values of heta maximizing x2t Exercise 628 Consider the function Jx1x22 a Sketch Jx for 5 leq x leq 5 b Analytically determine all local minima and maxima of Jx for 5 leq x leq 5 Hint fracdfbdb signfb fracdfbdb where signa is defined in 69 c Is Jx unimodal as a function of x Explain your answer d Develop an iterative gradientdescent algorithm for updating x to minimize J e For an initial estimate of x12 what is the convergent value of x determined by an iterative gradientdescent algorithm with a satisfactorily small stepsize f Compute the direction either increasing x or decreasing x of the update from d for x12 g Does the direction determined in part f point from x12 toward the convergent value of part e Should it for a correct answer to e Explain your answer 67 Automatic Gain Control Any receiver is designed to handle signals of a certain average magnitude most effectively The goal of an AGC is to amplify weak signals and to attenuate strong signals so that they remain as much as possible within the normal operating range of the receiver Typically the rate at which the gain varies is slow compared with the data rate though it may be fast by human standards The power in a received signal depends on many things the strength of the broadcast the distance from the transmitter to the receiver the direction in which the antenna is pointed and whether there are any geographical features such as mountains or tall buildings that block reflect or absorb the signal Figure 618 The goal of the AGC is to maintain the dynamic range of the signal by attenuating it when it is too large as in a and by increasing it when it is too small as in b Figure 619 An automatic gain control adjusts the gain parameter a so that the average energy at the output remains roughly fixed despite fluctuations in the average received energy While more power is generally better from the point of view of trying to decipher the transmitted message there are always limits to the powerhandling 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 amplified Figure 618 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 effectively 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 619 The input rt is multiplied by the gain a to give the normalized signal st This is then sampled to give the output sk The assessment block measures sk and determines whether a must be increased or decreased The goal is to choose a so that the power or average energy of st is approximately equal to some specified S2 Since a2 avg r2ttkT approx avgs2kT approx avg s2k it would be ideal to choose a2 approx fracS2avgr2kT because this would imply that avgs2kT approx S2 The averaging operation in this case a moving average over a block of data of size N is defined by avgxk frac1N sumikN1k xi and is discussed in Appendix G in amazing detail Unfortunately neither the analog input rt nor its power is directly available to the assessment block in the DSP portion of the receiver so it is not possible to directly implement 611 Is there an adaptive element that can accomplish this task As suggested at the beginning of Section 65 there are three steps to the creation of a viable optimization approach setting a goal choosing a solution method and testing As in any reallife engineering task a proper mathematical statement of the goal can be tricky and this section proposes two slightly different possibilities for the AGC By comparing the resulting algorithms essentially alternative forms for the AGC design it may be possible to trade off among various design considerations One sensible goal is to try to minimize a simple function of the difference between the power of the sampled signal sk and the desired power S2 For instance the averaged squared error in the powers of s and S JLSa avgleftfrac14 lefts2k S2right2right frac14 avga2r2kTS22 penalizes values of a that cause s2k to deviate from S2 This formally mimics the parabolic form of the objective 64 in the polynomial minimization example of the previous section Applying the steepestdescent strategy yields ak1 ak mu leftfracdJLSadarightaak which is the same as 65 except that the name of the parameter has changed from x to a To find the exact form of 613 requires the derivative of JLSa with respect to the unknown parameter a This can be approximated by swapping the derivative and the averaging operations as formalized in G12 to give fracdJLSada frac14 davga2r2kT S22 approx frac14 avg leftfracda2r2kT S22daright avga2r2kT S2ar2kT The term a2r2kT inside the parentheses is equal to s2k The term ar2kT outside the parentheses is not directly available to the assessment mechanism though it can reasonably be approximated by s2ka Substituting the derivative into 613 and evaluating at a ak gives the algorithm ak 1 ak μ avgs2k S2 s2kak 614 Care must be taken when implementing 614 that ak does not approach zero Of course JLSa of 612 is not the only possible goal for the AGC problem What is important is not the exact form of the performance function but where the performance function has its optimal points Another performance function that has a similar error surface peek ahead to Figure 621 is JNa avgas2k3 S2 avgaa2r2kT3 S2 615 Taking the derivative gives dJNada d avgaa2r2kT3 S2da avgdaa2r2kT3 S2da avgsgnaks2k S2 where the approximation arises from swapping the order of the differentiation and the averaging recall G12 and the derivative of is the signum or sign function which holds as long as the argument is nonzero Evaluating this at a ak and substituting into 613 gives another AGC algorithm ak 1 ak μ avgsgnaks2k S2 616 Consider the logic of this algorithm Suppose that a is positive Since S is fixed avgsgnaks2k S2 avgs2k S2 avgs2k S2 Thus if the average energy in sk exceeds S2 a is decreased If the average energy in sk is less than S2 a is increased The update ceases when avgs2k S2 that is where a2 S2r2 as desired An analogous logic applies when a is negative The two performance functions 612 and 615 define the updates for the two adaptive elements in 614 and 616 JLSa minimizes the square of the deviation of the power in sk from the desired power S2 This is a kind of leastsquare performance function hence the subscript LS Such squarederror objectives are common and will reappear in phasetracking algorithms in Chapter 10 in clock recovery algorithms in Chapter 12 and in equalization algorithms in Chapter 13 On the other hand the algorithm resulting from JNa has a clear logical interpretation the N stands for naive and the update is simpler since 616 has fewer terms and no divisions To experiment concretely with these algorithms agcgradm provides an implementation in MATLAB It is easy to control the rate at which ak changes by 124 Chapter 6 Sampling with Automatic Gain Control choice of stepsize a larger µ allows ak to change faster while a smaller µ allows greater smoothing Thus µ can be chosen by the system designer to trade off the bandwidth of ak the speed at which ak 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 specified by the parameter lenavg will also influence the speed of adaptation longer averages imply slowermoving smoother estimates while shorter averages imply fastermoving more jittery esti mates Listing 66 agcgradm minimize the performance function Ja avga13a2r2 ds by choice of a n10000 number of s teps in simulation vr 10 power of the input rsqrt vr randnn 1 generate random inputs ds 015 des i r ed power of output mu0001 algorithm s t e p s i z e lenavg 10 length over which to average azeros n 1 a 11 i n i t i a l i z e AGC parameter szeros n 1 i n i t i a l i z e outputs aveczeros 1 lenavg vector to s tor e averaging terms for k1n1 s ka k r k normalize by a k add to avec avec sign a k s kˆ2 ds avec 1 lenavg 1 a k1a kmumean avec average adaptive update of a k end Typical output of agcgradm is shown in Figure 620 The gain parameter a adjusts automatically to make the overall power of the output s roughly equal to the specified parameter ds Using the default values above where the average power of r is approximately 1 we find that a converges to about 038 since 0382 015 S2 The objective JLSa can be implemented similarly by replacing the avec calculation inside the for loop with avec s kˆ2 ds s k ˆ2 a k avec 1 end 1 In this case with the default values a converges to about 022 which is the value that minimizes the leastsquare objective JLSa Thus the answer which minimizes JLSa is different from the answer which minimizes JNa More on this later As it is easy to see when playing with the parameters in agcgradm the size of the averaging parameter lenavg is relatively unimportant Even with lenavg1 the algorithms converge and perform approximately the same This is because the algorithm updates are themselves in the form of a lowpass filter See Appendix G for a discussion of the similarity between averagers and lowpass filters Removing the averaging from the update gives the simpler form for JNa a k1a kmusign a k s kˆ2 ds or for JLSa a k1a kmu s kˆ2 ds s k ˆ2 a k Sampling with Automatic Gain Control 125 0 2000 4000 6000 8000 10000 Iterations Amplitude Output sk Input rk Adaptive gain parameter 5 0 5 5 0 5 0 1 2 15 05 Figure 620 An automatic gain control adjusts the parameter a in the top panel automatically to achieve the desired output power 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 JLSa or JNa since they depend on the data sequence sk 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 steepestdescent algorithm for instance the objectives 64 and 68 dictates the evolution of the algorithms 66 and 610 The following code agcerrorsurfm shows how to calculate the error surface for JNa The variable n specifies the number of terms to average over and tot sums up the behavior of the algorithm for all n updates at each possible param eter value a The average of these totn is a close numerical approximation to JNa of 615 Plotting over all a gives the error surface Listing 67 agcerrorsurfm draw the error surface for the AGC n10000 number of s teps in simulation rrandnn 1 generate random inputs ds 015 des i r ed power of output range 0 7 0 0 2 0 7 s p e c i f y range of values of a Jagczeros size range j 0 for arange f o r each value a jj 1 tot 0 t o t a l cost for i 1n over a l l p o s s i b i l i t i e s tottotabs a 13 aˆ2 r i ˆ2 ds end Jagc j tot n take average value end 126 Chapter 6 Sampling with Automatic Gain Control 06 04 02 0 02 04 06 0 0005 0015 0025 cost JLSa 004 002 0 002 cost JNa Adaptive gain a 06 04 02 0 02 04 06 Adaptive gain a Figure 621 The error surface for the AGC objective functions 612 and 615 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 JLSa can be plotted using tottot 025aˆ2 r i ˆ2 ds ˆ2 er r or s ur f ace f o r JLS The output of agcerrorsurfm for both objective functions is shown in Figure 621 Observe that zero which is a critical point of the error surface is a local maximum in both cases The final converged answers a 038 for JNa and a 022 for JLSa occur at minima Were the algorithm to be initialized improperly to a negative value then it would converge to the negative of these values As with the algorithms in Figure 617 examination of the error surfaces shows why the algorithms converge as they do The parameter a descends the error surface until it can go no further But why do the two algorithms converge to different places The facile answer is that they are different because they minimize different performance functions Indeed the error surfaces in Figure 621 show minima in different locations The convergent value of a 038 for JNa is explicable because 0382 015 S2 The convergent value of a 022 for JLSa is calculated in closed form in Exercise 630 and this value does a good job minimizing its cost but it has not solved the problem of making a2 close to S2 Rather JLSa calculates a smaller gain that makes avgs2 S2 The minima are different The moral is this be wary of your performance functionsthey might do what you ask Exercise 629 Use agcgradm to investigate the AGC algorithm a What range of stepsize mu works Can the stepsize be too small Can the stepsize be too large b How does the stepsize mu affect the convergence rate c How does the variance of the input affect the convergent value of a d What range of averages lenavg works Can lenavg be too small Can lenavg be too large e How does lenavg affect the convergence rate Exercise 630 Show that the value of a that achieves the minimum of JLSa can be expressed as S2 k rk2 k rk4 Is there a way to use this closedform solution to replace the iteration 614 Exercise 631 Consider the alternative objective function Ja 12 a2 s2k6 S2 Calculate the derivative and implement a variation of the AGC algorithm that minimizes this objective How does this version compare with the algorithms 614 and 616 Draw the error surface for this algorithm Which version is preferable Exercise 632 Try initializing the estimate a12 in agcgradm Which minimum does the algorithm find What happens to the data record Exercise 633 Create your own objective function Ja 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 614 and 616 Draw the error surface for your algorithm Which version do you prefer Exercise 634 Investigate how the error surface depends on the input signal Replace randn with rand in agcerrorsurfm and draw the error surfaces for JNa and JLSa 68 Using an AGC to Combat Fading One of the impairments encountered in transmission systems is the degradation due to fading when the strength of the received signal changes in response to changes in the transmission path Recall the discussion in Section 415 on page 64 This section shows how an AGC can be used to counteract the fading assuming the rate of the fading is slow and provided the signal does not disappear completely Suppose that the input consists of a random sequence undulating slowly up and down in magnitude as in the top plot of Figure 622 The adaptive AGC compensates for the amplitude variations growing small when the power of the input is large and large when the power of the input is small This is shown in the middle graph The resulting output is of roughly constant amplitude as shown in the bottom plot of Figure 622 This figure was generated using the following code 128 Chapter 6 Sampling with Automatic Gain Control 5 x104 0 5 0 1 2 3 4 5 5 0 5 Input rk Adaptive gain parameter 05 1 0 15 Output sk Iterations Figure 622 When the signal fades top the adaptive parameter compensates middle allowing the output to maintain nearly constant power bottom Listing 68 agcvsfadingm compensating for fading with an AGC n50000 s teps in simulation rrandnn 1 generate random inputs env075abs sin 2 pi 1 n n the fading p r o f i l e rr env apply to raw input r k ds 05 des i r ed power of output azeros 1 n a 11 i n i t i a l i z e AGC parameter szeros 1 n i n i t i a l i z e outputs mu001 algorithm s t e p s i z e for k1n1 s ka k r k normalize by a to get s a k1a kmu s kˆ2 ds adaptive update of a k end The fading profile defined 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 635 Mimic the code in agcvsfadingm to investigate what happens when the input signal dies away Try removing the abs command from the fading profile variable Can you explain what you see Exercise 636 Mimic the code in agcvsfadingm 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 637 Would the answers to the previous two problems change on using algorithm 614 instead of 616 Sampling with Automatic Gain Control 129 69 Summary Sampling transforms a continuoustime analog signal into a discretetime 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 effectively The same AGC when adaptive can also provide a protection against signal fades The AGC can be designed using a steepestdescent optimization algorithm that updates the adaptive parameter by moving in the direction of the negative of the derivative This steepestdescent approach to the solution of optimization problems will be used throughout Software Receiver Design For Further Reading Details about resampling procedures are available in the published works of r Smith J O Bandlimited interpolationinterpretation and algorithm 1993 httpccrmawwwstanfordedujosresample A general introduction to adaptive algorithms centered around the steepest descent approach can be found in r B Widrow and S D Stearns Adaptive Signal Processing PrenticeHall 1985 One of our favorite discussions of adaptive methods is r C R Johnson Jr Lectures on Adaptive Parameter Estimation PrenticeHall 1988 7 Digital Filtering and the DFT Once the received signal is sampled the real story of the digital receiver begins An analog bandpass filter at the front end of the receiver removes extraneous signals for instance it removes televisionfrequency 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 filters are complicated and expensive to implement Digital filters 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 outof band 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 filters in the receiver and this chapter focuses on how to build digital filters The discussion begins by considering the digital impulse response and the related notion of discretetime 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 fluency in the spectral analysis of discrete data signals The final section on practical filter ing shows how to design digital filters with more or less any desired frequency response by using special Matlab commands 71 Discrete Time and Discrete Frequency The study of discretetime digital signals and systems parallels that of continuoustime analog signals and systems Many digital processes are fun damentally simpler than their analog counterparts though there are a few sub tleties unique to discretetime implementations This section begins with a brief overview and comparison and then proceeds to discuss the DFT which is the discrete counterpart of the Fourier transform Just as the impulse function δt plays a key role in defining signals and systems in continuous time the discrete pulse δk 1 k 0 0 k 0 71 can be used to decompose discrete signals and to characterize discretetime systems Any discretetime signal can be written as a linear combination of discrete impulses For instance if the signal wk is the repeating pattern 1 1 2 1 1 1 2 1 it can be written wk δk δk 1 2δk 2 δk 3 δk 4 δk 5 2δk 6 δk 7 In general the discretetime signal wk can be written wk j wj δk j This is the discrete analog of the sifting property 44 simply replace the integral with a sum and replace δt with δk Like their continuoustime counterparts discretetime systems map input signals into output signals Discretetime LTI linear timeinvariant systems are characterized by an impulse response hk which is the output of the system when the input is an impulse though of course 71 is used instead of 42 When an input xk is more complicated than a single pulse the output yk can be calculated by summing all the responses to all the individual terms and this leads directly to the definition of discretetime convolution yk j xjhk j xk hk 72 Observe that the convolution of discretetime sequences appears in the reconstruction formula 63 and that 72 parallels continuoustime convolution in 48 with the integral replaced by a sum and the impulse response ht replaced by hk The discretetime 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 informationpreserving transformation The pulse in discrete time is considerably more straightforward than the implicit definition of the continuoustime impulse function in 42 and 43 The DFT differs from the Fourier transform in three useful ways First it applies to discretetime 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 finite data record rather than an integration over all time Given a data record or vector wk of length N the DFT is defined by Wn k0N1 wkej2πNnk 73 for n 012 N1 For each value n 73 multiplies each term of the data by a complex exponential and then sums Compare this with the Fourier transform for each frequency f 21 multiplies each point of the waveform by a complex exponential and then integrates Thus Wn is a kind of frequency function in the same way that Wf is a function of frequency The next section will make this relationship explicit by showing how ej2πNnk can be viewed as a discretetime sinusoid with frequency proportional to n Just as a plot of the frequency function Wf is called the spectrum of the signal wt plots of the frequency function Wn are called the discrete spectrum of the signal wk One source of confusion is that the frequency f in the Fourier transform can take on any value while the frequencies present in 73 are all integer multiples n of a single fundamental with frequency 2πN This fundamental is precisely the sine wave with period equal to the length N of the window over which the DFT is taken Thus the frequencies in 73 are constrained to a discrete set these are the discrete frequencies of the section title The most common implementation of the DFT is called the fast Fourier transform FFT which is an elegant way to rearrange the calculations in 73 so that it is computationally efficient For all purposes other than numerical efficiency the DFT and the FFT are synonymous Like the Fourier transform the DFT is invertible Its inverse the IDFT is defined by wk 1N n0N1 Wnej2πNnk 74 for k 012 N1 The IDFT takes each point of the frequency function Wn multiplies by a complex exponential and sums Compare this with the IFT D2 takes each point of the frequency function Wf multiplies by a complex exponential and integrates Thus the Fourier transform and the DFT translate from the time domain into the frequency domain while the inverse Fourier transform and the IDFT translate from frequency back into time Many other aspects of continuoustime signals and systems have analogs in discrete time Here are some that will be useful in later chapters Symmetryif the time signal wk is real then Wn WNn This is analogous to A35 Parsevals theorem holds in discrete timek w²k 1N n Wn² This is analogous to A43 The frequency response Hn of an LTI system is the DFT of the impulse response hk This is analogous to the continuoustime result that the frequency response Hf is the Fourier transform of the impulse response ht Timedelay property in discrete timewkl Wnej2πNl This is analogous to A37 Modulation propertythis frequencyshifting property is analogous to A34 If wk sin2πfkT is a periodic sine wave then the spectrum is a sum of two delta impulses This is analogous to the result in Example 41 Convolution² in discrete time is the same as multiplication in discrete frequency This is analogous to 410 Multiplication in discrete time is the same as convolution in discrete frequency This is analogous to 411 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 412 Exercise 71 Show why Parsevals theorem is true in discrete time Exercise 72 Suppose a filter has impulse response hk When the input is xk the output is yk Show that if the input is xdk xk xk1 then the output is ydk yk yk1 Compare this result with Exercise 413 Exercise 73 Let wk sin2πkN for k 12 N1 Use the definitions 73 and 74 to find the corresponding values of Wn 711 Understanding the DFT Define a vector W containing all N frequency values and a vector w containing all N time values w w0 w1 w2 wN1T W W0 W1 W2 WN1T 2 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 discretetime convolution in the time and frequency domains in a concrete way using waystofiltm on page 143 and let M1 be a matrix with columns of complex exponentials 1 1 1 1 1 1 ej2πN ej4πN ej6πN ej2πN1N 1 ej4πN ej8πN ej12πN ej4πN1N 1 ej6πN ej12πN ej18πN ej6πN1N 1 ej2πN1N ej4πN1N ej6πN1N ej2πN12N Then the IDFT equation 74 can be rewritten as a matrix multiplication w 1N M1 W 75 and the DFT is W NMw 76 Since the inverse of an orthonormal matrix is equal to its own complex conjugate transpose M in 76 is the same as M1 in 75 with the signs on all the exponents flipped The matrix M1 is highly structured Let Cn be the nth column of M1 On multiplying both sides by N 75 can be rewritten as Nw W0C0 W1C1 WN1CN1 n0N1 WnCn 77 This form displays the time vector w as a linear combination³ of the columns Cn What are these columns They are vectors of discrete complexvalued sinusoids each at a different frequency Accordingly the DFT reexpresses the time vector as a linear combination of these sinusoids The complex scaling factors Wn define how much of each sinusoid is present in the original signal wk To see how this works consider the first few columns C0 is a vector of all ones it is the zerofrequency sinusoid or DC C1 is more interesting The ith element of C1 is ej2πiN which means that as i goes from 0 to N1 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 lowestfrequency sinusoid that can be represented other than DC it is the sinusoid that fits exactly one period in the time interval NTs where Ts is the distance in time between adjacent samples C2 is similar except that the ith element is ej4πiN Again the magnitude is unity and the phase is 4iπN radians Thus as i goes from 0 to N1 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 fits exactly two periods into 3 Those familiar with advanced linear algebra will recognize that M1 can be thought of as a change of basis that reexpresses w in a basis defined by the columns of M1 the time interval N Ts Similarly Cn represents a complex sinusoid of frequency n times that of C1 it orbits the circle n times and is the sinusoid that fits exactly n periods in the time interval N Ts One subtlety that can cause confusion is that the sinusoids in Ci are complexvalued yet most signals of interest are real Recall from Eulers identities 24 and A3 that the realvalued sine and cosine can each be written as a sum of two complexvalued exponentials that have exponents with opposite signs The DFT handles this elegantly Consider CN1 This is 1 ej2N1πN ej4N1πN ej6N1πN ej2N12 πNT which can be rewritten as 1 ej2πN ej4πN ej6πN ej2πN1NT since ej2π 1 Thus the elements of CN1 are identical to the elements of C1 except that the exponents have the opposite sign implying that the angle of the ith entry in CN1 is 2iπN radians Thus as i goes from 0 to N 1 the exponential assumes N uniformly spaced points around the unit circle in the opposite direction from C1 This is the meaning of what might be interpreted as negative frequencies that show up when taking the DFT The complex exponential proceeds in a negative clockwise manner around the unit circle rather than in a positive counterclockwise direction But it takes both to make a realvalued sine or cosine as Eulers formula shows For realvalued sinusoids of frequency 2πnN both Wn and WN n are nonzero and they are equal in magnitude⁴ Exercise 74 Which column Ci represents the highest possible frequency in the DFT What do the elements of this column look like Hint look at CN2 and think of a square wave This square wave is the highest frequency that can be represented by the DFT and occurs at exactly the Nyquist rate 712 Using the DFT Fortunately MATLAB makes it easy to do spectral analysis with the DFT by providing a number of simple commands that carry out the required calculations and manipulations It is not necessary to program the sum 73 or the matrix multiplication 75 The singleline commands W fftw and w ifftW invoke efficient FFT and IFFT routines when possible and relatively inefficient DFT and IDFT calculations otherwise The numerical idiosyncrasies are completely transparent with one annoying exception In MATLAB all vectors including W and w must be indexed from 1 to N instead of from 0 to N 1 ⁴ The discrete version of the symmetry property A35 shows that Wn WN n Hence the magnitudes are equal but the phases have opposite signs 136 Chapter 7 Digital Filtering and the DFT 0 200 400 600 800 1000 1200 What do these mean Magnitude N 210 0 500 1000 1500 2000 2500 Magnitude N 211 Figure 71 Naive and deceptive plots of the spectrum of a sine wave in which the frequency of the analyzed wave appears to depend on the size N of the analysis window The top figure has N 210 while the bottom uses N 211 While the FFTIFFT commands are easy to invoke their meaning is not always instantly transparent The intent of this section is to provide some exam ples that show how to interpret and how not to interpret the frequencyanalysis commands in Matlab Begin with a simple sine wave of frequency f sampled every Ts seconds as is familiar from previous programs such as speccosm The first step in any frequency analysis is to define the window over which the analysis will take place since the FFTDFT must operate on a finite data record The program specsin0m defines the length of the analysis with the variable N powers of two make for fast calculations and then analyzes the first N samples of w It is tempting to simply invoke the Matlab commands fft and to plot the results Typing plotfftw1N 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 first use the abs command as shown in specsin0m Listing 71 specsin0m naive and deceptive spectrum of a sine wave via the FFT f 100 Ts11000 time 50 freq sampling i nter val time tTs Ts time def i ne a time vector wsin 2 pi f t def i ne the s i nus oi d N2ˆ10 s i z e of a n a l y s i s window fwabs f f t w 1 N f i nd magnitude of DFTFFT plot fw pl ot the 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 71 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 71 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 Digital Filtering and the DFT 137 0 100 200 300 400 500 Magnitude 500 400 300 200 100 0 100 200 300 400 500 Magnitude Frequency Figure 72 Proper use of the FFT command can be done as in specsin1m the top graph which plots only the positive frequencies or as in specsin2m the bottom graph which shows the full magnitude spectrum symmetric about f 0 There are two problems First specsin0m plots the magnitude data against the index of the vector fw and this index by itself is meaningless The dis cussion surrounding 77 shows that each element of Wn represents a scaling of the complex sinusoid with frequency ej2πnN 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 76 the frequencies represented by the WN n are the negative of the frequencies represented by Wn There are two solutions The first is appropriate only when the original sig nal is realvalued In this case the Wns 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 specsin1m Listing 72 specsin1m spectrum of a sine wave via the FFTDFT f 100 Ts11000 time 50 freq sampling i nter val time tTs Ts time def i ne a time vector wsin 2 pi f t def i ne the s i nus oi d N2ˆ10 s i z e of a n a l y s i s window s s f 0N2 1TsN frequency vector fwabs f f t w 1 N f i nd magnitude of DFTFFT plot s s f fw 1 N2 pl ot f o r p o s i t i v e f r eq only The output of specsin1m is shown in the top plot of Figure 72 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 continuoustime intuition and graphs specsin2m exploits the builtin function fftshift which shuffles the output of the FFT com mand so that the negative frequencies occur on the left the positive frequencies on the right and DC in the middle 138 Chapter 7 Digital Filtering and the DFT Listing 73 specsin2m spectrum of a sine wave via the FFTDFT f 100 Ts11000 time 100 freq sampling i nter val time tTs Ts time def i ne a time vector wsin 2 pi f t def i ne the s i nus oi d N2ˆ10 s i z e of a n a l y s i s window s s f N2N2 1 TsN frequency vector fwf f t w 1 N do DFTFFT fwsf f t s h i f t fw s h i f t i t f o r p l o t t i n g plot s s f abs fws pl ot magnitude spectrum Running this program results in the bottom plot of Figure 72 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 75 Explore the limits of the FFTDFT 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 1500 1250 150 Comment on the rela tionship 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 76 Replace the sin function with sin2 Use wsin2piftˆ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 77 Replace the sin function with sinc What is the spectrum of the sinc function What is the spectrum of sinc2 Exercise 78 Plot the spectrum of wt sint jet Should you use the technique of specsin1m or of specsin2m Hint think symmetry Exercise 79 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 wsin2piftphi For phi 0 02 04 08 15 314 find the phase of the FFT output at the frequencies f b Find the phase of the output of the FFT when wsin2piftphiˆ2 These are all examples of simple functions which can be investigated in principle anyway analytically The greatest strength of the FFTDFT is that it can also be used for the analysis of data when no functional form is known Digital Filtering and the DFT 139 There is a data file on the website called gongwav which is a sound recording of an Indonesian gong a large struck metal plate The following code reads in the waveform and analyzes its spectrum using the FFT Make sure that the file gongwav is in an active Matlab path or you will get a file not found error If there is a sound card and speakers attached the sound command plays the wav file at the sampling rate fs 1Ts Listing 74 specgongm find spectrum of the gong sound filenamegongwav name of wave f i l e x s r wavread filename read in w avef i l e Ts1 s r sample i n t e r v a l of samples N2ˆ15 xx 1 N length f o r a n a l y s i s soundx 1 Ts play sound i f p o s s i b l e timeTs 0 length x 1 time base f o r p l o t t i n g subplot 2 1 1 plot time x and pl ot top f i g u r e magxabs f f t x take FFT magnitude s s f 0N2 1TsN f r eq base f o r p l o t t i n g subplot 2 1 2 plot s s f magx 1 N2 pl ot mag spectrum Running specgongm results in the plot shown in Figure 73 The top figure shows the time behavior of the sound as it rises very quickly when the gong is struck and then slowly decays over about 15 s The variable N defines the window over which the frequency analysis occurs The lowerleft plot shows the complete spectrum and the bottomright plot zooms in on the lowfrequency 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 specgongm analyzes approximately 15 s TsN seconds to be precise It is reasonable to suppose that the gong sound might undergo important transients during the first few milliseconds This can be investigated by decreasing N and applying the DFT to different segments of the data record Exercise 710 Determine the spectrum of the gong sound during the first 01 s What value of N is needed Compare this with the spectrum of a 01 s segment chosen from the middle of the sound How do they differ Exercise 711 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 specgongm What extra details can you see Exercise 712 The waveform of the sound produced by another much larger gong is given in gong2wav 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 713 Choose a wav file from the website in the Sounds folder or download a wav file of a song from the Internet Conduct a FFT analysis of the first few seconds of sound and then another analysis in the middle of the song 140 Chapter 7 Digital Filtering and the DFT 0 05 1 Time in seconds Frequency in Hertz 15 1 0 1 Amplitude 0 05 2 15 1 25 0 1 2 3 4 Magnitude Frequency in Hertz 400 450 500 750 800 600 650 700 550 0 1 2 3 4 x104 Figure 73 Time and frequency plots of the gong waveform The top figure shows the decay of the signal over 15 s The bottom left figure shows the magnitude spectrum and the right figure zooms in on the lowfrequency 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 FFTbased frequency analysis are as follows r The sampling interval Ts is the time resolution the shortest time over which any event can be observed The sampling rate fs 1Ts is inversely propor tional r The total time is T NTs where N is the number of samples in the analysis r The frequency resolution is 1T 1NTs fsN Sinusoids closer together in frequency than this value are indistinguishable For instance in the analysis of the gong conducted in specgongm the sampling interval Ts 144100 is defined by the recording With N 216 the total time is NTs 148 s and the frequency resolution is 1NTs 067 Hz Sometimes the total absolute time T is fixed Sampling faster decreases Ts and increases N but cannot give better resolution in frequency Sometimes it is pos sible to increase the total time Assuming a fixed Ts this implies an increase in N and better frequency resolution Assuming a fixed 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 res olution in frequency If this is still confusing or if you would like to see it from a different perspective check out Appendix D The DFT is a key tool in analyzing and understanding the behavior of com munications systems Whenever data flow 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 Digital Filtering and the DFT 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 72 Practical Filtering Filtering can be viewed as the process of emphasizing or attenuating certain frequencies within a signal Linear timeinvariant filters are common because they are easy to understand and straightforward to implement Whether in discrete or continuous time an LTI filter is characterized by its impulse response ie 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 filtering operation Thus while implementing the filter in the time domain as a convolution it is normal to specify design and understand it in the frequency domain as a pointbypoint multiplication of the spectrum of the input and the frequency response of the filter In principle this provides a method not only of understanding the action of a filter but also of designing a filter 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 filter that removes the noisy frequencies and passes the signal frequencies This intuitive notion translates directly into a mathematical specification for the frequency response The impulse response can then be calculated directly by taking the inverse transform and this impulse response defines the desired filter While this is the basic principle of filter design a number of subtleties can arise and sophisticated routines are available in Matlab that make the filter design process flexible even if they are not foolproof Filters are classified in several ways r Lowpass filters LPF try to pass all frequencies below some cutoff frequency and remove all frequencies above r Highpass filters try to pass all frequencies above some specified value and remove all frequencies below r Notch or bandstop filters try to remove particular frequencies usually in a narrow band and to pass all others r Bandpass filters try to pass all frequencies in a particular range and to reject all others 142 Chapter 7 Digital Filtering and the DFT The region of frequencies allowed to pass through a filter 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 filter specifications can be implemented as sums and concatenations of the above basic filter types For instance if h1k is the impulse response of a bandpass filter that passes only frequencies between 100 and 200 Hz and h2k is the impulse response of a bandpass filter that passes only frequencies between 500 and 600 Hz then hk h1k h2k passes only frequencies between 100 and 200 Hz or between 500 and 600 Hz Similarly if hlk is the impulse response of a lowpass filter that passes all frequencies below 600 Hz and hhk is the impulse response of a highpass filter that passes all frequencies above 500 Hz then hk hlk hhk is a bandpass filter that passes only frequencies between 500 and 600 Hz where represents convolution Filters are also classified by the length of their impulse response If the output of a filter depends only on a specified number of samples the filter is said to have a finite impulse response abbreviated FIR Otherwise it is said to have an infinite impulse response abbreviated IIR The bulk of the filters in Software Receiver Design are FIR filters with a flat passband because these are the most common filters in a typical receiver But other filter profiles are possible and the techniques of filter design are not restricted to flat passbands Section 721 shows several ways that digital FIR filters can be implemented in Matlab IIR filters arise whenever there is a loop such as in a phaselocked loop and one special case the integrator is an intrinsic piece of the adaptive elements Section 722 shows how to implement IIR filters Section 723 shows how to design filters with specific properties and how they behave on a number of test signals 721 Implementing FIR Filters Suppose that the impulse response of a discretetime filter is hi i 0 1 2 N 1 If the input to the filter is the sequence xi i 0 1 M 1 then the output is given by the convolution Equation 72 There are four ways to implement this filtering in Matlab r conv directly implements the convolution equation and outputs a vector of length N M 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 differences is to play with the four methods Digital Filtering and the DFT 143 Listing 75 waystofiltm conv vs filter vs freq domain vs time domain h1 1 2 2 3 3 impulse response h k x1 2 3 4 5 6 5 4 3 2 1 input data x k yconvconvh x convolve x k h k y f i l tf i l t e r h 1 x f i l t e r x k with h k nlength hlength x 1 pad length f o r FFT f f t hf f t h zeros 1 nlength h FFT of h k i s H n f f t xf f t x zeros 1 nlength x FFT of input i s X n f f t yf f t h f f t x product of H n and X n yfreqreal i f f t f f t y IFFT of product gi ves y k zzeros 1 length h 1 x i n i t i a l f i l t e r s tate 0 for k1 length x timedomain method ytim k f l i p l r h z k klength 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 first M terms of yconv yfilt yfreq and ytim are the same but that both yconv and yfreq have N1 extra values at the end For both the timedomain method and the filter command the output values are aligned in time with the input values one output for each input Effectively the filter command is a singleline implementation of the timedomain for loop For the FFT method the two vectors input and convolution must both have length NM1 The raw output has complex values due to numerical roundoff and the command real is used to strip away the imaginary parts Thus the FFTbased method requires more Matlab commands to implement Observe also that convhx and convxh are the same whereas filterh1x is not the same as filterx1h To view the frequency response of the filter h Matlab provides the command freqz which automatically zero pads5 the impulse response and then plots both the magnitude and the phase Type f r eqz h to see that the filter with impulse response h1 1 1 1 1 is a poor lowpass filter with two dips at 04 and 08 of the Nyquist frequency as shown in Figure 74 The command freqz always normalizes the frequency axis so that 10 corresponds to the Nyquist frequency fs2 The passband of this filter all frequencies less than the point where the magnitude drops 3 dB below the maximum ends just below 02 The maximum magnitude in the stopband occurs at about 06 where it is about 12 dB down from the peak at zero Better ie closer to the ideal lowpass filters would attenuate more in the stopband would be flatter across the passband and would have narrower transition bands 5 By default the Matlab command freqz creates a vector of length 512 that contains the specified 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 In discrete time crosscorrelation is a function of the time shift j between two sequences wk and vk j Rwvj limT 1T kT2T2 wkvk j 83 For finite data records the sum need only be accumulated over the nonzero elements and the normalization by 1T is often ignored This is how MATLABs xcorr function works While this may look like the convolution Equation 72 it is not identical since the indices are different 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 crosscorrelation quantifies the similarity of two signals In many communication systems each message is parcelled into segments or frames each having a predefined 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 predefined 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 82 correxm correlation can locate the header within the data header1 1 1 1 1 1 1 1 1 1 header is predefined string loc30 r25 place header in position loc datasignrandn1loc 1 header signrandn1r make signal sd025 datadatasdrandnsizedata add noise yxcorrheader data do crosscorrelation mindmaxy find largest correlation headstartlengthdataind1 place where header starts Running correxm results in a trio of figures much like those in Figure 82 Details will differ each time it is run because the actual data are randomly generated with MATLABs randn function The top plot in Figure 82 shows the 10sample 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 82 Observe that it is difficult 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 82 as a function of the lag index The index for which the correlation attains its largest value defines where the best match between the data and the header occurs Most likely this will be at index ind35 as in Figure 82 Because of the way MATLAB orders its output the calculations represent sliding the first vector the header term by term across the second vector the Digital Filtering and the DFT 145 z1 b a yk1 xk xk yk yk b Σ Delay Figure 75 The LTI system yk 1 ayk bxk with input xk and output yk is represented schematically using the delay z1 in this simple block diagram The special case when a 1 is called a summer because it effectively adds up all the input values and it is often drawn more concisely as on the right side of the figure where a a0 a1 anT b b0 b1 bmT are column vectors of the parameters of the filter and where xk xk xk 1 xk mT yk yk yk 1 yk nT are vectors of past input and output data The symbol zT 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 imple ments a complex conjugate as well as transpose Matlab has a number of functions that make it easy to explore IIR filtering For example the function impz plots the impulse response of a discrete IIR or FIR filter The impulse response of the system 78 is found by entering b1 a1 08 impz b a The parameters are the vectors bb0 b1 bm and a1 a0 a1 an Hence the above code gives the response when a of 78 is 08 Similarly the command freqzba displays the frequency response for the IIR filter where b and a are constructed in the same way The routine waystofiltIIRm explores ways of implementing IIR filters The simplest method uses the filter command For instance filterbad filters the data d through the IIR system with parameters b and a defined as above This gives the same output as first calculating the impulse response h and then using filterh1d The fastest and most general way to implement the filter is in the for loop at the end which mimics the timedomain method for FIR filters but includes the additional parameters a Listing 76 waystofiltIIRm ways to implement IIR filters a1 08 lenalength a 1 a u t o r e g r e s s i v e c o e f f i c i e n t s b 1 lenblength b moving average c o e f f i c i e n t s drandn 1 2 0 data to f i l t e r 146 Chapter 7 Digital Filtering and the DFT i f lenalenb dimpulse needs lenalenb himpz b a impulse response of f i l t e r y f i l tf i l t e r h 1 d f i l t e r x k with h k end y f i l t 2f i l t e r b a d f i l t e r using a and b yzeros lena 1 xzeros lenb 1 i n i t i a l s t a t e s in f i l t e r for k1length dlenb timedomain method xd k x 1 lenb 1 past values of inputs ytim ka 2 lena 1ybx d i r e c t l y c a l c u l a t e y k yytim k y 1 lena 1 past values of outputs end Like FIR filters IIR filters can be lowpass bandpass and highpass or can have almost any imaginable effect on the spectrum of their input Exercise 714 Some IIR filters can be used as inverses to some FIR filters Show that the FIR filter xk 1 brk a b rk 1 is an inverse of the IIR filter 78 Exercise 715 FIR filters can be used to approximate the behavior of IIR filters by truncating the impulse response Create a FIR filter with impulse response given by the first 10 terms of 79 for a 09 and b 2 Simulate the FIR filter and the IIR filter 78 in Matlab using the same random input to both Verify that the outputs are approximately the same 723 Filter Design This section gives an extended explanation of how to use Matlab to design a bandpass filter to fit a specified frequency response with a flat passband The same procedure with suitable modification also works for the design of other basic filter types A bandpass filter is intended to scale but not distort signals with frequen cies that fall within the passband and to reject signals with frequencies in the stopband An ideal distortionless response for the passband would be perfectly flat 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 pos sible In the stopband the frequency response magnitude should be sufficiently small and the phase is of no concern These objectives are captured in Figure 76 Recall from A35 for a real wt that Wf is even and Wf is odd as illustrated in Figure 76 Matlab has several commands that carry out filter design The firpm com mand6 provides a linear phase impulse response with real symmetric coefficients 6 Some early versions of Matlab use remez instead of firpm Digital Filtering and the DFT 147 H f H f Transition region Transition region Passband Stopband f Lower band edge Upper band edge Figure 76 Specifications of a realvalued bandpass filter in terms of magnitude and phase spectra hk that has the best approximation of a specified piecewiseflat frequency response7 The syntax of the firpm command for the design of a bandpass filter as in Figure 76 is b firpm f l fbe damps which has inputs fl fbe and damps and output b r fl specifies one fewer than the number of terms in the impulse response of the desired filter Generally more is better in terms of meeting the design specifications 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 r fbe is a vector of frequency band edge values as a fraction of the prevailing Nyquist frequency For example the filter specified in Figure 76 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 r 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 r b is the output vector containing the impulse response of the specified filter 7 There are many possible meanings of the word best for the firpm algorithm best is defined in terms of maintaining an equal ripple in the flat portions 148 Chapter 7 Digital Filtering and the DFT 80 60 40 20 0 20 Magnitude Response dB 0 01 02 03 04 05 06 07 08 09 1 Normalized frequency Nyquist 1 1500 1000 500 0 500 Phase degrees Figure 77 Frequency response of the bandpass filter designed by the firpm command in bandexm The variable fbe specifies a set of frequencies as a fraction of the Nyquist rate and damps specifies the corresponding amplitudes The freqz command plots both the magnitude and phase spectra of the filter The following Matlab script designs a filter that mimics Figure 76 Listing 77 bandexm design a bandpass filter and plot frequency response fbe 0 024 026 074 076 1 f r eq band edges as a f r a c t i o n of the Nyquist frequency damps0 0 1 1 0 0 des i r ed amplitudes at band edges f l 30 f i l t e r s i z e bfirpm f l fbe damps b i s the designed impulse response figure 1 f r eqz b pl ot f r eq response to check design The frequency response of the resulting finite impulse response FIR filter is shown in Figure 77 Observe that the stopband is about 14 dB lower than the passband a marginal improvement over the naive lowpass filter of Figure 74 but the design is much flatter in the passband The equiripple nature of this filter is apparent in the slow undulations of the magnitude in the passband Designing IIR filters is also straightforward For example the code b acheby1 1 0 5 0 2 5 designs a 10thorder lowpass filter with 5 dB of ripple in the passband which extends from DC to 025 times the Nyquist rate While commands such as firpm and cheby1 make filter design easy be warnedstrange things can happen even to nice filters Whenever using any of the filter design tools always check freqzba to verify that the output of the design behaves as anticipated There are many other ways to design LTI filters and Matlab includes several commands that design filter coefficients cfirpm firls fir1 fir2 butter cheby2 and ellip The subject of filter design is vast and each of these is useful in certain applications For simplic ity we have chosen to present most examples throughout Software Receiver Design by using firpm Digital Filtering and the DFT 149 Exercise 716 Rerun bandexm with very narrow transition regions for instance fbe 0 024 02401 06 0601 1 What happens to the ripple in the passband Compare the minimum magnitude in the passband with the max imum value in the stopband Exercise 717 Returning to the filter specified in Figure 76 try using different numbers of terms in the impulse response fl 5 10 100 500 1000 Comment on the resulting designs in terms of flatness of the frequency response in the passband attenuation from the passband to the stopband and the width of the transition band Exercise 718 Specify and design a lowpass filter with cutoff at 015 What values of fl fbe and damps work best Exercise 719 Specify and design a filter that has two passbands one between 02 03 and another between 05 06 What values of fl fbe and damps work best Exercise 720 Use the filter designed in bandexm to filter a white noise sequence generated by randn using the timedomain method from waystofiltm Verify that the output has a bandpass spectrum The preceding filter 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 filter design task Exercise 721 In Exercise 710 the program specgongm was used to ana lyze 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 filter using firpm that will remove the two highest partials from this sound without affecting the lowest partial b Use the filter command to process the gongwav file with your filter c Take the FFT of the resulting signal the output of your filter 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 filtered gong sound by using Matlabs sound command Comment on what you hear The next set of problems examines how accurate digital filters really are Exercise 722 With a sampling rate of 44100 Hz let xk be a sinusoid of frequency 3000 Hz Design a lowpass filter with a cutoff frequency fl of 1500 Hz and let yk LPFxk be the output of the filter 150 Chapter 7 Digital Filtering and the DFT a How much does the filter attenuate the signal Express your answer as the ratio of the power in the output yk to the power in the input xk b Now use an LPF with a cutoff of 2500 Hz How much does the filter attenuate the signal c Now use an LPF with a cutoff of 2900 Hz How much does the filter attenuate the signal Exercise 723 Repeat Exercise 722 without using the filter command implement the filtering using the timedomain method in waystofiltm Exercise 724 With the same setup as in Exercise 722 generate xk as a bandlimited noise signal containing frequencies between 3000 Hz and the Nyquist rate a Use an LPF with cutoff frequency fl of 1500 Hz How much does the filter attenuate the signal b Now use an LPF with a cutoff of 2500 Hz How much does the filter attenuate the signal c Now use an LPF with a cutoff of 3100 Hz How much does the filter attenuate the signal d Now use an LPF with a cutoff of 4000 Hz How much does the filter attenuate the signal Exercise 725 Let f1 f2 f3 Suppose xk has no frequencies above f1 Hz while zk has no frequencies below f3 If an LPF has cutoff frequency f2 in principle LPFxk zk LPFxk LPFzk xk 0 xk Explain how this is and is not consistent with the results of Exercises 722 and 724 Exercise 726 Let the output yk of an LTI system be created from the input xk according to the formula yk 1 yk µxk where µ is a small constant This is drawn in Figure 75 a What is the impulse response of this filter b What is the frequency response of this filter c Would you call this filter lowpass highpass or bandpass Exercise 727 Using one of the alternative filter design routines cfirpm firls fir1 fir2 butter cheby1 cheby2 or ellip repeat Exercises 716 721 Comment on the subtle and the notsosubtle differences in the resulting designs Digital Filtering and the DFT 151 Exercise 728 The effect of bandpass filtering can be accomplished by a modulating to DC b lowpass filtering and c modulating back Repeat the task given in Exercise 721 the Indonesian gong filter design problem by modulating with a 520 Hz cosine lowpass filtering and then remodulating Compare the final output of this method with the direct bandpass filter design For Further Reading Here are some of our favorite books on signal processing r K Steiglitz A Digital Signal Processing Primer AddisonWesley 1996 r J H McClellan R W Schafer and M A Yoder DSP First A Multimedia Approach PrenticeHall 1998 r C S Burrus and T W Parks DFTFFT and Convolution Algorithms Theory and Implementation WileyInterscience 1985 8 Bits to Symbols to Signals 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 efficiently these symbols are then translated again into short analog waveforms called pulse shapes that are com bined 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 sym bols back into binary digits from which the original message can with luck be reconstructed This chapter briefly 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 patternmatching tool for discovering key locations within the signal stream Section 83 shows how correlation can be viewed as a kind of linear filter and hence its properties can be readily understood both in the time and in the frequency domain 81 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 flow of electrons in a wire a digitized image or sound file the text in a book If the information is in analog form then it can be sampled as in Chapter 6 For instance an analogtodigital 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 flow The sound file which is already digital contains a long list of numbers that correspond to the instantaneous amplitude of the sound Similarly the picture file contains a list of numbers that describe the intensity and color of the pixels in the image Bits to Symbols to Signals 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 re expressed 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 efficient 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 difference 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 twoelement 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 fourlevel signal For example the binary sequence might be paired thus 000010110101 00 00 10 11 01 01 81 Then the pairs might be encoded as 11 3 10 1 01 1 00 3 82 to produce the symbol sequence 00 00 10 11 01 01 3 3 1 3 1 1 Of course there are many ways in which such a mapping between bits and symbols might be made and Exercise 82 explores one simple alternative called the Gray code The binary sequence may be grouped in many ways into triplets for an 8level signal into quadruplets for a 16level scheme into inphase and quadrature parts for transmission through a quadrature system The values assigned to the groups 1 3 in 82 are called the alphabet of the given system Example 81 Text is commonly encoded using ASCII and Matlab automat ically represents any string file as a list of ASCII numbers For instance let strI am text be a text string This can be viewed in its internal form by typing realstr 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 Chapter 8 Bits to Symbols to Signals in binary using dec2basestr28 which returns the binary base 2 repre sentation of the decimal numbers each with eight digits The Matlab function letters2pamm provided on the website changes a text string into the fourlevel alphabet 1 3 Each letter is represented by a sequence of four elements for instance the letter I is 1 3 1 1 The func tion is invoked with the syntax letters2pamstr The inverse operation is pam2lettersm Thus pam2lettersletters2pamstr returns the original string One complication in the decoding procedure is that the receiver must figure out when the groups begin in order to parse the digits properly For example if the first element of the sequence in 81 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 patternmatching technique This is discussed in detail in Section 83 Example 82 There are many ways to translate data into binary equiva lents Example 81 showed one way to convert text into 4PAM and then into binary Another way exploits the Matlab function text2binm and its inverse bin2textm which use the 7bit version of the ASCII code rather than the 8bit version This representation is more efficient since each pair of text letters can be represented by 14 bits or seven 4PAM symbols rather than 16 bits or eight 4PAM symbols On the other hand the 7bit version can encode only half as many characters as the 8bit version Again it is important to be able to correctly identify the start of each letter when decoding Exercise 81 The Matlab code in naivecodem which is on the website implements the translation from binary to 4PAM and back again suggested in 82 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 82 A Gray code has the property that the binary representation for each symbol differs from its neighbors by exactly one bit A Gray code for the Bits to Symbols to Signals 155 translation of binary into 4PAM is 01 3 11 1 10 1 00 3 Mimic the code in naivecodem to implement this alternative and plot the num ber of errors as a function of the noise variance v Compare your answer with Exercise 81 Which code is better 82 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 ie multiplied by 1 to represent the element 1 This is called a polar nonreturntozero line code The problem with such simple codes is that they use bandwidth inefficiently Recall that the Fourier transform of the rectangular pulse in time is the sincf function in frequency A20 which dies away slowly as f increases Thus simple codes like the nonreturntozero are compact in time but wide in frequency limiting the number of simultaneous nonoverlapping users in a given spectral band More generally consider the fourlevel signal of 82 This can be turned into an analog signal for transmission by choosing a pulse shape pt that is not necessarily rectangular and not necessarily of duration T and then transmitting pt kT if the kth symbol is 1 pt kT if the kth symbol is 1 3pt kT if the kth symbol is 3 3pt kT if the kth symbol is 3 Thus the sequence is translated into an analog waveform by initiating a scaled pulse at the symbol time kT where the amplitude scaling is proportional to the associated symbol value Ideally the pulse would be chosen so that r the value of the message at time k does not interfere with the value of the message at other sample times the pulse shape causes no intersymbol inter ference r the transmission makes efficient use of bandwidth and r the system is resilient to noise Unfortunately these three requirements cannot all be optimized simultaneously and so the design of the pulse shape must consider carefully the tradeoffs that are needed The focus in Chapter 11 is on how to design the pulse shape pt and the 156 Chapter 8 Bits to Symbols to Signals 0 01 02 03 04 05 06 07 08 09 The pulse shape 0 02 04 06 08 1 0 10 20 30 40 50 60 70 80 90 100 The waveform representing Transmit this text 3 2 1 0 1 2 3 Figure 81 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 consequences of that choice in terms of possible interference between adjacent symbols and in terms of the signaltonoise properties of the transmission For now to see concretely how pulse shaping works lets pick a simple non rectangular shape and proceed without worrying about optimality Let pt be the symmetric blip shape shown in the top part of Figure 81 and defined in pulseshapem by the hamming command The text string in str is changed into a fourlevel signal as in Example 81 and then the complete transmitted wave form is assembled by assigning an appropriately scaled pulse shape to each data value The output appears at the bottom of Figure 81 Looking at this closely observe that the first letter T is represented by the four values 1 1 1 and 3 which correspond exactly to the first four negative blips three small and one large The program pulseshapem represents the continuoustime or analog signal by oversampling both the data sequence and the pulse shape by a factor of M This technique was discussed in Section 63 where an analog sine wave sine100hzsampm was represented digitally at two sampling intervals a slow digital interval Ts and a faster rate shorter interval TsM representing the underlying analog signal The pulse shaping itself is carried out by the filter command which convolves the pulse shape with the data sequence Listing 81 pulseshapem applying a pulse shape to a text string s t rTransmit this text string message to be transmitted mletters2pam s t r Nlength m 4 l e v e l s i g n a l of length N Bits to Symbols to Signals 157 M10 mupzeros 1 NM mup 1 MNMm oversample by M pshammingM bl i p pulse of width M xf i l t e r ps 1 mup convolve pulse shape data Exercise 83 Assume the sampling period is T 01 and then plot the spec trum of the output x What is the bandwidth of this signal Exercise 84 Again with T 01 plot the spectrum of the output x when the pulse shape is changed to a rectangular pulse Change the definition of ps in the nexttolast line of pulseshapem What is the bandwidth of this signal Exercise 85 Can you think of a pulse shape that will have a narrower band width than either of the above but that will still be time limited by T Implement it by changing the definition of ps and check to see whether you are correct Thus the raw message is prepared for transmission by r encoding into an alphabet in this case 1 3 and then r pulse shaping the elements of the alphabet using pt The receiver must undo these two operations it must examine the received signal and recover the elements of the alphabet and then decode these to reconstruct the message Both of these tasks are made easier using correlation which is discussed in the next section The actual decoding processes used in the receiver are then discussed in Section 84 83 Correlation Suppose there are two signals or sequences Are they similar or are they differ ent 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 find appropriate sampling times and it can be applied at the frame level when it is necessary to find the start of a message for instance the beginning of each frame of a television signal This section discusses various techniques of cross correlation and autocorrelation which can be viewed in either the time domain or the frequency domain Figure 74 The frequency response of the filter with impulse response h1 1 1 1 1 has a poor lowpass character It is easier to see this in the frequency domain than directly in the time domain 722 Implementing IIR Filters At first glance it might seem counterintuitive that a useful filter could have an impulse response that is infinitely long To see how this infiniteness might arise in a specific case suppose that the output yk of an LTI system is created from the input xk according to the formula yk 1 ayk bxk 78 where a and b are constants This is shown in the lefthand portion of Figure 75 where the time delay between successive terms between k and k 1 for instance is represented by z¹ This is an example of the Ztransform and is described more fully in Appendix F If the initial value is y0 0 the response of the system 78 to an impulse xk δk where δk is the discrete impulse function 71 is bbaba²ba³ba⁴ 79 If a 1 this impulse response increases towards infinity 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 infinitely long and so the system 78 is IIR The special case when a 1 is called a summer or in analogy with continuous time an integrator because yk y0 b i0k1 xi sums up all the inputs The summer is often represented symbolically as in the righthand part of Figure 75 The general form of an IIR filter is yk 1 a0 yk a1 yk 1 an yk n b0 xk b1 xk 1 bm xk m which can be rewritten more concisely as yk 1 aᵀ yk bᵀ xk Bits to Symbols to Signals 159 1 2 3 4 5 6 7 8 9 10 1 05 0 05 1 Header 2 1 0 1 2 0 20 40 60 80 100 120 140 10 5 0 5 10 Correlation of header with data Data with embedded header 0 10 20 30 40 50 60 70 Figure 82 The correlation can be used to locate a known header within a long signal The predefined 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 different lengths The start of the header is given by lengthdataind1 One way in which the correlation might fail to find 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 86 Rerun correxm with differentlength data vectors try loc100 r100 and loc10 r10 Observe how the location of the peak changes Exercise 87 Rerun correxm with differentlength 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 different convention with the xcorr command If you find that the string of zeros occurs at the beginning try reversing the order of the arguments 160 Chapter 8 Bits to Symbols to Signals Exercise 88 Rerun correxm with different amounts of noise Try sd0 01 03 05 1 2 How large can the noise be made if the correlation is still to find the true location of the header Exercise 89 The code in corrvsconvm explores the relationship between the correlation and convolution The convolution of two sequences is essentially the same as the crosscorrelation of the timereversed 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 83 corrvsconvm comparing correlation and convolution h1 1 2 2 3 3 def i ne sequence h k x1 2 3 4 5 6 5 4 3 2 1 def i ne sequence x k yconvconvx h convolve x k h k ycorrxcorr h f l i p l r x c o r r e l a t e f l i p p e d x and h 84 Receive Filtering From Signals to Symbols Suppose that a message has been coded into its alphabet pulseshaped into an analog signal and transmitted The receiver must then unpulseshape the analog signal back into the alphabet which requires finding where in the received signal the pulse shapes are located Correlation can be used to accomplish this task because it is effectively the task of locating a known sequence in this case the sampled pulse shape within a longer sequence the sampled received signal This is analogous to the problem of finding the header within the received signal although some of the details have changed While optimizing this procedure is somewhat involved and is therefore postponed until Chapter 11 the gist of the method is reasonably straightforward and is shown by continuing the example begun in pulseshapem The code in recfiltm below begins by repeating the pulseshaping code from pulseshapem using the pulse shape ps defined in the top plot of Figure 81 This creates an analog signal x that is oversampled by a factor M The receiver begins by correlating the pulse shape with the received signal using the xcorr function2 After appropriate scaling this is downsampled to the symbol rate by choosing one out of each M regularly spaced samples These values are then quantized to the nearest element of the alphabet using the function quantalph which was introduced in Exercise 325 The function quantalph has two vector arguments the elements of the first vector are quantized to the 2 Because of the connections between crosscorrelation convolution and filtering this process is often called pulsematched filtering because the impulse response of the filter is matched to the shape of the pulse Bits to Symbols to Signals 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 pam2lettersm rebuilds the message from the received signal The final line of the program calculates how many symbol errors have occurred how many of the 1 3 differ between the message m and the reconstructed message mprime Listing 84 recfiltm undo pulse shaping using correlation run pulseshape m cr eate x yxcorr x ps c o r r e l a t e pulse s i g n a l zyNMMNM pow ps M downsample to symbol r ate mprimequantalph z 3 1 1 3 quantize to alphabet pam2letters mprime r econs tr uct message sumabs sign mprimem c a l c u l a t e number of e r r o r s In essence pulseshapem from page 156 is a transmitter and recfiltm is the corresponding receiver Many of the details of this simulation can be changed and the message will still arrive intact The following exercises encourage exploration of some of the options Exercise 810 Other pulse shapes may be used Try a a sinusoidal shaped pulse pssin01pi0M1 b a sinusoidal shaped pulse pscos01pi0M1 c a rectangular pulse shape psones1M Exercise 811 What happens if the pulse shape used at the transmitter differs from the pulse shape used at the receiver Try using the original pulse shape from pulseshapem at the transmitter but using the following a pssin01pi0M1 at the receiver What percentage errors occur b pscos01pi0M1 at the receiver What percentage errors occur Exercise 812 The received signal might not always arrive at the receiver unchanged Simulate a noisy channel by including the command xx10randnsizex before the xcorr command in recfiltm What percent age errors occur What happens as you increase or decrease the amount of noise by changing the 10 to a larger or smaller number 85 Frame Synchronization From Symbols to Bits In many communication systems the data in the transmitted signal are separated into chunks called frames In order to correctly decode the text at the receiver it is necessary to locate the boundary the start of each chunk This was done by fiat in the receiver of recfiltm by correctly indexing into the received signal 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 predefined symbols embedded at some specified location within each frame The receiver can locate the marker by crosscorrelating 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 84 where the marker M is used to indicate a frame transition A sevensymbol marker is to be used Consider two candidates marker A 1 1 1 1 1 1 1 marker B 1 1 1 1 1 1 1 1 The correlation of the signal with each of the markers can be performed as indicated in Figure 83 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 sevensymbol marker we want the flag 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 maximumlength pseudonoise PN sequence One property of a maximumlength PN sequence ci of plus and minus ones is that its autocorrelation is quite peaked Rck 1N sumcncnk 1 kℓN 1N kℓN 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 flatter 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 Bits to Symbols to Signals 163 Sum products of corresponding values Data sequence with embedded marker m1 m2 m3 m4 m5 m6 m7 1 1 1 1 1 1 1 1 m1 m2 m3 m4 m5 m6 m7 1 1 1 Shift marker to right and repeat m1 m2 m3 m4 m5 m6 m7 1 1 1 1 1 1 1 1 m1 m2 m3 m4 m5 m6 m7 1 1 1 sum m1 m2 m3 m4 m5 m6 m7 sum m1 m2 m3 m4 m5 m6 m7 Shift marker to right and repeat m1 m2 m3 m4 m5 m6 m7 1 1 1 1 1 1 1 1 m1 m2 m3 m4 m5 m6 m7 1 1 1 sum m1 m2 m3 m4 m5 m6 m1m7 Shift marker to right and repeat m1 m2 m3 m4 m5 m6 m7 1 1 1 1 1 1 1 1 m1 m2 m3 m4 m5 m6 m7 1 1 1 sum m1 m2 m3 m4 m5 m1m6 m2m7 Shift marker to right and repeat m1 m2 m3 m4 m5 m6 m7 1 1 1 1 1 1 1 1 m1 m2 m3 m4 m5 m6 m7 1 1 1 sum m1m1m2m2m3m3m4m4m5m5m6m6m7m7 Figure 83 The binary signal from 84 is shown with a sevensymbol embedded marker m1 m2 m7 The process of correlation multiplies successive elements of the signal by the marker and sums The marker shifts to the right and the process repeats The sum is largest when the marker is aligned with itself because all the terms are positive as shown in the bottom part of the diagram Thus the shift with the largest correlation sum points towards the embedded marker in the data sequence Correlation can often be useful even when the data are noisy 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 Chapter 8 Bits to Symbols to Signals appropriate additions at the transmitter The alignment can be accomplished using correlation Exercise 813 Redo the example of this section using Matlab Exercise 814 Add a channel with impulse response 1 0 0 a 0 0 0 b to this example Convolve the impulse response of the channel with the data sequence a For a 01 and b 04 how does the channel change the likelihood that the correlation correctly locates the marker Try using both markers A and B b Answer the same question for a 05 and b 09 c Answer the same question for a 12 and b 04 Exercise 815 Generate a long sequence of binary random data with the marker embedded every 25 points Check that marker A is less robust on average than marker B by counting the number of times marker A misses the frame start compared with the number of times marker B misses the frame start Exercise 816 Create your own marker sequence and repeat the previous prob lem Can you find one that does better than marker B Exercise 817 Use the 4PAM alphabet with symbols 1 3 Create a marker sequence and embed it in a long sequence of random 4PAM data Check to make sure it is possible to correctly locate the markers Exercise 818 Add a channel with impulse response 1 0 0 a 0 0 0 b to this 4PAM example a For a 01 and b 04 how does the channel change the likelihood that the correlation correctly locates the marker b Answer the same question for a 05 and b 09 Exercise 819 Choose a binary scrambling sequence s that is 17 bits long Create a message that is 170 bits long and scramble it using bitbybit mod 2 addition a Assuming the receiver knows where the scrambling begins add s to the scram bled data and verify that the output is the same as the original message b Embed a marker sequence in your message Use correlation to find the marker and to automatically align the start of the scrambling 9 Stuff 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 pro vided 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 disturbancefree 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 samples the received signal r demodulates to baseband r filters the signal to remove unwanted portions of the spectrum r correlates with the pulse shape to help emphasize the peaks of the pulse train r downsamples to the symbol rate and r decodes the symbols back into the character string 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 ele ments into a full simulation of a transmitter and receiver pair that can function successfully in an ideal setting 166 Chapter 9 Stuff Happens 91 An Ideal Digital Communication System The system is illustrated in the block diagram of Figure 91 This system is described in great detail in Section 92 which also provides a Matlab version of the transmitter and receiver Once everything is pieced together it is easy to verify that messages can be sent reliably from transmitter to receiver Unfortunately some of the assumptions made in the ideal setting are unlikely to hold in practice for example the presumption that there is no interference from other transmitters that there is no noise that the gain of the channel is always unity that the signal leaving the transmitter is exactly the same as the signal at the input to the digital receiver All of these assumptions will almost certainly be violated in practice Stuff happens Section 93 begins to accommodate some of the nonidealities encountered in real systems by addressing the possibility that the channel gain might vary with time For example a large metal truck might abruptly move between a cell phone and the antenna at the base station causing the channel gain to drop precipi tously If the receiver cannot react to such a change it may suffer debilitating errors when reconstructing the message Section 93 examines the effectiveness of incorporating an automatic gain control AGC adaptive element as described in Section 68 at the front end of the receiver With care the AGC can accom modate the varying gain The success of the AGC is encouraging Perhaps there are simple ways to compensate for other common impairments Section 94 presents a series of what if questions concerning the various assumptions made in the construction of the ideal system focusing on perfor a Transmitter Pulse filter Coder Tspaced symbol sequence Baseband signal Passband signal Message character string Mixer cos2πfct b Receiver Lowpass filter Tsspaced passband signal Tsspaced baseband signal Received signal Mixer Demodulator Downsampler kTs k 0 1 2 nMTs lTs n 0 1 2 Sampler cos2πfckTs Pulse correlator filter Decoder Quantizer MTsspaced soft decisions MTsspaced hard decisions Recovered character string Figure 91 Block diagram of an ideal communication system Stuff Happens 167 mance degradations caused by synchronization loss and various kinds of distor tions What if there is channel noise The ideal system is noisefree What if the channel has multipath interference There are no reflections or echoes in the ideal system What if the phase of the oscillator at the transmitter is unknown or guessed incorrectly at the receiver The ideal system knows the phase exactly What if the frequency of the oscillator at the transmitter is off just a bit from its specification In the ideal system the frequency is known exactly What if the sample instant associated with the arrival of topdeadcenter of the leading pulse is inaccurate so that the receiver samples at the wrong times The sampler in the ideal system is never fooled What if the number of samples between symbols assumed by the receiver is different from that used at the transmitter These are the same in the ideal case These questions are investigated via a series of experiments that require only modest modification of the ideal system simulation These simulations will show as with the timevarying channel gain that small violations of the idealized assumptions can often be tolerated However as the operational conditions become more severe as more stuff happens the receiver must be made more robust Of course it is not possible to fix all these problems in one chapter Thats what the rest of the book is for Chapter 10 deals with methods to acquire and track changes in the carrier phase and frequency Chapter 11 describes better pulse shapes and corresponding receive filters that perform well in the presence of channel noise Chapter 12 discusses techniques for tracking the symbol clock so that the samples can be taken at the best possible times Chapter 13 designs a symbolspaced filter that undoes multipath interference and can reject certain kinds of inband interference Chapter 14 describes simple coding schemes that provide protection against channel noise 92 Simulating the Ideal System The simulation of the digital communication system in Figure 91 divides into two parts just as the figure does The first part creates the analog transmitted signal and the second part implements the discretetime receiver The message consists of the character string 01234 I wish I were an Oscar Meyer wiener 56789 In order to transmit this important message it is first translated into the 4PAM symbol set 1 3 which is designated mi for i 1 2 N using the subroutine letters2pamm This can be represented formally as the analog pulse train miδt iT where T is the time interval between symbols The simulation operates with an oversampling factor M which is the speed at which the analog portion of the system evolves The pulse train enters a filter with pulse shape pt The sifting property A56 shows that the output of the pulseshaping filter is the analog signal mipt iT which is then modulated by multiplication with a cosine at the carrier frequency fc to form the transmitted signal mipt iTcos2πfct Since the channel is assumed to be ideal this is equal to the received signal rt This ideal transmitter is simulated in the first part of idsysm Listing 91 idsysm part 1 idealized transmission system the transmitter encode text string as Tspaced 4PAM sequence str01234 I wish I were an Oscar Meyer wiener 56789 mletters2pamstr Nlengthm 4level signal of length N zero pad Tspaced symbol sequence to create upsampled TMspaced sequence of scaled Tspaced pulses T1 M100 oversampling factor mupzeros1NM Hamming pulse filter with mup1MNMm TMspaced impulse response phammingM blip pulse of width M xfilterp1mup convolve pulse shape with data figure1 plotspecx1M baseband AM modulation t1M1M lengthxM TMspaced time vector fc20 carrier frequency ccos2pifct carrier rcx modulate message with carrier Since MATLAB cannot deal directly with analog signals the analog signal rt is sampled at M times the symbol rate and rttkTs the signal rt 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 first sampling block in the receiver of Figure 91 is implicit in the way MATLAB emulates the analog signal To be specific 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 MTs kTs iT ρTs Thus the received signal sampled at t kTs is rttkTs mipt iTcos2πfcttkTsiTρTs mipkTs iTcos2πfckTs The receiver performs downconversion in the second part of idsysm with a mixer that uses a synchronized cosine wave followed by a lowpass filter that removes outofband signals A quantizer makes hard decisions that are then decoded back from symbols to the characters of the message When all goes well the reconstructed message is the same as the original Listing 92 idsysm part 2 idealized transmission system the receiver AM demodulation of received signal sequence r c2cos2pifct synchronized cosine for mixing x2rc2 demod received signal fl50 fbe0 01 02 1 LPF parameters damps1 1 0 0 bfirpmflfbedamps create LPF impulse response x32filterb1x2 LPF and scale signal extract upsampled pulses using correlation implemented as a convolving filter filter with pulse and normalize yfilterfliplrppowpM1x3 set delay to first symbolsample and increment by M zy05flMMNM downsample to symbol rate figure2 plot1lengthzz plot soft decisions decision device and symbol matching performance assessment mprimequantalphz3113 quantize alphabet cvarmprimezmprimezlengthmprime cluster variance lmplengthmprime pererr100sumabssignmprimem1lmplmp symbol error decode decision device output to text string reconstructedmessagepam2lettersmprime This ideal system simulation is composed primarily of code recycled from previous chapters The transformation from a character string to a fourlevel Tspaced sequence to an upsampled TMspaced Twide Hamming pulseshape filter output sequence mimics pulseshapem from Section 82 This sequence of TMspaced pulse filter outputs and its magnitude spectrum are shown in Figure 92 type plotspecx1M after running idsysm Each pulse is one time unit long so successive pulses can be initiated without any overlap The unit duration of the pulse could be a millisecond for a pulse frequency of 1 kHz or a microsecond for a pulse frequency of 1 MHz The magnitude spectrum in Figure 92 has little apparent energy outside bandwidth 2 the meaning of 2 in Hz is dependent on the units of time This oversampled waveform is upconverted by multiplication with a sinusoid This is familiar from AMm of Section 52 The transmitted passband signal and its spectrum created using plotspecv1M are shown in Figure 93 The default carrier frequency is fc20 Nyquist sampling of the received signal occurs as long 170 Chapter 9 Stuff Happens 3 1 2 0 2 1 3 Amplitude 0 0 40 80 120 160 200 Seconds 8000 6000 4000 2000 Magnitude 50 40 30 20 10 0 10 20 30 40 50 Frequency Figure 92 The transmitter of idsysm creates the message signal x in the top plot by convolving the 4PAM data in m with the pulse shape p The magnitude spectrum Xf is shown at the bottom 3 1 2 0 2 1 3 Amplitude 0 20 40 60 80 100 120 140 160 180 Seconds 4000 3000 2000 1000 0 Magnitude 50 40 30 20 10 0 10 20 30 40 50 Frequency Figure 93 The received signal r and its spectrum Rf after upconversion as the sample frequency 1TM M for T 1 is twice the highest frequency in the received signal which will be the carrier frequency plus the baseband signal bandwidth of approximately 2 Thus M should be greater than 44 to prevent aliasing of the received signal This allows reconstruction of the analog received signal at any desired point which could prove valuable if the times at which the samples were taken were not synchronized with the received pulses The transmitted signal reaches the receiver portion of the ideal system in Figure 91 Downconversion is accomplished by multiplying the samples of the received signal by an oscillator that miraculously has the same frequency and phase as was used in the transmitter This produces a signal with the spectrum shown in Figure 94 type plotspecx21M after running idsysm a spec trum that has substantial nonzero components that must be removed at about twice the carrier frequency Stuff Happens 171 3 1 2 0 2 1 3 Amplitude 0 20 40 60 80 100 120 140 160 180 Seconds 4000 3000 2000 1000 0 Magnitude 50 40 30 20 10 0 10 20 30 40 50 Frequency Figure 94 Downconversion in idsysm mixes the received signal r with a cosine wave c2 to generate x2 The figure shows x2 in time in the top plot and its spectrum in the bottom plot Magnitude response dB Phase degrees 0 01 02 03 04 05 06 07 08 09 1 Normalized frequency Nyquist 1 1000 800 600 400 200 0 100 80 60 40 20 0 20 Figure 95 The frequency response of the lowpass filter designed using firpm in idsysm To suppress the components centered around 40 in Figure 94 and to pass the baseband component without alteration except for possibly a delay the lowpass filter is designed with a cutoff near 10 For M 100 the Nyquist frequency is 50 Section 723 details the use of firpm for filter design The frequency response of the resulting FIR filter from freqzb is shown in Figure 95 To make sense of the horizontal axes observe that the 1 in Figure 95 corresponds to the 50 in Figure 94 Thus the cutoff between normalized frequencies 01 and 02 corresponds to an unnormalized frequency near 10 as desired The output of the lowpass filter in the demodulator is a signal with the spec trum shown in Figure 96 drawn using plotspecx31M The spectrum in Figure 96 should compare quite closely to that of the transmitter baseband in Figure 92 as indeed it does It is easy to check the effectiveness of the low pass filter design by attempting to use a variety of different lowpass filters as suggested in Exercise 94 Recall the discussion in Section 84 of matching two scaled pulse shapes View ing the pulse shape as a kind of marker it is reasonable to correlate the pulse 172 Chapter 9 Stuff Happens 3 1 2 0 2 1 3 Amplitude 0 20 40 60 80 100 120 140 160 180 Seconds 8000 6000 4000 2000 0 Magnitude 50 40 30 20 10 0 10 20 30 40 50 Frequency Figure 96 After demodulation and lowpass filtering the signal x3 in idsysm is approximately the same as the baseband transmitted signal and spectrum in Figure 92 3 2 1 0 1 2 30 50 100 150 Best times to take samples Tsspaced samples Tspaced samples Amplitude of received signal Delay 200 250 300 350 400 0 T 2T 3T 4T Figure 97 The first four symbol periods recall that the oversampling factor was M 100 of the signal at the receiver after the demodulation LPF and pulse correlator filter The first three symbol values are 3 3 3 which can be deciphered from the signal assuming that the delay can be selected appropriately shape with the received signal in order to locate the pulses More justifica tion for this procedure is forthcoming in Chapter 11 This appears in Figure 91 as the block labelled pulse correlation filter The code in idsysm imple ments 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 corrvsconvm in Exercise 89 to see how the two functions are related The first 4M samples of the resulting signal y are plotted in Figure 97 via ploty14M The first three symbols of the message ie m13 are 3 3 and 3 and Figure 97 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 filter 05fl plus half the length of the correlator filter 05M plus half a symbol period 05M which accounts for the delay from the start of each pulse to its peak Stuff Happens 173 3 2 1 0 1 2 3 0 50 100 150 200 250 300 350 400 Figure 98 Repeatedly overlaying a time width of four symbols yields an eye diagram Selecting this delay and the associated downsampling are accomplished in the code zy 0 5 f lMM end downsample to symbol r ate in idsysm which recovers the T spaced samples z With reference to Figure 91 the parameter l in the downsampling block is 125 A revealing extension of Figure 97 is to plot the oversampled waveform y for the complete transmission in order to see whether the subsequent peaks of the pulses occur at regular intervals precisely on source alphabet symbol values as we would hope However even for small messages such as the wiener jingle squeezing such a figure onto one graph makes a detailed visual examination of the peaks fruitless This is precisely why we plotted Figure 97to see the detailed timing information for the first few symbols One idea is to plot the next four symbol periods on top of the first four by shifting the start of the second block to time zero Continuing this approach throughout the data record mimics the behavior of a welladjusted oscilloscope that triggers at the same point in each symbol group This operation can be implemented in Matlab by first determining the maximum number of groups of 4M samples that fit inside the vector y from the lth sample on Let ulfloor length yl 14M then the reshape command can be used to form a matrix with 4M rows and ul columns This is easily plotted using plot reshape y l ul 4M124 4M ul and the result is shown in Figure 98 Note that the first element plotted in Figure 98 is the lth element of Figure 97 This type of figure 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 imple mented in letters2pamm and pam2lettersm One idiosyncrasy is that each character starts off with a negative symbol Another is that the second symbol in 174 Chapter 9 Stuff Happens 40 20 40 60 80 100 120 140 160 180 200 3 2 1 0 1 3 2 4 Figure 99 Values of the reconstructed symbols called the soft decisions are plotted in this constellation diagram time history each character is never 1 in our chosen message These are not generic effects they are a consequence of the particular coding and message used in idsysm Had we chosen to implement a scrambling scheme recall Exercise 819 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 plot1lengthzz produces a time history of the output of the down sampler as shown in Figure 99 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 99 cluster tightly about the alphabet values 1 and 3 How tightly they cluster can be quantified using the cluster variance which is the average of the square of the difference between the decoded symbol values the soft decisions in z and the nearest member of the alphabet the final hard decisions The Matlab function quantalphm is used in idsysm to calculate the hard decisions which are then converted back into a text character string using pam2lettersm If all goes well this reproduces the original message The only flaw is that the last symbol of the message has been lost due to the inherent delay of the lowpass filtering and the pulseshape 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 pam2lettersm 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 91 Using idsysm examine the effect of using different carrier fre quencies Try fc 50 30 3 1 05 What are the limiting factors that cause some to work and others to fail Stuff Happens 175 Exercise 92 Using idsysm examine the effect of using different oversampling frequencies Try M 1000 25 10 What are the limiting factors that cause some to work and others to fail Exercise 93 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 94 What are the limits to the LPF design at the beginning of the receiver What is the lowest cutoff frequency that works The highest Exercise 95 Using the same specifications fbe0 01 02 1 damps 1 1 0 0 how short can you make the LPF Explain 93 Flat Fading A Simple Impairment and a Simple Fix Unfortunately a number of the assumptions made in the simulation of the ideal system idsysm are routinely violated in practice The designer of a receiver must somehow compensate by improving the receiver This section presents an impairment flat fading for which we have already developed a fix an AGC Later sections describe misbehavior due to a wider variety of common impair ments that we will spend the rest of the book combating Flat fading occurs when there are obstacles moving in the path between the transmitter and receiver or when the transmitter and receiver are moving with respect to each other It is most commonly modeled as a timevarying channel gain that attenuates the received signal The modifier flat implies that the loss in gain is uniform over all frequencies In communications jargon it is not frequencyselective This section begins by studying the loss of performance caused by a timevarying channel gain using a modified version of idsysm and then examines the ability of an adaptive element the automatic gain control AGC to make things right In the ideal system of the preceding section the gain between the transmit ter and the receiver was implicitly assumed to be unity What happens when this assumption is violated when flat fading is experienced in midmessage To examine this question suppose that the channel gain is unity for the first 20 of the transmission but that for the last 80 it drops by half This flat fade can easily be studied by inserting the following code between the transmitter and the receiver parts of idsysm Listing 93 idsysmod1m modification of idsysm with timevarying fading channel l rlength r length of transmitted s i g n a l vector fp ones 1 floor 0 2 l r 0 5 ones 1 lr floor 0 2 l r f l a t fading p r o f i l e rr fp apply p r o f i l e to transmitted s i g n a l 176 Chapter 9 Stuff Happens 40 20 40 60 80 100 120 140 160 180 200 3 2 1 0 1 2 3 Figure 910 Soft decisions with uncompensated flat fading The resulting plot of the soft decisions in Figure 910 obtained via plot1lengthz z shows the effect 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 68 has already introduced an adaptive element designed to compen sate for flat 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 agcvsfadingm on page 128 and combining it with the fading channel just dis cussed 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 94 idsysmod2m modification of idsysm with fading plus automatic gain control dspow r des i r ed average power of s i g n a l l rlength r length of transmitted s i g n a l fp ones 1 floor 0 2 l r 05 ones 1 lr floor 0 2 l r f l a t fading p r o f i l e rr fp apply to transmitted s i g n a l gzeros 1 l r g 11 i n i t i a l i z e gain nrzeros 1 l r mu00003 s t e p s i z e for i 1 lr 1 adaptive AGC element nr i g i r i AGC output g i 1g i mu nr i ˆ2 ds adapt gain end rnr r ecei ved s i g n a l i s s t i l l c a l l e d r Inserting this segment into idsysm immediately after the timevarying fading channel modification 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 plot1lengthzz in Figure 911 shows how quickly after the abrupt fade the soft decisions return Stuff Happens 177 0 20 40 60 80 100 120 140 160 180 200 4 3 2 1 0 1 2 3 4 Figure 911 Soft decisions with an AGC compensating for an abrupt flat fade 26 22 18 14 1 0 04 08 12 16 2 x104 AGC gain parameter Iteration Figure 912 Trajectory of the AGC gain parameter as it moves to compensate for the fade to the appropriate sector Look for where the larger soft decisions exceed a magnitude of 2 Figure 912 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 longterm average Exercise 96 Another idealized assumption made in idsysm is that the receiver knows the start of each frame that is it knows where each four symbol group begins This is a kind of frame synchronization problem and was absorbed into the specification of a parameter l which appears in the code as 05flM With the default settings l is 125 This problem poses the following question What if this is not known and how can it be fixed a Verify using idsysm that the message becomes scrambled if the receiver is mistaken about the start of each group of four Add a random number of 4PAM symbols before the message sequence but do not tell the receiver 178 Chapter 9 Stuff Happens that you have done so ie do not change l What value of l would fix the problem Can l really be known beforehand b Section 85 proposed the insertion of a marker sequence as a way to synchro nize the frame Add a sevensymbol marker sequence just prior to the first character of the text In the receiver implement a correlator that searches for the known marker Demonstrate the success of this modification 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 98 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 find the start of the frames d The previous two exercises showed two possible solutions to the frame synchronization problem Explain the pros and cons of each method and argue which is a better solution 94 Other Impairments More What Ifs Of course a fading channel is not the only thing that can go wrong in a telecom munication system Think back to the what if questions in the first section of this chapter This section considers a range of synchronization and interfer ence impairments that violate the assumptions of the idealized system Though each impairment is studied separately ie assuming that everything functions ideally except for the particular impairment of interest a single program is written to simulate any of the impairments The program impsysm leaves both the transmitter and the basic operation of the receiver unchanged the primary impairments are to the sampled sequence that is delivered to the receiver The rest of this chapter conducts a series of experiments dealing with stuff that can happen to the system Interference is added to the received signal as additive Gaussian channel noise and as multipath interference The oscillator at the transmitter is no longer presumed to be synchronized with the oscillator at the receiver The best sample times are no longer presumed to be known exactly in either phase or period Listing 95 impsysm impairments to the receiver cnginput channel noise gain try 0 06 or 2 cdiinput channel multipath 0 for none 1 for mild or 2 for harsh foinput tranmsitter mixer freq offset in percent try 0 or 001 poinput tranmsitter mixer phase offset in rad try 0 07 or 09 toperinput baud timing offset as percent of symb period try 0 20 or 30 soinput symbol period offset try 0 or 1 Stuff Happens 179 INSERT TRANSMITTER CODE FROM IDSYS M HERE i f cdi 0 5 channel ISI mc1 0 0 di s tor ti on f r e e channel e l s e i f cdi 15 mild multipath channel mc1 zeros 1 M 028 zeros 1 2 3M 0 1 1 else harsh multipath channel mc1 zeros 1 M 028 zeros 1 1 8M 0 4 4 end mcmc sqrt mcmc normalize channel power dvf i l t e r mc 1 r f i l t e r s i g n a l through channel nvdvcng randn size dv add Gaussian channel noi s e tofloor 001 toper M f r a c t i o n a l period delay rnvnv1 to NM delay in onsymbol des i gnati on r t1to M1M length nvM time vector with delayed s t a r t rMMso r e c e i v e r sampler timing o f f s e t INSERT RECEIVER CODE FROM IDSYS M HERE The first few lines of impsysm prompt the user for parameters that define 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 06 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 different delay and amplitude This is implemented by passing the transmitted signal through a filter whose impulse response is specified 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 first If the largest path gain were not first this could be interpreted as a delay between the receipt of the first sample of the first 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 first sample of the message In the ideal system this assumption was correct In impsysm 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 offset 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 differ by a small amount The user specifies the frequency offset 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 difference 180 Chapter 9 Stuff Happens 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 transmit ter oscillator the symbol clock at the receiver need not be properly synchronized with the transmitter symbol period clock Effectively 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 first sample time was read ily calculated using the parameter l But l cannot be known in a real system because the first sample depends for instance on when the receiver is turned on Thus the phase of the symbol clock is unknown at the receiver This impair ment is simulated in impsysm using the timing offset parameter toper which is specified 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 final impairment is specified by the symbol period offset which sets the symbol period at the transmitter to so less than that at the receiver Using impsysm it is now easy to investigate how each impairment degrades the performance of the system 941 Additive Channel Noise Whenever the channel noise is greater than half the gap between two adjacent symbols in the source constellation a symbol error may occur For the constel lation of 1s and 3s if a noise sample has magnitude larger than 1 then the output of the quantizer may be erroneous Suppose that a white broadband noise is added to the transmitted sig nal The spectrum of the received signal which is plotted in Figure 913 via plotspecnv1rM shows a nonzero noise floor compared with the ideal noisefree spectrum in Figure 93 A noise gain factor of cng06 leads to a cluster variance of about 002 and no symbol errors A noise gain of cng2 leads to a cluster variance of about 02 and results in approximately 2 symbol errors When there are 10 symbol errors the reconstructed text becomes undecipher able for the particular coding used in letters2pamm and pam2lettersm Thus as should be expected the performance of the system degrades as the noise is increased It is worthwhile taking a closer look to see exactly what goes wrong The eye diagram for the noisy received signal is shown in Figure 914 which should be compared with the noisefree eye diagram in Figure 98 This is plotted using the following Matlab commands ulfloor length x3 1244rM plot reshape x3 125 ul 4rM124 4rM ul Stuff Happens 181 5 0 50 20 40 60 80 100 Seconds 120 140 160 180 200 Amplitude 5000 4000 3000 2000 1000 050 40 30 20 10 0 Frequency 10 20 30 40 50 Magnitude Figure 913 When noise is added the received signal appears jittery The spectrum has a noticeable noise floor 5 4 3 2 1 0 1 2 3 4 50 50 100 150 200 250 300 350 400 Figure 914 The eye diagram of the received signal x3 repeatedly overlays foursymbolwide segments The channel noise is not insignificant It should be clear from the noisy eye diagram that it would be very difficult to correctly decode the symbols directly from this signal Fortunately the correla tion filter reduces the noise significantly as shown in the eye diagram in Figure 915 This is plotted as before substituting y for x3 Comparing Figures 914 and 915 closely observe that the whole of the latter is shifted over in time by about 50 samples This is the effect of the time delay of the correlator filter which is half the length of the filter Clearly it is much easier to correctly decode using y than using x3 though the pulse shapes of Figure 915 are still blurred when compared with the ideal pulse shapes in Figure 98 Exercise 97 The correlation filter in impsysm is a lowpass filter with impulse response given by the pulse shape p a Plot the frequency response of this filter What is the bandwidth of this filter 182 Chapter 9 Stuff Happens 4 3 2 1 0 1 2 3 40 50 100 150 200 250 300 350 400 Figure 915 The eye diagram of the received signal y after the correlation filter The noise is reduced significantly b Design a lowpass filter using firpm that has the same length and the same bandwidth as the correlation filter c Use your new filter in place of the correlation filter in impsysm Has the performance improved or worsened Explain in detail what tests you have used No peeking ahead to Chapter 11 942 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 different delays and attenuations multipath interference can be modeled as a linear filter Since filters can have complicated frequency responses some frequencies may be attenuated more than others and so this is called frequencyselective fading The mild multipath interference in impsysm has three nonzero paths between the transmitter and the receiver Its frequency response has numer ous 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 916 from plot1lengthzz which should be compared with the ideal con stellation diagram in Figure 99 The effect 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 impsysm also has three paths between the transmitter and receiver but the later reflections 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 effects are considerably more severe The effect of this channel can be seen directly by looking at the constellation diagram of the soft decisions in Figure 917 The constellation diagram is smeared and it is Stuff Happens 183 4 3 2 1 0 1 2 3 40 20 40 60 80 100 120 140 200 160 180 Figure 916 With mild multipath interference the soft decisions can readily be segregated into four stripes that correspond to the four symbol values 4 3 2 1 0 1 2 3 40 20 40 60 80 100 120 140 200 160 180 Figure 917 With harsher multipath interference the soft decisions smear and it is no longer possible to see which points correspond to which of the four symbol values 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 943 Carrier Phase Offset For the receiver in Figure 91 the difference between the phase of the modulating sinusoid at the transmitter and the phase of the demodulating sinusoid at the receiver is the carrier phase offset The effect of a nonzero offset is to scale the received signal by a factor equal to the cosine of the offset as was shown in 54 of Section 52 Once the phase offset is large enough the demodulated signal contracts so that its maximum magnitude is less than 2 When this happens the quantizer always produces a 1 Symbol errors abound 184 Chapter 9 Stuff Happens 2 15 1 05 0 05 1 15 20 20 40 60 80 100 120 140 200 160 180 Figure 918 Soft decisions for harsh carrier phase offset are never greater than 2 The quantizer finds no 3s and many symbol errors occur When running impsysm there are two suggested nonzero choices for the phaseoffset parameter po With po09 cos09 062 and 3 cos09 2 This is shown in the plot of the softdecision errors in Figure 918 For the milder carrier phase offset po07 the soft decisions result in no symbol errors because the quantizer will still decode values at 3 cos07 23 as 3 As long as the constellation diagram retains distinct horizontal stripes all is not lost In Figure 918 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 signal tonoise ratio A better approach is to identify the unknown phase offset as discussed in Chapter 10 Exercise 98 Using impsysm as a basis implement an AGCstyle adaptive element to compensate for a phase offset Verify that your method works for a phase offset of 09 and for a phase offset of 12 Show that the method fails when the phase offset is π2 944 Carrier Frequency Offset The receiver in Figure 91 has a carrier frequency offset when the frequency of the carrier at the transmitter differs from the assumed frequency of the carrier at the receiver As was shown in 55 in Section 52 this impairment is like a modulation by a sinusoid with frequency equal to the offset This modulat ing effect is catastrophic when the lowfrequency modulator approaches a zero crossing since then the gain of the signal approaches zero This effect is apparent for a 001 frequency offset in impsysm in the plot of the soft decisions via plot1lengthzz in Figure 919 This experiment suggests that the receiver mixer frequency must be adjusted to track that of the transmitter Stuff Happens 185 3 2 1 0 1 2 30 20 40 60 80 100 120 140 200 160 180 Figure 919 Soft decisions for 001 carrier frequency offset 945 Downsampler Timing Offset As shown in Figure 97 there is a sequence of best times at which to down sample When the starting point is correct and no intersymbol interference ISI is present as in the ideal system the sample times occur at the top of the pulses When the starting point is incorrect all the sample times are shifted away from the top of the pulses This was set in the ideal simulation using the parameter l with its default value of 125 The timingoffset parameter toper in impsysm is used to offset the received signal Essentially this means that the best value of l has changed though the receiver does not know it This is easiest to see by drawing the eye diagram Figure 920 shows an overlay of foursymbol wide segments of the received signal using the reshape command as in the code on page 173 The receiver still thinks the best times to sample are at l nT but this is clearly no longer true In fact whenever the sample time begins between 100 and 140 and lies in this or any other shaded region there will be errors when quantizing For example all samples taken at 125 lie between 1 and hence no symbols will ever be decoded at their 3 value In fact some even have the wrong sign This is a far worse situation than in the carrier phase impairment because no simple amplitude scaling will help Rather a solution must correct the problem it must slide the times so that they fall in the unshaded regions Because these unshaded regions are wide open this is often called the openeye region The goal of an adaptive element designed to fix the timingoffset problem is to open the eye as wide as possible 946 Downsampler Period Offset When the assumed period of the downsampler is in error there is no hope As mentioned in the previous impairment the receiver believes that the best times 186 Chapter 9 Stuff Happens 3 0 2 50 100 150 200 250 300 350 400 1 0 1 2 3 Assumed best times to take samples Figure 920 Eye diagram with downsampler timing offset of 50 Sample times used by the ideal system are no longer valid and lead to numerous symbol errors to sample are at l nT When there is a period offset it means that the value of T used at the receiver differs from the value actually used at the transmitter The prompt in impsysm for symbol period offset 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 filter 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 offset recall Figure 919 For an offset of 1 the soft decisions are plotted in Figure 921 Can you connect the value of the period of this periodic collapse to the parameters of the simulated example 947 Repairing Impairments When stuff 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 filtering Chapter 11 are intended primarily to counter the effects of noise Equalization Chapter 13 compensates for multipath interference and can reject narrowband interferers Carrier recov ery 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 offset All of these fixes can be viewed as digital signal processing DSP solutions to the impairments explored in impsysm Stuff Happens 187 3 2 1 0 2 3 1 400 350 300 250 200 150 100 50 0 3 2 1 0 2 3 1 200 0 20 40 60 80 100 120 140 160 180 Figure 921 When there is a 1 downsampler period offset all is lost as shown by the eye diagram in the top plot and the soft decisions in the bottom Each of these fixes will be designed separately as if the problem it is intended to counter were the only problem in the world Fortunately somehow they can all work together simultaneously Examining possible interactions between the various fixes which is normally a part of the testing phase of a receiver design will be part of the receiver design project of Chapter 15 95 A B3IG Deal While the idealized communication systems in idsysm and impsysm 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 B3IG as shown in Figure 922 Signal r as it enters the receiver Basic Black Box Impairment Generator MATLAB script defining transmitter parameters Figure 922 The Basic Black Box Impairment Generator or B3IG inputs a Matlab script that specifies the operation of the transmitter along with any desired impairments The output is the received signal r that enters the receiver You can find out how the system operates by peering ahead to Appendix H but we really shouldnt mention it at this point 188 Chapter 9 Stuff Happens The B3IG transmitter is a soupedup version of the idealized transmitters in idsysm and impsysm It allows easy incorporation of a number of impairments singly or in combination and is especially useful when examining possible inter actions between the various receiver strategies and fixes that are discussed in forthcoming chapters Though a complete description of the B3IG transmitter is presented in Appendix H it is probably not useful to jump ahead at this point Better to think of B3IG as a tool for exploration for generating noisy received signals with various userspecified and usercontrolled impairments In keeping with the theme of this chapter there is nothing genuinely new in B3IG the basic building blocks are the same as those in the previous chapters Using the B3IG transmitter is easy just type the command in Listing 96 Listing 96 This code calls the B3IG transmitter The received signal is in r and the transmitted encoded symbols are in s r s BigTransmitter m frameParams rfParams chanParams There are four inputs to the B3IG The message that is to be transmitted is spec ified in the variable m The frame parameters frameParams include a specification 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 idsysm and impsysm 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 97 Listing 97 Parameters in the script BigIdealm allow the B3IG transmission to mimic the idealized system idsysm and impsysm Message Generation m01234 I wish I were an Oscar Meyer wiener 56789 Frame parameters frameParams userDataLength1 frameParams preamble frameParams chanCodingFlag 0 frameParams bitEncodingFlag 0 Channel parameters Adj Users Int chanParams c1 1 0 0 chanParams c2 1 0 0 chanParams randomWalkVariance0 chanParams SNRInf chanParams adjacentUser1PowerInf chanParams a d j a c e n t U s e r 1 f i f 0 chanParams adjacentUser1Chan1 0 0 chanParams adjacentUser2PowerInf chanParams a d j a c e n t U s e r 2 f i f 0 chanParams adjacentUser2Chan1 0 0 chanParams NBIfreq 0 chanParams NBIPowerInf RF Parameters Stuff Happens 189 rfParams f i f e r r 0 rfParams T t er r 0 rfParams phaseNoiseVariance 0 rfParams SRRCLength4 rfParams SRRCrolloff 03 rfParams f s 100 rfParams T t 1 rfParams f i f 20 The channel parameters chanParams specify how the message is distorted as it moves from the transmitter to the receiver Intersymbol interference additive noise and interference from other users can all be modeled by changing these values Finally the RF parameters rfParams specify the parameters used the frequency of the transmitter the symbol rate the size of the pulse shape the intermediate frequency etc All frequency values are specified in Hz and all time values are given in seconds As before the values in BigIdealm of Listing 97 mimic the idealized transmission Exercise 99 One difference between BigIdealm and the received signal in impsysm is that the pulse shape is a squareroot raised cosine pulse instead of a Hamming pulse Run the script and plot the spectrum of the received signal in BigIdealm Compare this with the spectrum of the received signal from impsysm How do the spectra change when the SNR of the additive channel noise is decreased Exercise 910 A rudimentary receiver is provided in Listing 98 Observe that the code makes errors when noise is added because the gain the parameter receiver gain has not been chosen appropriately Find a new choice of gain that permits the receiver to operate errorfree even with the level of noise present How did you find this choice of gain Listing 98 BigIdealm part 2 idealized B3IG receiver Adjustable r e c e i v e r parameters r e c e i v e r g a i n 1 data s tar t 5 Fixed r e c e i v e r parameters M100 upsampling r a t i o f c 20 c a r r i e r frequency s r r c l e n g t h 4 length of pulse shape am demodulation of r ecei ved s i g n a l sequence r c2cos 2 pi f c 1M1M length r M cos i ne f o r mixing x2r c2 demod r ecei ved s i g n a l c o r r e l a t e f i l t e r to extr act upsampled pul s es yf i l t e r s r r c s r r c l ength 0 3 1 0 0 1 x2 f i l t e r with pulse s et delay to f i r s t symbolsample and increment by M zy s r r c l e n g t h MM end downsample to symbol r ate tos s out f i r s t few symbols s c a l e by gain zz data s tar t data s tar tlength m4 1 r e c e i v e r g a i n plot 1 length z z pl ot s o f t d e c i s i o n s d e c i s i o n device and symbol matching performance assessment 190 Chapter 9 Stuff Happens mprimequantalph z 3 1 1 3 quantize to alphabet cvarmprimez mprimez length mprime c l u s t e r variance lmplength mprime per er r 100sum abs sign mprimeletters2pam m lmp symb er r decode d e c i s i o n device output to text s t r i n g reconstructed messagepam2letters mprime Exercise 911 Use the AGC code from agcgradm to find the proper gain for the receiver in BigIdealm If the AGC converges slowly you may wish to use a longer message m Exercise 912 Observe that when the parameter dstart is specified 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 913 How would you change the frame channel or RF parameters to reproduce Figures 916 and 917 Exercise 914 How would you change the frame channel or RF parameters to reproduce Figure 919 Step 4 The Adaptive Components The fourth step describes all the practical fixes 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 fixes for additive noise for timing offset problems for clock frequency mismatches and jitter and for multipath reflections The order in which topics are discussed is the order in which they appear in the receiver Carrier recovery Chapter 10 the timing of frequency translation Receive filtering Chapter 11 the design of pulse shapes Clock recovery Chapter 12 the timing of sampling Equalization Chapter 13 filters that adapt to the channel Coding Chapter 14 making data resilient to noise 10 Carrier Recovery Figure 101 shows a generic transmitter and receiver pair that emphasizes the modulation and corresponding demodulation Even assuming that the transmis sion path is ideal as in Figure 101 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 figure out both the frequency and the phase of the modulating sinusoid used in the transmitter as was shown in 54 and 55 and graphically illustrated in Figures 918 and 919 This chapter discusses a variety of strategies that can be used to estimate the phase and frequency of the carrier and to fix the gain problem of 54 and Figure 918 and the problem of vanishing amplitudes in 55 and Figure 919 This process of estimating the frequency and phase of the carrier is called carrier recovery Figure 101 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 ana log 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 expen sive 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 offset 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 193 Pulse shaping Message mkT Modulation Received signal Ts Analog conversion to IF Digital down conversion to baseband Resampling Decision Reconstructed message mkT T Timing synchronization τ Frequency and phase tracking f0 θ fc φ Figure 101 Diagram of a communications system emphasizing the need for synchronization with the frequency fc and phase φ of the carrier The frequencytracking element adjusts the parameter f0 in an attempt to match fc and the phasetracking element adjusts the parameter θ in an attempt to match φ the transmitter with the frequency of the oscillator at the receiver Since the goal is to find the frequency and phase of a signal why not use a Fourier transform or more properly an FFT Section 101 shows how to isolate a sinusoid that is at twice the frequency of the carrier by squaring and filtering 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 esti mated 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 dis cussed in Section 102 is the square of the difference between the received signal and a locally generated sinusoid Another performance function leads to the wellknown phaselocked loop which is discussed in depth in Section 103 and yet another performance function leads to the Costas loop of Section 104 An alternative approach uses the decisiondirected method detailed in Section 105 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 appro priate error surface This approach should be familiar from Chapter 6 where it was used in the design of the AGC Section 106 then shows how to modify the adaptive elements to attack the frequencyestimation problem Three ways are shown The first tries unsuc cessfully 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 1062 uses two loops Since the phase of a sinusoid is the derivative of its frequency the first loop tracks a line the frequency offset and the second loop finetunes the estimation of the phase The third technique in Section 1063 shows how 194 Chapter 10 Carrier Recovery the dualloop method can be simplified and generalized by using an integrator within a single phaselocked loop This forms the basis for an effective adaptive frequencytracking element 101 Phase and Frequency Estimation via an FFT As indicated in Figure 101 the received signal consists of a message mkT modulated by the carrier In the simplest case when the modulation uses AM with a large carrier as in Section 51 it may be quite easy to locate the carrier and its phase More generally however the carrier will be well hidden within the received signal and some kind of extra processing will be needed to bring it to the foreground To see the nature of the carrierrecovery problem explicitly the following code generates two different received signals the first is AM modulated with large carrier and the second is AM modulated with suppressed carrier The phase and frequencies of both signals can be recovered using an FFT though the suppressedcarrier scheme requires additional processing before the FFT can successfully be applied Drawing on the code in pulseshapem on page 156 and modulating with the carrier c pulrecsigm creates the two different received signals The pam command creates a random sequence of symbols drawn from the alphabet 1 3 and then uses hamming to create a pulse shape1 The oversampling factor M is used to simulate the analog portion of the transmission and MTs is equal to the symbol time T Listing 101 pulrecsigm make pulseshaped signal N10000 M20 Ts0001 symbols oversampling f a c t o r timeTsNM tTs Ts time sampling i n t e r v a l time vector mpamN 4 5 4 l e v e l s i g n a l of length N mupzeros 1 NM mup 1 MNMm oversample by i n t e g e r length M pshamming M bl i p pulse of width M sf i l t e r ps 1 mup convolve pulse shape with data f c 1000 phoff 10 c a r r i e r f r eq and phase ccos 2 pi f c tphoff construct c a r r i e r r s cs c modulated s i g n a l small c a r r i e r r l c s 1c modulated s i g n a l l ar ge c a r r i e r Figure 102 plots the spectra of the large and suppressedcarrier 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 cf f t r l c spectrum of r l c m imaxmax abs f f t r l c 1 end 2 index of max peak s s f 0 length t 1Tslength t frequency vector 1 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 195 0 1000 2000 3000 4000 5000 0 1000 2000 3000 4000 5000 0 1000 2000 3000 4000 5000 Figure 102 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 suppressedcarrier method in the middle plot the carrier is not clearly visible After preprocessing of the suppressedcarrier signal using the scheme in Figure 103 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 freqLs s f imax f r eq at the peak phaseLangle f f t r l c imax phase at the peak Changing the default phase offset 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 suppressed carrier signal does not recover the phase offset In fact the maximum often occurs at frequencies other than the carrier and the phase values reported bear no resemblance to the desired phase offset 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 filter as shown in Figure 103 When the received signal rt consists of the pulse modulated data signal st times the carrier cos2πfct φ the output of the squaring block is r2t s2t cos22πfct φ 101 This can be rewritten using the identity 2 cos2x 1 cos2x in A4 to pro duce r2t 12s2t1 cos4πfct 2φ Rewriting s2t as the sum of its positive average value and the variation about this average yields s2t s2 avg vt 196 Chapter 10 Carrier Recovery Thus r2t 12s2 avg vt s2 avg cos4πfct 2φ vt cos4πfct 2φ A narrow bandpass filter centered near 2fc passes the pure cosine term in r2 and suppresses the DC component the presumably lowpass vt and the upcon verted vt The output of the bandpass filter is approximately rpt BPFr2t 1 2s2 avg cos4πfct 2φ ψ 102 where ψ is the phase shift added by the BPF at frequency 2fc Since ψ is known at the receiver rpt can be used to find the frequency and phase of the carrier Of course the primary component in rpt 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 rpt undulates slowly as s2 avg changes The following Matlab code carries out the preprocessing of Figure 103 First run pulrecsigm to generate the suppressed carrier signal rsc Listing 102 pllpreprocessm send received signal through square and BPF rr s c suppressed c a r r i e r r qr ˆ 2 square n o n l i n e a r i t y f l 500 f f 0 38 39 41 42 1 BPF center frequency at 4 fa 0 0 1 1 0 0 which i s twice f c hfirpm f l f f fa BPF design via firpm rpf i l t e r h 1 q f i l t e r gi ves preprocessed r Then the phase and frequency of rp can be found directly by using the FFT recover unknown f r eq and phase using FFT fftrBPFf f t rp spectrum of rBPF m imaxmax abs fftrBPF 1 end 2 f i nd f r eq of max peak s s f 0 length rp Tslength rp frequency vector freqSs s f imax f r eq at the peak phasepangle fftrBPF imax phase at the peak IR f f r eqz h 1 length rp 1Ts f r eq response of f i l t e r mi immin abs ffreqS f r eq where peak occurs phaseBPFangle IR im of BPF at peak f r eq phaseSmod phasepphaseBPF pi 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 estima tion The intent of this section is to clearly depict the problem of recovering the fre quency and phase of the carrier even when it is buried within the datamodulated 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 197 X2 BPF rt r2t Squaring nonlinearity Center frequency 2fc rpt cos4π fc t 2φ ψ Figure 103 Preprocessing the input to a PLL via a squaring nonlinearity and BPF results in a sinusoidal signal at twice the frequency with a phase offset equal to twice the original plus a term introduced by the known bandpass filtering Exercise 101 The squaring nonlinearity is only one possibility in the pllpreprocessm routine a Try replacing the r2t with rt Does this result in a viable method of emphasizing the carrier b Try replacing the r2t with r3t Does this result in a viable method of emphasizing the carrier c Can you think of other functions that will result in viable methods of empha sizing the carrier d Will a linear function work Why or why not Exercise 102 Determine the phase shift ψ at the frequency 2fc caused by the BPF when a fl490 496 502 b Ts00001 0000101 c M19 20 21 Explain why ψ should depend on fl Ts and M 102 Squared Difference Loop The problem of phase tracking is to determine the phase φ of the carrier and to follow any changes in φ using only the received signal The frequency fc of the carrier is assumed known though ultimately it too must be estimated The received signal can be preprocessed as in the previous section to create a signal that strips away the data in essence fabricating a sinusoid which has twice the frequency at twice the phase of the unmodulated carrier This can be idealized to rpt cos4πfct 2φ 103 which suppresses2 the dependence on the known phase shift ψ of the BPF and sets the constant s2 avg2 to unity compare with 102 The form of rpt 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 103 What can be done to recover φ modulo π from rpt 2 An example that takes ψ into account is given in Exercise 108 Is there some way to use an adaptive element Section 65 suggested that there are three steps to the creation of a good adaptive element setting a goal finding a method and then testing As a first try consider the goal of minimizing the average of the squared difference between rpt and a sinusoid generated using an estimate of the phase that is seek to minimize JSDθ avge²θ k 14 avgrpkTs cos4πf0kTs 2θ² 104 by choice of θ where rpkTs is the value of rpt sampled at time kTs and where f0 is presumed equal to fc The subscript SD stands for squared difference 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 rpkTs cos4πf0kTs 2θ eθ k 0 and so JSDθ 0 Hence 104 is minimized when θ has correctly identified the phase offset modulo the inevitable π ambiguity While there are many methods of minimizing 104 an adaptive element that descends the gradient of the performance function JSDθ leads to the algorithm³ θk 1 θk μ dJSDθdθ θθk 105 which is the same as 65 with the variable changed from x to θ Using the approximation detailed in G12 which holds for small μ the derivative and the average commute Thus dJSDθdθ d avge²θ kdθ avgde²θ kdθ 12 avgeθ k deθ kdθ avgrpkTs cos4πf0kTs 2θ sin4πf0kTs 2θ 106 Substituting this into 105 and evaluating at θ θk gives⁴ θk 1 θk μ avgrpkTs cos4πf0kTs 2θk sin4πf0kTs 2θk 107 This is implemented in pllsdm for a phase offset of phoff08 ie ϕ of 103 is 08 though this value is unknown to the algorithm Figure 104 plots the estimates theta for 50 different initial guesses theta1 Observe that many converge to the correct value at 08 Others converge to 08 π about 23 and to 08 π about 4 Listing 103 pllsdm phase tracking minimizing SD Ts110000 time1 t0TstimeTs time interval vector ³ Recall the discussion surrounding the AGC elements in Chapter 6 ⁴ Recall the convention that θk θkTs θttkTs Carrier Recovery 199 1 2 Phase offset 3 4 5 Time 6 7 8 9 10 0 3 2 1 0 1 2 3 Figure 104 The phasetracking algorithm 107 converges to the correct phase offset in this case 08 or to some multiple 08 nπ depending on the initial estimate f c 100 phoff 08 c a r r i e r f r eq and phase rpcos 4 pi f c t2 phoff s i m p l i f i e d rec s i g n a l mu001 algorithm s t e p s i z e thetazeros 1 length t theta 10 i n i t i a l i z e estimates f l 25 hones 1 f l f l averaging c o e f f i c i e n t s zzeros 1 f l f0f c b u f f e r f o r avg for k1 length t1 run algorithm f i l t i n rp kcos 4 pi f0 t k2 theta k sin 4 pi f0 t k2 theta k zz 2 f l f i l t i n z contains past inputs theta k1theta kmu f l i p l r h z update z convolve h end Observe that the averaging a kind of lowpass filter as discussed in Appendix G is not implemented using the filter or conv commands because the complete input is not available at the start of the simulation Instead the timedomain method is used and the code here may be compared to the fourth method in waystofiltm on page 143 At each time k there is a vector z of past inputs These are multiplied point by point with the impulse response h which is flipped in time so that the sum properly implements a convolution Because the filter is just a moving average the impulse response is constant 1fl over the length of the filtering Exercise 103 Use the preceding code to play with the SD phasetracking algorithm a How does the stepsize mu affect the convergence rate b What happens if mu is too large say mu10 c Does the convergence speed depend on the value of the phase offset d How does the final converged value depend on the initial estimate theta1 Exercise 104 Investigate these questions by making suitable modifications to pllsdm 200 Chapter 10 Carrier Recovery a What happens if the phase slowly changes over time Consider a slow small amplitude undulation in phoff b Consider a slow linear drift in phoff c What happens if the frequency f0 used in the algorithm is slightly different from the frequency fc used to construct the carrier d What happens if the frequency f0 used in the algorithm is greatly different from the frequency fc used to construct the carrier Exercise 105 How much averaging is necessary Reduce the length of the averaging filter Is it possible to make the algorithm work with no averaging Why does this work Hint yes it is possible Consider the relationship between 107 and G4 Exercise 106 Derive 106 following the technique used in Example G3 The performance function JSDθ of 104 provides a mathematical statement of the goal of an adaptive phasetracking element The method is defined by the algorithm 107 and simulations such as pllsdm suggest that the algorithm can function as desired But why does it work One way to understand adaptive elements as discussed in Section 66 and shown in Figure 617 on page 119 is to draw the error surface for the per formance 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 rpkTs as well as the estimate θ Recognizing that the averaging operation acts as a kind of lowpass filter see Appendix G if this makes you nervous allows considerable simplification of JSDθ Rewrite 104 as JSDθ 1 4 LPFrpkTs cos4πf0kTs 2θ2 108 Substituting rpkTs from 103 and assuming fc f0 this can be rewritten JSDθ 1 4 LPFcos4πf0kTs 2φ cos4πf0kTs 2θ2 Expanding the square gives JSDθ 1 4 LPFcos24πf0kTs 2φ 2 cos4πf0kTs 2φ cos4πf0kTs 2θ cos24πf0kTs 2θ Using the trigonometric formula A4 for the square of a cosine and the formula A13 for the cosine angle sum ie expand cosx y with x 4πf0kTs and y 2φ and then again with y 2θ yields JSDθ 1 8 LPF2 cos8πf0kTs 4φ 2 cos2φ 2θ 2 cos8πf0kTs 2φ 2θ cos8πf0kTs 4θ Carrier Recovery 201 4 04 04 04 0 08 0 2 0 2 Phase estimates θ JPLL 0 08 04 JSD JC 4 6 8 Figure 105 The error surface 109 for the SD phasetracking algorithm is shown in the top plot Analogous error surfaces for the phaselocked loop 1011 and the Costas loop 1013 are shown in the middle and bottom plots All have minima or maxima at the desired locations in this case 08 plus nπ offsets Since the LPF is linear 1 4 1 8 LPFcos8πf0kTs 4φ 1 4 LPFcos2φ 2θ 1 4 LPFcos8πf0kTs 2φ 2θ 1 8 LPFcos8πf0kTs 4θ Assuming that the cutoff frequency of the lowpass filter is less than 4f0 this simplifies to JSDθ 1 41 cos2φ 2θ 109 which is shown in the top plot of Figure 105 for φ 08 The algorithm 107 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 θ 08 nπ for some n Thus Figure 105 provides evidence that the algorithm can successfully locate the unknown phase assuming that the preprocessed signal rpt has the form of 103 Figure 106 shows the algorithm 107 with the averaging operation replaced by the more general LPF In fact this provides a concrete answer to Exercise 105 the averaging the LPF and the integral block all act as lowpass filters All that was required of the filtering in order to arrive at 109 from 108 was that it remove frequencies above 4f0 This mild requirement is accomplished even by the integrator alone Exercise 107 The code in pllsdm is simplified in the sense that the received signal rp contains just the unmodulated carrier Implement a more realistic scenario by combining pulrecsigm to include a binary message sequence pllpreprocessm to create rp and pllsdm to recover the unknown phase offset of the carrier 202 Chapter 10 Carrier Recovery LPF 2 µΣ sin4πf0kTs 2θk cos4πf0kTs 2θk θk rpkTs Figure 106 A block diagram of the squareddifference phasetracking algorithm 107 The input rpkTs is a preprocessed version of the received signal as shown in Figure 103 The integrator block Σ has a lowpass character and is equivalent to a sum and delay as shown in Figure 75 Exercise 108 Using the default values in pulrecsigm and pllpreprocessm results in a ψ of zero Exercise 102 provided several situations in which ψ 0 Modify pllsdm to allow for nonzero ψ and verify the code for the cases suggested in Exercise 102 Exercise 109 Investigate how the SD algorithm performs when the received signal contains pulseshaped 4PAM data Can you choose parameters so that θ φ Exercise 1010 Consider the sampled cosine wave xkTs cos2πf0kTs α where the frequency f0 is known but the phase α is not Form vkTs xkTs cos2πf0kTs βk using the current ie at the kth sample instant estimate βk of α and define the candidate performance function Jβ LPFv2kTs where the cutoff frequency of the ideal lowpass filter is 08f0 a Does minimizing or maximizing Jβ result in β α Justify your answer b Develop a smallstepsize gradientdescent algorithm for updating βk to esti mate α Be certain that all of the signals needed to implement this algorithm are measurable quantities For example x is directly measurable but α is not c Determine the range of the initial guesses for βk in the algorithm of part b that will lead to the desired convergence to α given a suitably small stepsize 103 The PhaseLocked Loop Perhaps the bestloved method of phase tracking is known as the phaselocked loop PLL This section shows that the PLL can be derived as an adaptive element ascending the gradient of a simple performance function The key idea is to modulate the processed received signal rpt of Figure 103 down to DC using a cosine of known frequency 2f0 and phase 2θ ψ After filtering to remove the highfrequency 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 rpt To be specific let JPLLθ 12 LPFrpkTs cos4πf0kTs 2θ ψ 1010 Using the cosine product relationship A9 and the definition of rpt from 103 under the assumption that fc f0 JPLLθ 12 LPFcos4πf0kTs 2ϕ ψ cos4πf0kTs 2θ ψ 14 LPFcos2ϕ 2θ cos8πf0kTs 2θ 2ϕ 2ψ 14 LPFcos2ϕ 2θ 14 LPFcos8πf0kTs 2θ 2ϕ 2ψ 14 cos2ϕ 2θ 1011 assuming that the cutoff frequency of the lowpass filter is well below 4f0 This is shown in the middle plot of Figure 105 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 find the correct answer JPLLθ needs to be maximized The substantive difference 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 1010 with respect to θ at time k can be approximated using G12 as dLPFrpkTs cos4πf0kTs 2θ ψdθ θθk LPF drpkTs cos4πf0kTs 2θ ψdθ θθk LPFrpkTs sin4πf0kTs 2θk ψ The corresponding adaptive element θk 1 θk μ LPFrpkTs sin4πf0kTs 2θk ψ 1012 is shown in Figure 107 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 difference between the PLL and SD algorithms is clear from a comparison of Figures 106 and 107 The PLL requires one fewer oscillator and one fewer addition block Since the performance functions JSDθ and JPLLθ are effectively the same the performance characteristics of the two are roughly equivalent 204 Chapter 10 Carrier Recovery sin4πf0kTs 2θk ψ LPF Fz 2 µΣ θk rpkTs ek Figure 107 A block diagram of the digital phaselockedloop algorithm 1012 The input signal rpkTs has already been preprocessed to emphasize the carrier as in Figure 103 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 lowfrequency energy Suppose that fc is the frequency of the transmitter and f0 is the assumed frequency at the receiver with f0 close to fc The following program simulates 1012 for time seconds Note that the firpm filter creates an h with a zero phase at the center frequency and so ψ is set to zero Listing 104 pllconvergem simulate PhaseLocked Loop Ts110000 time 1 tTs Ts time time vector f c 1000 phoff 08 c a r r i e r f r eq and phase rpcos 4 pi f c t2 phoff s i m p l i f i e d rec d s i g n a l f l 100 f f 0 01 02 1 fa 1 1 0 0 hfirpm f l f f fa LPF design mu003 algorithm s t e p s i z e f0 1000 f r eq at r e c e i v e r thetazeros 1 length t theta 10 i n i t i a l i z e estimates zzeros 1 f l 1 i n i t i a l i z e LPF for k1length t1 z contains past inputs zz 2 f l 1 rp k sin 4 pi f0 t k2 theta k updatef l i p l r h z new output of LPF theta k1 theta kmuupdate algorithm update end Figures 108a 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 offset φ 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 definite trend the simulation in Figure 108b used f0 1000 Hz and fc 1001 Hz Can you figure out how the slope of θ relates to the frequency offset The caption in Figure 108b provides a hint Can you imagine how the PLL might be used to estimate the frequency as well as to find the phase offset These questions and more will be answered in Section 106 Exercise 1011 Use the preceding code to play with the phaselockedloop algorithm How does µ affect the convergence rate How does µ affect the oscil lations in θ What happens if µ is too large say µ 1 Does the convergence speed depend on the value of the phase offset Carrier Recovery 205 08 0 02 04 Time a b 06 08 1 06 Phase offset 04 02 0 80 2 4 Time 6 8 10 6 4 2 0 Figure 108 Using the PLL the estimates θ in a converge to a region about the phase offset φ and then oscillate When the frequency estimate is incorrect as in b θ becomes a line whose slope is proportional to the frequency difference Exercise 1012 In pllconvergem how much filtering is necessary Reduce the length of the filter Does the algorithm still work with no LPF Why How does your filter affect the convergent value of the algorithm How does your filter affect the tracking of the estimates when f0 fc Exercise 1013 The code in pllconvergem is simplified in the sense that the received signal rp contains just the unmodulated carrier Implement a more real istic scenario by combining pulrecsigm to include a binary message sequence pllpreprocessm to create rp and pllconvergem to recover the unknown phase offset of the carrier Exercise 1014 Using the default values in pulrecsigm and pllpreprocessm results in a ψ of zero Exercise 102 provided several situations in which ψ 0 Modify pllconvergem to allow for nonzero ψ and verify the code on the cases suggested in Exercise 102 Exercise 1015 TRUE or FALSE The optimum settings of phase recovery for a PLL operating on a preprocessed ie squared and narrowly bandpassfiltered at twice the carrier frequency received PAM signal are unaffected by the channel transfer function outside a narrow band around the carrier frequency Exercise 1016 Investigate how the PLL algorithm performs when the received signal contains pulseshaped 4PAM data Can you choose parameters so that θ φ Exercise 1017 Many variations on the basic PLL theme are possible Let ting ukTs rpkTs cos4πf0kTs θ the preceding PLL corresponds to a per formance function of JP LLθ LPFukTs Consider the alternative Jθ LPFu²kTs which leads directly to the algorithm⁵ θk 1 θk μ LPF ukTs dukTsdθ θθk which is θk 1 θk μLPFr²pkTs sin4πf0kTs 2θk cos4πf0kTs 2θk a Modify the code in pllconvergem to play with this variation on the PLL Try a variety of initial values theta1 Are the convergent values always the same as with the PLL b How does μ affect the convergence rate c How does μ affect the oscillations in θ d What happens if μ is too large say μ 1 e Does the convergence speed depend on the value of the phase offset f What happens when the LPF is removed set equal to unity g Draw the corresponding error surface Exercise 1018 Consider the alternative performance function Jθ ukTs where ukTs is defined in Exercise 1017 Derive the appropriate adaptive element and implement it by imitating the code in pllconvergem In what ways is this algorithm better than the standard PLL In what ways is it worse The PLL can be used to identify the phase offset of the carrier It can be derived as a gradient descent on a particular performance function and can be investigated via simulation with variants of pllconvergem for instance When the phase offset changes the PLL can track the changes up to some maximum rate Conceptually tracking a small frequency offset is identical to tracking a changing phase and Section 106 investigates how to use the PLL as a building block for the estimation of frequency offsets Section 1063 also shows how a linearized analysis of the behavior of the PLL algorithm can be used to concretely describe the convergence and tracking performance of the loop in terms of the implementation of the LPF ⁵ This is sensible because values of θ that minimize u²kTs also minimize ukTs received signal rkTs skTs cos2πfckTs ϕ by reversing the order of the processing first modulating to DC then lowpass filtering and finally squaring This reversal of operations leads to the performance function JCθ avgLPFrkTs cos2πf0kTs θ2 1013 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 103 To see why this works suppose that fc f0 and substitute rkTs into 1013 JCθ avgLPFskTs cos2πf0kTs ϕ cos2πf0kTs θ2 Assuming that the cutoff of the LPF is larger than the absolute bandwidth of skTs and following the same logic as in 1011 but with ϕ instead of 2ϕ θ in place of 2θ and 2πf0kTs replacing 4πf0kTs shows that LPFskTs cos2πf0kTs ϕ cos2πf0kTs θ 12 LPFskTs cosϕ θ 1014 Substituting 1014 into 1013 yields JCθ avg12 skTs cosϕ θ2 14 avgs2kTs cos2ϕ θ 14 savg2 cos2ϕ θ where savg2 is the fixed average value of the square of the data sequence skTs Thus JCθ is proportional to cos2ϕ θ This performance function is plotted for an unknown phase offset of ϕ 08 in the bottom part of Figure 105 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 JPLL because cos2ϕ θ 121 cos2ϕ 2θ as shown using A4 The Costas loop can be implemented as a standard adaptive element 105 The derivative of JCθ is approximated by swapping the order of the differentiation and the averaging as in G12 applying the chain rule and then swapping the derivative with the LPF Thus dJCθdθ can be approximated as avgdLPFrkTs cos2πf0kTs θ2dθ 2 avgLPFrkTs cos2πf0kTs θ dLPFrkTs cos2πf0kTs θdθ 2 avgLPFrkTs cos2πf0kTs θ LPFdrkTs cos2πf0kTs θdθ 2 avgLPFrkTs cos2πf0kTs θ LPFrkTs sin2πf0kTs θ Accordingly an implementable version of the Costas loop can be built as θk 1 θk μ dJCθdθ θθk θk μ avgLPFrkTs cos2πf0kTs θk LPFrkTs sin2πf0kTs θk This is diagrammed in Figure 109 leaving off the first or outer averaging operation as is often done since it is redundant given the averaging effect of the two LPFs and the averaging effect inherent in the smallstepsize update With this averaging removed the algorithm is θk 1 θk μLPFrkTs cos2πf0kTs θk LPFrkTs sin2πf0kTs θk 1015 Basically there are two paths The upper path modulates by a cosine and then lowpass filters to create 1014 while the lower path modulates by a sine wave and then lowpass filters to give skTs 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 4PAM transmitted signal r is created as in pulrecsigm from page 194 with carrier frequency fc1000 The Costasloop phasetracking method 1015 can be implemented in much the same way that the PLL is implemented in pllconvergem Listing 105 costasloopm simulate the Costas loop with input from pulrecsigm rrsc rsc from pulrecsigm fl500 ff0 01 02 1 fa1 1 0 0 hfirpmflfffa LPF design mu003 algorithm stepsize f01000 freq at receiver thetazeros1lengtht theta10 estimate vector zszeros1fl1 zczeros1fl1 buffers for LPFs for k1lengtht1 z contains past inputs Carrier Recovery 209 0 04 08 12 16 Time 4 3 2 1 0 1 2 3 Phase offset Figure 1010 Depending on where it is initialized the estimates made by the Costasloop algorithm converge to φ nπ For this plot the unknown φ was 08 and there were 50 different initializations zs zs 2 f l 1 2 r k sin 2 pi f0 t ktheta k zc zc 2 f l 1 2 r k cos 2 pi f0 t ktheta k l p f sf l i p l r h zs l p f cf l i p l r h zc output of f i l t e r s theta k1theta kmu l p f s l p f c algorithm update end Typical output of costasloopm is shown in Figure 1010 which shows the evolution of the phase estimates for 50 different starting values theta1 Some of these converge to φ 08 and others converge to nearby π multiples These stationary points occur at all the maxima of the error surface the bottom plot in Figure 105 When the frequency is not exactly known the phase estimates of the Costas algorithm try to follow For example in Figure 1011 the frequency of the carrier is fc 1000 while the assumed frequency at the receiver was f0 10001 Fifty different starting points are shown and in all cases the estimates converge to a line Section 106 shows how this linear phase motion can be used to estimate the frequency difference Exercise 1019 Use the preceding code to play with the Costasloop algo rithm a How does the stepsize mu affect the convergence rate b What happens if mu is too large say mu1 c Does the convergence speed depend on the value of the phase offset d When there is a small frequency offset what is the relationship between the slope of the phase estimate and the frequency difference Exercise 1020 How does the filter h influence the performance of the Costas loop 210 Chapter 10 Carrier Recovery 0 04 08 12 16 2 Time Phase offset 6 4 2 0 2 4 Figure 1011 When the frequency of the carrier is unknown at the receiver the phase estimates converge to a line a Try fl1000 30 10 3 b Remove the LPFs completely from costasloopm How does this affect the convergent values and the tracking performance Exercise 1021 Oscillators that can adjust their phase in response to an input signal are more expensive than freerunning oscillators Figure 1012 shows an alternative implementation of the Costas loop a Show that this is actually carrying out the same calculations albeit in a different order as the implementation in Figure 109 b Write a simulation or modify costasloopm to implement this alternative Exercise 1022 Reconsider the modified PLL of Exercise 1017 This algorithm also incorporates a squaring operation Does it require the preprocessing step of Figure 103 Why Exercise 1023 TRUE or FALSE Implementing a Costasloop phaserecovery scheme on the preprocessed version ie squared and narrowly bandpassfiltered at twice the carrier frequency of a received PAM signal results in one and only one local minimum in any 179 window of the adjusted phase In some applications the Costas loop is considered a better solution than the standard PLL because it can be more robust in the presence of noise 105 DecisionDirected Phase Tracking A method of phase tracking that works only in digital systems exploits the error between the received value and the nearest symbol For example suppose that Carrier Recovery 211 LPF LPF cosθk cosθk sinθk µΣ 2cos2πf0kT 2sin2πf0kT θk rkTs 1 Figure 1012 An alternative implementation of the Costas loop trades off less expensive oscillators for a more complex structure as discussed in Exercise 1021 a 09 is received in a binary 1 system suggesting that a 1 was transmitted Then the difference between the 09 and the nearest symbol 1 provides infor mation that can be used to adjust the phase estimate This method is called decisiondirected DD because the decisions the choice of the nearest allow able symbol direct or drive the adaptation To see how this works let st be a pulseshaped signal created from a message in which the symbols are chosen from some finite alphabet At the transmitter st is modulated by a carrier at frequency fc with unknown phase φ creating the signal rt st cos2πfct φ At the receiver this signal is demodulated by a sinusoid and then lowpass filtered to create xt 2 LPFst cos2πfct φ cos2πf0t θ 1016 As shown in Chapter 5 when the frequencies f0 and fc and phases φ and θ are equal then xt st In particular xkTs skTs at the sample instants t kTs where the skTs are elements of the alphabet On the other hand if φ θ then xkTs will not be a member of the alphabet The difference between what xkTs is and what it should be can be used to form a performance function and hence a phasetracking algorithm A quantization function Qx is used to find the nearest element of the symbol alphabet The performance function for the decisiondirected method is JDDθ 1 4 avgQxk xk2 1017 This can be used as the basis of an adaptive element by using the approximation G12 to calculate dJDDθdθ 14 avgdQxk xk2dθ 12 avgQxk xk dxkdθ which assumes that the derivative of Q with respect to θ is zero The derivative of xk can similarly be approximated as recall that xk xkTs xttkTs is defined in 1016 dxkdθ 2 LPFrk sin2πfckTs θ Thus the decisiondirected algorithm for phase tracking is θk 1 θk μ avgQxk xk LPFrk sin2πf0kTs θk Suppressing the redundant outer averaging operation gives θk 1 θk μQxk xk LPFrk sin2πf0kTs θk 1018 which is shown in block diagram form in Figure 1013 Suppose that a 4PAM transmitted signal rsc is created as in pulrecsigm from page 194 with oversampling factor M20 and carrier frequency fc1000 Then the DD phasetracking method 1018 can be simulated Listing 106 pllddm decisiondirected phase tracking fl100 fbe0 2 3 1 LPF parameters damps1 1 0 0 hfirpmflfbedamps impulse response fzczeros1fl1fzszeros1fl1 initialize filters thetazeros1N theta109 initial phase mu03 j1 f0fc algorithm stepsize for k1lengthrsc cc2cos2pif0tkthetaj cosine for demod ss2sin2pif0tkthetaj sine for demod rcrsckcc rsrsckss do the demods fzcfzc2fl1rc states for LPFs fzsfzs2fl1rs Carrier Recovery 213 xk f l i p l r h fzc LPF gi ves x xderf l i p l r h fzs i t s d e r i v a t i v e i f mod0 5 f lM2k M0 downsample f o r timing qxquantalph xk 3 1 1 3 quantize to alphabet theta j 1theta j mu qxxk xder algorithm update jj 1 end end The same lowpass filter is used after demodulation with the cosine to create x and with the sine to create its derivative xder The filtering is done using the timedomain method the fourth method presented in waystofiltm on page 143 because the demodulated signals are unavailable until the phase estimates are made One subtlety in the decisiondirected phasetracking 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 1018 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 Tsrate sampled data points The output of pllddm for many different starting values is shown in Figure 1014 For initializations near the correct answer φ 10 the estimates con verge to 10 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 N1000 symbols drawn from the 4PAM alphabet Listing 107 plldderrsysm error surface for decisiondirected phase tracking N1000 average over N symbols mpamN 4 5 use 4PAM symbols phi 10 unknown phase o f f s e t phi theta 2016 gr i d f o r phase estimates for k1 length theta f o r each p o s s i b l e theta xmcos phitheta k f i nd x with t h i s theta qxquantalph x 3 1 1 3 q x f o r t h i s theta j theta kqxx qxx N J f o r t h i s theta end plot theta j theta The output of plldderrsysm is shown in Figure 1015 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 φ 10 2nπ and the other at φ 10 π 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 214 Chapter 10 Carrier Recovery 0 1 2 3 4 5 4 3 2 1 0 1 2 Time Phase estimates 5 Figure 1014 The decisiondirected tracking algorithm is adapted to locate a phase offset of φ 10 Many of the different initializations converge to φ 10 nπ but there are also other convergent values 2 1 0 1 2 3 4 5 6 0 02 04 06 08 1 Phase estimates θ Cost JDDθ Figure 1015 The error surface for the DD phasetracking algorithm 1018 has several minima within each 2π repetition The phase estimates will typically converge to the closest of these minima of 1 This inverts each data symbol 1 is mapped to 1 and 3 is mapped to 3 The other four occur near π multiples of 3π8 10 and 5π8 10 which correspond to values of the cosine that jumble the data sequence in various ways The implication of this error surface is clear there are many values to which the decisiondirected method may converge Only some of these correspond to desirable answers Thus the DD method is local in the same way that the steepest descent minimization of the function 68 in Section 66 depends on the initial value of the estimate If it is possible to start near the desired answer then convergence can be assured However if no good initialization is possible the method may converge to one of the undesirable minima This suggests that the decisiondirected method can perform acceptably in a tracking mode when following a slowly varying phase but would perform worse than the alternatives at startup when nothing is known about the correct value of the phase Carrier Recovery 215 Exercise 1024 Use the code in pllddm 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 fre quency fc of the carrier Exercise 1025 The direct calculation of dxkTsdθ as a filtered version of 1016 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 pllddm Exercise 1026 Consider the DD phasetracking algorithm when the message alphabet is binary 1 a Modify pllddm to simulate this case b Modify plldderrsysm to draw the error surface Is the DD algorithm better or worse suited to the binary case than the 4PAM case Exercise 1027 Consider the DD phasetracking algorithm when the message alphabet is 6PAM a Modify pllddm to simulate this case b Modify plldderrsysm to draw the error surface Is the DD algorithm better or worse suited to 6PAM than to 4PAM Exercise 1028 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 1029 Investigate how the error surface depends on the input signal a Draw the error surface for the DD phasetracking algorithm when the inputs are binary 1 b Draw the error surface for the DD phasetracking algorithm when the inputs are drawn from the 4PAM constellation for the case in which the symbol 3 never occurs Exercise 1030 TRUE or FALSE Decisiondirected phase recovery can exhibit local minima of different depths Exercise 1031 This problem uses the B3IG to test the carrierrecovery algo rithm of your choice a Currently the receiver portion of the script in BigIdealm knows the phase of the carrier Add a carrierrecovery algorithm of your choice to BigIdealm 216 Chapter 10 Carrier Recovery so that the receiver can accommodate unknown carrier phases Run the mod ified code and use the carrierrecovery algorithm to estimate the phase offset φ State the carrierrecovery method used and plot the tracking of φ If the receiver employs preprocessing take care to design the BPF appropriately b Modify the B3IG so that a phase offset is introduced In BigTransmitterm set the variable phi05 and add a phase offset xrfxcos2pirfParamsfiftx 1lengthxrfParamsTttxMpnoisephi where upconversion is performed Rerun the code How does the behavior of your algorithm differ Include plots to justify your claim c Repeat part b for the case when phi12 106 Frequency Tracking The problems inherent in even a tiny difference in the frequency of the carrier at the transmitter and the assumed frequency at the receiver are shown in 55 and illustrated graphically in Figure 919 on page 185 Since no two independent oscillators are ever exactly aligned it is important to find ways of estimating the frequency from the received signal The direct method of Section 1061 derives an algorithm based on a performance function that uses a square difference in the time domain Unfortunately this does not work well and its failure can be traced to the shape of the error surface Section 1062 begins with the observation familiar from Figures 108b and 1011 that the estimates of phase made by the phasetracking algorithms over time lie on a line whose slope is proportional to the difference 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 dualloop 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 1063 1061 Direct Frequency Estimation Perhaps the simplest setting in which to begin frequency estimation is to assume that the received signal is rt cos2πfct where fc is unknown By analogy with the squareddifference method of phase estimation in Section 102 a rea sonable strategy is to try to choose f0 so as to minimize Jf0 1 2 LPFrt cos2πf0t2 1019 Carrier Recovery 217 Frequency estimates f0 Frequency Time Figure 1016 The frequencyestimation algorithm 1020 appears to function well at first But over time the estimates diverge from the desired answer Following a gradient strategy for updating the estimates leads to the algorithm How well does this algorithm work First observe that the update is multiplied by This arises from application of the chain rule when taking the derivative of with respect to 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 offending term and go ahead and simulate the methodAt first glance it might seem that the method works well Figure 1016 shows 20 different starting values All 20 appear to converge nicely within one second to the unknown frequency value at But then something strange happens one by one the estimates diverge In the figure one peels off 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 simplified and idealized simulations function poorly it is a safe bet that the algorithm is somehow flawed What is the flaw in this case Recall that error surfaces are often a good way of picturing the behavior of gradientdescent algorithms Expanding the square and using the standard identities A4 and A9 can be rewritten The code is available in the program pllfreqestm on the website 218 Chapter 10 Carrier Recovery 05 0 fc Frequency estimate f0 J f0 Figure 1017 The error surface corresponding to the frequency estimation performance function 1019 is flat everywhere except for a deep crevice at the correct answer f0 fc assuming that the cutoff frequency of the lowpass filter is less than fc and that f0 fc At the point where f0 fc Jf0 0 For any other value of f0 how ever as time progresses the cosine term undulates up and down with an average value of zero Hence Jf0 averages to 1 2 for any f0 fc This pathological situ ation is shown in Figure 1017 When f0 is far from fc this analysis does not hold because the LPF no longer removes the first two cosine terms in 1021 Somewhat paradoxically the algo rithm behaves well until the answer is nearly correct Once f0 fc the error surface flattens and the estimates wander around There is a slight possibil ity that it might accidently fall into the exact correct answer but simulations suggest that such luck is rare Oh well never mind 1062 Indirect Frequency Estimation Because the direct method of the previous section is unreliable this section pursues an alternative strategy based on the observation that the phase estimates of the PLL converge to a line that has a slope proportional to the difference between the actual frequency of the carrier and the frequency that is assumed at the receiver Recall Figures 108b and 1011 The indirect method cascades two PLLs the first finds this line and hence indirectly specifies the frequency the second converges to a constant appropriate for the phase offset The scheme is pictured in Figure 1018 Suppose that the received signal has been preprocessed to form rpt cos4πfct 2φ This is applied to the inputs of two PLLs8 The top PLL functions exactly as expected from previous sections if the frequency of its oscillator is 2f0 then the phase estimates 2θ1 converge to a ramp with slope 2πf0 fc that is θ1t 2πfc f0t b 8 Or two SD phasetracking algorithms or two Costas loops though in the latter case the squaring preprocessing is unnecessary Carrier Recovery 219 LPF F1z LPF F2z 2 2 X X µ1Σ sin4πf0kTs2θ1k 2θ2k sin4πf0kTs2θ1k θ1k θ2k θ1k µ2Σ θ2k rpkTs e1k e2k Figure 1018 A pair of PLLs can efficiently estimate the frequency offset at the receiver The parameter θ1 in the top loop converges to a slope that corrects the frequency offset and the parameter θ2 in the bottom loop corrects the residual phase offset The sum θ1 θ2 is used to drive the sinusoid in the carrierrecovery scheme where b is the yintercept 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 sin4πf0t 2θ1t 2θ2t sin4πf0t 4πfc f0t 2b 2θ2t sin4πfct 2b 2θ2t Effectively the top loop has synthesized a signal that has the correct frequency for the bottom loop Accordingly θ2t φ b Since a sinusoid with frequency 2πf0t and phase θ1t θ2t is indistinguishable from a sinusoid with fre quency 2πfct and phase θ2t these values can be used to generate a sinusoid that is aligned with rpt 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 dualpllsm Listing 108 dualpllsm estimation of carrier via dualloop structure Ts110000 time 5 t 0Ts timeTs time vector f c 1000 phoff 2 c a r r i e r f r eq and phase rpcos 4 pi f c t2 phoff preprocessed s i g n a l rBPF mu101 mu2003 algorithm s t e p s i z e s f0 1001 assumed f r eq at r e c e i v e r l entlength t th1zeros 1 l ent i n i t i a l i z e estimates th2zeros 1 l ent car es tzeros 1 l ent for k1 lent 1 combine top PLL th1 th1 k1th1 kmu1rp k sin 4 pi f0 t k2 th1 k th2 k1th2 kmu2rp k sin 4 pi f0 t k2 th1 k2 th2 k with bottom PLL th2 to form estimate of preprocessed s i g n a l car es t kcos4 pi f0 t k2 th1 k2 th2 k end The output of this program is shown in Figure 1019 The upper graph shows that θ1 the phase estimate of the top PLL converges to a ramp The middle plot 220 Chapter 10 Carrier Recovery 20 0 20 01 0 01 02 03 0 1 2 3 4 5 1 0 1 Time error θ1 θ2 Figure 1019 The output of Matlab program dualpllsm shows the output of the first PLL converging to a line which allows the second PLL to converge to a constant The bottom figure shows that this estimator can be used to construct a sinusoid that is very close to the preprocessed carrier 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 1019 that θ1 converges to a line What line does it converge to Looking carefully at the data generated by dualpllsm the line can be calculated explicitly The two points at 2 1136 and 4 2393 fit a line with slope m 628 and an intercept b 121 Thus 2πfc f0 628 or fc f0 1 Indeed this was the value used in the simulation Reading the final converged value of θ2 from the simulation shown in the middle plot gives 00627 b 00627 is 1147 which is almost exactly π away from 2 the value used in phoff Exercise 1032 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 effect 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 pulseshaped data instead of by a simple sinusoid Exercise 1033 Build a frequency estimator using two SD phasetracking algo rithms rather than two PLLs How does the performance change Which do you think is preferable Carrier Recovery 221 Exercise 1034 Build a frequency estimator that incorporates the preprocess ing of the received signal from Figure 103 as coded in pllpreprocessm Exercise 1035 Build a frequency estimator using two Costas loops rather than two PLLs How does the performance change Which do you think is preferable Exercise 1036 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 1037 Repeat Exercise 1036 for the dual SD algorithm Exercise 1038 Repeat Exercise 1036 for the dual Costasloop algorithm Exercise 1039 Repeat Exercise 1036 for the dual DD algorithm Exercise 1040 Investigate via simulation how the PLL functions when there is intersymbol interference caused by a nonunity channel Pick a channel for instance chan1 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 1041 Repeat Exercise 1040 for the dual Costas loop Exercise 1042 Repeat Exercise 1040 for the Costasloop algorithm Exercise 1043 Repeat Exercise 1040 for the DD algorithm 1063 Generalized PLL Section 1062 showed that two loops can be used in concert to accomplish the carrierrecovery task the first loop estimates frequency offset and the second loop estimates the phase offset This section shows an alternative structure that folds one of the loops into the lowpass filter in the form of an IIR filter and accomplishes both estimations at once This is shown in Figure 1020 which looks the same as Figure 107 but with the FIR lowpass filter Fz replaced by an IIR lowpass filter Gz GNzGDz To see the operation of the generalized PLL concretely pllgeneralm imple ments the system of Figure 1020 with GNz 2 µ 2z and GDz z 1 The implementation of the IIR filter follows the timedomain method in waystofiltIIRm on page 145 When the frequency offset is zero when f0fc 222 Chapter 10 Carrier Recovery sin4πf0kTs 2θk Gz 2 rpkTs µ z1 θk θk1 Figure 1020 The general PLL can track both phase and frequency offsets using an IIR LPF Gz This figure is identical to Figure 107 except that the FIR lowpass filter is replaced by a suitable IIR lowpass filter Linearizing this structure gives Figure 1022 Appendix F presents conditions on Gz under which the tracking occurs theta converges to phoff When there is a frequency offset as in the default values with f0fc01 theta converges to a line Essentially this θ value con verges to θ1 θ2 in the dualloop structure of Figure 1019 Listing 109 pllgeneralm the PLL with an IIR LPF Ts110000 time 1 tTs Ts time time vector f c 1000 phoff 08 c a r r i e r f r eq and phase rpcos 4 pi f c t2 phoff s i m p l i f i e d rec d s i g n a l mu003 algorithm s t e p s i z e a1 1 lenalength a 1 a u t o r e g r e s s i v e terms b2 2mu lenblength b moving average terms xveczeros lena 1 i n i t i a l i z e f i l t e r s eveczeros lenb 1 f0 10000 f r eq at r e c e i v e r thetazeros 1 length t theta 10 i n i t i a l i z e estimates for k1length t1 erp k sin 4 pi f0 t k2 theta k input to f i l t e r evec e evec 1 lenb 1 past values of inputs xa 2 lena 1 xvecb evec output of f i l t e r xvec x xvec 1 lena 1 1 past values of outputs theta k1 theta kmux algorithm update end 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 non linear components with nearby linear elements A linearization is valid only for a small range of values For example the nonlinear function sinx is approxi mately x for small values This can be seen by looking at sinx 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 107 are the oscillators and the mixers Consider a nonideal lowpass filter Fz with impulse response fk that has a cutoff frequency below 2f0 The output of the LPF is ek fk sin2θk 2φk where represents convolution With φ θ φ and φ θ sin2φk 2φk Thus the linearization is fk sin2φk fk 2φk 1022 Carrier Recovery 223 In words applying an LPF to sinx is approximately the same as applying the LPF to x at least for sufficiently small x There are two ways to understand why the general PLL structure in Figure 1020 works both of which involve linearization arguments The first method lin earizes Figure 1020 and applies the finalvalue theorem for Ztransforms Details can be found in Section F4 The second method is to show that a linearization of the generalized singleloop structure of Figure 1020 is the same as a lineariza tion of the dualloop method of Figure 1019 at least for certain values of the parameters Exercise 1050 shows that for certain special cases the two strate gies the dualloop and the generalized singleloop behave similarly in the sense that both have the same linearization Exercise 1044 What is the largest frequency offset that pllgeneralm can track How does theta behave when the tracking fails Exercise 1045 Examine the effect of different filters in pllgeneralm a Show that the filter used in pllgeneralm has a lowpass character b Let a1 0 What kind of IIR filter does this represent How does the loop behave for a frequency offset c Can you choose b so that the loop fails d Design an IIR a and b pair using cheby1 or cheby2 Test whether the loop functions to track small frequency offsets Exercise 1046 Design the equivalent squareddifference loop combining the IIR structure of pllgeneralm with the squareddifference objective function as in pllsdm Exercise 1047 Design the equivalent general Costasloop structure Hint replace the FIR LPFs in Figure 109 with suitable IIR filters Create a simu lation to verify the operation of the method Exercise 1048 The code in pllgeneralm is simplified in the sense that the received signal rp contains just the unmodulated carrier Implement a more real istic scenario by combining pulrecsigm to include a binary message sequence pllpreprocessm to create rp and pllgeneralm to recover the unknown phase offset of the carrier Demonstrate that the same system can track a frequency offset Exercise 1049 Investigate how the method performs when the received signal contains pulseshaped 4PAM data Verify that it can track both phase and frequency offsets 224 Chapter 10 Carrier Recovery µ z1 θ1k 2φk θ1k1 2θ1k 2θ2k µ z1 θ2k θ2k1 e1k e2k F1z F2z 2 2 Figure 1021 A linearization of the dualloop frequency tracker of Figure 1018 For small offsets this linear structure closely represents the behavior of the system µ z1 θk 2φk θk1 ek GDz GNz 2 Figure 1022 This is the linearization of Figure 1020 A B C A B B C Figure 1023 The lefthand block diagram with overlapping loops can be redrawn as the righthand split diagram Exercise 1050 This exercise outlines the steps needed to show the conditions under which the general PLL of Figure 1020 and the dualloop structure of Figure 1018 are the same in the sense of having the same linearization a Show that Figure 1021 is the linearization of Figure 1018 b Show that Figure 1022 is the linearization of the general PLL of Figure 1020 c Show that the two block diagrams in Figure 1023 are the same d Suppose that the lowpass filters are ideal F1z F2z 1 for all frequencies below the cutoff and F1z F2z 0 at all frequencies above Make the following assignments A µ z 1 2µ B µ z 1 and C 2 Carrier Recovery 225 Using the blockdiagram manipulation of part c show that Figures 1021 and 1022 are the same when GNz µ2z 2 2µ and GDz z 1 For Further Reading r J P Costas Synchronous Communications Proceedings of the IRE vol 44 no 12 pp 17131718 Dec 1956 r L E Franks Carrier and Bit Synchronization in Data Communication A Tutorial Review IEEE Transactions on Communications vol 28 no 8 pp 11071120 Aug 1980 11 Pulse Shaping and Receive Filtering 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 pulseshaping filter which changes each symbol in the digital message into a suitable analog pulse After transmission the receive filter assists in recapturing the digital values from the received pulses This chapter focuses on the design and specifi cation of these filters The symbols in the digital input sequence wkT are chosen from a finite set of values For instance they might be binary 1 or they may take values from a larger set such as the fourlevel alphabet 1 3 As suggested in Figure 111 the sequence wkT is indexed by the integer k and the data rate is one symbol every T seconds Similarly the output mkT assumes values from the same alphabet as wkT and at the same rate Thus the message is fully specified at times kT for all integers k But what happens between these times between kT and k 1T The analog modulation of Chapter 5 operates continuously and some values must be used to fill in the digital input between the samples This is the job of the pulseshaping filter to turn a discretetime sequence into an analog signal Each symbol wkT 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 112 shows how this happens and the eye diagram is used in Section 113 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 wave form 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 Pulse Shaping and Receive Filtering 227 Noise Interferers Message 3 1 1 3 Reconstructed message 3 1 1 3 Figure 111 System diagram of a baseband communication system emphasizing the pulse shaping at the transmitter and the corresponding receive filtering at the receiver Section 114 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 filter 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 signaltonoise ratio that can be maximized by choice of the pulse shape This is discussed in Section 115 The chapter concludes in Section 116 by considering pulse shaping and receive filters that both provide a Nyquist pulse and maximize the signaltonoise ratio The transmit and receive filter 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 111 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 111 Spectrum of the Pulse Spectrum of the Signal Probably the major reason why the design of the pulse shape is important is because the shape of the spectrum of the pulse dictates the spectrum of the whole transmission To see this suppose that the discretetime message sequence is turned into the analog pulse train as it enters the pulseshaping filter The response of the filter with impulse response is the convolution 228 Chapter 11 Pulse Shaping and Receive Filtering 1 08 06 04 02 0 Pulse shape 01 02 03 04 05 06 07 08 09 0 Sample periods a 102 100 102 104 Spectrum of the pulse shape 01 02 03 04 05 06 07 08 09 1 0 Normalized frequency b Figure 112 The Hamming pulse shape and its magnitude spectrum as suggested by Figure 111 Since the Fourier transform of a convolution is the product of the Fourier transforms from A40 it follows that Xf WafPf Though Waf is unknown this shows that Xf can have no energy at fre quencies at which Pf vanishes Whatever the spectrum of the message the transmission is directly scaled by Pf In particular the support of the spec trum Xf is no larger than the support of the spectrum Pf As a concrete example consider the pulse shape used in Chapter 9 which is the blip function shown in the top plot of Figure 112 The spectrum of this pulse shape can readily be calculated using freqz and this is shown at the bottom plot of Figure 112 It is a kind of mild lowpass filter The following code generates a sequence of N 4PAM symbols and then carries out the pulse shaping using the filter command Listing 111 pulsespecm spectrum of a pulse shape N1000 wpamN 4 5 4 l e v e l s i g n a l of length N M10 wupzeros 1 NM oversampling f a c t o r wup 1 MNMw oversample by M pshamming M bl i p pulse of width M xf i l t e r ps 1 wup convolve pulse shape with data The program pulsespecm represents the continuoustime or analog sig nal by oversampling both the data sequence and the pulse shape by a fac tor of M This technique was discussed in Section 63 where an analog sine wave sine100hzsampm was represented digitally at two sampling intervals a slow symbol interval T MTs and a faster rate shorter interval Ts represent ing 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 convo lution of the oversampled pulse shape and the oversampled data sequence is accomplished by the filter command Typical output is shown in the top plot Pulse Shaping and Receive Filtering 229 3 2 1 0 1 2 3 0 5 10 15 20 25 Symbols Output of pulse shaping filter 104 102 100 102 104 0 01 02 03 04 05 06 07 08 09 1 Normalized frequency Spectrum of the output Figure 113 The top plot shows a segment of the output x of the pulseshaping filter 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 112 of Figure 113 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 113 As expected from the previous discussion the spectrum Xf has the same contour as the spectrum of the individual pulse shape in Figure 112 112 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 first 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 Example 111 Suppose that the pulse shape in pulsespecm is stretched so that its width is 3T This triplewidth Hamming pulse shape is shown in Figure 114 along with its spectrum Observe that the spectrum has roughly onethird the nulltonull bandwidth of the singlesymbolwide Hamming pulse Since the 230 Chapter 11 Pulse Shaping and Receive Filtering 1 08 06 04 02 0 The pulse shape 0 05 1 15 2 25 3 Sample periods a 102 100 102 104 Spectrum of the pulse shape 0 01 02 03 04 05 06 07 08 09 1 Normalized frequency b Figure 114 The triplewidth Hamming pulse shape and its magnitude spectrum which is drawn using freqz 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 115 shows the output of the pulseshaping filter 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 tradeoff 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 111 Modify pulsespecm to reproduce Figures 114 and 115 for the doublewidth pulse shape Exercise 112 Modify pulsespecm 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 Pulse Shaping and Receive Filtering 231 0 0 5 10 15 20 25 5 5 Symbols 01 02 03 04 05 06 07 08 09 1 0 Normalized frequency Output of pulseshaping filter 102 100 102 104 Spectrum of the output Figure 115 The top plot shows a segment of the output x of the pulseshaping filter 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 114 113 Eye Diagrams While the differences between the pulseshaped sequences in Figures 113 and 115 are apparent it is difficult to see directly whether the distortions are seri ous that is whether they cause errors in the reconstructed data ie 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 briefly in Chapter 9 refer back to Figure 98 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 wave form In the ideal case the trace begins with n pulses each of which is a scaled copy of pt Then the n 1st to 2nth pulses arrive and overlay the first n though each is scaled according to its symbol value When there is noise channel distortion and timing jitter the overlays will differ 232 Chapter 11 Pulse Shaping and Receive Filtering 3 2 1 0 1 2 3 Optimum sampling times Sensitivity to timing error Distortion at zero crossings The eye Noise margin kT k 1T Figure 116 Interpreting eye diagrams a T wide Hamming blip is used to pulse shape a 4PAM data sequence As the number of superimposed traces increases the eye diagram becomes denser and gives a picture of how the pulse shape channel and other factors combine to determine the reliability of the recovered message Consider the n 2symbol eye diagram shown in Figure 116 In this figure the message is taken from the 4PAM alphabet 1 3 and the Hamming pulse shape is used The center of the eye gives the best times to sample since the openings ie the difference between the received pulse shape when the data value is 1 and the received pulse shape when the data value is 1 or between the received pulse shape when the data value is 1 and the received pulse shape when the data value is 3 are the largest The width marked sensitivity to timing error shows the range of time over which the samples quantize correctly The noise margin is the smallest vertical distance between the bands and is proportional to the amount of additive noise that can be resisted by the system without reporting erroneous values Thus eye diagrams such as Figure 116 give a clear picture of how good or how bad a pulse shape may be Sometimes the smearing in this figure is so great that the open segment in the center disappears The eye is said to be closed and this indicates that a simple quantizer slicer decision device will make mistakes in recovering the data stream This is not good For example reconsider the 4PAM example of the previous section that used a triplewidth Hamming pulse shape The eye diagram is shown in Figure 117 No noise was added when drawing this picture In the left two plots there are clear regions about the symbol locations where the eye is open Samples taken in these regions will be quantized correctly though there are also regions where mistakes will occur The other plots show the closed eye diagrams using 3T Pulse Shaping and Receive Filtering 233 4 2 0 2 4 Eye diagram for the Twide Hamming pulse shape 4 2 0 2 4 Eye diagram for the 2Twide Hamming pulse shape 4 2 0 2 4 Eye diagram for the 3Twide Hamming pulse shape 5 0 5 Eye diagram for the 5Twide Hamming pulse shape Symbols 0 1 2 3 4 5 Symbols 0 1 2 3 4 5 Figure 117 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 defined by the variable ps As in the pulseshaping 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 reshapexab command changes a vector x of size ab 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 112 eyediagm plot eye diagrams for a pulse shape N1000 mpamN 2 1 random s i g n a l of length N M20 mupzeros 1 NM oversampling f a c t o r of M mup 1 MNMm oversample by M pshammingM hamming pulse of width M xf i l t e r ps 1 mup convolve pulse shape neye 5 s i z e of groups cfloor length x neye M number of eyes to pl ot xpxNMneyeMc 1NM ignore t r a n s i e n t s at s t a r t plot reshape xp neye M c pl ot in groups Typical output of eyediagm is shown in Figure 118 The rectangular pulse shape in the top plot uses psones1M the Hamming pulse shape in the middle uses pshammingM and the bottom plot uses a truncated sinc pulse shape pssrrcL0M for L10 that is normalized so that the largest value is one The rectangular pulse is insensitive to timing errors since sampling almost anywhere except right at the transition boundaries will return the correct values The Hamming pulse shape has a wide eye but may suffer from a loss of SNR if the 234 Chapter 11 Pulse Shaping and Receive Filtering 0 Eye diagram for rectangular pulse shape 1 1 0 Eye diagram for Hamming pulse shape 1 1 2 0 Eye diagram for sinc pulse shape 2 Optimum sampling times Figure 118 Eye diagrams for rectangular Hamming and sinc pulse shapes with binary data 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 113 Modify eyediagm 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 114 Modify eyediagm to add noise to the pulseshaped signal x Use the Matlab command vrandn for different 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 115 Combine the previous two exercises Modify eyediagm as in Exercise 113 so that the data sequence is drawn from the alphabet 1 3 5 Add noise and answer the same question as in Exercise 114 Which alphabet is more susceptible to noise Exercise 116 TRUE or FALSE For two rectangular impulse responses with the same maximum magnitude but different time widths with T1 T2 the half power bandwidth of the frequency response of the pulse with width T1 exceeds that of the pulse with width T2 Pulse Shaping and Receive Filtering 235 uk yk kT equalizer receive filter channel pulse shape filter mk Figure 119 The baseband communications system of Exercise 119 Exercise 117 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 halfpower bandwidth of the sequence using the triangular pulse exceeds that of the rectangular pulse Exercise 118 Exercise 210 asked the following question TRUE or FALSE The flatter the top of the pulse shape the less sensitive the receiver is to small timing offsets In the absence of noise and without matched filtering this is TRUE Describe a noisy situation and a matched filtering that might cause the answer to be FALSE Exercise 119 Consider the baseband communication system in Figure 119 The difference equation relating the symbols mk to the T spaced equalizer input uk for the chosen baudtiming factor ǫ is uk 004mk ρ 100mk 1 ρ 060mk 2 ρ 038mk 3 ρ where ρ is a nonnegative integer The finiteimpulseresponse equalizer filter is described by the difference equation yk uk αuk 1 a Suppose α 04 and the message source is binary 1 Is the system from the source symbols mk to the equalizer output yk openeye Justify your answer b If the message source is 4PAM 1 3 can the system from mk to the equalizer output yk be made openeye by selection of α If so provide a successful value of α If not explain It is now easy to experiment with various pulse shapes pulseshape2m applies a sincshaped pulse to a random binary sequence Since the sinc pulse extends infinitely in time both backward and forward it cannot be represented exactly in the computer or in a real communication system and the parameter L spec ifies the duration of the sinc in terms of the number of symbol periods Listing 113 pulseshape2m pulse shape a random sequence N2000 mpamN 2 1 2PAM s i g n a l of length N M10 mupzeros 1 NM oversampling f a c t o r mup 1 MNMm oversample by M L10 pss r r c L 0 M s i nc pulse shape 2L symbols wide scsum ps M normalizing constant xf i l t e r ps sc 1 mup convolve pulse shape with data 236 Chapter 11 Pulse Shaping and Receive Filtering 04 03 02 01 0 01 Using a sinc pulse shape 10 8 6 4 2 0 2 4 6 8 10 3 2 1 0 1 2 Pulseshaped data sequence Symbol number Symbol interval 0 2 4 6 8 10 12 14 16 18 20 Figure 1110 A binary 1 data sequence is pulse shaped using a sinc pulse Figure 1110 plots the output of pulseshape2m The left figure shows the pulse shape while the right plot shows the analog pulseshaped signal xt over a duration of about 25 symbols The function srrcm first appeared in the discussion of interpolation in Section 64 and again in Exercise 622 and is used here to generate the sinc pulse shape The sinc function that srrcm produces is actually scaled and this effect is removed by normalizing with the variable sc Changing the second input argument from beta0 to other small positive numbers changes the shape of the curve each with a sinclike shape called a squareroot raised cosine This will be discussed in greater detail in Sections 114 and 116 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 Fig ure 113 each binary value was clearly delineated With the sinc pulse of Figure 1110 the analog waveform is more complicated However at the correct sam pling 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 1110 In pulseshape2m examine the effect of using different over sampling rates M Try M 1 5 100 Exercise 1111 Change pulseshape2m so that the data sequence is drawn from the alphabet 1 3 5 Can you visually identify the correct values in the pulseshaped signal Exercise 1112 In pulseshape2m examine the effect of using sinc approxi mations of different lengths L Try L 1 5 100 1000 Exercise 1113 In pulseshape2m examine the effect 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 Pulse Shaping and Receive Filtering 237 Exercise 1114 The goal is to design a frequencydivision multiplexed FDM system with a squareroot raised cosine as the transmitter pulse shape The symbol period is T 137 ms The design uses T4 sampling pulse lengths of 8T and a rolloff factor of 09 but it does not work since only three modulated carrier signals fit into the allotted bandwidth without multiuser interference Five are needed What parameters in the design would you change and why Exercise 1115 Using the code from Exercise 1111 examine the effects of adding noise in pulseshape2m Does the same amount of noise in the sixlevel data have more or less effect than in the twolevel data Exercise 1116 Modify pulseshape2m to include the effect of a nonunity channel Try both a highpass channel and a bandpass channel Which appears worse What are reasonable criteria for better and worse in this context Exercise 1117 A Matlab question in pulseshape2m examine the effect of using the filtfilt command for the convolution instead of the filter com mand Can you figure out why the results are different Exercise 1118 Another Matlab question in pulseshape2m examine the effect of using the conv command for the convolution instead of the filter command Can you figure out how to make this work 114 Nyquist Pulses Consider a multilevel signal drawn from a finite alphabet with values wkT where T is the sampling interval Let pt be the impulse response of the linear filter representing the pulse shape The signal just after pulse shaping is xt wat pt where wat is the pulsetrain signal 111 The corresponding output of the received filter is yt wat pt hct hRt as depicted in Figure 111 where hct is the impulse response of the channel and hRt is the impulse response of the receive filter Let hequivt pt hct hRt be the overall equivalent impulse response Then the equivalent overall frequency response ie Fhequivt is Hequivf PfHcfHRf 112 One approach would be to attempt to choose HRf so that Hequivf attained a desired value such as a pure delay for all f This would be a specification of Chapter 11 Pulse Shaping and Receive Filtering 238 the impulse response at all 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 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 spaced sample instants is formalized by saying that is a Nyquist pulse if there is a such that for all integers where is some nonzero constant The timing offset in will need to be found by the receiver A rectangular pulse with timewidth less than certainly satisfies as does any pulse shape that is less than 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 efficiently But if just any wide shape is used such as the multiplewide Hamming pulses then the eye may close What is needed is a signal that is wide in time and narrow in frequency that also fulfills the Nyquist condition One possibility is the sinc pulse with This has the narrowest possible spectrum since it forms a rectangle in frequency ie the frequency response of a lowpass filter Assuming that the clocks at the transmitter and receiver are synchronized so that the sinc pulse is Nyquist because and for all integers But there are several problems with the sinc pulse It has infinite duration In any real implementation the pulse must be truncated It is noncausal In any real implementation the truncated pulse must be delayed The steep band edges of the rectangular frequency function are difficult to approximate The sinc function decays slowly at a rate proportional to The slow decay recall the plot of the sinc function in Figure 211 on page 32 means that samples that are far apart in time can interact with each other when there are even modest clocksynchronization errors 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 off time and frequency behaviors can be tricky Desirable pulse shapes 1 have appropriate zero crossings ie 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 profile in the frequency domain One popular option is called the raised cosinerolloff or raised cosine filter It is defined by its Fourier transform where B is the absolute bandwidth f0 is the 6 dB bandwidth equal to 12T half the symbol rate fΔ B f0 and f1 f0 fΔ The corresponding timedomain function is Define the rolloff factor β fΔ f0 Figure 1111 shows the magnitude spectrum HRCf of the raised cosine filter on the right and the associated time response hRCt on the left for a variety of rolloff factors With T 12f0 hRCkT 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 hRCt becomes a sinc The raised cosine pulse hRCt with nonzero β has the following characteristics zero crossings at desired times band edges of HRCf that are less severe than with a sinc pulse an envelope that falls off at approximately 1t3 for large t look at 114 This is significantly faster than 1t As the rolloff factor β increases from 0 to 1 the significant part of the impulse response gets shorter Thus we have seen several examples of Nyquist pulses rectangular Hamming sinc and raised cosine with a variety of rolloff factors What is the general principle that distinguishes Nyquist pulses from all others A necessary and sufficient condition for a signal vt with Fourier transform Vf to be a Nyquist pulse is that the sum over all n of Vf nf0 be constant To see this use the Figure 1111 Raised cosine pulse shape in the time and frequency domains sifting property of an impulse A56 to factor Vf from the sum Given that convolution in the frequency domain is multiplication in the time domain A40 on applying the definition of the Fourier transform and using the transform pair from A28 with wt 1 and Wf δf where f0 1T this becomes If vt is a Nyquist pulse the only nonzero term in the sum is v0 and Thus the sum of the Vf nf0 is a constant if vt is a Nyquist pulse Conversely if the sum of the Vf nf0 is a constant then only the DC term in 115 can be nonzero and so vt is a Nyquist pulse Exercise 1119 Write a MATLAB routine that implements the raised cosine impulse response 114 with rolloff parameter β Hint 1 if you have trouble with divide by zero errors imitate the code in srrcm Plot the output of your program for a variety of β Hint 2 there is an easy way to use the function srrcm Pulse Shaping and Receive Filtering 241 3 3 15 15 pt t ms 02 06 10 Figure 1112 Pulse shape for Exercise 1123 Exercise 1120 Use your code from the previous exercise along with pulseshape2m to apply raised cosine pulse shaping to a random binary sequence Can you spot the appropriate times to sample by eye Exercise 1121 Use the code from the previous exercise and eyediagm to draw eye diagrams for the raised cosine pulse with rolloff parameters r 0 05 09 10 50 Compare these with the eye diagrams for rectangular and sinc functions Consider a sensitivity to timing errors b peak distortion c distortion of zero crossings and d the noise margin Exercise 1122 TRUE or FALSE The impulse response of a series combination of any αsecondwide pulseshape filter and its matched filter form a Nyquist pulse shape for a T spaced symbol sequence for any T α Exercise 1123 Consider the pulse shape pt of width 12 ms shown in Figure 1112 a Is pt a Nyquist pulse for the symbol period T 035 ms Justify your answer b Is pt a Nyquist pulse for the symbol period T 070 ms Justify your answer Exercise 1124 Neither s1t nor s2t is a Nyquist pulse a Can the product s1ts2t be a Nyquist pulse Explain b Can the convolution s1t s2t be a Nyquist pulse Explain Intersymbol interference occurs when data values at one sample instant inter fere with the data values at another sampling instant Using Nyquist shapes such as the rectangle sinc and raised cosine pulses removes the interference at least at the correct sampling instants when the channel is ideal The next sections parlay this discussion of isolated pulse shapes into usable designs for the pulse shaping and receive filters 115 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 filtering is aimed at reducing the sensitivity to noise which can be specified in terms of the power spectral density this is reviewed in some detail in Appendix E Consider the filtering problem in which a message signal is added to a noise signal and then both are passed through a linear filter This occurs for instance when the signal gt of Figure 111 is the output of the pulseshaping filter ie no interferers are present the channel is the identity and there is noise nt present Assume that the noise is white that is assume that its power spectral density Pnf is equal to some constant η for all frequencies The output yt of the linear filter with impulse response hRt can be described as the superposition of two components one driven by gt and the other by nt that is where This is shown in blockdiagram form in Figure 1113 In both components the processing and the output signal are the same The bottom diagram separates out the component due to the signal vkT which contains the message filtered through the pulse shape and the receive filter and the component due to the noise wkT which is the noise filtered through the receive filter The goal of this section is to find the receive filter that maximizes the ratio of the power in the signal vkT to the power in the noise wkT at the sample instants Consider choosing hRt so as to maximize the power of the signal vt at time t τ compared with the power in wt ie to maximize v2τ relative to the total power of the noise component wt This choice of hRt tends to emphasize the signal vt and suppress the noise wt The argument proceeds by finding the transfer function HRf that corresponds to this hRt From E2 the total power in wt is From the inverse Fourier transform Figure 1113 The two block diagrams result in the same output The top shows the data flow in a normal implementation of pulse shaping and receive filtering The bottom shows an equivalent that allows easy comparison between the parts of the output due to the signal ie vkT and the parts due to the noise ie wkT where Vf HRfGf Thus v2τ HRfGfej2πτf df2 Recall E3 which says that for Y f HRfUf Pyf HRf2Puf Thus Pwf HRf2Pnf ηHRf2 The quantity to be maximized can now be described by v2τPw HRfGfej2πτf df2 ηHRf2df 116 Schwarzs inequality A57 says that axbxdx2 ax2dx bx2dx and equality occurs only when ax kbx This converts 116 to v2τPw HRf2df Gfej2πτf 2df η HRf2df 117 which is maximized with equality when HRf kGfej2πτf 244 Chapter 11 Pulse Shaping and Receive Filtering HRf must now be transformed to find the corresponding impulse response hRt Since Y f Xf when yt xt use the frequencyscaling prop erty of Fourier transforms A38 with a scale factor of 1 F1W f wt F1W f wt Applying the timeshift property A37 yields F1Wfej2πfTd wt Td Combining these two transform pairs yields F1Wfej2πfTd wt Td wTd t Thus when gt is real F1kGfej2πfτ kgτ t kgτ t Observe that this filter has the following characteristics r This filter results in the maximum signaltonoise ratio of v2tPw at the time instant t τ for a noise signal with a flat power spectral density r Because the impulse response of this filter is a scaled time reversal of the pulse shape pt it is said to be matched to the pulse shape and is called a matched filter r The shape of the magnitude spectrum of the matched filter HRf is the same as the magnitude spectrum Gf r The shape of the magnitude spectrum of Gf is the same as the shape of the frequency response of the pulse shape Pf for a broadband mkT as in Section 111 r The matched filter for any filter with an even symmetric about some t time limited impulse response is a delayed replica of that filter The minimum delay is the upper limit of the timelimited range of the impulse response The following code allows handson exploration of this theoretical result The pulse shape is defined by the variable ps the default is the sinc function srrcL0M for L10 The receive filter is analogously defined by recfilt As usual the symbol alphabet is easily specified by the pam subroutine and the system operates at an oversampling rate M The noise is specified in n and the ratio of the powers is output as powvpoww Observe that for any pulse shape the ratio of the powers is maximized when the receive filter is the same as the pulse shape the fliplr command carries out the time reversal This holds no matter what the noise no matter what the symbol alphabet and no matter what the pulse shape Listing 114 matchfiltm test of SNR maximization N2ˆ15 mpamN 2 1 2PAM s i g n a l of length N M10 mupzeros 1 NM oversampling f a c t o r mup 1 MNMm oversample by M L10 pss r r c L 0 M def i ne pulse shape pspssqrtsumps2 and normalize n05randnsizemup noise gfilterps1mup convolve ps with data recfiltsrrcL0M receive filter H sub R recfiltrecfiltsqrtsumrecfilt2 normalize pulse shape vfilterfliplrrecfilt1g matched filter with data wfilterfliplrrecfilt1n matched filter with noise vdownsampv1MNM downsample to symbol rate wdownsampw1MNM downsample to symbol rate powvpowvdownsamp power in downsampled v powwpowwdownsamp power in downsampled w powvpoww ratio In general when the noise power spectral density is flat ie Pnf η the output of the matched filter may be realized by correlating the input to the matched filter with the pulse shape pt To see this recall that the output is described by the convolution xα sλhαλdλ of the matched filter with the impulse response ht Given the pulse shape pt and the assumption that the noise has flat power spectral density it follows that ht pα t 0 t T 0 otherwise where α is the delay used in the matched filter Because ht 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 xα λααT sλpα α λdλ λααT sλpλdλ This is the crosscorrelation of p with s as defined in 83 When Pnf is not a constant 116 becomes v2τPw HfGfej2πτf df2 PnfHf2df To use the Schwarz inequality A57 associate a with HPn and b with Gej2πτf Pn Then 117 can be replaced by v2τPw Hf2Pnfdf Gfej2πτf 2Pnfdf Hf2Pnfdf and equality occurs when a kb that is Hf kGfej2πτf Pnf When the noise power spectral density Pnf is not flat it shapes the matched filter Recall that the power spectral density of the noise can be computed from its autocorrelation as is shown in Appendix E 246 Chapter 11 Pulse Shaping and Receive Filtering Transmit filter Receive filter yk si k iN σ wk mk f k gk Figure 1114 Baseband communication system considered in Exercise 1129 Exercise 1125 Let the pulse shape be a T wide Hamming blip Use the code in matchfiltm to find the ratio of the power in the downsampled v to that in the downsampled w when a the receive filter is an SRRC with beta 0 01 05 b the receive filter is a rectangular pulse and c the receive filter is a 3T wide Hamming pulse When is the ratio largest Exercise 1126 Let the pulse shape be an SRRC with beta 025 Use the code in matchfiltm to find the ratio of the power in the downsampled v to that in the downsampled w when a the receive filter is an SRRC with beta 0 01 025 05 b the receive filter is a rectangular pulse and c the receive filter is a T wide Hamming pulse When is the ratio largest Exercise 1127 Let the symbol alphabet be 4PAM a Repeat Exercise 1125 b Repeat Exercise 1126 Exercise 1128 Create a noise sequence that is uniformly distributed using rand with zero mean a Repeat Exercise 1125 b Repeat Exercise 1126 Exercise 1129 Consider the baseband communication system in Figure 1114 The symbol period T is an integer multiple of the sample period Ts ie T NTs The message sequence is nonzero only each Nth k ie k NTs δTs where the integer δ is within the range 0 δ N and δTs is the onsample baudtiming offset at the transmitter a Suppose that fk 02 0 0 10 10 0 0 02 for k 0 1 2 3 4 5 6 7 and zero otherwise Determine the causal gk that is the matched filter to fk Arrange gk so that the final nonzero element is as small as possible Pulse Shaping and Receive Filtering 247 b For the gk specified in part a determine the smallest possible N so the path from mk to yk forms an impulse response that would qualify as a Nyquist pulse for some wellchosen baudtiming offset σ when y is downsampled by N c For the gk chosen in part a and the N chosen in part b determine the downsampler offset σ for si to be the nonzero entries of mk when wk 0 for all k 116 Matched Transmit and Receive Filters While focusing separately on the pulse shaping and the receive filtering makes sense pedagogically the two are intimately tied together in the communication system This section notes that it is not really the pulse shape that should be Nyquist but rather the convolution of the pulse shape with the receive filter Recall the overall block diagram of the system in Figure 111 where it was assumed that the portion of the system from upconversion to passband to final downconversion back to baseband is done perfectly and that the channel is just the identity Thus the central portion of the system is effectively transparent except for the intrusion of noise This simplifies the system to the baseband model in Figure 1115 The task is to design an appropriate pair of filters a pulse shape for the transmitter and a receive filter that is matched to the pulse shape and the presumed noise description It is not crucial that the transmitted signal itself have no intersymbol interference Rather the signal after the receive filter should have no ISI Thus it is not the pulse shape that should satisfy the Nyquist pulse condition but the combination of the pulse shape and the receive filter The receive filter should simultaneously 1 allow no intersymbol interference at the receiver and 2 maximize the signaltonoise ratio Hence it is the convolution of the pulse shape and the receive filter that should be a Nyquist pulse and the receive filter should be matched to the pulse shape Con sidering candidate pulse shapes that are both symmetric and even about some time t the associated matched filter modulo the associated delay is the same as the candidate pulse shape What symmetric pulse shapes when convolved with themselves form a Nyquist pulse Previous sections examined several Nyquist Pulse shape Receive filter Noise Signal Figure 1115 Noisy baseband communication system 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 filter 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 122 The convolution of a sinc function with itself is more easily viewed in the frequency domain as the pointbypoint 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 effectively and because its impulse response dies away quickly One possibility is to define 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 filter SRRC By definition the square in frequency of the SRRC which is the raised cosine is a Nyquist pulse The timedomain 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 vt 1 β 4βπT t 0 βπ22Tπ sin π4β βπ22Tπ cos π4β t T4β sinπ1βtT4βtTcosπ13 tT TπtT14βtT2 otherwise 118 Exercise 1130 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 srrcm 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 squareroot raised cosine is the most commonly used pulse in bandwidthconstrained communication systems Exercise 1131 Consider the baseband communication system with a symbolscaled impulse train input st i siδt iT ε where T is the symbol period in seconds and 0 ε 025 ms The system contains a pulseshaping filter Pf a channel transfer function Cf with additive Pulse Shaping and Receive Filtering 249 1 1 xt t ms 1 2 3 4 5 yk kT P f C f V f st yt nt Figure 1116 The system of Exercise 1131 and the time signal xt corresponding to the inverse Fourier transform of Xf noise nt and a receive filter V f as shown in Figure 1116 In addition con sider the time signal xt shown in the left part of Figure 1116 where each of the arcs is a halfcircle Let Xf be the Fourier transform of xt a If the inverse of PfCfV f is Xf what is the highest symbol frequency with no intersymbol interference supported by this communication system when 0 b If the inverse of PfCfV f is Xf select a sampler time offset T2 T2 to achieve the highest symbol frequency with no intersymbol inter ference What is this symbol rate c Consider designing the receive filter under the assumption that a symbol period T can be and will be chosen so that samples yk of the receive filter output suffer no intersymbol interference If the inverse of PfCf is Xf and the power spectral density of nt is a constant plot the impulse response of the causal minimumdelay matched receive filter 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 timingoffset experiments of Section 945 showed that one kind of stuff 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 deter mine 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 find performance functions that have their maximum or mini mum at the optimal point ie at the correct sampling instants when the eye is open widest These performance functions are then used to define adaptive elements that iteratively estimate the sampling times As usual all other aspects of the system are presumed to operate flawlessly the up and down conversions are ideal there are no interferers and the channel is benign The discussion of timing recovery begins in Section 121 by showing how a sampled version of the received signal xk can be written as a function of the timing parameter τ which dictates when to take samples Section 122 gives several examples that motivate several different possible performance functions functions of xk which lead to different 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 agreedupon header or training sequence An alternative is to use the cluster variance which takes the square of the difference between the received data values and the nearest element of the source alphabet This is analogous to the decisiondirected approach to carrier recovery from Section 105 and an adaptive element based on the cluster variance is derived and studied in Section 123 A popular alternative is to measure the power of the T spaced output of the matched filter Maximizing this power by choice of τ also leads to a good 252 Chapter 12 Timing Recovery Transmit filter Receive filter Sampler Channel si wt xt xkTM τ ht gRtctgTt gTt ct gRt Figure 121 The transfer function h combines the effects of the transmitter pulse shaping gT the channel c and the receive filter gR ASP DSP Sampler a ASP DSP DSP Sampler b ASP Sampler c Figure 122 Three generic structures for timing recovery In a an analog processor determines when the sampling instants will occur In b a digital postprocessor is used to determine when to sample In c the sampling instants are chosen by a freerunning clock and digital postprocessing is used to recover the values of the received signal that would have occurred at the optimal sampling instants There are three ways in which timingrecovery algorithms can be implemented and these are shown in Figure 122 In the first an analog processor determines when the sampling instants will occur In the second a digital postprocessor is used to determine when to sample In the third the sampling instants are chosen by a freerunning clock and digital postprocessing interpolation is used to recover the values of the received signal that would have occurred at the optimal sampling instants The adaptive elements of the next sections can be implemented in any of the three ways though in digital radio systems the trend is to remove as much of the calculation from analog circuitry as possible 122 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 255 3T2 T T2 T2 T 3T2 05 Timing offset τ avgQx x2 Figure 124 Cluster variance as a function of offset timing τ 3T2 T T2 T2 T 3T2 05 10 Timing offset τ avgx2 Figure 125 Average squared output as a function of timing offset τ Example 122 Another measure of the quality of the timing parameter τ is given by the power average energy of the xk Using the four formulas 123 and observing that analogous formulas also apply when τ0 0 the average energy can be calculated for any k by avgx2k 1412 1 2τT 2 1 2τT 2 12 142 21 2τT 2 1 2τT 2τ2T 2 assuming that the four symbol pairs are equally likely The average of x2k is plotted in Figure 125 as a function of τ Over T2 τ T2 this average is maximized with τ 0 Thus the problem of timing recovery can also be viewed as a onedimensional search for the τ that maximizes avgx2k Thus at least in the simple case of binary transmission with ht a triangular pulse the optimal timing offset for the plots in Figures 124 and 125 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 there is channel noise r the source alphabet is multilevel r more common pulse shapes are used and r there is intersymbol interference The next two sections show how to design adaptive elements that carry out these minimizations and maximizations The error surfaces corresponding to Timing Recovery 257 µΣ xt τk Resample xkTM τk xkTM τk δ xkTM τk δ Q Sampler Resample Resample xk Figure 126 One implementation of the adaptive element 129 uses three digital interpolations resamplers After the τk converge the output xk is a sampled version of the input xt with the samples taken at times that minimize the cluster variance where the stepsize µ µδ As usual this algorithm acts as a lowpass filter to smooth or average the estimates of τ and it is common to remove the explicit outer averaging operation from the update which leads to τk 1 τk µQxk xk x kTM τk δ x kTM τk δ 129 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 129 is easy to implement though it requires samples of the waveform xt at three different points xkTM τk δ xkTM τk and xkTM τk δ One possibility is to straightforwardly sample three times Since sampling is done by hardware this is a hardwareintensive solu tion 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 xkTM τk δ and at xkTM τk δ can be interpolated from the nearby samples xk Recall that interpolation was discussed in Sec tion 64 and the Matlab routine interpsincm on page 112 makes it easy to implement bandlimited interpolation and reconstruction Of course this requires extra calculations so it is a more softwareintensive solution This strategy is diagrammed in Figure 126 The following code prepares the transmitted signal that will be used subse quently to simulate the timingrecovery methods The user specifies the signal constellation the default is 4PAM the number of data points n and the over sampling factor m The channel is allowed to be nonunity and a squareroot raised cosine pulse with width 2l1 and rolloff beta is used as the default transmit pulseshaping filter An initial timing offset is specified in toffset and the 258 Chapter 12 Timing Recovery code implements this delay with an offset in the srrcm function The matched filter is implemented using the same SRRC but without the time delay Thus the timing offset is not known at the receiver Listing 121 clockrecDDm part 1 prepare transmitted signal n10000 number of data points m2 oversampling f a c t o r beta 03 r o l l o f f parameter f o r s r r c l 50 12 length of pulse shape chan 1 Tm channel t o f f s e t 03 i n i t i a l timing o f f s e t pulshaps r r c l beta m t o f f s e t pulse shape with o f f s e t spamn 4 5 random data sequence var5 supzeros 1 nm upsample the data pl aci ng sup 1 m nms m1 zer os between data points hhconv pulshap chan and pulse shape rconvhh sup to get r ecei ved s i g n a l m atchf i l ts r r c l beta m 0 matched f i l t e rs r r c xconv r m atchf i l t convolve with matched f i l t e r The goal of the timing recovery in clockrecDDm is to find the negative of the value of toffset using only the received signalthat is to have tau converge to toffset The adaptive element is implemented in clockrecDDm using the iterative cluster variance algorithm 129 The algorithm is initialized with an offset estimate of tau0 and stepsize mu The received signal is sampled at m times the symbol rate and the while loop runs though the data incrementing i once for each symbol and incrementing tnow by m for each symbol The offsets tau and taum are indistinguishable from the point of view of the algorithm The update term contains the interpolated value xs as well as two other interpolated values to the left and right that are used to approximate the derivative term Listing 122 clockrecDDm part 2 clock recovery minimizing cluster variance tnowl m1 tau 0 xszeros 1 n i n i t i a l i z e v a r i a b l e s tausavezeros 1 n tausave 1 tau i 0 mu001 algorithm s t e p s i z e del ta 01 time f o r d e r i v a t i v e while tnowlength x2 l m run i t e r a t i o n ii 1 xs i i n t e r p s i n c x tnowtau l i nter p value at tnowtau x deltapi n t e r p s i n c x tnowtaudelta l value to r i ght x deltami n t e r p s i n c x tnowtaudelta l value to l e f t dxx deltap x deltam numerical d e r i v a t i v e qxquantalph xs i 3 1 1 3 quantize to alphabet tautaumudxqxxs i alg update DD tnowtnowm tausave i tau save f o r p l o t t i n g end Typical output of the program is plotted in Figure 127 which shows the 4 PAM constellation diagram along with the trajectory of the offset estimation as it converges towards the negative of the unknown value 03 Observe that initially the values are widely dispersed about the required 4PAM values but as the algorithm nears its convergent point the estimated values of the symbols converge nicely Timing Recovery 259 Constellation history 0 1000 2000 3000 4000 5000 4 0 4 2 2 Iterations 0 1000 2000 3000 4000 5000 01 03 0 2 Symbol estimates Offset estimates Figure 127 Output of the program clockrecDDm shows the symbol estimates in the top plot and the trajectory of the offset estimation in the bottom As usual a good way to conceptualize the action of the adaptive element is to draw the error surfacein this case to plot JCV τ of 125 as a function of the timing offset τ In the examples of Section 122 the error surface was drawn by exhaustively writing down all the possible input sequences and evalu ating the performance function explicitly in terms of the offset τ In the binary setup with an identity channel where the pulse shape is only 2T long and with M 1 oversampling there were only four cases to consider But when the pulse shape and channel are long and the constellation has many elements the num ber of cases grows rapidly Since this can get out of hand an experimental method can be used to approximate the error surface For each timing offset the code in clockrecDDcostm chooses n random input sequences evaluates the performance function and averages Listing 123 clockrecDDcostm error surfaces for cluster variance performance function l 10 12 duration of pulse shape beta 05 r o l l o f f f o r pulse shape m20 evaluate at m d i f f e r e n t points pss r r c l beta m make s r r c pulse shape psrcconv ps ps convolve 2 srrc s to get rc psrcpsrc l m13 l m1 truncate to same length as ps costzeros 1 m n20000 experimental performance xzeros 1 n for i 1m f o r each o f f s e t ptpsrc i m end rc i s s h i f t e d i m of a symbol for k1n do i t n times rdpam length pt 4 5 random 4PAM vector x ksum rd pt r ecei ved data point w ISI end er rquantalph x 3 1 1 3 x quantize to alphabet cost i sum er r ˆ2 length er r DD performance f uncti on end The output of clockrecDDcostm is shown in Figure 128 The error surface is plotted for the SRRC with five different rolloff factors For all β the correct 260 Chapter 12 Timing Recovery 0 01 02 03 04 05 Value of performance function 0 T2 T Timing offset τ β 04 β 06 β 08 β 02 β 0 Figure 128 The performance function 125 is plotted as a function of the timing offset τ for five different pulse shapes characterized by different rolloff factors β The correct answer is at the global minimum at τ 0 answer at τ 0 is a minimum For small values of β this is the only minimum and the error surface is unimodal over each period In these cases no matter where τ is initialized it should converge to the correct answer As β is increased however the error surface flattens across its top and gains two extra minima These represent erroneous values of τ to which the adaptive element may con verge Thus the error surface can warn the system designer to expect certain kinds of failure modes in certain situations such as certain pulse shapes Exercise 121 Use clockrecDDm to play with the clockrecovery algorithm a How does mu affect the convergence rate What range of stepsizes works b How does the signal constellation of the input affect the convergent value of tau Try 2PAM and 6PAM Remember to quantize properly in the algo rithm update Exercise 122 Implement a rectangular pulse shape Does this work better or worse than the SRRC Exercise 123 Add noise to the signal add a zeromean noise to the received signal using the Matlab randn function How does this affect the convergence of the timingoffset parameter tau Does it change the final converged value Exercise 124 Modify clockrecDDm by setting toffset08 This starts the iteration in a closedeye situation How many iterations does it take to open the eye What is the convergent value Exercise 125 Modify clockrecDDm by changing the channel How does this affect the convergence speed of the algorithm Do different channels change the convergent value Can you think of a way to predict given a channel what the convergent value will be Timing Recovery 263 Constellation history Symbol estimates Iterations Offset estimates 0 1000 2000 3000 4000 5000 0 15 1 1 02 04 0 Figure 1210 Output of the program clockrecOPm shows the estimates of the symbols in the top plot and the trajectory of the offset estimates in the bottom tausavezeros 1 n tausave 1 tau i 0 mu005 algorithm s t e p s i z e del ta 01 time f o r d e r i v a t i v e while tnowlength x l m run i t e r a t i o n ii 1 xs i i n t e r p s i n c x tnowtau l i nter p at tnowtau x deltapi n t e r p s i n c x tnowtaudelta l value to r i ght x deltami n t e r p s i n c x tnowtaudelta l value to l e f t dxx deltap x deltam numerical d e r i v a t i v e tautaumudxxs i alg update energy tnowtnowm tausave i tau save f o r p l o t t i n g end Typical output of the program is plotted in Figure 1210 For this plot the message was drawn from a 2PAM binary signal which is recovered nicely by the algorithm as shown in the top plot The bottom plot shows the trajectory of the offset estimation as it converges to the unknown value at toffset The error surface for the outputpowermaximization algorithm can be drawn using the same experimental method as was used in clockrecDDcostm Replacing the line that calculates the performance function with cost i sumx ˆ2 length x calculates the error surface for the output power algorithm 1213 Figure 1211 shows this along with three variants 1 the average value of the absolute value of the output of the sampler avgxk 2 the average of the fourth power of the output of the sampler avgx4k and 3 the average of the dispersion avgx2k 12 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 figure 264 Chapter 12 Timing Recovery 0 T T2 0 02 04 06 08 1 12 Timing offset τ Dispersion Fourth Power Output Power Abs Value Value of performance functions Figure 1211 Four performance functions that can be used for timing recovery plotted as a function of the timing offset τ In this figure the optimal answer is at τ 0 Some of the performance functions must be minimized and some must be maximized shows the 2PAM case with an SRRC pulse shape with beta05 the maxima or minima may occur at different values of τ in more extreme settings Exercise 129 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 1210 Use the code in clockrecOPm to play with the output power clockrecovery algorithm How does mu affect the convergence rate What range of stepsizes works How does the signal constellation of the input affect the convergent value of tau try 4PAM and 8PAM Exercise 1211 Implement a rectangular pulse shape Does this work better or worse than the SRRC Exercise 1212 Add noise to the signal add a zeromean noise to the received signal using the Matlab randn function How does this affect the convergence of the timingoffset parameter tau Does it change the final converged value Exercise 1213 Modify clockrecOPm by setting toffset1 This starts the iteration in a closedeye 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 final convergent value will be Try toffset23 Now let the oversampling factor be m 4 and answer the same questions Exercise 1214 Redo Figure 1211 using a sinc pulse shape What happens to the output power performance function Exercise 1215 Redo Figure 1211 using a T wide Hamming pulse shape Which of the four performance functions need to be minimized and which need to be maximized 266 Chapter 12 Timing Recovery b Add a timingrecovery algorithm to the receiver so that the receiver samples at the appropriate time State the timingrecovery method used and plot the tracking of τ c Add an AGC to the code and decode the message Does the code recover the message appropriately Calculate the error rate of the receiver 125 Two Examples This section presents two examples in which timing recovery plays a significant role The first 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 ISIfree setting This happens because the ISI of the channel causes an effective delay in the energy that the algorithm measures The sec ond example shows how the timingrecovery algorithms can be used to estimate slow changes in the optimal sampling time When these changes occur linearly they are effectively a change in the underlying period and the timingrecovery algorithms can be used to estimate the offset of the period in the same way that the phase estimates of the PLL in Section 106 can be used to find a small frequency offset in the carrier Example 123 Modify the simulation in clockrecDDm by changing the channel chan1 07 0 0 5 Tm channel With an oversampling of m2 2PAM constellation and beta05 the output of the outputpowermaximization algorithm clockrecOPm is shown in Figure 1212 With these parameters the iteration begins in a closedeye situation Because of the channel no single timing parameter can hope to achieve a perfect 1 outcome Nonetheless by finding a good compromise position in this case converging to an offset of about 06 the hard decisions are correct once the eye has opened which first occurs around iteration 500 Example 123 shows that the presence of ISI changes the convergent value of the timingrecovery algorithm Why is this Suppose first that the channel was a pure delay For instance set chan0 1 in Example 123 Then the timing algorithm will change the estimates tau in this case by one to maximize the output power to account for the added delay When the channel is more complicated the timing recovery again moves the estimates to that position which maximizes the output power but the actual value attained is a weighted version of all the taps For example with chan1 1 the energy is maximized halfway between the two taps and the answer is offset by 05 Similarly with chan3 1 the energy is located a quarter of the way between the taps and the answer is offset by 025 In general the offset is roughly proportional to the size of the taps and their delay Timing Recovery 267 Constellation diagram Iterations 0 1000 2000 3000 4000 5000 3 0 3 2 1 1 2 04 08 0 Symbol estimates Offset estimates Figure 1212 Output of the program clockrecOPm modified for Example 123 shows the constellation history in the top plot The trajectory of the offset estimation is shown in the bottom plot To see the general situation consider the received analog signal due to a single symbol triggering the pulseshape filter and passing through a channel with ISI An adjustment in the baudtiming setting at the receiver will sample at slightly different points on the received analog signal A change in τ is effectively equiv alent to a change in the channel ISI This will be dealt with in Chapter 13 when designing equalizers Example 124 With the signal generated as in clockrecDDm 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 125 clockrecperiodm resample to change the period f ac 10001 zzeros size x percent change in period tl 1 f ac length x2 l vector of new times for il 1length t resample x at new r ate z i i n t e r p s i n c x t i l to cr eate r ecei ved s i g n a l end with period o f f s e t xz r e l a b e l s i g n a l If this code is followed by one of the timingrecovery schemes then the timing parameter τ follows the changing period For instance in Figure 1213 the timing estimation converges rapidly to a line with slope that is proportional to the difference in period between the assumed value of the period at the receiver and the actual value used at the transmitter Thus the standard timingrecovery algorithms can handle the case in which the clock periods at the transmitter and receiver are somewhat different More accurate estimates could be made using two timingrecovery algorithms anal ogous to the dualcarrier recovery structure of Section 1062 or by mimicking the secondorder filter 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 timingrecovery algorithms such as the earlylate method the method of Mueller and Muller and bandedge timing algorithms 268 Chapter 12 Timing Recovery Constellation history Iterations 0 05 1 15 2 x104 15 0 15 1 05 05 1 4 1 0 1 3 2 Symbol estimates Offset estimates Figure 1213 Output of clockrecperiodm as modified for Example 124 shows the constellation history in the top plot and the trajectory of the offset estimation in the bottom The slope of the estimates is proportional to the difference between the nominal and the actual clock period Exercise 1220 Modify clockrecOPm to implement one of the alternative performance functions of Figure 1211 avgxk avgx2k or avgx2k 12 Exercise 1221 Modify clockrecOPm by changing the channel as in Exam ple 123 Use different values of beta in the SRRC pulseshape routine How does this affect the convergence speed of the algorithm Do different pulse shapes change the convergent value Exercise 1222 Investigate how the error surface depends on the input signal a Draw the error surface for the outputenergymaximization timingrecovery algorithm when the inputs are binary 1 b Draw the error surface when the inputs are drawn from the 4PAM constel lation for the case in which the symbol 3 never occurs Exercise 1223 Imitate Example 123 using a channel of your own choosing Do you expect that the eye will always be able to open Exercise 1224 Instead of the ISI channel used in Example 123 include a whitenoise channel How does this change the timing estimates Exercise 1225 Explore the limits of the period tracking in Example 124 How large can fac be made and still have the estimates converge to a line What happens to the cluster variance when the estimates cannot keep up Does it help to increase the size of the stepsize mu For Further Reading A comprehensive collection of timing and carrierrecovery schemes can be found in the following two texts Timing Recovery 269 r H Meyr M Moeneclaey and S A Fechtel Digital Communication Receivers Wiley 1998 r J A C Bingham The Theory and Practice of Modem Design Wiley Inter science 1988 13 Linear Equalization When all is well in the receiver there is no interaction between successive sym bols 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 difficult to decipher the message from such a received signal This impairment is called intersym bol interference and was discussed in Chapter 11 in terms of nonNyquist pulse shapes overlapping in time This chapter considers another source of interference between symbols that is caused by multipath reflections or frequencyselective 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 inter ference 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 finiteimpulseresponse linear filter C and the delay spread is the total time interval during which reflec tions with significant energy arrive The idea of the equalizer is to build another filter in the receiver that counteracts the effect 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 chan nel 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 Decision device Linear digital equalizer Digital source Received analog signal Sampled received signal Noise and interferers Ts Figure 131 The baseband linear digital equalizer is intended to automatically cancel out unwanted effects of the channel and to cancel out certain kinds of additive interferences the system designer in advance The second job of the equalizer is to reject such additive narrowband interferers by designing appropriate linear notch filters on thefly 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 Fig ure 131 which emphasizes the role of the equalizer in trying to counteract the effects 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 car rier synchronization all those parts of the receiver that are not shown in Figure 131 are assumed to be flawless and unchanging Modeling the channel as a time invariant FIR filter the next section focuses on the task of selecting the coeffi cients in the block labeled linear digital equalizer with the goal of removing the intersymbol interference and attenuating the additive interferences These coeffi cients are to be chosen using the sampled received signal sequence and possibly knowledge of a prearranged training sequence While the channel may actually be timevarying the variations are often much slower than the data rate and the channel can be viewed as effectively timeinvariant over small time scales This chapter suggests several different ways in which the coefficients of the equalizer can be chosen The first procedure in Section 1321 minimizes the square of the symbolrecovery 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 133 When there is no training sequence other performance functions are appropriate and these lead to equalizers such as the decisiondirected approach in Section 134 and the dispersionminimization method in Section 135 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 sufficiently slow 1 This is the error between the equalizer output and the transmitted symbol and is known whenever there is a training sequence 272 Chapter 13 Linear Equalization 131 Multipath Interference The villains of this chapter are multipath and other additive interferers Both should be familiar from Section 41 The distortion caused by an analog wireless channel can be thought of as a combination of scaled and delayed reflections of the original transmitted signal These reflections occur when there are different 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 reflections from nearby hills and bounces from a field or lake between the towers For indoor digital TV reception there are many local timevarying reflectors including people in the receiving room and nearby vehicles The strength of the reflections depends on the physical properties of the reflecting objects while the delay of the reflections is primarily determined by the length of the transmission path Let ut be the transmitted signal If N delays are represented by 1 2 N and the strength of the reflections is α1 α2 αN then the received signal is yt α1ut 1 α2ut 2 αNut N ηt 131 where ηt represents additive interferences This model of the transmission chan nel has the form of a finiteimpulseresponse filter 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 fixed sam pling period Ts Thus 131 is approximated by ykTs a0ukTs a1uk 1Ts anuk nTs ηkTs 132 In order for the model 132 to closely represent the system 131 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 filter ie larger n For example consider a sampling interval of Ts 40 ns ie a transmission rate of 25 MHz A delay spread of approximately 4 µs would correspond to 100 taps in the model 132 Thus at any time instant the received signal would be a combination of up to 100 data values If Ts were increased to 04 µs ie 25 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 ie 025 MHz only one term would be needed in the discretetime impulse response In this case adjacent sampled symbols would not interfere Such finiteduration impulseresponse models as 132 can also be used to represent the frequency selective dynamics that occur in the wired local endloop in telephony and other approximately linear finitedelayspread channels The design objective of the equalizer is to undo the effects of the channel and to remove the interference Conceptually the equalizer attempts to build a system that is a delayed inverse of 132 removing the intersymbol interference while Linear Equalization 273 simultaneously rejecting additive interferers uncorrelated with the source If the interference ηkTs is unstructured for instance white noise then there is little that a linear equalizer can do to remove it But when the interference is highly structured such as narrowband interference from another user then the linear filter can often notch out the offending frequencies As shown in Example 123 of Section 125 the solution for the optimal sam pling times found by the clockrecovery algorithms depends on the ISI in the channel Consequently the digital model such as 132 formed by sampling an analog transmission path such as 131 depends on when the samples are taken within each period Ts To see how this can happen in a simple case consider a twopath transmission channel δt 06δt where is some fraction of Ts For each transmitted symbol the received signal will contain two copies of the pulse shape pt the first undelayed and the second delayed by and attenuated by a factor of 06 Thus the receiver sees ct pt 06pt This is shown in Figure 132 for 07Ts The clockrecovery algorithms cannot separate the individual copies of the pulse shapes Rather they react to the complete received shape which is their sum The power maximization will locate the sampling times at the peak of this curve and the lattice of sampling times will be different from what would be expected without ISI The effective digital channel model is thus a sampled version of ct This is depicted in Figure 132 by the small circles that occur at Tsspaced intervals In general an accurate digital model for a channel depends on many things the underlying analog channel the pulse shaping used and the timing of the sampling process At first glance this seems like it might make designing an equalizer for such a channel almost impossible But there is good news No matter what timing instants are chosen no matter what pulse shape is used and no matter what the underlying analog channel may be as long as it is linear there is an FIR linear representation of the form 132 that closely models its behavior The details may change but it is always a sampling of the smooth curve like ct in Figure 132 that defines the digital model of the channel As long as the digital model of this channel does not have deep nulls ie a frequency response that practically zeroes out some important band of frequencies there is a good chance that the equalizer can undo the effects of the channel 132 Trained LeastSquares Linear Equalization When there is a training sequence available for instance in the known frame information that is used in synchronization this can also be used to help build or train an equalizer The basic strategy is to find a suitable function of the 274 Chapter 13 Linear Equalization 0 Lattice of Tsspaced optimal sampling times with ISI pt 06 pt ct pt 06 pt Lattice of Tsspaced optimal sampling times with no ISI Sum of received pulses The digital channel model is given by Tsspaced samples of ct Figure 132 The optimum sampling times as found by the energymaximization algorithm differ when there is ISI in the transmission path and change the effective digital model of the channel Source sk Channel Equalizer Additive interferers Delay Impulse response f Received signal rk Training signal Error ek Equalizer output yk Figure 133 The problem of linear equalization is to find a linear system f that undoes the effects of the channel while minimizing the effects of the interferences unknown equalizer parameters that can be used to define an optimization prob lem Then applying the techniques of Chapters 6 10 and 12 the optimization problem can be solved in a variety of ways 1321 A Matrix Description The linear equalization problem is depicted in Figure 133 A prearranged train ing sequence sk is assumed known at the receiver The goal is to find an FIR filter 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 yk sk δ for some specific δ Linear Equalization 277 Given 138 and 139 JLS in 1310 can be written as JLS ETE S RFTS RF STS RFTS STRF RFTRF 1311 Because JLS is a scalar RFTS and STRF are also scalars Since the transpose of a scalar is equal to itself RFTS STRF and 1311 can be rewritten as JLS STS 2STRF RFTRF 1312 The issue is now one of choosing the n 1 entries of F to make JLS as small as possible 1323 The LeastSquares Solution Define the matrix Ψ F RTR1RTSTRTRF RTR1RTS F TRTRF STRF F TRTS STRRTR1RTS The purpose of this definition is to rewrite 1312 in terms of Ψ JLS Ψ STS STRRTR1RTS Ψ STI RRTR1RTS 1313 Since STI RRTR1RTS is not a function of F the minimum of JLS occurs at the F that minimizes Ψ This occurs when F RTR1RTS 1314 assuming that RTR1 exists2 The corresponding minimum achievable by JLS at F F is the summed squared delayed source recovery error This is the remaining term in 1313 that is Jmin LS STI RRTR1RTS 1315 The formulas for the optimum F in 1314 and the associated minimum achievable JLS in 1315 are for a specific δ To complete the design task it is also necessary to find the optimal delay δ The most straightforward approach is to set up a series of S RF calculations one for each possible δ to compute the associated values of Jmin LS and pick the delay associated with the smallest one This procedure is straightforward to implement in Matlab and the program LSequalizerm allows you to play with the various parameters to get a feel for their effect Much of this program will be familiar from openclosedm The first 2 A matrix is invertible as long as it has no eigenvalues equal to zero Since RTR is a quadratic form it has no negative eigenvalues Thus all eigenvalues must be positive in order for it to be invertible 278 Chapter 13 Linear Equalization three lines define 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 131 LSequalizerm find a LS equalizer f for the channel b b05 1 06 def i ne channel m1000 ssign randn 1 m binary source of length m rf i l t e r b 1 s output of channel n3 length of e q u a l i z e r 1 del ta 3 use delay n length b plength r del ta Rtoeplitz r n1p r n1 11 build matrix R Ss n1del ta pdel ta and vector S finv R RR S c a l c u l a t e e q u a l i z e r f JminS SS Rinv R RR S Jmin f o r t h i s f and del ta yf i l t e r f 1 r e q u a l i z e r i s a f i l t e r decsign y quantize and f i nd e r r o r s er r 05sum abs dec del ta 1ms 1 mdel ta The variable n defines the length of the equalizer and delta defines the delay that will be used in constructing the vector S defined in 138 observe that delta must be positive and less than or equal to n The Toeplitz matrix R is defined in 135 and 136 and the equalizer coefficients f are computed as in 1314 The value of minimum achievable performance is Jmin which is calculated as in 1315 To demonstrate the effect of the equalizer the received signal r is filtered by the equalizer coefficients and the output is then quantized If the equalizer has done its job ie if the eye is open then there should be some shift sh at which no errors occur For example using the default channel b 05 1 06 and length4 equalizer n3 four values of the delay delta give delay delta Jmin equalizer f 0 832 033 0027 0070 001 1 134 066 036 016 008 2 30 028 065 030 014 3 45 01 027 064 03 1316 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 131 Plot the frequency response using freqz of the channel b in LSequalizerm Plot the frequency response of each of the four equalizers found by the program For each channelequalizer pair form the product of the magnitude of the frequency responses How close are these products to unity Exercise 132 Add uncorrelated normally distributed noise into the simula tion using the command rfilterb1ssdrandnsizes 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 133 Use LSequalizerm to find an equalizer that can open the eye for the channel b 1 1 08 03 1 1 a What equalizer length n is needed b What delays delta give zero error at the output of the quantizer c What is the corresponding Jmin d Plot the frequency response of this channel e Plot the frequency response of your equalizer f Calculate and plot the product of the two Exercise 134 Modify LSequalizerm to generate a source sequence from the alphabet 1 3 For the default channel 05 1 06 find an equalizer that opens the eye a What equalizer length n is needed b What delays delta give zero error at the output of the quantizer c What is the corresponding Jmin d Is this a fundamentally easier or more difficult task than when equalizing a binary source e Plot the frequency response of the channel and of the equalizer 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 sα 1 sα s1 sα 2 sα 1 s2 sp sp 1 sp α 1317 where α specifies the number of delays δ that will be searched from δ 0 to δ α The p α n 1 matrix of received data is R rα 1 rα rα n 1 rα 2 rα 1 rα n 2 rp rp 1 rp n 1318 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 Linear Equalization 283 in the document A Digital Quadrature Amplitude Modulation Radio which can be found on the website The same basic strategy for equalizer design can also be used in the complex case Consider a complex delayed source recovery error ek eRk jeIk where j 1 Consider its square e2k e2 Rk 2jeRkeIk e2 Ik which is typically complexvalued and potentially realvalued and negative when eR 0 Thus a sum of e2 is no longer a suitable measure of performance since e might be nonzero but its squared average might be zero Instead consider the product of a complex e with its complex conjugate e eR jeI that is ekek e2 Rk jeRkeIk jeRkeIk j2e2 Ik e2 Rk e2 Ik In vector form the summed squared error of interest is EHE rather than the EHE of 1311 where the superscript H denotes the operations of both transposition and complex conjugation Thus 1314 becomes F RHR1RHS Note that in implementing this refinement in the Matlab code the symbol pair implements a transpose while alone implements a conjugate transpose 1326 Fractionally Spaced Equalization The preceding development assumes that the sampled input to the equalizer is symbol spaced with the sampling interval equal to the symbol interval of T seconds Thus the unit delay in realizing the tappeddelayline equalizer is T seconds Sometimes the input to the equalizer is oversampled such that the sample interval is shorter than the symbol interval and the resulting equalizer is said to be fractionally spaced The same kinds of algorithms and solutions can be used to calculate the coefficients in fractionally spaced equalizers as are used for T spaced equalizers Of course details of the construction of the matrices corresponding to S and R will necessarily differ due to the structural differences The more rapid sampling allows greater latitude in the ordering of the blocks in the receiver This is discussed at length in Equalization on the website Exercise 135 Consider the multiuser system shown in Figure 135 Both users transmit binary 1 PAM signals that are independent and equally probable sym bols The signal from the first user is distorted by a frequencyselective channel with impulse response h1k δk bδk 1 286 Chapter 13 Linear Equalization f k Sign rk yk ek sk training signal Equalizer Adaptive algorithm Performance evaluation Decision device Sampled received signal Figure 136 A trained adaptive linear equalizer uses the difference between the received signal and a prespecified training sequence to drive the adaptation of the coefficients of the equalizer LSequalizerm 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 difference between the prediction and the reality This is the calculation of ek from 1323 The equalizer coefficients f are then updated as in 1327 Listing 132 LMSequalizerm find a LMS equalizer f for the channel b b05 1 06 def i ne channel m1000 spamm 2 1 binary source of length m rf i l t e r b 1 s output of channel n4 fzeros n 1 i n i t i a l i z e e q u a l i z e r at 0 mu01 del ta 2 s t e p s i z e and delay del ta for in1m i t e r a t e r rr i 1 i n1 vector of r ecei ved s i g n a l es i del ta rr f c a l c u l a t e er r or ffmue r r update e q u a l i z e r c o e f f i c i e n t s end As with the matrix approach the default channel b05 1 06 can be equalized easily with a short equalizer one with a small n The convergent val ues of the f are very close to the final values of the matrix approach that is for a given channel the value of f given by LMSequalizerm is very close to the value found using LSequalizerm 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 timevarying Similarly if the explicit averaging operation is retained longer averages imply smoother estimates but slower convergence Similar trade offs 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 EqualizerTestm shows one way to verify that the equal izer has or has not done a good job The code generates a new received signal and passes it through the same channel and the final converged equalizer from LMSequalizerm 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 133 EqualizerTestm verify the operation of an equalizer f for the channel b F i r s t run LMSequalizer m to s et channel b and e q u a l i z e r f f i n a l e qf t e s t f i n a l f i l t e r f m1000 new data points spamm 2 1 new binary source of length m rf i l t e r b 1 s output of channel ytf i l t e r f 1 r use f i n a l f i l t e r f to t e s t decsign real yt quantization for sh0n i f e q u a l i z e r i s working one er r sh 105sum abs dec sh1ms 1 msh end of these delays has zero er r or This trained adaptive approach along with several others is implemented in the program daem which is available on the website Simulated examples of LMS with training and other adaptive equalization methods are presented in Section 136 Exercise 136 Verify that by proper choice of n and delta the convergent values of f in LMSequalizerm are close to the values shown in 1316 Exercise 137 What happens in LMSequalizerm when the stepsize parameter mu is too large What happens when it is too small Exercise 138 Add uncorrelated normally distributed noise into the simula tion using the command rfilterb1ssdrandnsizes a For the equalizer with delay 2 what is the largest sd you can add and still have no errors How does this compare with the result from Exercise 132 Hint it may be necessary to simulate for more than the default m data points b Now try the equalizer with delay 1 What is the largest sd you can add and still have no errors c Which is a better equalizer Exercise 139 Use LMSequalizerm to find an equalizer that can open the eye for the channel b 1 1 08 03 1 1 a What equalizer length n is needed b What delays delta give zero error in the output of the quantizer c How does the answer compare with the design in Exercise 133 Exercise 1310 Modify LMSequalizerm and EqualizerTestm to generate a source sequence from the alphabet 1 3 For the default channel 05 1 06 find an equalizer that opens the eye Linear Equalization 289 Sign Equalizer Adaptive algorithm Performance evaluation Decision device f k rk yk ek Sampled received signal Figure 137 A decisiondirected adaptive linear equalizer uses the difference between the received signal and the output of the decision device to drive the adaptation of the coefficients of the equalizer When the signal sk is multilevel instead of binary the sign function in 1328 can be replaced with a quantizer Exercise 1312 Show that the decisiondirected LMS algorithm 1328 can be derived as an adaptive element with performance function 12avgsignyk yk2 Hint suppose that the derivative of the sign func tion dsignxdx is zero everywhere Observe that the source signal sk does not appear in 1328 Thus no train ing signal is required for its implementation and the decisiondirected LMS equal izer adaptation law of 1328 is called a blind equalizer Given its genesis one should expect decisiondirected LMS to exhibit poor behavior when the assump tion regarding perfect decisions is violated The basic rule of thumb is that 5 or so decision errors can be tolerated before decisiondirected LMS fails to converge properly The Matlab program DDequalizerm has a familiar structure The only code changed from LMSequalizerm is the calculation of the error term which imple ments ek signyk yk rather than the LMS error 1323 and the ini tialization of the equalizer Because the equalizer must begin with an open eye f0 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 centerspike ini tialization 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 finding good initial values for the equal izer parameters As with the LMS equalizer the code in EqualizerTestm can be used to test the operation of the converged equalizer Listing 134 DDequalizerm find a DD equalizer f for the channel b b05 1 06 def i ne channel m1000 ssign randn 1 m binary source of length m rf i l t e r b 1 s output of channel n4 f 0 1 0 0 i n i t i a l i z e e q u a l i z e r mu1 s t e p s i z e for in1m i t e r a t e r rr i 1 i n1 vector of r ecei ved s i g n a l 290 Chapter 13 Linear Equalization esign f r r f r r c a l c u l a t e er r or ffmue r r update e q u a l i z e r c o e f f i c i e n t s end Exercise 1313 Try the initialization f0 0 0 0 in DDequalizerm With this initialization can the algorithm open the eye Try increasing m Try changing the stepsize mu What other initializations will work Exercise 1314 What happens in DDequalizerm when the stepsize parameter mu is too large What happens when it is too small Exercise 1315 Add uncorrelated normally distributed noise into the simu lation using the command rfilterb1ssdrandnsizes What is the largest sd you can add and still have no errors Does the initial value for f influence this number Try at least three initializations Exercise 1316 Use DDequalizerm to find an equalizer that can open the eye for the channel b1 1 08 03 1 1 a What equalizer length n is needed b What initializations for f did you use c How does the converged answer compare with the design in Exercises 133 and 139 Exercise 1317 Modify DDequalizerm to generate a source sequence from the alphabet 1 3 For the default channel 05 1 06 find an equalizer that opens the eye a What equalizer length n is needed b What initializations for f did you use c Is this a fundamentally easier or more difficult task than when equalizing a binary source d How does the answer compare with the design in Exercises 134 and 1310 Section 136 provides the opportunity to view the simulated behavior of the decisiondirected equalizer and to compare its performance with the other meth ods 135 DispersionMinimizing Linear Equalization This section considers an alternative performance function that leads to another kind of blind equalizer Observe that for a binary 1 source the square of the source is known even when the particular values of the source are not Thus s2k 1 for all k This suggests creating a performance function that penalizes 292 Chapter 13 Linear Equalization 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 DMAequalizerm The first few lines define the channel create the binary source and pass the input through the channel The last few lines implement the equal izer 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 LSequalizerm The new part of the code is in the center which defines the length n of the equalizer the stepsize mu of the algorithm and the initialization of the equalizer which defaults to a centerspike initialization The coefficients of the equalizer are updated as in 1329 As with the other equalizers the code in EqualizerTestm can be used to test the operation of the converged equalizer Listing 135 DMAequalizerm find a DMA equalizer f for the channel b b05 1 06 def i ne channel m1000 ssign randn 1 m binary source of length m rf i l t e r b 1 s output of channel n4 f 0 1 0 0 center spike i n i t i a l i z a t i o n mu01 algorithm s t e p s i z e for in1m i t e r a t e r rr i 1 i n1 vector of r ecei ved s i g n a l ef r r 1 f r r ˆ 2 c a l c u l a t e er r or ffmue r r update e q u a l i z e r c o e f f i c i e n t s end Running DMAequalizerm results in an equalizer that is numerically similar to the equalizers of the previous two sections Initializing with the spike at dif ferent locations results in equalizers with different effective delays The following exercises are intended to encourage you to explore the DMA equalizer method Exercise 1318 Try the initialization f0 0 0 0 in DMAequalizerm With this initialization can the algorithm open the eye Try increasing m Try changing the stepsize mu What other nonzero initializations will work Exercise 1319 What happens in DMAequalizerm when the stepsize parame ter mu is too large What happens when it is too small Exercise 1320 Add uncorrelated normally distributed noise into the simu lation using the command rfilterb1ssdrandnsizes What is the largest sd you can add and still have no errors Does the initial value for f influence this number Try at least three initializations Linear Equalization 293 Exercise 1321 Use DMAequalizerm to find an equalizer that can open the eye for the channel b1 1 08 03 1 1 a What equalizer length n is needed b What initializations for f did you use c How does the converged answer compare with the designs in Exercises 133 139 and 1316 Exercise 1322 Modify DMAequalizerm to generate a source sequence from the alphabet 1 3 For the default channel 05 1 06 find an equalizer that opens the eye a What equalizer length n is needed b What is an appropriate value of γ c What initializations for f did you use d Is this a fundamentally easier or more difficult task than when equalizing a binary source e How does the answer compare with the designs in Exercises 134 1310 and 1317 Exercise 1323 Consider a DMAlike performance function J 1 2 avg1 y2k Show that the resulting gradient algorithm is fik 1 fik µavgsign1 y2kykrk i Hint assume that the derivative of the absolute value is the sign function Imple ment the algorithm and compare its performance with the DMA of 1329 in terms of a speed of convergence b number of errors in a noisy environment recall Exercise 1320 and c ease of initialization Exercise 1324 Consider a DMAlike performance function J avg1 yk What is the resulting gradient algorithm Implement your algorithm and compare its performance with the DMA of 1329 in terms of a speed of convergence of the equalizer coefficients f b number of errors in a noisy environment recall Exercise 1320 and c ease of initialization 294 Chapter 13 Linear Equalization 136 Examples and Observations This section uses the Matlab program daem which is available on the website The program demonstrates some of the properties of the leastsquares solution to the equalization problem and its adaptive cousins LMS decisiondirected LMS and DMA6 The default settings in daem are used to implement the equalizer designs for three channels The source alphabet is a binary 1 signal Each channel has an FIR impulse response and its output is summed with a sinusoidal interference and some uniform white noise before reaching the receiver The user is prompted for the 1 choice of channels 0 1 or 2 2 maximum delay of the equalizer 3 number of samples of training data 4 gain of the sinusoidal interferer 5 frequency of the sinusoidal interferer in radians and 6 magnitude of the white noise The program returns plots of the 1 received signal 2 optimal equalizer output 3 impulse response of the optimal equalizer and the channel 4 recovery error at the output of the decision device 5 zeros of the channel and the combined channelequalizer pair and 6 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 1391314 The program also prints the condition number of RT R the minimum average squared recovery error ie 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 condition number 1302631 minimum value of performance function 00534 optimum delay 16 percentage of errors 0 6 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 295 0 05 1 05 0 1000 2000 3000 4000 1 08 04 0 0 10 20 30 40 12 0 1 2 1 0 1000 2000 3000 4000 2 Decision device recovery error 0 1 1 2 0 1000 2000 3000 4000 Combined channel and optimal equalizer impulse response Optimal equalizer output Received signal Figure 139 Trained leastsquares 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 sufficient separation to open the eye The bottomleft figure 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 bottomright plot shows that the message signal is recovered without error r Channel 1 condition number 14795 minimum value of performance function 00307 optimum delay 12 percentage of errors 0 r Channel 2 condition number 1641081 minimum value of performance function 00300 optimum delay 10 percentage of errors 0 To see what these figures mean consider the eight plots contained in Figures 139 and 1310 The first plot is the received signal which contains the trans mitted 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 296 Chapter 13 Linear Equalization 30 50 60 10 20 40 0 0 1 2 3 4 10 0 05 05 1 1 1 0 1 0 10 20 10 0 1 2 3 4 20 Freq Resp Phase 05 0 05 1 1 05 0 05 1 1 Zeros of channelequalizer combination Freq Resp Magnitude Normalized frequency FIR channel zeros Imaginary part Imaginary part db radians Real part Normalized frequency Real part Figure 1310 Trained leastsquares equalizer for channel 0 singularities and frequency responses The large circles show the locations of the zeros of the channel in the upperleft plot and the locations of the zeros of the combined channelequalizer pair in the lowerleft 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 0 1000 2000 3000 4000 1 05 0 05 1 Received signal 0 1000 2000 3000 4000 Optimal equalizer output 15 1 05 0 05 15 1 0 10 20 30 40 Combined channel and optimal equalizer impulse response 0 1000 2000 3000 4000 Decision device recovery error 1 05 0 05 1 02 02 06 0 04 08 1 12 Figure 1311 Trained leastsquares equalizer for channel 1 time responses As in Figure 139 the equalizer is able to effectively undo the effects of the channel Linear Equalization 297 1 0 1 FIR channel zeros 0 1 2 3 4 Freq Resp Magnitude Zeros of channelequalizer combination 0 1 2 3 4 Freq Resp Phase Normalized frequency radians db Normalized frequency Real part Real part Imaginary part Imaginary part 40 30 20 10 0 1 05 05 0 1 20 10 0 10 20 2 4 0 2 4 10 8 6 4 2 0 Figure 1312 Trained leastsquares equalizer for channel 1 singularities and frequency responses The large circles show the locations of the zeros of the channel in the upperleft plot and the locations of the zeros of the combined channelequalizer pair in the lowerleft 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 signal7 The width of these stripes is related to the cluster variance The difference 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 1310 show the same situation but in the frequency domain The zeros of the channel are depicted in the upperleft plot This con stellation of zeros corresponds to the darkest of the frequency responses drawn in the second plot The primarily lowpass character of the channel can be intu ited directly from the zero plot with the technique of Section F2 The T spaced equalizer accordingly has a primarily highpass character as can be seen from the dashed frequency response in the upperright plot of Figure 1310 Combin ing these two gives the response in the middle This middle response plotted with the solid line is mostly flat except for a large dip at 14 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 Chapter 13 Linear Equalization 15 1 05 0 05 1 150 1000 2000 3000 4000 Received signal 12 1 08 06 02 04 0 1 05 0 05 1 020 0 1000 2000 3000 4000 10 20 30 40 50 Combined channel and optimal equalizer impulse response 15 1 05 0 05 15 1 20 1000 2000 3000 4000 Optimal equalizer output Decision device recovery error Figure 1313 Trained leastsquares equalizer for channel 2 time responses Even for this fairly severe channel the equalizer is able to effectively undo the effects of the channel as in Figures 139 and 1311 second major use of the equalizer it is capable of removing uncorrelated interfer ences Observe that the equalizer design is given no knowledge of the frequency of the interference nor even that any interference exists Nonetheless it auto matically compensates for the narrowband interference by building a notch at the offending frequency The plot labeled Zeros of channelequalizer combina tion 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 flat But observe that one pair of zeros at 14 radi ans 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 notch8 The eight plots for each of the other channels are displayed in similar fashion in Figures 1311 to 1314 Figures 13151317 demonstrate equalizer design using the various recursive methods of Sections 133 to 135 on the same problem After running the least squares design in daem the script asks whether you wish to simulate a recursive solution If yes then you can choose r which algorithm to run trained LMS decisiondirected LMS or blind DMA r the stepsize and 8 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 299 15 1 05 0 05 1 15 1 0 1 2 FIR channel zeros Real part Imaginary part db 0 10 15 5 20 25 30 350 1 2 3 4 Zeros of channelequalizer combination 30 20 10 0 10 30 20 0 1 2 3 4 Freq Resp Magnitude Normalized frequency Normalized frequency Freq Resp Phase 15 1 05 0 05 1 15 1 0 1 2 Real part Imaginary part radians Figure 1314 Trained leastsquares equalizer for channel 2 singularities and frequency responses The large circles show the locations of the zeros of the channel in the upperleft plot and the locations of the zeros of the combined channelequalizer pair in the lowerleft 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 specifies 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 13151317 all three adaptive schemes are suc cessful with the recommended default values which were used in equalizing channel 0 All three exhibit in the upperleft plots of Figures 13151317 decay ing averaged squared parameter error relative to their respective trained least squares equalizer for the data block This means that all are converging to the vicinity of the trained leastsquares equalizer about which daem initializes the algorithms The collapse of the squared prediction error is apparent from the upperright plot in each of these figures An initially closed eye appears for a short while in each of the lowerleft plots of equalizer output history in the fig ures The match of the magnitudes of the frequency responses of the trained block leastsquares equalizer plotted with the solid line and the last adaptive equalizer setting plotted with asterisks from the datablock stream is quite striking in the lowerright plots in these figures As expected we find 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 leastsquares solution exhibits peaks valleys where the channel response has valleys peaks so that the combined response is nearly flat The phase of the trained leastsquares equalizer adds with the channel phase so 300 Chapter 13 Linear Equalization 5 10 15 0 0 1 2 3 4 5 Normalized frequency 0 1 2 3 1 0 1000 2000 3000 4000 2 Iterations dB Adaptive equalizer output 2 15 1 05 0 25 0 1000 2000 3000 4000 3 Iterations Combined magnitude response 100 101 0 1000 2000 3000 101 Iterations Squared prediction error Summed squared parameter error Figure 1315 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 meansquareerror solution that their combination approximates a linear phase curve Refer to plots in the right columns of Figures 1310 1312 and 1314 r With modest channel noise and interferers as the length of the equalizer increases the zeros of the combined channel and equalizer form rings The rings are denser the nearer the channel zeros are to the unit circle There are many ways in which the program daem 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 leastsquares 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 leastsquares equalizer at the frequency of the interferer 3 DMA is considered slower than trained LMS Do you find that DMA takes longer to converge Can you think of why it might be slower 4 DMA typically accommodates larger initialization error than decisiondirected LMS Can you find cases where with the same initialization DMA converges to an errorfree solution but the decisiondirected LMS does not Do you think there are cases in which the opposite holds Linear Equalization 301 5 10 15 0 0 1 2 3 4 5 Normalized frequency 1 0 1 2 3 2 0 1000 2000 3000 4000 3 Iterations dB Adaptive equalizer output 1 05 0 15 0 1000 2000 3000 4000 2 Iterations Combined magnitude response 100 101 0 1000 2000 3000 101 Iterations Squared prediction error Summed squared parameter error Figure 1316 Decisiondirected 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 meansquareerror solution 5 10 15 0 0 1 2 3 4 5 Normalized frequency 1 0 1 2 3 2 0 1000 2000 3000 4000 3 Iterations dB Adaptive equalizer output 2 1 0 3 0 1000 2000 3000 4000 4 Iterations Combined magnitude response 100 101 0 1000 2000 3000 101 Iterations Squared prediction error Summed squared parameter error Figure 1317 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 meansquareerror solution 302 Chapter 13 Linear Equalization 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 appro priate delay is implicit in the initialization of the equalizer coefficients Can you find a case in which with the delay poorly specified DMA outperforms trained LMS from the same initialization For Further Reading A comprehensive survey of trained adaptive equalization can be found in r S U H Qureshi Adaptive Equalization Proceedings of the IEEE vol 73 no 9 pp 13491387 Sept 1985 An overview of the analytical tools that can be used to analyze LMSstyle adap tive algorithms can be found in r W A Sethares The LMS Family in Efficient System Identification and Sig nal Processing Algorithms Eds N Kalouptsidis and S Theodoridis Prentice Hall 1993 A copy of this paper can also be found on the accompanying website One of our favorite discussions of adaptive methods is r C R Johnson Jr Lectures on Adaptive Parameter Estimation PrenticeHall 1988 This whole book can be found in pdf form on the website An extensive discussion of equalization can also be found in Equalization on the website 14 Coding The underlying purpose of any communication system is to transmit information But what exactly is information How is it measured Are there limits to the amount of data that can be sent over a channel even when all the parts of the system are operating at their best This chapter addresses these fundamental questions using the ideas of Claude Shannon 19162001 who defined a measure of information in terms of bits The number of bits per second that can be transmitted over the channel taking into account its bandwidth the power of the signal and the noise is called the bit rate and can be used to define the capacity of the channel Unfortunately Shannons results do not give a recipe for how to construct a system that achieves the optimal bit rate Earlier chapters have highlighted several problems that can arise in communication systems including synchro nization errors such as intersymbol interference This chapter assumes that all of these are perfectly mitigated Thus in Figure 141 the inner parts of the communication system are assumed to be ideal except for the presence of chan nel noise Even so most systems still fall far short of the optimal performance promised by Shannon There are two problems First most messages that people want to send are redundant and the redundancy squanders the capacity of the channel A solu tion is to preprocess the message so as to remove the redundancies This is called source coding and is discussed in Section 145 For instance as demonstrated in Section 142 any natural language such as English whether spoken or written is repetitive Information theory as Shannons approach is called quantifies the repetitiveness and gives a way to judge the efficiency of a source code by com paring the information content of the message with the number of bits required by the code The second problem is that messages must be resistant to noise If a message arrives at the receiver in garbled form then the system has failed A solution is to preprocess the message by adding extra bits which can be used to determine whether an error has occurred and to correct errors when they do occur For 304 Chapter 14 Coding Source coding Channel coding Undo channel coding Undo source coding Transmitter Channel Receiver Inherently redundant message to be transmitted Compressed redundancy removed Structured redundancy removed Structured redundancy added Reconstructed message Noise Figure 141 Source and channel coding techniques manage redundancies in digital communication systems by first removing inherent redundancies in the message then adding structured redundancies which aid in combatting noise problems and finally restoring the original message example one simple system would transmit each bit three times Whenever a singlebit error occurs in transmission then the decoder at the receiver can figure out by a simple voting rule that the error has occurred and what the bit should have been Schemes for finding and removing errors are called errorcorrecting codes or channel codes and are discussed in Section 146 At first glance this appears paradoxical source coding is used to remove redundancy while channel coding is used to add redundancy But it is not really selfdefeating 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 141 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 141 What Is Information Like many common English words information has many meanings The Amer ican Heritage Dictionary catalogs six 1 Knowledge derived from study experience or instruction 2 Knowledge of a specific event or situation intelligence 3 A collection of facts or data 4 The act of informing or the condition of being informed communication of knowledge 5 Computer Science A nonaccidental signal or character used as an input to a computer or communication system 6 A numerical measure of the uncertainty of an experimental outcome Coding 305 It would clearly be impossible to capture all of these senses in a technical defini tion that would be useful in transmission systems The final definition 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 sim ple relationship between the amount of information conveyed in a message and the probability of the message being sent This does not apply directly to mes sages such as sentences images or wav files 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 send ing H is 09 while the probability of sending T is 01 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 informa tion 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 first 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 first 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 pos sible outcome of an experiment such as the flipping of a coin or the transmission of a symbol across a communication channel Let pxi be the probability that the ith event occurs and suppose that some event must occur1 This means that 1 When flipping the coin it cannot roll into the corner and stand on its edge each flip results in either H or T 308 Chapter 14 Coding percentage of the time is 5 transmitted What is the information conveyed by each of the symbols Exercise 143 The 8bit binary ASCII representation of any letter or any character of the keyboard can be found using the Matlab command dec2bintext where text is any string Using ASCII how much information is contained in the letter a assuming that all the letters are equally probable Exercise 144 Consider a decimal representation of π 31415926 Calcu late the information number of bits required to transmit successive digits of π assuming that the digits are independent Identify N xi and pxi How much information is contained in the first million digits of π There is an alternative definition of information in common usage in the mathematicallogic and computerscience communities in which information is defined in terms of the complexity of representation rather than in terms of the reduction in uncertainty Informally speaking this alternative defines the complexity or information content of a message by the length of the shortest computer program that can replicate the message For many kinds of data such as a sequence of random numbers the two measures agree because the shortest program that can represent the sequence is just a listing of the sequence But in other cases they can differ dramatically Consider transmitting the first million digits of the number π Shannons definition gives a large information content as in Exercise 144 while the complete sequence can in principle be transmitted with a very short computer program 142 Redundancy All the examples in the previous section presume that there is no relationship between successive symbols This was the independence assumption in 142 This section shows by example that real messages often have significant corre lation 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 8bit binary ASCII character set recognized by computers as the text format which translates the char acter 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 flipped from one to zero or from zero to one Then about 35 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 deci pher 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 exten sive 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 hwav3p dhat by sending phc hformatIon if a rEdundaft fnre thd prkbahity 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 hAed At by sjdafd th hfFoPmati f a pd5jdan fLbe thd rabDITy o drkp1 aa bE rdued These examples were all generated using the following Matlab program redundantm which takes the text textm translates it into a binary string and then causes per percent of the bits to be flipped The program then gathers statistics on the resulting numbers of bit errors and symbol errors how many letters were changed Listing 141 redundantm redundancy of written english in bits and letters textmIt is clear however that by sending the 310 Chapter 14 Coding information in a redundant form the probability of errors can be reduced 8bi t a s c i i binary equi val ent of text ascmdec2bin double textm 8 turn i nto one long binary s t r i n g binmreshape ascm 1 8 length textm per 01 p r o b a b i l i t y of bi t er r or for i 18 length textm rrand swap 0 and 1 with p r o b a b i l i t y per i f r1per binm i0 binm i 1 end i f r1per binm i1 binm i 0 end end ascrreshape binm 8 length textm to a s c i i binary textrsetstr bin2dec ascr to text b i t e r r o rsumsumabs ascr ascm of bi t e r r o r s symerrrorsum sign abs textmtextr of symbol e r r o r s numwordssum sign find textm321 of words in textm l e t t e r r o rsymerrror length textm of l e t t e r e r r o r s Exercise 145 Read in a large text file using the following Matlab code Use one of your own or use one of the included text files2 Make a plot of the symbol error rate as a function of the bit error rate by running redundantm 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 142 readtextm read in a text document and translate to character string fid messagei fopen OZtxt r f i l e must be text fdatafread f i d read text as a vector textchar fdata to character s t r i n g Thus for English text encoded as ASCII characters a significant number of errors can occur about 10 of the letters can be arbitrarily changed without altering the meaning of the sentence While these kinds of errors can be corrected by a human reader the redundancy is not in a form that is easily exploited by a computer Even imagining that the computer could look up words in a dictionary the person knows from context that It is clear is a more likely phrase than It is clean when correcting Shannons sentence with 1 errors The person can figure out from context that cAf from the phrase with 2 bit errors must have had two errors by using the longterm correlation of the sentence ie its meaning Computers do not deal readily with meaning3 In the previous section the information contained in a message was defined to depend on two factors the number of symbols and their probability of occurrence But this assumes that the symbols do not interactthat the letters are indepen 2 Through the Looking Glass by Lewis Carroll carrolltxt and The Wonderful Wizard of Oz by Frank Baum OZtxt are available on the website 3 A more optimistic rendering of this sentence Computers do not yet deal readily with mean ing 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 20345 times and t appears 14811 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 647 h 575 o 649 v 059 b 109 i 463 p 101 w 249 c 177 j 008 q 007 x 007 d 419 k 090 r 471 y 191 e 1029 l 342 s 451 z 013 f 161 m 178 t 749 g 160 n 490 u 205 144 Space is the most frequent character occurring 20 of the time It was easier to use the following Matlab code in conjunction with readtextm than to count the letters by hand Listing 143 freqtextm frequency of occurrence of letters in text l i t t l elength find t e x t s t r i n gt how many times t occurs biglength find t e x t s t r i n gT how many times T occurs f r eq l i t t l ebig length t e x t s t r i n g percentage If English letters were truly independent then it should be possible to generate Englishlike text using this table of probabilities Here is a sample Od m shous t ad schthewe be amalllingod ongoutorend youne he Any bupecape tsooa w beves p le t ke teml ley une weg rloknd which does not look anything like English How can the nonindependence of the text be modeled One way is to consider the probabilities of successive pairs of letters instead of the probabilities of individual letters For instance the pair th is quite frequent occurring 11014 times in the Wizard of Oz while sh occurs 861 times Unlikely pairs such as wd occur in only five places4 and pk not at all For example suppose that He was chosen first The next pair would be e followed by something with the probability of the something dictated by the entries in the table Following this procedure results in output like this Her gethe womfor if you the to had the sed th and the wention At th youg the yout by and a pow eve cank i as saing paill 4 In the words crowd and sawdust 312 Chapter 14 Coding Observe that most of the twoletter combinations are actual words as well as many threeletter words Longer sets of symbols tend to wander improbably While in principle it would be possible to continue gathering probabilities of all threeletter combinations then four etc the table begins to get rather large a matrix with 26n elements would be needed to store all the nletter 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 textsimm which allows specification of any text with the default being The Wizard of Oz and any num ber of terms for the probabilities For instance with m1 the letters are chosen completely independently with m2 the letters are chosen from successive pairs and with m3 they are chosen from successive triplets Thus the probabilities of clusters of letters are defined implicitly by the choice of the source text Listing 144 textsimm use large text to simulate transition probabilities m1 terms f o r t r a n s i t i o n l i n e l e n g t h 60 l e t t e r s in each l i n e load OZ mat f i l e f o r input ntext 1 m nl i nen nl etx i n i t i a l i z e v a r i a b l e s for i 1100 l i n e s in output j 1 while jl i n e l e n g t h nl et scan through f i l e kfindstr text n a l l occurrences of seed indround length k1rand1 pick one nl ettext k indm i f abs nl et 13 tr eat c a r r i a g e r etur ns nl et as spaces end nl i ne nline nl et add next l e t t e r nn 2 m nl et new seed jj 1 end disp nl i ne setstr 1 3 format output add CRs nl i ne i n i t i a l i z e next l i n e end Typical output of textsimm depends heavily on the number of terms m used for the transition probabilities With m1 or m2 the results appear much as above When m3 Be end claime armed yes a bigged wenty for me fearabbag girl Humagine ther mightmarkling the 5 C E Shannon A Mathematical Theory of Communication The Bell System Technical Journal vol 27 nos 7 and 10 pp 379423 and 623656 July and October 1948 Coding 313 many the scarecrow pass and I havely and lovery wine end at then only we pure never many words appear and many combinations of letters that might be words but arent quite Humagine is suggestive though it is not clear exactly what mightmarkling might mean When m4 Water of everythinkies friends of the scarecrow no head we She time toto be well as some although to they would her been Them became the small directions and have a thing woodman the vast majority of words are actual English though the occasional conjunction of words such as everythinkies is not uncommon The output also begins to strongly reflect the text used to derive the probabilities Since many fourletter combinations occur only once there is no choice for the method to continue spelling a longer word this is why the scarecrow and the woodman figure prominently For m5 and above the random output is recognizably English and strongly dependent on the text used Four trouble and to taken until the bread hastened from its Back to you over the emerald city and her in toward the will Trodden and being she could soon and talk to travely lady Exercise 146 Run the program textsimm using the input file carrollmat 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 147 Run the program textsimm using the input file foreignmat 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 148 The program textsimm operates at the level of letters and the probabilities of transition between successive sets of mlength letter sequences Write an analogous program that operates at the level of words and the prob abilities of transition between successive sets of mlength word sequences Does your program generate plausiblesounding phrases or sentences 314 Chapter 14 Coding Exercise 149 There is nothing about the technique of textsimm that is inherently limited to dealing with text sequences Consider a piece of notated music as a sequence of symbols labeled so that each C note is 1 each C note is 2 each D note is 3 etc Create a table of transition probabilities from a piece of music and then generate new melodies in the same way that textsimm generates new sentences Observe that this procedure can be automated using standard MIDI files as input Because this method derives the multiletter probabilities directly from a text there is no need to compile transition probabilities for other languages Using Vergils Aeneid with m3 gives Aenere omnibus praeviscrimus habes ergemio nam inquae enies Media tibi troius antis igna volae subilius ipsis dardatuli Cae sanguina fugis ampora auso magnum patrix quis ait longuin which is not real Latin Similarly Que todose remosotro enga tendo en guinada y ase aunque lo Se dicielos escubra la no fuerta pare la paragales posa derse Y quija con figual se don que espedios tras tu pales del is not Spanish the input file was Cervantes Don Quijote also with m3 and Seule sontagne trait homarcher de la t au onze le quance matices Maississait passepart penaient la ples les au cherche de je Chamain peut accide bien avaien rie se vent puis il nez pande is not French the source was Le Tour du Monde en Quatre Vingts Jours a translation of Jules Vernes Around the World in Eighty Days The input file to the program textsimm is a Matlab mat file that has been preprocessed to remove excessive line breaks spaces and capitalization using textmanm which is why there is no punctuation in these examples A large assortment of text files is available for downloading at the website of Project Gutenberg at httpwwwgutenbergorg Text in a variety of languages retains some of the character of its language with correlations of 3 to 5 letters 2135 bits when coded in ASCII Thus mes sages written in those languages are not independent except possibly at lengths greater than this A result from probability theory suggests that if the letters are clustered into blocks that are longer than the correlation then the blocks may be nearly independent This is one strategy to pursue when designing codes 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 defines 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 four level data is generated by calling the pamm routine Noise is then added with power specified by p and the number of errors caused by this amount of noise is calculated in err Listing 145 noisychanm generate 4level data and add noise m1000 length of data sequence p115 s 10 power of noi s e and s i g n a l xpamm 4 s 4PAM input with power 1 Lsqrt 1 5 with amp l e v e l s L nsqrt prandn 1 m noi s e with power p yxn output adds noi s e to data qyquantalph y 3LL L3L quantize to 3LL L3L er rsum abs sign qyx m percent transmission e r r o r s Typical outputs of noisychanm are shown in Figure 144 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 righthand case is the maximum noise allowable in the plausibility argument used to derive 147 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 1412a the noise was chosen to be independent and normally distributed with power P to ensure that 4 1 P P The middle plot used a noise with power P3 and the lefthand plot had noise power P6 As can be seen from the plots there were essentially no errors when using the smallest noise a handful of errors in the middle and about 6 errors when the power of the noise matched the Shannon capacity Thus this naive transmission of fourlevel data ie with no coding has many more errors than the Shannon limit suggests Exercise 1412 Find the amplitudes of the Nlevel equally spaced signal with unity power when a N 4 b N 6 c N 8 Exercise 1413 Use noisychanm to compare the noise performance of two level fourlevel and sixlevel transmissions 322 Chapter 14 Coding 2 1 1 2 2000 4000 0 16 max noise 2000 0 0 4000 13 max noise 2000 0 4000 max noise Amplitude Figure 144 Each plot shows a fourlevel PAM signal the four solid lines the signal plus noise the scattered dots and the error between the data and the quantized output the dark stars The noise in the righthand plot was at the Shannon limit N S P P the noise in the middle plot was at onethird the power and the noise in the lefthand plot was at onesixth the power a Modify the program to generate two and sixlevel signals b Make a plot of the noise power versus the percentage of errors for two four and six levels Exercise 1414 Use noisychanm to compare the power requirements for two level fourlevel and sixlevel transmissions Fix the noise power at p001 and find the error probability for fourlevel transmission Experimentally find the power S that is required to make the twolevel and sixlevel transmissions have the same probability of error Can you think of a way to calculate this Exercise 1415 Consider the asymmetric nonuniformly spaced alphabet con sisting of the symbols 1 1 3 4 a Find the amplitudes of this fourlevel signal with unity power b Use noisychanm to examine the noise performance of this transmission by making a plot of the noise power versus the percentage of errors c Compare this alphabet with 4PAM using the standard alphabet 1 3 Which would you prefer There are two different problems that can keep a transmission system from reaching the Shannon limit The first is that the source might not be coded with maximum entropy and this will be discussed next in Section 145 The second is when different symbols experience different amounts of noise Recall that the plausibility argument for the channel capacity rested on the idea of the average 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 righthand plot of Figure 144 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 146 145 Source Coding The results from Section 143 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 142 for English and other natural languages There are two basic approaches The first 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 variable length code words assigning short codes to common letters like e and long codes to infrequent letters like x Perhaps the most common variablelength 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 144a in which px1 05 px2 025 and px3 px4 0125 As shown earlier the entropy of this source is 175 bitssymbol which means that there must be some way of coding the source so that on average 175 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 148 An alternative representation is x1 1 x2 01 x3 001 and x4 000 149 where moreprobable symbols use fewer bits and lessprobable 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 148 175 bits per symbol so this coding is as good as possible since it equals the entropy 324 Chapter 14 Coding In contrast the naive code of 148 requires 16 bits to represent the eight sym bols for an average of 2 bits per symbol One feature of the variablelength code in 149 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 first symbol begins For example the string 01 10 11 00 1 is very different 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 prefix codes Since the entropy defines the smallest number of bits that can be used to encode a source it can be used to define the efficiency of a code efficiency entropy average of bits per symbol 1410 Thus the efficiency of the naive code 148 is 1752 0875 while the effi ciency of the variablerate code 149 is 1 Shannons source coding theorem says that if an independent source has entropy H then there exists a pre fix 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 aver age length Thus if N symbols each with entropy H are compressed into fewer than NH bits information is lost while information need not be lost if NH 1 bits are used Shannon has defined the goal towards which all codes aspire but provides no way of finding good codes for any particular case Fortunately D A Huffman proposed an organized procedure to build variable length codes that are as efficient 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 defines 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 first N 4 code from Example 144 in which the symbols have probabilities px1 05 px2 025 and px3 px4 0125 Following the foregoing procedure leads to the chart shown in Figure 145 In the first step x3 and x4 are combined to form a new node with probability equal to 025 the sum px3 px4 Then this new node is combined with x2 to form a new node with probability 05 Finally this is combined with x1 to form the rightmost node Coding 325 1 1 0 1 0 0 025 05 Symbol Probability x1 05 x3 0125 x2 025 x4 0125 Figure 145 The Huffman code for the source defined in the first part of Example 144 can be read directly from this chart which is constructed using the procedure 1 to 4 in the text Each branch is now labeled The convention used in Figure 145 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 Huffman code for this source can be read from the chart Reading from the righthand side x1 corresponds to 1 x2 to 01 x3 to 001 and x4 to 000 This is the same code as in 149 The Huffman procedure with a consistent branchlabeling convention always leads to a prefix code because all the symbols end the same except for the maximallength symbol x4 More importantly it always leads to a code that has average length very near the optimal Exercise 1416 Consider the source with N 5 symbols with probabilities px1 116 px2 18 px3 14 px4 116 and px5 12 a What is the entropy of this source b Build the Huffman chart c Show that the Huffman code is x1 0001 x2 001 x3 01 x4 0000 and x5 1 d What is the efficiency of this code e If this source were encoded naively how many bits per symbol would be needed What is the efficiency Exercise 1417 Consider the source with N 4 symbols with probabilities px1 03 px2 03 px3 02 and px4 02 a What is the entropy of this source b Build the Huffman code c What is the efficiency of this code d If this source were encoded naively how many bits per symbol would be needed What is the efficiency Exercise 1418 Build the Huffman chart for the source defined by the 26 English letters plus space and their frequency in the Wizard of Oz as given in 144 326 Chapter 14 Coding The Matlab program codexm demonstrates how a variablelength code can be encoded and decoded The first step generates a 4PAM sequence with the probabilities used in the first part of Example 144 In the code the symbols are assigned numerical values 1 3 The symbols their probabilities the numerical values and the variablelength Huffman code are as follows symbol probability value Huffman code x1 05 1 1 x2 025 1 01 x3 0125 3 001 x4 0125 3 000 This Huffman code was derived in Figure 145 For a lengthm input sequence the second step replaces each symbol value with the appropriate binary sequence and places the output in the vector cx Listing 146 codexm step 2 encode the sequence using Huffman code j 1 cx for i 1m i f x i 1 cx j 1 jj 1 e l s e i f x i 1 cx j j 10 1 jj 2 e l s e i f x i 3 cx j j 20 0 1 jj 3 e l s e i f x i 3 cx j j 20 0 0 jj 3 end end 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 147 codexm step 3 decode the variablelength sequence j 1 i 1 y while ilength cx i f cx i i 1 y j 1 ii 1 jj 1 e l s e i f cx i i 10 1 y j 1 ii 2 jj 1 e l s e i f cx i i 20 0 1 y j 3 ii 3 jj 1 e l s e i f cx i i 20 0 0 y j 3 ii 3 jj 1 end end Indeed running the program codexm which contains all three steps gives a perfect decoding Exercise 1419 Mimicking the code in codexm create a Huffman encoder and decoder for the source defined in Example 1416 Exercise 1420 Use codexm to investigate what happens when the probabili ties 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 01 x2 01 x3 01 and x4 07 1411 b Without changing the Huffman encoding to account for these changed prob abilities compare the average length of the coded data vector cx with the average length of the naive encoder 148 Which does a better job compress ing 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 Huffman chart for the probabilities defined in 1411 e Implement this new Huffman code and compare the average length of the coded data cx with the previous results Which does a better job compressing the data Exercise 1421 Using codexm implement the Huffman code from Exer cise 1418 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 Huffman coding in Exer cise 1421 would be optimal no other coding method could achieve a better com pression 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 stud ies in Section 142 there is a lot that can be gained by exploiting higherorder relationships between the symbols Exercise 1422 Zipped files 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 files Note the file size when the file is in its compressed form and the file size after decompressing unzipping the file How does this compare with the compression ratio achieved in Exercise 1421 Exercise 1423 Using the routine writetextm this file which can be found on the website uses the Matlab command fwrite write the Wizard of Oz text to a file OZdoc Use a compression routine uuencode on a Unix or Linux machine zip on a Windows machine or stuffit on a Mac to compress OZdoc Note the file size when the file is in its compressed form and the file size after decompressing How does this compare with the compression ratio achieved in Exercise 1421 Coding 329 Table 141 Modulo 2 arithmetic 0 1 0 0 1 1 1 0 0 1 0 0 0 1 0 1 and paritycheck matrix HT 1 0 1 0 1 1 1 0 0 0 1 0 0 0 1 1414 This code bundles the bits into pairs and the four corresponding code words are x1 00 c1 x1G 00000 x2 01 c2 x2G 01011 x3 10 c3 x3G 10101 and x4 11 c4 x4G 11110 There is one subtlety The arithmetic used in the calculation of the code words and indeed throughout the linearblockcode method is not standard Because the input source is binary the arithmetic is also binary Binary addition and multiplication are shown in Table 141 The operations of binary arithmetic may be more familiar as exclusive OR binary addition and logical AND binary multiplication In effect at the end of every calculation the answer is taken modulo 2 For instance in standard arithmetic x4G 11112 The correct code word c4 is found by reducing each calculation modulo 2 In Matlab this is done with modx4g2 where x411 and g is defined as in 1413 In modulo 2 arith metic 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 HT If there were no errors in transmission then y is equal to one of the four code words ci With H defined as in 1414 c1HT c2HT c3HT c4HT 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 yHT 0 and the received signal is one of the code words However when there are errors yHT 0 and the value can be used to deter mine the most likely error to have occurred To see how this works rewrite y c y c c e 330 Chapter 14 Coding Table 142 Syndrome table for the binary 5 2 code with generator matrix 1413 and paritycheck matrix 1414 Syndrome eHT Most likely error e 000 00000 001 00001 010 00010 011 01000 100 00100 101 10000 110 11000 111 10010 where e represents the errors that have occurred in the transmission Note that yHT c eHT cHT eHT eHT since cHT 0 The value of eHT is used by looking in the syndrome table Table 142 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 paritycheck matrix gives yHT eHT 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 find 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 paritycheck matrix gives yHT eHT 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 eHT for each As long as the columns of H are nonzero and distinct each error pattern corresponds to a different syndrome To fill out the remainder of the table take each of the possible double errors each of the es with exactly two 1s and calculate eHT Pick two that correspond to the remaining unused syndromes Since there are many more possible double errors nn 1 20 than there are syndromes 2nk 8 these are beyond the ability of the code to correct The Matlab program blockcode52m shows details of how this encoding and decoding proceeds The first part defines the relevant parameters of the 5 2 binary linear block code the generator g the paritycheck matrix h and the Coding 331 syndrome table syn The rows of syn are ordered so that the binary digits of eHT can be used to directly index into the table Listing 148 blockcode52m part 1 definition of 5 2 binary linear block code the generator and paritycheck matrices g1 0 1 0 1 0 1 0 1 1 h1 0 1 0 0 0 1 0 1 0 1 1 0 0 1 the four code words cwxg 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 the syndrome tabl e syn0 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 specifies 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 paritycheck 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 blockcode52m in the for j loop by searching Listing 149 blockcode52m part 2 encoding and decoding data p1 p r o b a b i l i t y of bi t f l i p m10000 length of message dat 05 sign rand1 m 051 m random 0s and 1s for i 12m cmod dat i dat i 1g 2 build codeword for j 1length c i f randp c jc j 1 end f l i p b i t s with prob p end yc r ecei ved s i g n a l ehmodyh 2 multiply by par i ty check h ehindeh14 eh22 eh 31 turn syndrome i nto index esyn ehind er r or from syndrome tabl e ymodye 2 add e to c o r r e c t e r r o r s 9 This is explored in the context of blockcode52m in Exercise 1426 332 Chapter 14 Coding for j 1max size x get message from codewords i f ycw j z i i 1x j end end end er rsumabs zdat how many e r r o r s occurred Running blockcode52m with the default parameters of 10 bit errors and length m10000 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 blockcode52m Exercise 1424 Use blockcode52m to investigate the performance of the binary 5 2 code Let p take on a variety of values p 0001 001 002 005 01 02 and 05 and plot the percentage of errors as a function of the percentage of bits flipped Exercise 1425 This exercise compares the performance of the 5 2 block code in a more realistic setting and provides a good warmup exercise for the receiver to be built in Chapter 15 The program nocode52m all Matlab files 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 4PAM for transmission For efficiency the text is encoded using text2binm recall Example 82 At the receiver the process is reversed the raw 4PAM data are translated into binary then decoded using the 5 2 block decoder and finally translated back into text using bin2textm 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 blockcode52m and nocode52m 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 ie running nocode52m without modification Exercise 1426 Use the matrix ginv1 11 0 0 01 00 1 to replace the for j loop in blockcode52m Observe that this reverses the effect of con structing the code words from the x since cwginvx mod 2 Exercise 1427 Implement the simple majorityrules code described in 1412 a Plot the percentage of errors after coding as a function of the number of symbol errors b Compare the performance of the majorityrules code to the 5 2 block code c Compare the data rate required by the majorityrules code with that required by the 5 2 code and with the naive no coding case Coding 333 1462 Minimum Distance of a Linear Code In general linear codes work much like the example in the previous section although the generator matrix paritycheck matrix and syndrome table are unique to each code The details of the arithmetic may also be different when the code is not binary Two examples will be given later This section discusses the general performance of linear block codes in terms of the minimum distance of a code which specifies how many errors the code can detect and how many errors it can correct A code C is a collection of code words ci which are nvectors with elements drawn from the same alphabet as the source An encoder is a rule that assigns a klength message to each codeword Example 145 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 respec tively 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 d00000 01011 3 The distance between 1001 and 1011 is d1001 1011 1 The minimum distance of a code C is the smallest distance between any two code words In symbols dmin min ij dci cj where ci C Exercise 1428 Show that the minimum distance of the 5 2 binary linear block code is dmin 3 Exercise 1429 Write down all code words for the majorityrules code 1412 What is the minimum distance of this code Exercise 1430 A code C has four elements 0000 0101 1010 1111 What is the minimum distance of this code Let Dit be the decoding sets of all possible received signals that are less than t away from ci For instance the majorityrules code has two code words and hence two decoding sets With t 1 these are D11 000 001 100 010 D21 111 110 011 101 1415 10 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 Chapter 14 Coding When any of the elements in D11 are received the code word c1 0 is used when any of the elements in D21 are received the code word c2 1 is used For t 0 the decoding sets are D10 000 and D20 111 1416 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 Dit are not disjoint and hence cannot be used for decoding Exercise 1431 What are the t 0 decoding sets for the fourelement code in Exercise 1430 Are the t 1 decoding sets disjoint Exercise 1432 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 errorcorrection code that handles up to t errors Now suppose that the decoding sets are disjoint with 2t s dmin but that t dc 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 off Example 146 Consider again the majorityrules 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 1415 code words could suffer 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 1416 the code word could suffer up to two errors and the error would be detected but there would be no way to correct it with certainty Example 147 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 suffer up to three errors and still be correctly decoded But if four errors occurred the message would be incorrect Coding 335 Table 143 Syndrome table for the binary 7 3 code Syndrome Most likely eHT error e 0000 0000000 0001 0000001 0010 0000010 0100 0000100 1000 0001000 1101 0010000 1011 0100000 0111 1000000 0011 0000011 0110 0000110 1100 0001100 0101 0011000 1010 0001010 1001 0010100 1110 0111000 1111 0010010 2 t 2 s 2 In this mode if the codeword suffered up to two errors then it would be correctly decoded If there were three or four errors then the errors would be detected but because they cannot be corrected with certainty no incorrect message is generated Thus the minimum distance of a code is a resource that can be allocated between error detection and error correction How to trade these off is a system design issue In some cases the receiver can ask for a symbol to be retransmitted when an error occurs for instance in a computer modem or when reading a file from disk and it may be sensible to allocate dmin to detecting errors In other cases such as broadcasting it is more common to focus on error correction The discussion in this section so far is completely general that is the definition and results on minimum distance apply to any code of any size whether linear or nonlinear There are two problems with large nonlinear codes r It is hard to specify codes with large dmin r Implementing coding and decoding can be expensive in terms of memory and computational power To emphasize this consider a code that combines binary digits into clusters of 56 and codes these clusters using 64 bits Such a code requires about 10101 code words Considering that the estimated number of elementary particles in the universe is about 1080 this is a problem When the code is linear however it is not necessary to store all the code words they can be generated as needed This 336 Chapter 14 Coding was noted in the discussion of the 5 2 code of the previous section Moreover finding 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 definition by finding the distances between all the code words or by finding 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 1463 Some More Codes This section gives two examples of n k linear codes If the generator matrix G has the form G IkP 1417 where Ik is the k by k identity matrix and P is some k by n k matrix then IkP P Ink 0 1418 where the 0 is the k by n k matrix of all zeros Hence define H PInk Observe that the 5 2 code is of this form since in binary arithmetic 1 1 and so P P Example 148 A 7 3 binary code has generator matrix G 1 0 0 0 1 1 1 0 1 0 1 0 1 1 0 0 1 1 1 0 1 and paritycheck matrix HT 0 1 1 1 1 0 1 1 1 1 0 1 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 The syndrome Table 143 is built by calculating which error pattern is most likely ie has the fewest bits flipped for each given syndrome eHT This code has dmin 4 and hence the code can correct any 1bit errors 7 out of 21 possible 2bit errors and 1 of the many 3bit errors Coding 337 Table 144 Modulo 5 arithmetic 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 1433 Using the code from blockcode52m implement the binary 7 3 linear block code Compare its performance and efficiency with the 5 2 code and the majorityrules code a For each code plot the percentage p of bit flips in the channel versus the percentage of bit flips 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 141 is inappropriate For example consider a source alphabet with five symbols labeled 0 1 2 3 4 Arithmetic operations for these elements are addition and multipli cation modulo 5 which are defined in Table 144 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 define the desired operations via tables like Tables 141 and 144 Example 149 A 6 4 code using a q 5element source alphabet has generator matrix G 1 0 0 0 4 4 0 1 0 0 4 3 0 0 1 0 4 2 0 0 0 1 4 1 and paritycheck matrix HT 4 4 4 3 4 2 4 1 1 0 0 1 1 1 1 2 1 3 1 4 1 0 0 1 338 Chapter 14 Coding Table 145 Syndrome table for the q 5 source alphabet 6 4 code Syndrome Most likely eHT error e 00 000000 01 000001 10 000010 14 000100 13 001000 12 010000 11 100000 02 000002 20 000020 23 000200 21 002000 24 020000 22 200000 03 000003 30 000030 32 000300 34 003000 31 030000 33 300000 04 000004 40 000040 41 000400 42 004000 43 040000 44 400000 since in modulo 5 arithmetic 4 1 3 2 2 3 and 1 4 Observe that these fit in the general form of 1417 and 1418 Table 145 lists the qnk 564 25 syndromes and corresponding errors The code in this example corrects all onesymbol errors and no others Exercise 1434 Find all the code words in the q 5 6 4 linear block code from Example 149 Exercise 1435 What is the minimum distance of the q 5 6 4 linear block code from Example 149 Exercise 1436 Mimicking the code in blockcode52m implement the q 5 6 4 linear block code from Example 149 Compare its performance with the 5 2 and 7 3 binary codes in terms of Coding 339 a performance in correcting errors b data rate Be careful how can a q 5 source alphabet be compared fairly with a binary alphabet Should the comparison be in terms of percentage of bit errors or percentage of symbol errors 147 Encoding a Compact Disc The process of writing to and reading from a compact disc is involved The essential idea in optical media is that a laser beam bounces off the surface of the disc If there is a pit then the light travels a bit further than if there is no pit The distances are controlled so that the extra time required by the round trip corresponds to a phase shift of 180 Thus the light traveling back interferes destructively if there is a pit whereas it reinforces constructively if there is no pit The strength of the beam is monitored to detect a 0 a pit or a 1 no pit While the complete system can be made remarkably accurate the reading and writing procedures are prone to errors This is a perfect application for error correcting codes The encoding procedure is outlined in Figure 146 The original signal is digitized at 44100 samples per second in each of two stereo channels Each sample is 16 bits and the effective data rate is 141 Mbps megabits per second The Cross Interleave ReedSolomon Code CIRC encoder described shortly has an effective rate of about 34 and its output is at 188 Mbps Then control and timing information is added which contains the track and subtrack numbers that allow CD tracks to be accessed rapidly The EFM Eightto Fourteen Module is an encoder that spreads the audio information in time by changing each possible 8bit sequence into a predefined 14bit sequence so that each one is separated by at least two and at most ten zeros This is used to help the tracking mechanism Reading errors on a CD often occur in clusters a small scratch may be many hundreds of bits wide and interleaving distributes the errors so that they can be corrected more effectively Finally a large number of synchronization bits is added These are used by the control mechanism of the laser to tell it where to shine the beam in order to find the next bits The final encoded data rate is 432 Mbps Thus about 13 of the bits on the CD are actual data and about 23 of the bits are present to help the system function and to detect andor correct errors when they occur The CIRC encoder consists of two special linear block codes called Reed Solomon codes which are named after their inventors Both use q 256 8 bit symbols and each 16bit audio sample is split into two code words The first code is a 3228 linear code with dmin 5 and the second code is a linear 2824 code also with dmin 5 These are nonbinary and use special arithmetic operations defined by the Galois field with 256 symbols The encoding is split 340 Chapter 14 Coding Music AD MUX EFM MUX Optical media CIRC Encoder 141 Mbps 188 Mbps 192 Mbps 432 Mbps 441 kHz per channel at 16 bitssample ReedSolomon Linear Block Codes Control and timing tracksubtracks EighttoFourteen Module Synchronization Figure 146 CDs can be used for audio or for data The encoding procedure is the same though decoding may be done differently for different applications 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 andor correct The encoding process on the CD is completely specified 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 five 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 effective if the cause is a defect in the medium For Further Reading The paper that started information theory is still a good read half a century after its initial publication r C E Shannon A Mathematical Theory of Communication The Bell Sys tem Technical Journal vol 27 pp 379423 and 623656 July and October 1948 Step 5 Putting It All Together The projects of Chapters 15 and 16 integrate all the fixes of the fourth step into the receiver structure of the third step to create fully functional digital receivers The wellfabricated 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 Digital Radio your name here 15 Make It So This chapter describes a softwaredefinedradio design project called M6 the Mix n Match Mostly Marvelous Message Machine The M6 transmission standard is specified so that the receiver can be designed using the building blocks of the preceding chapters The DSP portion of the M6 can be simulated in Matlab by combining the functions and subroutines from the examples and exercises of the previous chapters The input to the digital portion of the M6 receiver is a sampled signal at intermediate frequency IF that contains several simultaneous messages each transmitted in its own frequency band The original message is text that has been converted into symbols drawn from a 4PAM constellation and the pulse shape is a squareroot raised cosine The sample frequency can be less than twice the highest frequency in the analog IF signal but it must be sufficiently greater than the inverse of the transmitted symbol period to be twice the bandwidth of the baseband signal The successful M6 Matlab program will demodulate syn chronize equalize and decode the signal so it is a fully operational software defined receiver although it is not intended to work in real time The receiver must overcome multiple impairments There may be phase noise in the trans mitter oscillator There may be an offset between the frequency of the oscillator in the transmitter and the frequency of the oscillator in the receiver The pulse clocks in the transmitter and receiver may differ The transmission channel may be noisy Other users in spectrally adjacent bands may be actively transmitting at the same time There may be intersymbol interference caused by multipath channels The next section describes the transmitter the channel and the analog front end of the receiver Then Section 152 makes several generic observations about receiver design and proposes a methodology for the digital receiver design The final section describes the receiver design challenge that serves as the culminating design experience of this book Actually building the M6 receiver however is left to you You will know that your receiver works when you can recover the mystery message hidden inside the received signal Make It So 343 151 How the Received Signal Is Constructed Receivers cannot be designed in a vacuum they must work in tandem with a par ticular transmitter Sometimes a communication system designer gets to design both ends of the system More often however the designer works on one end or the other with the goal of making the signal in the middle meet some standard specifications The standard for the M6 is established on the transmitted signal and consists in part of specifications on the allowable bandwidth and on the precision of its carrier frequency The standard also specifies the source constel lation the modulation and the coding schemes to be used The front end of the receiver provides some bandpass filtering downconversion to IF and automatic gain control prior to the sampler This section describes the construction of the sampled IF signal that must be processed by the M6 receiver The system that generates the analog received signal is shown in blockdiagram form in Figure 151 The front end of the receiver that turns this into a sampled IF signal is shown in Figure 152 The original message in Figure 151 is a character string of English text Each character is converted into a 7bit binary string according to the ASCII conver sion format eg the letter a is 1100001 and the letter M is 1001101 as in Example 82 The bit string is coded using the 5 2 linear block code specified in blockcode52m which associates a 5bit code with each pair of bits The output of the block code is then partitioned into pairs that are associated with the four Coding Character to binary conversion Pulse shape Text message Baseband signal Transmitted passband signal Analog received signal Adjacent users Broadband noise Modulation includes phase noise Channel Bits Symbols si Scaling 1 Trigger i Tt εt includes periodic marker and training sequence Figure 151 Construction of the received signal Bandpass filter Downconversion to IF Automatic gain control kTs Analog received signal Sampled received signal Figure 152 Front end of the receiver Make It So 345 Table 151 M6 Transmitter specifications Symbol source alphabet 1 3 Assigned intermediate frequency 2 MHz Nominal symbol period 64 µs SRRC pulseshape rolloff factor β 01 03 FDM user slot allotment 204 kHz Width of SRRC pulse shape 8 clock periods Frame markertraining sequence See 152 Frame marker sequence period 1120 symbols Timevarying IF carrier phase Filtered white noise IF offset Fixed 001 Timing offset Fixed Symbol period offset Fixed 001 Intersymbol interference Max delay spread 7 symbols Sampler frequency 850 kHz The channel may be near ideal ie a unit gain multisymbol delay or it may have significant 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 flat 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 001 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 intermediatefrequency signal presented to the receiver sampler may also vary The bandpass filter before the downconverter in the front end of the receiver in Figure 152 partially attenuates adjacent 204kHzwide FDM user bands The automatic gain control is presumed locked and fixed over each transmission The freerunning 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 153 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 filter to frequencies between zero and IF 152 A Design Methodology for the M6 Receiver Before describing the specific design requirements that must be met by a suc cessful M6 receiver this section makes some generic remarks about a systematic approach to receiver design There are four generic stages 346 Chapter 15 Make It So Downconversion Matched filter Carrier recovery Timing recovery Interpolator downsampler Adaptive layer Sampled received signal Equalizer Decision device Equalizer adaptation Training segment locator Frame synchronization Decoder Recovered source Figure 153 DSP portion of softwaredefined receiver 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 preced ing stages be fixed in reality difficulties encountered at one stage in the design process may require a return to and different choices to be made in earlier stages As will soon become clear the M6 problem specification has basically preresolved the design issues of the first two stages 1521 Stage One Ordering the Pieces The first stage is to select the basic components and the order in which they occur The design layout first established in Figure 213 and reappearing in the DSP portion of the receiver in Figure 153 suggests one feasible structure As the signal enters the receiver it is downconverted with carrier recovery matched filtered interpolated with timing recovery equalized adaptively quantized and decoded with frame synchronization This classical ordering while popular is not the only nor necessarily the best way to recover the message from the noisy ISIdistorted FDMPAMIF received signal However it offers a useful foundation for assessing the relative benefits and costs of alternative receiver configurations Also we know for sure that the M6 receiver can be built this way Other configurations may work but we have not tested them1 How was this ordering of components chosen The authors have consulted with worked for talked about and argued with engineers working on a num ber of receiver systems including HDTV highdefinition television DSL and 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 application specific circumstance is a popular pastime of communication engineers Perhaps you too will come up with a unique approach Make It So 347 AlohaNet The ordering of components in Figures 213 and 153 represents an amalgamation of ideas from these and other systems Sometimes it is easy to argue why a particular order is good sometimes it is a matter of preference or personal experience and sometimes the choice is based on factors outside the engineers control2 For example the carrierrecovery algorithms of Chapter 10 are not greatly affected by noise or intersymbol interference as was shown in Exercises 1036 and 1040 Thus carrier recovery can be done before equalization and this is the path we have followed But it need not be done in this order3 Another example is the placement of the timingrecovery element The algorithms of Chapter 12 operate at baseband and hence the timing recovery in Figure 153 is placed after the demodulation But there are passband timingrecovery algorithms that could have been used to reverse the order of these two operations 1522 Stage Two Selecting Components Choices for the second design stage are relatively set as well Since the sampling is done at a subNyquist rate fs relative to the IF frequency fI the spec trum of the analog received signal is replicated every fs The integer n for which f fI nfs is smallest defines the nominal frequency f from which further downconversion is needed Recall that such downconversion by sampling was dis cussed in Section 62 Using different specifications the M6 sampling frequency fs may be above the Nyquist frequency associated with the IF frequency fI4 The most common method of downconversion is to use mixing followed by an FIR lowpass filter This will be followed by an FIR matched filter an interpolatordecimator for downsampling and a symbolspaced FIR equalizer that adapts its coefficients in response to the training data contained in the trans mission The output of the equalizer is quantized to the nearest 4PAM symbol value translated back into binary decoded using the 5 2 block decoder and finally turned back into readable text Given adequate knowledge of the operating environment the SNR in the received signal the carrier frequency and phase the clock period and symbol timing and the marker location the designerselected parameters within these components can be set to recover the message This was in fact the strategy followed in the idealized receiver of Chapter 9 Said another way the choices in stages one and two are presumed to admit an acceptable answer if prop erly tuned Component selections at this point including specification of the 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 3 For instance in the QAM radio of A Digital Quadrature Amplitude Modulation Radio avail able in the website the blocks appear in a different order 4 Indeed changing parameters such as this allows an instructor to create new transmission standards for each class 348 Chapter 15 Make It So fixed lowpass filter in the downconverter and the fixed matched filter preceding the interpolatordownsampler can be confirmed by simulations of the ISIfree idealfullknowledge setting Thus the upper half of Figure 153 is specified by stagetwo activities 1523 Stage Three Anticipating Impairments In the third design stage the choices are less constrained Elements of the third stage are shown in the lower half of the receiver the adaptive layer of Fig ure 153 and include the selection of algorithms for carrier timing frame syn chronization and equalizer adaptation There are several issues to consider One of the primary stagethree activities is algorithm selectionwhich per formance function to use in each block For example should the M6 receiver use a phaselocked loop a Costas loop or a decisiondirected method for carrier recovery Is a dual loop needed to provide adequate carrier tracking or will a single loop suffice What performance function should be used for the equalizer Which algorithm is best for the timing recovery Is simple correlation suitable to locate the training and marker segment Once the specific methods have been chosen it is necessary to select specific variables and parameters within the algorithms This is a traditional aspect of engineering design that is increasingly dominated by computeraided design simulation and visualization tools For example error surfaces and eye diagrams can be used to compare the performance of the various algorithms in particular settings They can be used to help determine which technique is more effective for the application at hand As softwareaided design packages proliferate the need to understand the com putational mechanics underlying a particular design becomes less of a barrier For instance Software Receiver Design has relied exclusively on the filter design algorithms built into Matlab But the specification of the filter its shape cutoff frequencies computational complexity and filter length cannot be left to Matlab The more esoteric the algorithm the less transparent is the process of selecting design parameters Thus Software Receiver Design has devoted considerable space to the design and operation of adaptive elements But even assuming that the tradeoffs associated with each of the individual components are clear how can everything be integrated together to succeed at a multifaceted design objective such as the M6 receiver 1524 Sources of Error and Tradeoffs Even when a receiver is fully operational it might not decode every symbol precisely There is always a chance of error Perhaps part of the error is due to a frequency mismatch part of the error is due to noise in the channel part of the error is due to a nonoptimal timing offset etc This section and the next suggest a general strategy for allocating part of the error to each component Then as 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 specifications 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 accu mulation 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 effectively 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 r Residual interference from adjacent FDM bands caused by imperfect bandpass filtering before downconversion and imperfect lowpass filtering after downcon version r AGC jitter caused by the deviation in the instantaneous signal from its desired average and scaled by the stepsize in the AGC element r Quantization noise in the sampler caused by coarseness in the magnitudes of the quantizer r Roundoff noise in filters caused by wordlength limitations in filter parame ters and filter algebra r Residual interference from the doubly upconverted spectrum caused by imperfect lowpass filtering after downconversion r Carrier phase jitter occurs physically as a system impairment and is caused by the stepsize in the carrierrecovery element r Timing jitter occurs physically as a system impairment and is caused by the stepsize in the timingrecovery element r Residual meansquared error left by the equalizer even an infinitely long lin ear equalizer cannot remove all recovery error in the presence of simultaneous channel noise and ISI r Equalizer parameter jitter caused by the nonvanishing stepsize in the adap tive equalizer r Noise enhancement by the equalizer caused by ISI that requires large equal izer gains such as a deep channel null at frequencies that also include noise Because Matlab implements all calculations in floatingpoint arithmetic the quantization and roundoff noise in the simulations is imperceptible The project setup presumes that the AGC has no jitter A welldesigned and sufficiently long lowpass filter in the downconverter can effectively remove the interference from outside the user band of interest The inband interference from sloppy adjacent FDM signals should be considered part of the inband channel noise This leaves 350 Chapter 15 Make It So carrier phase timing jitter imperfections in the equalizer tap jitter and noise gain All of these are potentially present in the M6 softwaredefined 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 algo rithm 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 ele ment 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 analo gous tradeoff 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 tradeoffs are common in any engineering design task The next section suggests a method of quantifying the tradeoffs to help make concrete decisions 1525 Tuning and Testing The testing and verification stage of receiver design is not a simple matter because there are so many things that can go wrong There is so much stuff that can happen Of course it is always possible to simply build a proto type and then test to see whether the specifications are met Such a haphazard approach may result in a working receiver but then again it might not Surely there is a better way This section suggests a commonsense approach that is not uncommon among practicing engineers It represents a practical compromise between excessive analysis such as one might find in some advanced commu nication texts and excessive trial and error such as try something and cross your fingers The idea is to construct a simulator that can create a variety of test signals that fall within the M6 specification The parameters within the simulator can then be changed one at a time and their effect on various candidate receivers noted By systematically varying the test signals the worst components of the receiver can be identified and then replaced As the tests proceed the receiver gradually improves As long as the complete set of test signals accurately represents the range of situations that will be encountered in operation the testing will lead to a successful design Given the particular stageone and two design choices for the M6 receiver the previous section outlined the factors that may degrade the performance of the receiver The following steps suggest some detailed tests that may facilitate the design process Make It So 351 r Step 1 Tuning the Carrier Recovery As shown in Chapter 10 any of the carrierrecovery algorithms will be capable of locating a fixed phase offset in a receiver in which everything else is operating optimally Even when there is noise or ISI the best settings for the frequency and phase of the demodulation sinusoid are those that match the frequency and phase of the carrier of the IF signal For the M6 receiver there are two issues that must be considered First the M6 specification allows the frequency to be somewhat different from its nominal value Is a dualloop structure needed Or can a single loop adequately track the expected variations Second the transmitter phase may be jittering The userchoosable features of the carrierrecovery algorithms are the LPF and the algorithm stepsize both of which influence the speed at which the estimates can change Since the carrierrecovery scheme needs to track a time varying phase the stepsize cannot be chosen too small Since a large stepsize increases the error due to phase jitter it cannot be chosen too large Thus an acceptable stepsize will represent a compromise To conduct a test to determine the stepsize and LPF requires creating test signals that have a variety of offnominal frequency offsets and phase jitters A simple way to model phase jitter is to add a lowpassfiltered version of zeromean white noise to a nominal value The quality of a particular set of parameters can then be measured by averaging over all the test signals the mean squared recovery error Choosing the LPF and stepsize parameters to make this error as small as possible gives the best values This average error provides a measure of the portion of the total error that is due to the carrierrecovery component in the receiver r Step 2 Tuning the Timing Recovery As shown in Chapter 12 there are several algorithms that can be used to find the best timing instants in the ideal setting When the channel impairment consists purely of additive noise the optimal sampling times remain unchanged though the estimates will likely be more noisy As shown by Example 123 and in Figure 1212 however when the channel contains ISI the answer returned by the algorithms differs from what might be naively expected There are two parts to the experiments at this step The first is to locate the best timingrecovery parameter for each test signal This value will be needed in the next step to assess the performance of the equalizer The second part is to find the mean squared recovery error due to jitter of the timingrecovery algorithm The first part is easy For each test signal run the chosen timingrecovery algorithm until it converges The convergent value gives the timing offset and indirectly specifies the ISI to which the equalizer will need to respond If it jiggles excessively then decrease the stepsize Assessing the mean squared recovery error due to timing jitter can be done much like the measurement of jitter for the carrier recovery measure the average error that occurs over each test signal when the algorithm is initialized 352 Chapter 15 Make It So at its optimum answer then average over all the test signals The answer may be affected by the various parameters of the algorithm the δ that determines the approximation to the derivative the l parameter that specifies the time support of the interpolation and the stepsize these variable names are from the first part of the timingrecovery algorithm clockrecDDm on page 258 In operation there may also be slight inaccuracies in the specification of the clock period When the clock period at the transmitter and that at the receiver differ the stepsize must be large enough that the timing estimates can follow the changing period Recall the discussion surrounding Example 124 Thus again there is a tension between a large stepsize needed to track rapid changes and a small stepsize to minimize the effect 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 r Step 3 Tuning the Equalizer After choosing the equalizer method as specified 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 equal izer the test signals should contain a variety of ISI channels andor additive interferences As suggested in Chapter 13 in a highSNR 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 five 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 differently at the receiver because of the sampling This effect was discussed at length in Section 131 where it was shown how the effective digital model of the channel includes the timing offset Thus as mentioned in the previous step assess ing the actual channel to which the equalizer will adapt requires knowing the timing offset that will be found by the timing recovery Fortunately in the M6 receiver structure of Figure 153 the timingrecovery algorithm oper ates 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 centerspike initial ization is used This was justified in Section 134 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 finding an appropriate delay was discussed in Section 1323 where the leastsquares 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 first 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 designerselected variable is stepsize As with all adaptive methods there is a tradeoff 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 r Step 4 Frame Synchronization Any error in locating the first symbol of each foursymbol 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 markertraining sequence The chosen markertraining sequence A0Oh well whatever Nevermind should be long enough that there are few false spikes when correlating to find 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 specifications described in the previous section as if the downconverter clock timing equalizer and quantizer had recovered the transmitted symbol sequence perfectly Finally after tuning each component separately it is necessary to confirm that when all the pieces of the system are operating simultaneously there are no excessive negative interactions With luck little further tuning will prove necessary to complete a successful design The next section has more specifics about the M6 receiver design Exercise 151 From the parameters in Table 151 do the following a Determine the oversampling or upsampling factor b Determine what frequency the sampled received signal will be centered around Recall that the receiver front end samples at a rate lower than the IF frequency and your answer should be something between 0 and fs2 354 Chapter 15 Make It So Exercise 152 The B3IG transmitter can be used to implement the M6 trans mission specifications as provided in m6paramsm Plot the received signal and its spectrum Use these plots to explain why your answers to Exercise 151 are correct 153 No Soap Radio The M6 Receiver Design Challenge The analog front end of the receiver in Figure 152 takes the signal from an antenna amplifies it and crudely bandpass filters it to partially suppress fre quencies outside the desired users frequency band An analog downconverter modulates the received signal approximately down to the nominal IF fI at 2 MHz The output of the analog downconverter is set by an automatic gain controller to fit the range of the sampler The output of the AGC is sampled at intervals of Ts 850 kHz to give rk which provides a Nyquist bandwidth of 425 kHz that is ample for a 102 kHz baseband user bandwidth The sampled received signal rk from Figure 152 is the input to the DSP portion of the receiver in Figure 153 The following comments on the components of the digital receiver in Fig ure 153 help characterize the design task r The downconversion to baseband uses the sampler frequency fs the known intermediate frequency fI and the current phase estimates to determine the mixer frequency needed to demodulate the signal The M6 receiver may use any of the phasetracking algorithms of Chapter 10 A second loop may also help with frequency offset r The lowpass filtering in the demodulator should have a bandwidth of roughly 102 kHz which will cover the selected source spectrum but reject components outside the frequency band of the desired user r The interpolatordownsampler implements the reduction in sample rate to T spaced values This block must also implement the timing synchronization so that the time between samples after timing recovery is representative of the true spacing of the samples at the transmitter You are free to implement this in any of the ways discussed in Chapter 12 r Since there could be a significant amount of intersymbol interference due to channel dynamics an equalizer is essential Any one will do A trained equalizer requires finding the start of the markertraining segment while a blind equalizer may converge more slowly r The decision device is a quantizer defined to reproduce the known alphabet of the si by a memoryless nearestelement decision r At the final step the decoding from blockcode52m in conjunction with bin2textm can be used to reconstruct the original text This also requires a frame synchronization that finds and removes the start block consisting of Make It So 355 marker plus training which is most likely implemented using a correlation technique The softwaredefined radio should have the following userselectable variables that can readily be set at the start of processing of the received block of data r rolloff factor β for the squareroot raised cosine pulse shape r initial phase offset r initial timing offset and r initial equalizer parameterization The following are some suggestions r Use the B3IG transmitter with m6paramsm to implement the M6 transmis sion specification 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 r Try to break your receiver See how much noise can be present in the received signal before accurate eg 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 r In order to facilitate more effective debugging while building the project implementation of a debug mode in the receiver is recommended The infor mation of interest will be plots of the time histories of pertinent signals as well as timing information eg a graph of matched filter average output power versus receiver symbol timing offset One convenient way to add this feature to your Matlab receiver would be to include a debug flag as an argument that produces these plots when the flag is activated r 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 fixed 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 andor its suitability for the circumstance at hand Several test files that contain a mystery signal with a quote from a wellknown book are available on the website They are labeled easymat mediummat and hardmat5 These have been created with a variety of different 5 One student remarked that these should have been called hardmat hardermat and completelyridiculousmat Nonetheless a wellcrafted M6 receiver can recover the hidden messages 356 Chapter 15 Make It So rolloff factors carrier frequencies phase noises ISI interferers and symbol tim ing offsets We encourage the adventurous reader to try to receive these secret signals Solve the mystery Break it down For Further Reading An overview of a practical application of softwaredefined radio emphasizing the redefinability of the DSP portion of the receiver can be found in r B Bing and N Jayant A Cellphone for All Standards IEEE Spectrum pp 3439 May 2002 The field of software radio erupted with a special issue of the IEEE Commu nications Magazine in May 1995 This was called a landmark special issue in an editorial in the more recent r J Mitola III V Bose B M Leiner T Turletti and D Tennenhouse Eds IEEE Journal on Selected Areas in Communications Special Issue on Soft ware Radios vol 17 April 1999 For more information on the technological context and the relevance of software implementations of communications systems see r E Buracchini The Software Radio Concept IEEE Communications Mag azine 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 H Reed Software Radio A Modern Approach to Radio Engineering PrenticeHall 2002 which overlaps in content if not style with the first half of Software Receiver Design Two recommended monographs that devote more attention than most to the methodology of the same slice of digital receiver design as we consider here are r J A C Bingham The Theory and Practice of Modem Design Wiley Inter science 1988 especially Chapter 5 r H Meyr M Moeneclaey and S A Fechtel Digital Communication Receivers Synchronization Channel Estimation and Signal Processing Wiley Inter science 1998 especially Section 41 16 A Digital Quadrature Amplitude Modulation Radio The preceding chapters of Software Receiver Design focus on a realvalued PAM transmission protocol Though this is one of the simplest digital trans mission systems a working radio for PAM needs to include a variety of tech niques that address the nonideal behaviors encountered in reality Fixes such as the PLL the Costas loop timing recovery and equalization are necessary parts of the system This chapter describes a complexvalued generalization of PAM called quadrature amplitude modulation QAM which forms the basis of a better radio While the change from realvalued PAM to complexvalued QAM signals is straightforward the bulk of this chapter fleshes out the details of operation of the resulting system The various parts of the digital radio need to be rethought carrier recovery timing recovery and equalization The theme of this chapter is that such rethinking can follow the same path as the original designs The basic techniques for the PAM radio of earlier chapters generalize smoothly to more sophisticated designs This chapter begins with the observation already noted in Section 53 that PAM modulations waste bandwidth QAM a more clever modulation strategy is able to halve the bandwidth requirements which represents a significant step towards practicality This is accomplished by sending and then unravelling two real PAM signals simultaneously on orthogonal carriers sine and cosine that occupy the same frequency band A straightforward way to describe QAM is to model the two signals as the real and imaginary portions of a single complex valued signal 161 The Song Remains the Same Sections 162 and 163 show explicitly how QAM can be viewed as PAM that uses complexvalued modulation and demodulation In an ideal world this would be the end of the story But reality intrudes in several ways Just as a PAM radio needs to align the phase at the transmitter with the phase at the receiver so 358 Chapter 16 A Digital Quadrature Amplitude Modulation Radio 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 1641 extends the Costasloop idea to 4QAM while Section 1643 extends the PLL for 4QAM 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 166 extends the timingrecovery methods of PAM in Chapter 12 to QAM Just as a PAM radio needs to build an equalizer to combat intersymbol inter ference 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 complexvalued adaptive equalizer as in Section 168 An interesting feature of QAM is that the carrier recovery can be carried out before the equalizer as in Section 164 or after the equalizer Such post equalization carrier recovery can be accomplished as in Section 167 by derotating the complexvalued 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 different possible QAM constellations are discussed in Section 165 and several possible ways of ordering the receiver elements are drawn from the technical literature in Section 169 As is done throughout Software Receiver Design exercises are structured as minidesign exercises for individual pieces of the system These pieces come together at the end with a description of and Matlab code for the Q3AM prototype receiver which parallels the M6 receiver of Chapter 15 but for QAM A series of experiments with the Q3AM receiver is intended to encourage explo ration of a variety of alternative architectures for the radio Exercises ask for assessments of the practicality of the various extensions and allow for experi mentation discovery and perhaps even a small dose of frustration as the impor tance of realworld 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 162 Quadrature Amplitude Modulation QAM Sections 51 and 52 demonstrate the use of amplitude modulation with and without a large carrier An unfortunate feature of these modulation techniques and of the resulting realvalued AM systems is that the range of frequencies used by the modulated signal is twice as wide as the range of frequencies in the baseband For example Figures 410 and 53 on pages 70 and 82 show baseband 360 Chapter 16 A Digital Quadrature Amplitude Modulation Radio 01 11 10 00 a s1 s2 1 1 1 1 00 01 11 10 b s1 s2 1 1 1 1 Figure 161 Two choices for associating symbol pairs s1 s2 with bit pairs In a 1 1 is associated with 00 1 1 with 01 1 1 with 11 and 1 1 with 10 In b 1 1 is associated with 10 1 1 with 00 1 1 with 01 and 1 1 with 11 1 sequence s2k Taken together these can be thought of as the 4QAM constel lation 1 j There are many ways in which two binary signals can be combined two are shown in Figure 161 which plots s1 s2 pairs in a twodimensional 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 mes sage For example a 1 3 4PAM coding could be recast as 4QAM using an assignment like 3 1 j 1 1 j 1 1 j 3 1 j In either case s1k and s2k are assumed to have zero average and to be uncor related so that their average product is zero The process of generating QAM signals such as 164 is demonstrated in qamcomparem which draws on the PAM pulseshaping routine pulrecsigm from page 194 qamcomparem uses a simple Hamming pulse shape pt and ran dom binary values for the messages s1k and s2k The modulation is carried out in two ways with real sines and cosines corresponding to the first part of 164 and with complex modulation corresponding to the second part of 164 The two outputs can be compared by calculating maxabsvcompvreal which verifies that the two are identical Listing 161 qamcomparem compare real and complex QAM implementations N1000 M20 Ts0001 symbols oversampling f a c t o r timeTsNM1 t 0Ts time sampling i n t e r v a l and time s1pamN 2 1 s2pamN 2 1 length N r e a l 2 l e v e l s i g n a l s pshamming M pulse shape of width M f c 1000 th 10 jsqrt 1 c a r r i e r f r eq and phase s1upzeros 1 NM s2upzeros 1 NM s1up 1 M ends1 oversample by M s2up 1 M ends2 oversample by M sp1f i l t e r ps 1 s1up convolve pulse shape with s1 sp2f i l t e r ps 1 s2up convolve pulse shape with s2 make r e a l and complexvalued ver s i ons and compare vr ealsp1 cos 2 pi f c tthsp2 sin 2 pi f c tth vcomp real sp1j sp2 exp j 2 pi f c tth max absvcompvr eal v e r i f y that they re the same A Digital Quadrature Amplitude Modulation Radio 363 mt e j2πfctθ ej2πf0tφ Transmitter Receiver xt vt st LPF Re Figure 163 Quadraturemodulation transmitter and receiver complexvalued version When f0 fc and φ θ the output st is equal to the message mt This is mathematically the same as the realvalued system shown in Figure 165 163 Demodulating QAM Figure 510 on page 91 shows how a quadraturemodulated signal like 161 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 53 and is also shown in the context of finding the envelope of a complex signal in Appendix C This section focuses on the more practical case where there may be phase and frequency offsets The math is simplified by using the complexvalued form where the received signal vt of 162 is mixed with the complex sinusoid ej2πf0tθ as in Figure 163 Algebraically this can be written xt ej2πf0tθvt ej2πf0tθRemtej2πfctφ ej2πf0tθm1t cos2πfct φ m2t sin2πfct φ ejφθ 2 m1tej2πf0fct m1tej2πf0fct j ejφθ 2 m2tej2πf0fct m2tej2πf0fct Assuming fc f0 and that the cutoff frequency of the LPF is less than 2fc and greater than fc the two highfrequency terms are removed by the LPF so that st LPFxt ejφθ 2 m1tej2πf0fct jm2tej2πf0fct 1 2ej2πf0fctjφθmt 167 where mt m1t jm2t 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 st is an attenuated copy of the message mt The spectra of the various signals in the demodulation process are shown in Figure 164 The transmitted signal vt is realvalued and hence has a symmetric spectrum This is shifted by the mixer so that one of the asymmetric pieces of Xf is near the origin and the other lies near 2fc The lowpass filter removes the highfrequency portion leaving only the copy of 364 Chapter 16 A Digital Quadrature Amplitude Modulation Radio fc fc V f fc 2fc fc X f fc fc S f Figure 164 Spectra of the various signals in the complexvalued demodulator of Figure 163 Observe the asymmetry of the spectra Xf and Sf m1t sin2πf0tθ cos2πf0tθ cos2πfctφ Transmitter Receiver m2t x1t vt x2t s1t s2t LPF LPF sin2πfctφ 1 Figure 165 Quadrature modulation transmitter and receiver realvalued version This is mathematically identical to the system shown in Figure 163 mt near the origin Though the calculations use complexvalued signals the same procedure can be implemented purely with real signals as shown in Figure 165 When f0 fc but θ φ st of 167 simplifies to ejφθmt2 This can be interpreted geometrically by observing that multiplication by a complex expo nential ejα is a rotation in the complex plane through an angle α In terms of the pulsed data sequences s1 and s2 shown in Figures 161 and 162 the constel lations become rotated about the origin through an angle given by φ θ This is the difference 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 st This can be accomplished by estimating the unknown values using techniques that are analogous to the phaselocked loop the Costas loop and decisiondirected methods as will be discussed in Section 164 The details will change in order to account for the differences 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 167 is st 1 2mtej2πf0fct This is a timevarying rotation of the constellation the points s1 and s2 spin as a function of time at a rate proportional to the frequency difference between the carrier frequency fc and the estimate f0 Again it is necessary to estimate this difference using carrierrecovery techniques A Digital Quadrature Amplitude Modulation Radio 365 This complexvalued modulation and demodulation is explored in qamdemodm A message m is chosen randomly from the constellation 1 j and then pulse shaped with a Hamming blip to form mp Modulation is carried out as in 162 to give the realvalued v Demodulation is accomplished by a complexvalued mixer as in Figure 163 to give x which is then lowpass filtered Observe that the spectra of the signals as shown using plotspecm for instance agree with the stylized drawings in Figure 164 After the lowpass filtering the demodulated s is equal to the original mp though it is shifted in time by half the length of the filter and attenuated by a factor of 2 Listing 162 qamdemodm modulate and demodulate a complexvalued QAM signal N10000 M20 Ts 0001 symbols oversample M timeTsNM1 t 0Ts time sampling times mpamN2 1 j pamN 2 1 s i g n a l s of length N pshammingM pulse shape of width M f c 1000 th 10 c a r r i e r f r eq and phase mupzeros 1 NM mup 1 M endm oversample by M mpf i l t e r ps 1 mup convolve pulse shape data vreal mp exp j 2 pi f c tth complex c a r r i e r f0 1000 ph10 f r eq and phase of demod xv exp j 2 pi f0 tph demodulate v l 50 f 0 0 2 0 2 5 1 s p e c i f y f i l t e r parameters a1 1 0 0 bfirpm l f a design f i l t e r sf i l t e r b 1 x sLPFx Exercise 166 qamdemodm shows that when fc f0 and φ θ the reconstruc tion 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 offset tau so that sktau mk for all k b Examine the consequences of a phase offset Let φ 0 th0 and examine the output when θ ph is 10 20 45 90 180 and 270 Explain what you see in terms of 167 c Examine the consequences of a frequency offset Let fc1000 f010001 and thph0 What is the correct timing offset tau for this case Is it possible to reconstruct m from s Explain what you see in terms of 167 Exercise 167 Implement the demodulation shown in Figure 165 using real valued sines and cosines to carry out the same task as in qamdemodm Hint begin with vreal of qamcomparem and ensure that the message can be recovered without use of complexvalued signals Exercise 168 Exercise 162 generates a 16QAM signal What needs to be changed in qamdemodm to successfully demodulate this 16QAM signal Exercise 169 Design a complexvalued demodulation for the imaginary method of Exercise 163 Show that the demodulation can also be carried out using purely real signals A Digital Quadrature Amplitude Modulation Radio 367 164 Carrier Recovery for QAM It should be no surprise that the ability to reconstruct the message symbols from a demodulated QAM signal depends on identifying the phase and frequency of the carrier because these are also required in the simpler PAM case of Chapter 10 Equation 167 illustrates explicitly what is required in order to recover mt from st To see how the recovery might begin observe that the receiver can adjust the phase θ and demodulating frequency f0 to any desired values If necessary the receiver could vary the parameters over time This section discusses two methods of building an adaptive element to iteratively estimate a time varying θ including the Costas loop for 4QAM which parallels the discussion in Section 104 of the Costas loop for PAM and a phaselocked loop for 4QAM which parallels the discussion in Section 103 of a PLL for PAM The variations in phase can then be parlayed into improved frequency estimates following the same kinds of strategies as in Section 106 1641 Costas Loop for 4QAM If it were possible to choose a timevarying θt in 167 so that θt 2πfc f0t φ 169 then st would be directly proportional to mt because ej2πf0fctjφθt 1 The simplest place to begin is to assume that the frequencies are correct ie that fc f0 and that φ is fixed but unknown As in previous chapters the approach is to design an adaptive element by specifying a performance or objective function Equation 169 suggests that the goal in carrier recovery of QAM should involve an adaptive parameter θ that is a function of the unknown parameter φ Once this objective has been chosen an iterative algorithm can be implemented to achieve convergence Sampling perfectly downconverted 4QAM signals s1t and s2t at the proper times should produce one of the four pairs 1 1 1 1 1 1 and 1 1 from the symbol constellation diagram in Figure 161 A rotation through 90ρ for any integer ρ will also produce samples with the same values though they may be a mixture of the symbol values from the two original messages Recall that Exercise 166b asked for an explicit formula relating the various rotations to the sampled s1 s2 pairs For the PAM system of Chapter 10 the phase θ is designed to converge to an offset of an integer multiple of 180 The corresponding objective function JC for the Costas loop from 1015 is proportional to cos2φ θ which has maxima at θ φ ρπ for integers ρ This observation can be exploited by seeking an objective function for QAM that causes the carrierrecovery phase to converge to an integer multiple of 90 It will later be necessary to resolve the ambiguity among the four choices This is postponed until Section 1642 370 Chapter 16 A Digital Quadrature Amplitude Modulation Radio LPF LPF µΣ cos2πf0kTsθkπ2 cos2πf0kTsθkπ4 θk LPF cos2πf0kTsθk vkTs LPF cos2πf0kTsθk3π4 x1k x2k x3k x4k Figure 167 This quadriphase Costasloop adaptive element can be used to identify an unknown phase offset in a 4QAM transmission The figure is a block diagram of Equation 1614 This adaptive element is shown schematically in Figure 167 where the received signal vt is sampled to give vk and then mixed with four outof phase cosines Each path is lowpass filtered with a cutoff frequency above 2fc and then multiplied to give the update term The integrator µΣ is the standard structure of an adaptive element indicating that the new value is updated at each iteration with a step size of µ The QAM Costas loop of 1614 and Figure 167 is implemented in qamcostasloopm The received signal is from the routine qamcomparem on page 360 where the variable vreal is created by modulating a pair of binary message signals The four filters are implemented using the timedomain method of Section 721 and the entire procedure mimics the Costas loop for PAM which is implemented in costasloopm on page 208 Listing 163 qamcostasloopm simulate Costas loop for QAM rvr eal vr eal from qamcompare m f l 100 f 0 2 3 1 a1 1 0 0 f i l t e r s p e c i f i c a t i o n hfirpm f l f a LPF design mu003 algorithm s t e p s i z e f0 1000 qf l 1 f r eq at r e c e i v e r thzeros 1 length t th 1randn i n i t i a l i z e estimate z1zeros 1 q z2zeros 1 q i n i t i a l i z e LPFs z4zeros 1 q z3zeros 1 q z s contain past inputs for k1length t1 s2r k z1z1 2 q s cos 2 pi f0 t kth k z2z2 2 q s cos 2 pi f0 t kpi4th k z3z3 2 q s cos 2 pi f0 t kpi2th k z4z4 2 q s cos 2 pi f0 t k3 pi4th k A Digital Quadrature Amplitude Modulation Radio 371 0 02 04 06 4 2 0 2 Time Phase offset Figure 168 Depending on where it is initialized the estimates made by the QAM Costasloop element converge to θ ρπ2 For this plot the unknown θ was 10 and there were 50 different initializations l p f 1f l i p l r h z1 output of f i l t e r 1 l p f 2f l i p l r h z2 output of f i l t e r 2 l p f 3f l i p l r h z3 output of f i l t e r 3 l p f 4f l i p l r h z4 output of f i l t e r 4 th k1th kmu l p f 1 l p f 2 l p f 3 l p f 4 algorithm update end Typical output of qamcostasloopm appears in Figure 168 which shows the evolution of the phase estimates for 50 different starting values of θ th1 Some of these converge to the correct phase offset θ 10 and others converge to nearby values 1 ρπ2 for integers ρ As expected these stationary points occur at all the 90 offsets of the desired value of θ When the frequency is not exactly known the phase estimates of the Costas algorithm try to follow For example in Figure 169 the frequency of the carrier is f0 1000 while the assumed frequency at the receiver was fc 10001 Fifty different starting points were used and in all cases the estimates converge to lines with the same slope The slope of these lines is directly proportional to the difference in frequency between fc and f0 and this slope can be used as in Section 106 to estimate the frequency difference Exercise 1615 Use the preceding code to play with the Costas loop for QAM a How does the stepsize mu affect the convergence rate b What happens if mu is too large say mu1 c Does the convergence speed depend on the value of the phase offset d When there is a small frequency offset what is the relationship between the slope of the phase estimate and the frequency difference Exercise 1616 How does the filter h influence the performance of the Costas loop 372 Chapter 16 A Digital Quadrature Amplitude Modulation Radio 0 02 04 06 4 6 2 0 2 Time Phase offset Figure 169 When the frequency of the carrier is unknown at the receiver the phase estimates converge to lines The slope of these lines is proportional to the frequency offset and can be used to correct the estimate of the carrier frequency a Try fl 1000 30 10 3 In each case use freqz to verify that the filter has been properly designed b Remove the LPFs completely from costasloopm How does this affect the convergent values The tracking performance Exercise 1617 What changes are needed to qamcostasloopm to enable it to function with 16QAM Recall Exercises 162 and 168 Exercise 1618 Exercise 1021 shows an alternative implementation of the PAM Costas loop that uses cheaper fixedphase oscillators rather than adjustable phase oscillators Refer to Figure 1012 on page 211 Design an analogous QAM implementation and write a simulation or modify qamcostasloopm to demon strate its operation Exercise 1619 Figure 1610 shows a highlevel block diagram of a dualloop system for tracking a frequency offset 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 1018 b Implement the dualloop frequency tracker and verify that small frequency offsets can be tracked For comparison the PAM equivalent is implemented in dualpllsm on page 219 c How large can the frequency offset 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 A Digital Quadrature Amplitude Modulation Radio 373 θ1k vk θ2k θk Carrier Recovery Carrier Recovery Figure 1610 Dualcarrierrecoveryloop Configuration general pulse shapes The key is to find conditions under which the update term 1613 remains proportional to the derivative of the objective function 1612 The generic effect of any smallstepsize adaptive element like 1614 is to average the update term over time Observe that the fourterm product 1613 has two parts one is proportional to cos4φ 4θ and the other is proportional to sin4φ 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 first term is avg4m1tm3 2t 4m2tm3 1t while the average of the second is avgm4 1t 6m2 1tm2 2t m4 2t In QAM the messages mit are built as the product of the data sik and a pulse shape as in 163 Even assuming that the average of the data values is zero which implies that the average of the messages is also zero finding these by hand for various pulse shapes is not easy But they are straightforward to find 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 redefining the variable unpsrrc1003M0 for a squareroot raised cosine pulse or unpones1M 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 1613 with a negative sign the sine term is proportional to the derivative sin4φ 4θ Thus it is possible to approximate all the terms that enter into the algorithm 1614 Listing 164 qamconstantsm calculate constants for avgx1 x2 x3 x4 N2000 M50 of symbols oversample M s1pamN 2 1 s2pamN 2 1 r e a l 2 l e v e l s i g n a l s mup1zeros 1 NM mup2zeros 1 NM mup1 1 M ends1 zero pad Tspaced sequence mup2 1 M ends2 oversample by M unphamming M unnormalized pulse shape psqrt M unpsqrt sum unp ˆ 2 normalized pulse shape m1f i l t e r p 1 mup1 convolve pulse shape data m2f i l t e r p 1 mup2 convolve pulse shape data stermsumm1ˆ4 6m1 ˆ 2 m2ˆ2m2 ˆ 4 NM ctermsum4m1 m2ˆ34m1 ˆ 3 m2NM 374 Chapter 16 A Digital Quadrature Amplitude Modulation Radio Exercise 1620 Find a pulse shape pt and a set of symbol values s1 and s2 that will cause the QAM Costas loop to fail Hint find values so that the average of the sinusoidal term is near zero Redo the simulation qamcostasloopm with these values and verify that the system does not achieve convergence Exercise 1621 Suppose that sik are binary 1 and that avgs1k avgs2k 0 The message sequences mit are generated as in 163 Show that avgm1t avgm2t 0 for any pulse shape pt Exercise 1622 Suppose that avgm1t avgm2t 0 Which of the following are true a avgm1t avgm2t avgm1t m2t b avg4m1t 2 avgm2t avg4m1t 2m2t c avgm1tm2t avgm1t avgm2t d avgm2 1t avgm1t2 e avgm2 1tm2 2t avgm2 1t avgm2 2t f Show that even if c holds e need not Other variations of this quadriphase Costas loop can be found in Sections 631 and 632 of Bingham 1988 and in Section 423 of Anderson 1999 1642 Resolution of the Phase Ambiguity The carrierrecovery element for QAM does not have a unique convergent point because the objective function JCQ of 1610 has maxima whenever θ φ ρπ2 This is shown clearly in the multiple convergence points of Figure 168 The four possibilities are also evident from the rotational symmetry of the constellation diagrams such as Figures 161 and 162 There are several ways in which the phase ambiguity can be resolved including 1 the output of the downsampler can be correlated with a known training signal 2 the message source can be differentially encoded so that the information is carried in the successive changes in the symbol values rather than in the symbol values themselves One way to implement the first method is to correlate the real part of the training signal t with both the real s1 and the imaginary s2 portions of the output of the downsampler Whichever correlation has the larger magnitude is selected and its polarity examined To write this concisely let t si represent A Digital Quadrature Amplitude Modulation Radio 375 the correlation of t with si The four possibilities are as follows if t s1 t s2 t s1 0 no change t s1 0 add 180 if t s1 t s2 t s2 0 add 90 t s2 0 add 90 Using differential encoding of the data bypasses the need for resolving the ambiguous angle To see how this might work consider the 2PAM alphabet 1 and reencode the data so that a 1 is transmitted when the current symbol is the same as the previous symbol and a 1 is transmitted whenever it changes Thus the sequence 1 1 1 1 1 1 1 1 1 is differentially encoded starting from the second element as 1 1 1 1 1 1 1 1 The process can be reversed as long as the value of the first bit in this case a 1 is known This strategy can be extended to complexvalued 4QAM by encoding the differences sk sk 1 This is described in Figure 164 of Barry Lee and Messerschmitt 2004 An advantage of differential encoding is that no training sequence is required A disadvantage is that a single error in the transmission can cause two symbol errors in the recovered sequence Exercise 1623 Implement the correlation method to remove the phase ambi guity a Generate a complex 4QAM signal with a phase rotation φ by use of qamcomparem Specify a fixed training sequence b Use the QAM Costas loop qamcostasloopm to estimate φ c Implement the correlation method in order to disambiguate the received sig nal Verify that the disambiguation works with φ 60 85 and 190 Exercise 1624 Design a differential encoding scheme for 4QAM using suc cessive differences in the data Verify that the scheme is insensitive to a 90 rotation 1643 PhaseLocked Loop for 4QAM Section 101 shows how the carrier signal in a PAM transmission is concealed within the received signal Using a squaring operation followed by a bandpass 376 Chapter 16 A Digital Quadrature Amplitude Modulation Radio filter as in Figure 103 on page 197 passes a strong sinusoid at twice the fre quency and twice the phase of the carrier This doublefrequency surrogate can then be used as an input to a phaselocked loop for carrier recovery as in Section 103 In QAM the carrier is better hidden because it is generated as in 161 by combining two different signals modulated by both sin and cos or equiv alently by the real and imaginary parts of a complex modulating wave as in 162 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 fre quency of the underlying carrier and so the fourth power needs to be followed by a narrowbandpass filter centered at about four times the carrier frequency This quadruplefrequency surrogate can then be used as an input to a standard phaselocked loop for carrier recovery The first step is to verify that using the square really is futile With vt defined in 161 it is straightforward though tedious to show that v2t 1 2m2 1t m2 2t m2 1t m2 2t cos4πfct 2φ 2m1tm2t sin4πfct 2φ A bandpass filter with center frequency at 2fc removes the constant DC term and this cannot be used as in PAM to extract the carrier since avgm2 1t m2 2t avgm1tm2t 0 Nothing is left after passing v2t through a narrowbandpass filter The fourth power of vt 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 BPFv4t 1 84m1tm2tm2 2t m2 1t sin8πfct 4φ m4 1t 6m2 1tm2 2t m4 2t cos8πfct 4φ What is amazing about this equation is that the two terms 4m1m2m2 2 m2 1 and m4 1 6m2 1m2 2 m4 2 are identical to the two terms in 1613 Accordingly the former averages to zero while the latter has a nonzero average Thus BPFv4t cos8πfct 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 filter 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 A Digital Quadrature Amplitude Modulation Radio 377 µΣ θk vkTs sin8πf0kTs4θk LPF BPF X4 centered at 4fc Figure 1611 The sampled QAM input vkTs 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 tradeoff between the uncertainty in fc and the desire for a narrow BPF Exercise 1625 Generate a complex 4QAM signal vt with phase shift φ as in qamcomparem Imitate the code in pllpreprocessm 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 1626 What happens on raising vt 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 BPFv4t of the preprocessor is presumed to be a sinusoid that can be applied to a phasetracking element such as the digital phaselocked loop PLL from Section 103 The preprocessor plus PLL are shown in Figure 1611 which is the same as the PLL derived for PAM in Figure 107 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 sufficient 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 fourthpower method of carrier recovery for 4QAM the methods are also applicable to larger constellations such as 16 QAM The literature offers some encouraging comments For instance Anderson 1999 on page 149 states When the modulation is for instance 16QAM instead of QPSK the PLL refer ence signal is not a steady cos4ω0t 4ψ0 and the phase difference signal has other components besides sin4ψ0 4φ0 Nonetheless the synchronizer still works passably well Bingham 1988 on page 173 says This simple method PLL tracking of quadrupled frequency can be used for constel lations with 16 points but it has been generally assumed that the pattern jitter would be intolerable However it can be shown that at least for 16QAM the outer points dominate and the fourthpower signal has a component at 4fc that is usable if a very narrow band PLL is used to refine it Whether the independence from data 378 Chapter 16 A Digital Quadrature Amplitude Modulation Radio decisions and equalizer convergence that this forwardacting method offers outweighs the problems of such a narrowband PLL remains to be seen Exercise 1627 Implement the 4QAM PLL system shown in Figure 1611 Begin with the preprocessor from Exercise 1625 and combine this with a modi fied version of pllconvergem from page 204 Exercise 1628 What changes need to be made to the 4QAM preprocessor of Exercise 1625 and the corresponding PLL of Exercise 1627 in order to operate with a 16QAM constellation 165 Designing QAM Constellations This chapter has focused on 4QAM and occasionally considered other QAM constellations such as the 16QAM configuration in Figure 162 This section shows a few common variations and suggests some of the tradeoffs that occur with different spacing of the points in the constellation As with PAM the clearest indicator of the resilience of a constellation with respect to noise is the distance between points The transmission is less likely to have bits and hence symbols changed when the points are far apart and more likely to encounter errors when the points are close together This means that when greater power is used in the transmission more noise can be tolerated Accordingly it is common to normalize the power and to consider the symbol error rate SER as a function of the signaltonoise ratio SNR Effectively this means that the points in a constellation such as 16QAM of Figure 162 are closer together than in a simpler constellation such as 4QAM It is straightforward to calculate the SER as a function of the SNR via simula tion The routine qamserm specifies a MQAM constellation and then generates N symbols Noise with variance N0 is added and then a comparison is made If the noise causes the symbol to change then an error has occurred This can be plotted for a number of different noise variances The most complicated lines in the routine are those comparing the real and imaginary portions of the data s and the noisy version r to determine whether the noise has caused a symbol error Listing 165 qamserm symbol error rate for QAM in additive noise N010ˆ0 2 3 noi s e var i ances N10000 symbols to simulate M4 symbols in c o n s t e l l a t i o n spamN sqrt M 1 j pamN sqrt M 1 QAM symbols ss sqrt 2 normalize power constunique real s normalized symbol values a l l s e r s zeros size N0 for i 1length N0 loop over SNR nsqrt N0 i 2 randn 1 N j randn 1 N rsn r ecei ved s i g n a lnoi s e 380 Chapter 16 A Digital Quadrature Amplitude Modulation Radio Figure 1613 The V29 constellation has 16 symbols and four different energy levels 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 elec tronics 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 exam ple Figure 1613 shows an irregular constellation called the V29 constellation Anderson 1999 comments on page 97 that the V29 modem standard has worse error performance in AWGN than does square 16QAM but it is easier to synchronize Another consideration in constellation design is the assignment of bit values to the points of the constellation One common goal is to reduce the number of bit changes between adjacent symbols For 4QAM this might map 45 00 135 01 135 11 and 45 10 Mappings from constellation points to symbols that minimize adjacent symbol errors are called Gray codes Exercise 1629 Adapt qamserm to draw the waterfall plot for the V29 con stellation of Figure 1613 Exercise 1630 If different noises are used the waterfall plot may look signif icantly different than Figure 1612 Redraw the SER vs SNR curves for 4 16 64 and 256QAM when the noise is uniform 166 Timing Recovery for QAM When a QAM signal arrives at the receiver it is a complicated analog waveform that must be demodulated and sampled in order to eventually recover the two messages hidden within The timingrecovery element specifies the exact times at which to sample the demodulated signals One approach would be to use two timing parameters τ1 and τ2 operating independently on the two message signals s1 and s2 using any of the methods described in Chapter 12 But the two A Digital Quadrature Amplitude Modulation Radio 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 specifies when to sample both signals The problem is approached by finding performance or objective functions that have maxima or minima at the optimal point ie at the correct sampling instants The performance functions are then used to define 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 flawlessly the upconversions and downconversions are ideal the pulsematched filters are well designed there is no interference and the channel is benign More over 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 filtered by matched filters that correspond to the pulse shape at the transmitter The output of the matched filters is sent into interpolators that extract the two baudspaced sequences When all goes well these can be decoded into the original messages s1 and s2 For PAM signals as in Chapter 12 the baudtiming rate can be found by optimizing the average of the first second or fourth power of the absolute values of the baudspaced 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 offset or equivalently it is a single complexvalued 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τ avgs1p s2pq 1616 for p 1 2 or 4 and q 1 2 1 or 2 Of course other values for p and q might also be reasonable While the error surfaces for these objective functions are difficult to draw exactly they are easy to calculate numerically as is familiar for PAM from clockrecDDcostm on page 259 also see Figures 128 and 1211 The routine qamtimobjm calculates the value of the objective function over a range of dif ferent τs for a given pulse shape unp In this simulation an offset of τ 1 2 is the desired answer Listing 166 qamtimobjm draw error surfaces for baseband signal objective functions m20 n1000 n data points m1 taus unphamming m pulse shape cpconvunp unp matched f i l t e r pssqrt m cpsqrt sum cp ˆ 2 normalize costzeros m1 1 for i 1m1 f o r each o f f s e t s1pamnm 2 1 s2pamnm 2 1 cr eate 4QAM sequence mup1zeros 1 n mup1 1 m ends1 zero pad and upsample A Digital Quadrature Amplitude Modulation Radio 383 As in Sections 123 and 124 the derivative can be approximated numerically τk 1 τk µm3 1kT τk m3 2kT τk m1kT τ δ m1kT τ δ m2kT τ δ m2kT τ δ where µ µδ and δ is small and positive All of the values for the mit for the offsets τk τk δ and τk δ can be interpolated from the oversampled mi Clearly a similar derivation can be made for any of the objective functions ae Which criterion is best Barry Lee and Messerschmitt 2004 on page 747 say that For some signals particularly when the excess bandwidth is low a fourth power nonlin earity is better than the magnitude squared In fact fourthpower timing recovery can even extract timing tones from signals with zero excess bandwidth Simulations for QPSK suggest that fourthpower circuits outperform absolutevalue circuits for signals with less than about 20 excess bandwidth What about aliasing Barry Lee and Messerschmitt continue If timing recovery is done in discretetime aliasing must be considered Any non linearity will increase the bandwidth of the signal In the presence of sampling however the high frequency components due to the nonlinearity can alias back into the bandwidth of the bandpass filter resulting in additional timing jitter Therefore in a discretetime realization a magnitudesquared nonlinearity usually has a considerable advantage over either absolutevalue or fourthpower nonlinearity What about attempting baudtiming recovery on a passband signal prior to full downconversion to baseband Barry Lee and Messerschmitt 2004 consider this on page 750 The same relative merits of squaring absolutevalue and fourthpower techniques apply to passband timing recovery as to baseband In particular absolutevalue and fourth power are usually better than squaring except when aliasing is a problem in discrete time implementations As with baseband signals it is sometimes advantageous to pre filter the signal before squaring Exercise 1631 Use qamtimobjm as a basis to calculate the five objective functions for 4QAM using the SRRC pulse shape with rolloff factors 01 05 and 07 a For each case state whether the objective must be maximized or minimized b Do any of the objective functions have local stationary points that are not globally optimal Recall Figure 128 which shows local minima for PAM c Derive the corresponding adaptive element ie the update equation for τk for one of the objective functions when using the SRRC Which rolloff factor is best Why 384 Chapter 16 A Digital Quadrature Amplitude Modulation Radio Exercise 1632 Mimic clockrecOPm on page 262 to implement the timing recovery algorithm for τk using objective function e a Derive the adaptiveelement 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 1633 State a dispersionbased objective function for timing recovery of QAM analogous to that in Figure 1211 a Plot the value of the objective function against the timing offset τ b Derive the corresponding adaptive element ie the update equation for τk c Implement the adaptive element mimicking clockrecOPm on page 262 167 Baseband Derotation Carrier recovery identifies the phase and frequency differences between the mod ulating sinusoids at the transmitter and the demodulating sinusoids at the receiver Standard approaches such as the PLL or Costas loop of Section 164 operate at passband that is the iteration that identifies the phases and fre quencies operates at the sampling rate of the receiver which is typically higher than the symbol rate As observed in Section 163 a phase offset can be pictured as a rotation of the constellation and a frequency offset 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 ele ments can derotate a QAM constellation These are essentially singleparameter equalizers that operate on the two real data streams by treating the signal and equalizer as complexvalued quantities Bingham 1988 on page 231 motivates the postequalization carrierrecovery process for QAM A complex equalizer can compensate for any demodulating carrier phase but it is easier to deal with frequency offset by using a separate circuit or algorithm that because it deals with only one variable carrier phase can move faster without causing jitter 386 Chapter 16 A Digital Quadrature Amplitude Modulation Radio The x can be rewritten explicitly as a function of θ since x ejθr which is x1 r1 cosθ r2 sinθ x2 r2 cosθ r1 sinθ when expressed in real and imaginary form observe the similarity to Exercise 1610 Accordingly x1 θ r1 sinθ r2 cosθ x2 x2 θ r2 sinθ r1 cosθ x1 Thus JBDθ θ s1 x1x2 s2 x2x1 s1x2 s2x1 leads to the adaptive update for 4QAM θk 1 θk µs1kx2k s2kx1k 1617 which can be compared directly to Figure 166 in Barry Lee and Messerschmitt Implementation of 1617 requires access to the signals s1k and s2k This can be accomplished using a training sequence or more commonly by using a decisiondirected variation that replaces s1k with ˆs1k and s2k with ˆs2k The adaptive derotator element can be examined in operation in qamderotatem where the 4QAM message is rotated by an angle phi After the derotator the x and the hard decisions shat1 and shat2 restore the con stellation to its proper orientation Listing 167 qamderotatem derotate a complexvalued QAM signal N1000 jsqrt 1 symbols time base spamN2 1 j pamN 2 1 s i g n a l s of length N phi 01 angle to r otate rs exp j phi r otati on mu001 theta 0 thetazeros 1 N i n i t i a l i z e v a r i a b l e s for i 1N1 adapt through a l l data xexp j theta i r i xrotated r x1real x x2imagx r e a l and imaginary parts shat1sign x1 shat2sign x2 hard d e c i s i o n s theta i 1 theta i mu shat1 x2shat2 x1 i t e r a t i o n end An alternative objective function based on dispersion minimization considers the average of JDMθ Rerejθ2 γ2 1618 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 4QAM symbols cluster around 1 choosing γ 1 allows JDMθ to be zero when θ φ For other constellations JDMθθφ will on A Digital Quadrature Amplitude Modulation Radio 387 average be smaller than nearby values The associated dispersionminimizing adaptive element is θk 1 θk µRerejθ2 γRerejθkImrejθk 1619 Exercise 1634 Rewrite the system in Figure 1615 in its real implementable form by letting st s1t js2t and ejz cosz j sinz Express xt directly as a function of the realvalued signals s1t and s2t Show that θ φ implies xt st Exercise 1635 Reimplement the qamderotatem routine without using any complex numbers Exercise 1636 Calculate the derivative of JDMθ of 1618 with respect to θ which is used to implement the algorithm 1619 Exercise 1637 Implement the dispersionminimization derotator by mimick ing qamderotatem Exercise 1638 Formulate a DD derotator for use with 16QAM Implement it in imitation of qamderotatem Is the convergence faster or slower than with 4QAM Exercise 1639 Formulate a dispersionminimization derotator for use with 16QAM Exercise 1640 Formulate a derotator for use with 16QAM that uses only the four corner points of the constellation those with the highest SNR 168 Equalization for QAM Intersymbol interference ISI occurs when symbols interact when the waveform of one symbol overlaps and corrupts the waveform of other symbols nearby in time ISI may be caused by overlapping pulse shapes as discussed in Chapter 11 or it may be caused by a nonunity transmission channel physically a result of multipath reflections or frequencyselective dispersion Chapter 13 showed that for PAM the realvalued received symbols can often be passed through a real valued equalizer in order to undo the effects of the channel It is possible to pass both the real and the imaginary parts of a QAM signal through separate real valued equalizers but it is far more convenient to model the equalization portion of a QAM receiver as complexvalued symbols passing through a complexvalued equalizer This section shows that complexvalued equalizers are no more difficult to design and implement than their realvalued counterparts As in Chapter 13 the A Digital Quadrature Amplitude Modulation Radio 389 where indicates complex conjugation The output of the equalizer yk XTkf can be expanded as XTkf XT Rk jXT I kfR jfI XT RkfR XT I kfI jXT I kfR XT RkfI which has complex conjugate XTkf XT RkfR XT I kfI jXT I kfR XT RkfI Note that ekek e2 Rk e2 Ik which can be expanded using 1621 as eRk Reek Redk ReXTkf dRk XT RkfR XT I kfI eIk Imek Imdk ImXTkf dIk XT I kfR XT RkfI Since the training sequence d is independent of the filter f the derivative df 0 and ekek fR e2 Rk e2 Ik fR e2 Rk eRk eRk fR e2 Ik eIk eIk fR 2eRkXRk 2eIkXIk Similarly ekek fI 2eRkXIk 2eIkXRk Therefore the update is fk 1 fk µeRkXRk eIkXIk jeRkXIk eIkXRk which simplifies to fk 1 fk µekXk 1622 Compare this with the real version of trained LMS for PAM in 1327 Except for the notation the present version is written with vectors the only difference is the complex conjugation The complexvalued 4QAM equalizer LMSequalizerQAMm passes a 4QAM signal through an arbitrary complex channel to simulate the occurrence of ISI The equalizer f adapts and with luck converges to a filter that is roughly the inverse of the channel The equalizer can be tested by generating a new set of data filtered through the same channel and then filtered through the equalizer If it is working the doubly filtered signal should be almost equal to the original though it will likely be shifted in time as it passes through the two 390 Chapter 16 A Digital Quadrature Amplitude Modulation Radio filters Observe that in Matlab when the transpose operator is applied to a complexvalued vector the result is the complexconjugated transpose Hence the final line directly implements 1622 Listing 168 LMSequalizerQAMm 4QAM LMS equalizer b0502 j 1 0602 j def i ne complex channel m1000 how many data points spamm2 1 j pamm 2 1 4QAM source of length m rf i l t e r b 1 s output of channel n4 fzeros n 1 i n i t i a l i z e e q u a l i z e r at 0 mu01 del ta 2 s t e p s i z e and delay del ta yzeros n 1 place to s tor e output for in1m i t e r a t e y i r i 1 i n1 f output of e q u a l i z e r es i del ta y i c a l c u l a t e er r or term ffmue r i 1 i n1 update e q u a l i z e r c o e f f i c i e n t s end 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 final converged equalizer if this is close to a pure possibly multisample delay ie 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 031 0019j 066 015j 034 001j 014 003j and the convolution of b and f is 015 007j 005 004j 101 001j 002 001j 006 004j 008 005j which is reasonably close to 0 0 1 0 0 0 The test routine LMSequalizerQAMTestm uses the final converged value f of the equalizer and the definition of the channel b from LMSequalizerQAMm 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 169 searches over a number of different 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 169 LMSequalizerQAMTestm tests final equalizer filter f i n a l e qf t e s t f i n a l f i l t e r f m1000 new data points spamm2 1 j pamm 2 1 new 4QAM source of length m rf i l t e r b 1 s output of channel ytf i l t e r f 1 r use f i n a l f i l t e r f to t e s t decsign real yt j sign imag yt quantization for sh0n i f e q u a l i z e r working one er r sh105sumabs dec sh 1ends 1 endsh end of these delays zero er r or A Digital Quadrature Amplitude Modulation Radio 391 Exercise 1641 Derive a decisiondirected equalizer for 4QAM analogous to the DD equalizer for PAM in Section 134 Implement the DD equalizer starting with LMSequalizerQAMm Find a channel b for which the LMS equalizer provides a correct equalizer while the DD equalizer does not Exercise 1642 Another way of investigating the quality of an equalizer is to plot the frequency responses Use freqz to plot the frequency response of the default channel and of the resulting equalizer How close is their product to a transfer function that has magnitude unity at all frequencies Because the signals are complex it is necessary to plot both positive and negative frequencies The phase spectrum should be approximately a straight line Can you relate the slope of this line to the total delay in the filter Exercise 1643 Show that a complex dispersionminimization equalizer for 4 QAM analogous to the dispersionminimization equalizer for PAM in Section 135 is given by the update fk 1 fk µXkykγ yk2 where yk is defined in 1620 and where γ 1 Implement the equalizer start ing with LMSequalizerQAMm Discuss the advantages and disadvantages of this equalizer in comparison with LMS Exercise 1644 Modify LMSequalizerQAMm to generate a source sequence from the 16QAM alphabet a jb where a and b can be be 1 or 3 For the default channel 0502j 1 0602j find an equalizer that opens the eye a What equalizer length n is needed b What delays delta give zero error in the output of the quantizer c Is this a fundamentally easier or more difficult task than equalizing a 4QAM signal Exercise 1645 Derive and implement a dispersionminimization equalizer for 16QAM using the update in Exercise 1643 Hint the 4QAM algorithm is still OK but γ 1 might scale the constellation improperly 169 Alternative Receiver Architectures for QAM There are many ways to organize a digital receiver This section takes a glance at the QAM literature and shows how the components of the receiver can be shuffled and rearranged in a surprising number of ways Bingham 1988 calls the receiver in Figure 1616 the analog receiver because the filtering downconversion 392 Chapter 16 A Digital Quadrature Amplitude Modulation Radio 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 1617 is the decisiondirected 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 1642 The third of Binghams receiver structures is the nearlyalldigital receiver of Figure 1618 This uses a freerunning sampler and digital interpolation to esti mate the value of the signals at the desired sampling times as is familiar from Chapter 12 There is a freerunning downconversion before the equalizer and postequalization carrier recovery as described in Section 1642 that operates on the hard decisions The equalization element is also decisiondirected Inter estingly the AGC also incorporates feedback from the same signals entering the carrier recovery The final architecture from Bingham is the alldigital receiver of Figure 1619 The initial sampling is accomplished by a freerunning sampler that oper ates at a subNyquist 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 fixed freerunning oscillator followed by a decisiondirected derotation The decisionfeedback equalizer is a finiteimpulseresponse filter that operates in the feedback loop It is adapted using a decisiondirected objective function LPF Timing Recovery Decoder cos2πf0t sin2πf0t Carrier Recovery LPF BPF Figure 1616 Binghams analog receiver for QAM carries out the bulk of the processing in analog circuitry before sampling This is a redrawing of Figure 51 in Bingham 1988 The figure is c1988 John Wiley Sons Inc and is reprinted with permission Timing Recovery Decoder cos2πf0t sin2πf0t DD Carrier Recovery AGC BPF LPF LPF Figure 1617 The second of Binghams QAM radio designs uses a decisiondirected carrier recovery This is a redrawing of Figure 52 in Bingham 1988 The figure is c1988 John Wiley Sons Inc and is reprinted with permission A Digital Quadrature Amplitude Modulation Radio 393 AGC ADC BPF LPF Timing Recovery Carrier Recovery Phase Splitter Magnitude Error Equalizer interpolation filter Rotator Derotator e jθ ej2πfckTs ejθ Figure 1618 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 Figure 53 of Bingham 1988 The figure is c1988 John Wiley Sons Inc and is reprinted with permission AGC ADC BPF Timing Recovery Carrier Recovery Phase Splitter Magnitude Error Allpass Filter Interpolator e jθ e j2πfckTs ejθ Equalizer Figure 1619 Binghams alldigital receiver structure is a redrawing of Figure 54 of Bingham 1988 The receiver samples at the start of the signal chain and carries out all processes in the digital domain The figure is c1988 John Wiley Sons Inc and is reprinted with permission The receiver structures in Figures 1616 to 1619 follow the development of the generic receivers in Figure 122 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 decisionfeedback equalizer could replace a feedforward equalizer the adaptive elements could operate by optimizing a dis persion objective rather than a decisiondirected objective etc The possibilities are staggering A typical digital QAM receiver is presented in Figure 42 of Meyr Moeneclaey and Fechtel 1998 and is shown here in Figure 1620 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 freerunning 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 filter occurs after the interpolation but before the timing element This helps to 394 Chapter 16 A Digital Quadrature Amplitude Modulation Radio Timing Recovery Phase Estimator an mn Frequency Integrator Frequency Integrator Frequency Error Detection Frequency Synthesizer Coarse Frequency Correction Analog Prefilter Interpolator Filter Matched Prefilter Symbol Detection mnTs unTs znTεT rf kTs rf t rt f1Ts ejω0ωt e jθmnTs Figure 1620 This typical digital QAM receiver is adopted from Figure 42 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 figure is c1998 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 1621 shows a generic equalized data demodulator from Treichler Larimore and Harp 1998 The most prominent feature of this design is the controlloop architecture which emphasizes how tightly coupled the various com ponents 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 downmodulates again after the equalizer which is working faster than the symbol rate Two equalizers are shown a feedforward equalizer and a decisionfeedback equalizer The generic blind demodulator for QAM shown in Figure 1622 is also taken from Treichler Larimore and Harp 1998 The control sequencer amalga mates signals from various places in the receiver and uses them to create a more centralized control structure embedding various elements within the loops of oth ers As before the analog AGC uses feedback correction from the freerunning sampler output The quadrature freerunning downconversion is trimmed by the hard decisions and the resampler uses a timingrecovery 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 1623 The design uses a sampler with an adjustable clock rate a passband equalizer with despun error and a postequalization carrier recovery The final architecture of this section is Lee and Messerschmitts typical pass band QAM receiver that begins with an analog bandpass filter and uses a A Digital Quadrature Amplitude Modulation Radio 395 ControlLoop Bus Carrier Recovery Forward Error Correction Timing Recovery Soft Decisions Hard Decisions w FEC Hard Decisions no FEC Power Estimation BPF AGC Equalizer Equalizer Adjustment DFE θ Figure 1621 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 decisiondirected carrier recovery Many of the loops include significant and complicated portions of the receiver such as the feedforward equalizer and the decisionfeedback equalizer Such nesting of adaptive elements is a tricky business since they must must not interfere with each other The figure is c1998 IEEE and is used with permission Control Sequencer Carrier Recovery Timing Recovery Soft Decisions CMA LMS Hard Decisions Power Estimation BPF AGC QDC AD Equalizer Equalizer Adjustment θ Figure 1622 This receiver can switch between two equalizers LMS for faster convergence when there is a training sequence available and CMA dispersion minimization when there is no training Redrawn from Figure 11 in Treichler Larimore and Harp 1998 The figure is c1998 IEEE and is used with permission sampler adjusted by a decisiondirected method as shown in Figure 1624 The phase splitter is followed by a preliminary freerunning downconversion and then downsampled to T2 sampling again with a decisiondirected adjustment The fractionally spaced equalizer has a despun decisiondirected adjustment and the digital downconversion uses a decisiondirected carrier recovery The decision feedback equalizer at the end is also decisiondirected 396 Chapter 16 A Digital Quadrature Amplitude Modulation Radio Timing Recovery Error Computation Sampling Clock PLL AGC AD Equalizer Decoding ejθk ejθk Figure 1623 This QAM receiver simplified from the original Figure 2 in Jablon 1992 uses a passband equalizer before the demodulation and trimming by the PLL The figure is c1992 IEEE and is used with permission Carrier Recovery Timing Recovery BPF Fractionally Spaced Precursor Equalizer Postcursor Equalizer e j2πfckTs Phase Splitter Twice symbolrate sampling Symbolrate sampling Preliminary demodulation Nyquistrate sampling Hard Decisions Figure 1624 This typical passband QAM receiver is redrawn from Figure 521 of Barry Lee and Messerschmitt 2004 The figure is c2004 Kluwer Academic and is used with the kind permission of Springer Science and Business Media Why are there so many receiver architectures Why not figure 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 difficulty arises when an adaptive equalizer is used in conjunction with a decisiondirected carrier recovery loop Baseband adaptive equalizers assume that the input has been demodulated The solution to this difficulty 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 timevarying 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 A Digital Quadrature Amplitude Modulation Radio 397 From page 429 of Gitlin Hayes and Weinstein 1992 At low SNR the designer can of course use the nonlinearPLL carrier recovery scheme but at moderatetohigh SNR levels when data decisions reliably replicate the transmitted data the datadirected loop has become the preferred carrier recovery system These represent only a handful of the many possible architectures for a QAM radio The next section asks you to explore some alternatives 1610 The Q3AM Prototype Receiver 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 Quasi Quixotic QAM receiver Q3AM for short is somewhat different A complete working prototype was coded by a crack team of students at Cornell University in winter of 20021 The routine qpskRxm 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 16QAM As Section 169 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 Q3AM receiver will be asked to handle including r a carrier frequency that may differ from its nominal value r a clock frequency that may differ from its nominal value r phase noise that may vary over time r a timing offset that may vary over time r multipath interference r timevarying multipath gains r wideband additive channel noise r interference from other narrowband signals nearby in frequency These impairments also bedeviled the M6 design challenge The receiver will include many fixes for these impairments 1 a freerunning four times oversampled relative to baud interval received passband signal 2 a mixer with phase adaptation via dual quadriphase Costas loop 1 Many thanks to J M Walsh C E Orlicki A G Pierce J W Smith and S R Leventhal 398 Chapter 16 A Digital Quadrature Amplitude Modulation Radio 3 lowpass filtering for downconversion matched filter and interpolation all pro vided by a matched filter with adjusted timing offset adapted with maximiza tion of the fourth power of downsampled signals in dualloop configuration 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 decisiondirected LMS adap tation during the data ie nontraining portion 6 framesynchronized descrambler and 5 2 linear blockcode decoder 1611 Q3AM Prototype Receiver Users Manual This section outlines the operation and usage of the Q3AM software radio including the specifications for the transmitter and the receiver The full struc ture is diagrammed in Figure 1625 and the m software routines may be found on the website 16111 Transmitter and Impairments Generated in the Received Signal The transmitter and channel portions of the software use a number of parameters as shown in Tables 161 and 162 in order to generate a sampled received signal with the following impairments Descrambling and Decoding Comparison and BER calculation Carrier Recovery Timing Recovery Trained LMS Equalization DecisionDirected Equalization Correlation Oversampled Carrier Synchronized Signal BaudSpaced ClockSynchronized Signal Equalized and Quantized Message Message Recovered Oversampled Output from Analog Front End Message Original Receiver Inputs Bit Error Rate Receiver Output initial equalizer training data Figure 1625 An overview of the receiver simulator and tester A Digital Quadrature Amplitude Modulation Radio 399 Phase Noise The carrier phase noise is modeled as a random walk such that θk1 θk δk 1623 where δk is a white noise whose variance is dictated when running the software See Section 16113 Timing Offset Noise The timing offset noise is modeled in the same manner as the phase noise only with a white noise δ of a different variance which is specified when running the software Carrier Oscillator Frequency and Phase Offset The frequency offset between the transmitter and receiver carrier oscillators is specified as a ratio γoff such that fact 1 γofffc The phase offset can be specified in any region from 0 to 2π Baud Oscillator Frequency and Phase Offset The frequency offset between the transmitter and receiver baud oscillators aka clocks is also specified as a ratio σoff such that Tsact Tsσoff1 σoff The baud oscillator phase offset which is also known as the fixed timing offset may also be specified Multipath Channels The software has the ability to simulate transmission through a fixed multipath channel specified at run time TimeVarying Multipath It is possible to study the receivers ability to track timingvarying multipath by turning on a flag in the software and specifying the speed of time variation for a particular builtin timevarying multipath channel See Section 16113 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 specified by specifying the channel SNR when running the software 16112 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 first block this data enters is the carrierrecovery unit which uses a quadriphase Costas loop The estimates φestk from the adaptive Costas loop are then used to demodulate the signal by multiplication by expj2πfcTsk φestk The lowpass filtering done in the timingrecovery unit by the matched filter completes the demodulation Timing Recovery The oversampled signal is then sent to the baudtimingrecovery unit which interpolates the signal using a pulse shape with nonzero timing offset with the timing offset estimated adaptively matched to the transmitter pulse shape This is slightly different from sincinterpolation because it uses the timeshifted pulse 400 Chapter 16 A Digital Quadrature Amplitude Modulation Radio Table 161 The parameters which must be set in the first structure b passed into the transmitter portion of the software suite See the example in Section 16113 for more details Name Description debugFlag Flag to indicate whether or not to generate plots ph off Phase offset between the transmitter and receiver carrier f off Frequency offset between the transmitter and receiver carrier t off Timing offset between the transmitter and receiver baud SNR Signaltonoise ratio in the channel channel Fixed channel impulse response ignored if TVChan 1 tNoiseVar Variance of noise in the receiver baud timing bfo Frequency offset between the transmitter and receiver baud pNoiseVar Variance of phase noise in receiver and transmitter carrier TVChan 0 use static channel defined by channel parameter 1 use 1 0 0 0 c g cos2πfcαkTs alpha Controls parameter α variation in timevarying channel c Mean value c of the timevarying channel tap g Variation g about mean value of timevarying channel tap Table 162 The parameters which must be specified in the second structure specs when running the transmitter portion of the the software suite See the example in Section 16113 for more details Name Description v Square QAM constellation has 22v points v 1 for QPSK codingF Whether or not to use coding same as for transmitter scrambleF1 Whether or not to generate diagnostic plots when scrambling beta The rolloff factor used in the SRRC matched filter scrambleF2 Whether or not to scramble same as for transmitter OverSamp Oversampling factor usually set to 4 shape to interpolate instead The timing offset is estimated using an adaptive fourthpower maximization scheme The signal is then downsampled to symbol spaced samples Correlation Correlation must be performed to find the segment used to train the equalizer thus this block correlates the signal with the prearranged 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 first using an adaptive trained LMS algorithm and then when the training runs out using the adaptive decisiondirected LMS A Digital Quadrature Amplitude Modulation Radio 401 algorithm Step sizes for this algorithm along with those mentioned above may be specified as inputs to the software Descrambling and Decoding In order to lower the probability of symbol error the data are mapped to binary and coded at the transmitter using a 5 2 linear block code Because coding cor relates the data scrambling with a length21 random sequence is then performed to restore signal whiteness Scrambling is done by exclusiveoring the data with a length21 sequence Descrambling is then performed at the receiver by exclusiveoring with the same sequence The synchronization for the descram bling is aided by the equalizer training data Just as soon as the equalizer training data end the descrambling begins Performance Evaluation After the receiver has finished processing the received signal its soft decisions data at the equalizer output are compared with the original sent symbols in order to determine the meansquared error at the equalizer output It is then assumed that the dispersion around the decisions is due to additive cir cularly 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 predecoding 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 meansquared error a measured predecoder SER and an empirical coded BER are determined If the coded BER is sufficiently 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 errorsbit by the number of bitssymbol ie 2 for 4QAM When there is only a small amount of data running through the system the first method with its MSEbased approximation will be capable of more accurately estimating smaller probabilities of error because the MSE becomes substantial before the SER does 16113 Using the Software The parameters that must be specified when running the software are all listed and explained in Table 163 These parameters must be within a structure that is passed to the software suite as an argument An example run can be found in sampleTestm In this example m and specs were the structures that were used to pass the arguments into the transmitter software b was the structure used to pass parameters into the receiver software t was the SER derived from a Gaussian approximation of the noise z was the measured predecoding SER and c was the measured BER after decoding 402 Chapter 16 A Digital Quadrature Amplitude Modulation Radio Table 163 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 16113 Name Description Costas Mu1 First step size to use in the typeII Costas loop Costas Mu2 Second step size to use in the typeII Costas loop Time mu1 First step size to use in the dual timing recovery Time mu2 Second step size to use in the dual timing recovery EqMu Step size to use with the trained LMS equalizer ddEqMu Step size to use with the decisiondirected equalizer debugFlag Flag that indicates whether or not to generate plots If debugFlag 1 the plots are drawn scrambleF Flag that turns on and off the scrambling of the signal codingFlag Flag that turns on and off the coding of the signal OverSamp 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 1626 can be found in snrTestm 5 10 15 20 10 3 10 2 10 1 10 0 SER as the SNR increases SNR SER Approximate Measured Figure 1626 The plot generated by the example performance study code snrTest 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 PrenticeHall 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 A Digital Quadrature Amplitude Modulation Radio 403 R D Gitlin J F Hayes and S B Weinstein Data Communication Principles Plenum Press 1992 N K Jablon Joint Blind Equalization Carrier Recovery and Timing Recovery for HighOrder QAM Signal Constellations IEEE Transactions on Signal Processing vol 40 no 6 pp 13831398 June 1992 H Meyr M Moeneclaey and S A Fechtel Digital Communication Receivers Synchronization Channel Estimation and Signal Processing Wiley 1998 J G Proakis and M Salehi Communication Systems Engineering 2nd edition PrenticeHall 2002 J R Treichler M R Larimore and J C Harp Practical Blind Demodulators for HighOrder QAM Signals Proceedings of the IEEE vol 86 no 10 pp 19071926 October 1998 B Simulating Noise Noise generally refers to unwanted or undesirable signals that disturb or interfere with the operation of a system There are many sources of noise In electrical systems there may be coupling with the power lines lightning bursts of solar radiation or thermal noise Noise in a transmission system may arise from atmo spheric disturbances from other broadcasts that are not well shielded and from unreliable clock pulses or inexact frequencies used to modulate signals Whatever the physical source there are two very different kinds of noise nar rowband and broadband Narrowband noise consists of a thin slice of frequencies With luck these frequencies will not overlap the frequencies that are crucial to the communication system When they do not overlap it is possible to build fil ters that reject the noise and pass only the signal analogous to the filter designed in Section 723 to remove certain frequencies from the gong waveform When running simulations or examining the behavior of a system in the presence of narrowband noise it is common to model the narrowband noise as a sum of sinusoids Broadband noise contains significant amounts of energy over a large range of frequencies This is problematic because there is no obvious way to separate the parts of the noise that lie in the same frequency regions as the signals from the signals themselves Often stochastic or probabilistic models are used to charac terize the behavior of systems under uncertainty The simpler approach employed here is to model the noise in terms of its spectral content Typically the noise v will also be assumed to be uncorrelated with the signal w in the sense that Rwv of 83 is zero The remainder of this section explores mathematical models of and computer implementations for simulations of several kinds of noise that are common in communications systems The simplest type of broadband noise contains all frequencies in equal amounts By analogy with white light which contains all frequencies of visi ble light this is called white noise Most randomnumber generators by default give approximately white noise For example the following Matlab code uses 414 Appendix B Simulating Noise given time the program is run some frequencies appear slightly larger than oth ers In Figure B1 there is such a spurious peak near 275 Hz and a couple more near 440 Hz Verify that these spurious peaks occur at different frequencies each time the program is run Exercise B1 Use randspecm to investigate the spectrum when different num bers 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 frequencies1 Exercise B2 Matlabs randn function is designed so that the mean is always approximately zero and the variance is approximately unity Consider a signal defined by w a randn b that is the output of randn is scaled and offset What are the mean and variance of w Hint use B1 and B2 What values must a and b have to create a signal that has mean 10 and variance 50 Exercise B3 Another Matlab function to generate random numbers is rand which creates numbers between 0 and 1 Try the code xrand1N05 in randspecm where the 05 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 05 is removed Explain what you see Exercise B4 Create two different white signals wk and vk that are at least N 216 elements long a For each j between 100 and 100 find the crosscorrelation Rwvj between wk and vk b Find the autocorrelations Rwj and Rvj What values 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 filter with a specified passband The output then has a spectrum that coincides with the passband of the filter For example the following program creates such colored noise by passing white noise through a bandpass filter that attenuates all frequencies but those between 100 and 200 Hz Listing B2 randcolorm generating a colored noise spectrum N2ˆ16 how many random numbers Ts0001 nyq05Ts sampling and nyquist r ates s s f N2N2 1 TsN frequency vector 1 Matlab allows control over whether the random numbers are the same each time using the seed option in the calls to the randomnumber generator Details can be found in the help files for rand and randn Simulating Noise 415 a Spectrum of input random numbers 400 200 0 200 400 b Spectrum of output random numbers Frequency in Hz 0 600 400 200 0 800 600 400 200 Magnitude Magnitude Figure B2 A white input signal top is passed through a bandpass filter creating a noisy signal with bandwidth between 100 and 200 Hz xrandn 1 N N random numbers fbe 0 100 110 190 200 nyq nyq def i ne des i r ed f i l t e r damps0 0 1 1 0 0 des i r ed amplitudes f l 70 f i l t e r s i z e bfirpm f l fbe damps design impulse response yf i l t e r b 1 x f i l t e r x with b Plots from a typical run of randcolorm are shown in Figure B2 which illus trates 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 B5 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 filter using firpm Verify its frequency response by using freqz b Generate a white noise and pass it through the filter Plot the spectrum of the input and the spectrum of the output Exercise B6 Create two noisy signals wk and vk that are N 216 elements long The bandwidths of both wk and vk should lie between 100 and 200 Hz as in randcolorm a For each j between 100 and 100 find the crosscorrelation Rwvj between wk and vk b Find the autocorrelations Rwj and Rvj What values 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 filter C Envelope of a Bandpass Signal The envelope of a signal is a curve that smoothly encloses the signal as shown in Figure C1 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 mes sage from the modulated carrier as discussed in Section 51 One simple design includes a diode capacitor and resistor arranged as in Figure C2 The oscillat ing 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 C1 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 filter the capacitor and resistor For example the Matlab code in AMlargem on page 83 extracted the envelope using an absolute value nonlinearity and an LPF and this method is also used in envsigm Listing C1 envsigm envelope of a bandpass signal time 33 Ts110000 sample i n t e r v a l time t 0Ts time l entlength t def i ne time vector f c 1000 ccos 2 pi f c t s i g n a l i s f a s t wave fm10 f r eq f o r slow wave wcos 2 pifm t exp5 t 05 times slow decay xc w with o f f s e t fbe 0 005 01 1 damps1 1 0 0 lowpass f i l t e r design f l 100 bfirpm f l fbe damps impulse response of LPF envxpi 2 f i l t e r b 1 abs x r e c t i f y f o r envelope 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 Envelope of a Bandpass Signal 417 Signal Lower envelope Upper envelope Approximation of envelope using analog circuit Figure C1 The envelope of a signal outlines the extremes in a smooth manner Signal Envelope Figure C2 A circuit that extracts the envelope from a signal π2 in the definition of envx accounts for this factor so that the output rides on crests of the wave The output of envsigm is shown in Figure C3a where the envelope signal envx follows the outline of the narrowbandwidth passband signal x though with a slight delay This delay is caused by the linear filter and can be removed by shifting the envelope curve by the group delay of the filter This is fl2 half the length of the lowpass filter when designed using the firpm command A more formal definition of envelope uses the notion of inphase and quadra ture components of signals to reexpress the original bandpass signal xt as the product of a complex sinusoid and a slowly varying envelope function xt Regtej2πfct C1 The function gt is called the complex envelope of xt and fc is the carrier frequency in Hz To see that this is always possible consider Figure C4 The input xt 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 xct and xst are contained between B to B Modulation by the final two sinusoids returns the baseband signals to a region around fc and adding them together gives exactly the signal xt Thus Figure C4 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 inphase and quadrature components of the signal 420 Appendix C Envelope of a Bandpass Signal xcf i l t e r b 1 2 x cos 2 pi f c t inphase component xsf i l t e r b 1 2 x sin 2 pi f c t quadrature component envxabs xcsqrt1 xs envelope of s i g n a l Exercise C4 For those who have access to the Matlab signalprocessing tool box an even simpler syntax for the complex envelope is envxabshilbertx Can you figure out why the Hilbert transform is useful for calculating the envelope Exercise C5 Find a signal xt for which all the methods of envelope detection fail to provide a convincing envelope Hint try signals that are not narrowband 424 Appendix D Relating the Fourier Transform to the DFT 1 05 0 05 1 4 2 0 2 4 a Switched sinusoid b Raw DFT magnitude c Magnitude spectrum d Zoom into magnitude spectrum Timeseconds 05 04 03 01 02 0 100 50 0 50 100 FrequencyHz 05 04 03 01 02 0 40 20 0 20 40 FrequencyHz 60 40 20 0 0 500 1000 1500 Bin number Figure D1 Spectrum of the switched sinusoid calculated using the DFT a the time waveform b the raw magnitude data c the magnitude spectrum and d zoomed into the magnitude spectrum samples is T 8 s and that the underlying sinusoid of frequency f0 10 Hz is switched on for only the first Td 1 s Listing D1 switchsinm spectrum of a switched sine Td1 pulse width Td2 Td2 N1024 number of data points f 10 frequency of s i ne T8 t o t a l time window tr ezTN f r e z 1T time and f r eq r e s o l u t i o n wzeros 1 N vector f o r f u l l data record wN2Td tr ez 21N2Td2 tr ez sin tr ez 1 Td tr ez 2 pi f dftmagabs f f t w magnitude of spectrum of w spectr ez dftmag N21N dftmag 1 N 2 s s ff r e z N211N 2 frequency vector plot tr ez length w21 length w 2 w pl ot a plot dftmag pl ot b plot s s f spec pl ot c Plots of the key variables are shown in Figure D1 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 final plot shows a zoom into the lowfrequency region In this case the time resolution is t TN 00078 s and the frequency resolution is f 1T 0125 Hz The largest allowable f0 without aliasing is N2T 64 Hz Exercise D1 Rerun the preceding program with T16 Td2 and f5 Com ment on the location and the width of the two spectral lines Can you find particular values so that the peaks are extremely narrow Can you relate the locations of these narrow peaks to D3 Power Spectral Density 427 where yT t ytΠtT and xT t xtΠtT are truncated versions of yt and xt 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 Hf2 for each frequency f F The ZTransform This appendix presents background material that is useful when designing equal izers 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 Ztransform the discretetime counterpart of the sdomain Laplace transform can be used to represent a linear system such as a channel model or a filter 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 openeye criterion provides a way of determining how good the design is F1 ZTransforms 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 mathemati cally and this section uses the Ztransform which is closely related to a discrete version of the Fourier transform Define the variable z to represent a forward time shift of one sample interval Thus zukT uk 1T The inverse is the backward time shift z1ukT uk 1T These are most commonly written without explicit reference to the sampling rate as zuk uk 1 and z1uk uk 1 For example the FIR filter with input uk and output yk uk 06uk 1 091uk 2 can be rewritten in terms of the timedelay operator z as yk 1 06z1 091z2uk 430 Appendix F The ZTransform can be represented in transferfunction form by taking the Ztransform of both sides of the equation applying F2 and using linearity Thus Y z Zyk Zuk buk 1 Zuk Zbuk 1 Uz bz1Uz 1 bz1Uz which can be solved algebraically for Hz Y z Uz 1 bz1 z b z F4 Hz is called the transfer function of the filter F3 There are two types of singularities that a zdomain transfer function may have Poles are those values of z that make the magnitude of the transfer function infinite The transfer function in F4 has a pole at z 0 Zeros are those values of z that make the magnitude of the frequency response equal to zero The transfer function in F4 has one zero at z b There are always exactly as many poles as there are zeros in a transfer function though some may occur at infinite values of z For example the transfer function z a1 has one finite valued zero at z a and a pole at z A zdomain discretetime system transfer function is called minimum phase maximum phase if it is causal and all of its singularities are located inside outside the unit circle If some singularities are inside and others outside the unit circle the transfer function is mixed phase If it is causal and all of the poles of the transfer function are strictly inside the unit circle ie if all the poles have magnitudes less than unity then the system is stable and a bounded input always leads to a bounded output For example the FIR difference equation yk uk 06uk 1 091uk 2 has the transfer function Hz Y z Uz 1 06z1 091z2 1 07z11 13z1 z 07z 13 z2 This is mixed phase and stable with zeros at z 07 and 13 and two poles at z 0 It can also be useful to represent IIR filters analogously For example Section 722 shows that the general form of an IIR filter is yk a0yk 1 a1yk 2 anyk n 1 b0xk b1xk 1 bmxk m This can be rewritten more concisely as 1 a0z1 a1z2 anznY z 1 b0z1 b1z2 bmzmUz The ZTransform 431 and rearranged to give the transfer function Hz Y z Uz 1 b0z1 b1z2 bmzm 1 a0z1 a1z2 anzn zm b0zm1 b1zm2 bm zn a0zn1 a1zn2 an F5 An interesting and sometimes useful feature of the Ztransform is the relation ship between the asymptotic value of the sequence in time and a limit of the transfer function FinalValue Theorem for Ztransforms If Xz converges for z 1 and all poles of z 1Xz are inside the unit circle then lim k xk lim z1z 1Xz F6 Exercise F1 Use the definition of the Ztransform to show that the transform is linear that is show that Zaxk buk aXz bUz Exercise F2 Find the zdomain transfer function of the system defined by yk b1uk b2uk 1 a What are the poles of the transfer function b What are the zeros c Find limk yk d For what values of b1 and b2 is the system stable e For what values of b1 and b2 is the system minimum phase f For what values of b1 and b2 is the system maximum phase Exercise F3 Find the zdomain transfer function of the system defined by yk ayk 1 buk 1 a What are the poles of the transfer function b What are the zeros c Find limk yk d For what values of a and b is the system stable e For what values of a and b is the system minimum phase f For what values of a and b is the system maximum phase Exercise F4 Find the zdomain transfer function of the filter defined by yk yk 1 2uk 2 µuk 1 a What are the poles of the transfer function b What are the zeros c Find limk yk d Is this system stable 432 Appendix F The ZTransform F2 Sketching the Frequency Response from the ZTransform A complex number α a jb can be drawn in the complex plane as a vector from the origin to the point a b Figure F1 is a graphical illustration of the difference between two complex numbers β α which is equal to the vector drawn from α to β The magnitude is the length of this vector and the angle is measured counterclockwise from the horizontal drawn to the right of α to the direction of β α as shown As with Fourier transforms the discretetime transfer function in the zdomain can be used to describe the gain and phase that a sinusoidal input of frequency ω in radianssecond will experience when passing through the system With transfer function Hz the frequency response can be calculated by evaluating the magnitude of the complex number Hz at all points on the unit circle that is at all z ejωT T has units of secondssample For example consider the transfer function Hz z a At z ej0T 1 zero frequency Hz 1 a As the frequency increases as ω increases the test point z ejωT moves along the unit circle think of this as the β in Figure F1 The value of the frequency response at the test point HejωT is the difference between this β and the zero of Hz at z a which corresponds to α in Figure F1 Suppose that 0 a 1 Then the distance from the test point to the zero is smallest when z 1 and increases continuously as the test point moves around the circle reaching a maximum at ωT π radians Thus the frequency response is highpass The phase goes from 0 to 180 as ωT goes from 0 to π On the other hand if 1 a 0 then the system is lowpass More generally consider any polynomial transfer function aNzN aN1zN1 a2z2 a1z a0 Im ImβImα Re β α α β α β α ReβReα Figure F1 Graphical calculation of the difference between two complex numbers The ZTransform 433 DC or zero frequency Frequency of test points given in radians z2 z1 180o π radians Nyquist sampling rate a3 b3 b1 b2 a2 a1 Zeros Figure F2 Suppose a transfer function has three zeros At any frequency test point specified in radians around the unit circle the magnitude of the transfer function is the product of the distances from the test point to the zeros This can be factored into a product of N possibly complex roots Hz gΠN i1z γi F7 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 F2 where a transfer function has three zeros Two test points are shown at frequencies corresponding to approximately 15 and 80 The magnitude at the first test point is equal to the product of the lengths a1 a2 and a3 while the magnitude at the second is b1b2b3 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 filter Exercise F5 Consider the transfer function z az 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 complexz plane The resulting frequencyresponse magnitude will be relatively flat 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 frequencyresponse magnitude will become more less pronounced This is true irrespective of whether the ring of transfer function zeros is inside or outside the unit circle Of course the phase curves will be different in the two cases Exercise F6 Sketch the frequency response of Hz z a when a 2 Sketch the frequency response of Hz z a when a 2 Exercise F7 Sketch the frequency responses of The ZTransform 435 F3 Measuring Intersymbol Interference The ideas of frequency response and difference equations can be used to inter pret and analyze properties of the transmission system When all aspects of the system operate well quantizing the received signal to the nearest element of the symbol alphabet recovers the transmitted symbol This requires among other things that there is no significant multipath interference This section uses the graphical tool of the eye diagram to give a measure of the severity of the inter symbol interference In Section 113 the eye diagram was introduced as a way to visualize the intersymbol interference caused by various pulse shapes Here the eye diagram is used to help visualize the effects of intersymbol interference caused by multipath channels such as 132 For example consider a binary 1 source sk and a threetap FIR channel model that produces the received signal rk b0sk b1sk 1 b2sk 2 This is shown in Figure F3 where the received signal is quantized using the sign operator in order to produce the binary sequence yk which provides an estimate of the source Depending on the values of the bi this estimate may but might not accurately reflect the source Suppose b1 1 and b0 b2 0 Then rk sk 1 and the output of the decision device is as desired a replica of a delayed version of the source ie yk signsk 1 sk 1 Like the eye diagrams of Chapter 9 which are open whenever the intersymbol interference admits perfect reconstruction of the source message the eye is said to be open If b0 05 b1 1 and b2 0 the system is rk 05sk sk 1 and there are four possibilities sk sk 1 1 1 1 1 1 1 or 1 1 for which rk is 15 05 05 and 15 respectively In each case signrk sk 1 The eye is still open Now consider b0 04 b1 1 and b2 02 The eight possibilities for sk sk 1 sk 2 in rk 04sk sk 1 02sk 2 are 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 and 1 1 1 The resulting choices for rk are 12 16 08 04 04 08 16 and 12 respectively with the corresponding sk 1 of 1 1 1 1 1 1 1 and 1 For all of the possibilities yk signrk sk 1 b0 b1z1 b2z2 sign Decision device Reconstructed source estimate Channel Received signal Source y r s Figure F3 Channel and binary decision device 438 Appendix F The ZTransform 01 10 01 have an open eye Hint use 2srand05 to generate the noise Exercise F14 Modify openclosedm so that the input uses the source alphabet 1 3 Are any of the channels in Problem F12 open eye Is the channel b 01 01 10 01 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 F15 The sampled impulse response from symbol values to the out put of the downsampler in the receiver depends on the baud timing of the downsampler For example let ht be the impulse response from symbol values mkT to downsampler output ykT The sampled impulse response sequence is httkT δ for integers k and symbol period T where δ is the selected baud timing offset Consider the nonzero impulse response values for two different choices for δ httkT δ1 004 100 052 032 018 httkT δ2 001 094 050 026 006 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 openeye Clearly justify your answer b With δ δ2 and a binary source alphabet 1 is the system from the source symbols to the downsampler output openeye Clearly justify your answer c Consider filtering the downsampler output with an equalizer with transfer function Fz z γz to produce soft decisions yk Thus the discrete time impulse response from the symbols mk to the soft decisions yk 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 fourelement source alphabet 1 3 can the system from the source sym bols to the equalizer output be made openeye by selecting γ 06 Explain F4 Analysis of Loop Structures The Ztransform can also be used to understand the behavior of linearized loop structures such as the PLL and the dualloop variations This section begins by studying the stability and tracking properties of the system in Figure 1022 on page 224 which is the linearization of the general structure in Figure 1020 The finalvalue theorem F6 shows that for certain choices of the transfer function 440 Appendix F The ZTransform and so Φz αzz 12 In this case Ez αzAz z 1z 1Az 2µBz and the finalvalue theorem shows that lim k ek lim z1 z 1 z Ez lim z1 αAz z 1Az 2µBz αA1 2µB1 as long as B1 0 and the roots of F9 are strictly inside the unit circle If A1 0 limk ek is nonzero and decreases with larger µ If A1 0 limk ek is zero and θk converges to the ramp φk This means that the loop can also asymptotically track frequency offsets in the carrier Changing µ shifts the closedloop poles in F9 This impacts both the stabil ity of the roots of z and the decay rate of the transient response as θk locks onto and tracks φk Poles closer to the origin of the zplane correspond to faster decay of the transient repsonse Poles closer to the origin of the zplane than to z 1 tend to deemphasize the lowpass nature of the Gz thereby weaken ing the suppression of any highfrequency disturbances from the input Thus the location of the closedloop poles compromises between improved removal of broadband noises and a faster decay of the transient error The choice of Gz which includes a pole at z 1 ie an integrator results in a PLL with typeII 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 typeI polynomial i 1 in input αki with k the time index with zero error asymptotically and a typeII polynomial αk2 with asymptotically constant and finite offset Exercise F16 Suppose that a loop such as Figure 1020 has Gz bz a a What is the corresponding z of F9 b Does this loop track phase offsets Does it track frequency offsets c For what value of µ does z become unstable d Find a value of µ for which the roots of z are complexvalued What does this imply about the convergence of the loop e Describe the behavior of the loop when a 1 Exercise F17 Suppose that a loop such as Figure 1020 has Gz bz cz 1 a What is the corresponding z of F9 b Does this loop track phase offsets Does it track frequency offsets c For what value of µ does z become unstable d Find a value of µ for which the roots of z are complexvalued What does this imply about the convergence of the loop The ZTransform 441 Exercise F18 Suppose that a loop such as Figure 1020 has Gz bz 12z 1 µ a What is the corresponding z of F9 b Does this loop track phase offsets Does it track frequency offsets c For what value of µ does z become unstable Exercise F19 The general loop in Figure 1020 is simulated in pllgeneralm a Implement the filter Gz from Exercise F16 and verify that it behaves as predicted b Implement the filter Gz from Exercise F17 and verify that it behaves as predicted c Implement the filter Gz from Exercise F19 and verify that it behaves as predicted H The B3IG Transmitter In Chapter 9 the Basic Black Box Impairment Generator of Figure 922 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 B3IG The B3IG is implemented in Matlab as the routine BigTransmitterm and it allows straightforward modeling of any or all of the possible impairments discussed throughout Software Receiver Design including carrierfrequency offset baudtiming offsets and frequencyselective and timevarying 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 B3IG is more than a transmitter it includes the communication channel and receiver RF front end as well An overview of the B3IG is shown in Figure H1 The B3IG architecture expands on the simplified 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 Transmitter Channel Between Base Station and User n Sampled IF Receiver for User n Received Digital Signal Message for User 1 Message for User 2 Message for User K Figure H1 The B3IG 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 Appendix H The B3IG Transmitter Figure H2 A base station transmitting to several mobile users within a single cell Users within the cell may use a timedelay protocol whereby each user is assigned a sequential time slot while adjacent cells operate using nearby frequencies Assumption that the receiver employs a sampled intermediatefrequency archi tecture Section 62 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 B3IG transmitter generates a received signal that has been brought down to a lower intermediate frequency IF and then sampled at some specified 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 B3IG 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 Fig ure H2 Thus there are many users in the same geographical region all wishing to transmit and receive simultaneously How is a given receiver able to sepa rate 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 time division multiple access TDMA frequencydivision multiple access FDMA and codedivision multiple access CDMA Within a single cell the transmitter implements multiple users that send mes sages 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 B3IG TDMA is shown in Figure H3 This may be contrasted with the FDMA situation where users each employ their own frequency range as was discussed in Figure 23 on page 22 Typically adjacent cells transmit on different frequencies though frequencies may be reused in cells that are sufficiently 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 The B3IG Transmitter 453 User K User K User 1 User 2 User 1 Preamble Np Characters in Preamble Ns Characters per User Slot 4Ns KNp Symbols per Frame Preamble Figure H3 The timedivision multiple access TDMA frame structure used in the B3IG The indicated sizes are valid for the 8bit ASCII encoding interference from adjacent cells The B3IG makes it easy to study the effects of this kind of interference In codedivision 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 B3IG does not currently implement a CDMA protocol Adding a CDMA component to the receiver would make a great course project H1 Constructing the Received Signal The B3IG transmitter ie the base station simulates K simultaneous users using TDMA Each receiver ie each mobile device in Figure H2 retains and decodes only its intended portion of the signal For singleuser operation K 1 Each of the three blocks in Figure H1 is itself built from several components that are familiar from previous chapters The system that generates the ana log received signal ie the actual transmitter and channel is shown in block diagram form in Figure H4 This is of course the marginally magical M6 trans mitter from Chapter 15 When the signal arrives at the front end of the receiver it is transformed into a sampled IF signal as in Figure H5 The original message in Figure H4 is a character string of English text Each character is mapped into a sequence of 4PAM symbols The mappings may be made using the Matlab function letters2pamm which converts each letter into an 8bit binary string and hence to four 4PAM symbols as in Example 81 Alternatively the mappings may be made with the more terse text2binm TDMA user multiplexing Character tobinary conversion Pulse shape P f Text message Baseband signal st Transmitted passband signal Analog received signal Adjacent users Broadband noise Modulation including phase noise Channel Bits Symbols si Scaling 1 Trigger iTt εt Figure H4 The signalflow diagram of the B3IG transmitter closely follows that of the M6 transmitter of Figure 151 on page 343 The B3IG Transmitter 455 The channel may be near ideal ie a unit gain multisymbol delay or it may have significant intersymbol interference In addition it can be timevarying and the B3IG code allows two ways to introduce time variation The first permits specification 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 randomwalk process can be specified 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 B3IG transmitter and they are assumed to be unknown at the receiver The achieved intermediate frequency is required to be within some user specified 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 intermediatefrequency signal presented to the receiver sampler may also vary The front end of the sampled IF receiver as shown in Figure H5 consists of a lownoise amplifier a preselect filter an AGC a mixer for downconversion to IF and the sampler The preselect filter partially attenuates adjacent FDM user bands The automatic gain control is presumed locked and fixed over each transmission and outputs a signal whose average power is unity The freerunning 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 frontend analog downconverter lowpass filter to frequencies between zero and IF H2 Matlab Code for the Notorious B3IG H21 Function Call To generate the received signal the B3IG transmitter is called by r sBigTransmitterm 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 analogRFrelated parameters and 456 Appendix H The B3IG Transmitter chanParams contains the channel parameters There are two output arguments r is the received sampled signal and s is the 4PAM symbols which were trans mitted Thus the length of s is approximately equal to the length of r times the effective oversampling factor H22 The Input Parameters In order to control all these features of the B3IG various parameters are needed An overview of these parameters is given in Figure H6 and more details are as follows m A characterstring matrix with dimensions equal to the number of users by the message length containing the ASCII messages to be transmitted If there is only a single user this is a single string row vector Description Symbol Matlab variable message m number of characters per user per frame Ns frameParamsuserDataLength character string of preamble text frameParamspreamble channel coefficients at start of transmission c c 1 chanParamsc1 channel coefficients at end of transmission 2 chanParamsc2 variance of timevarying channel enable or disable channel coding frameParamschanCodingFlag 7bit or 8bit ASCII representation frameParamsbitEncodingFlag chanParamsrandomWalkVariance SNR SNR chanParamsSNR power of adjacent interferer 1 chanParamsadjacentUser1Power carrier frequency of adjacent interferer 1 chanParamsadjacentUser1f if channel of adjacent interferer 1 chanParamsadjacentUser1Chan power of adjacent interferer 2 chanParamsadjacentUser2Power carrier frequency of adjacent interferer 2 chanParamsadjacentUser2f if channel of adjacent interferer 2 chanParamsadjacentUser2Chan frequency of narrowband interferer chanParamsNBIfreq power of narrowband interferer chanParamsNBIPower sampler frequency fs rfParamsf s nominal symbol period Tt rfParamsT t error of transmitter symbol period rfParamsT t err assigned intermediate frequency f IF rfParamsf if error transmitter intermediate frequency rfParamsf if err variance of phase noise rfParamsphaseNoiseVariance SRRC filter length rfParamsSRRCLength SRRC pulseshape rolloff factor β rfParamsSRRCrolloff Figure H6 B3IG parameters passed via the stuctures frameParams rfParams and chanParams The B3IG Transmitter 457 frameParamsuserDataLength The number of text characters per user per frame which together with frameParamspreamble effectively determines the length of a frame See Figure H3 frameParamspreamble A character string ie a row vector containing the preamble text which is presumed known at all receivers frameParamschanCodingFlag This parameter can be set to either 0 or 1 If set to 0 the transmitter sends uncoded bits If set to 1 the transmitter encodes the data using the binary block 52 channel code described in Section 1461 frameParamsbitEncodingFlag This parameter can be set to either 0 or 1 and controls how the transmitter translates text into bits If set to 0 the transmitter uses an 8bit representation of the ASCII code and employs letters2pamm If set to 1 the transmitter uses the 7bit representation of the ASCII code and employs text2binm See Examples 81 and 82 for details chanParamsc1 The impulse response of the timevarying channel at the start of the transmission is specified as a row vector chanParamsc2 The impulse response of the timevarying channel at the end of the transmission is also a row vector The actual channel varies linearly over the course of the transmission from the impulse response in chanParamsc1 to that in chanParamsc2 Hence if chanParamsc1 chanParamsc2 and chanParamsrandomWalkVariance 0 the channel will be time invariant chanParamsrandomWalkVariance In addition to being able to control the evo lution of the channel using chanParamsc1 and chanParamsc2 this param eter specifies a random variation in the channel taps using a random walk The parameter controls the variance of the randomwalk process chanParamsSNR The signaltonoise ratio of the signal Note that it controls only the amount of AWGN present in the band of the transmitted signal chanParamsadjacentUser1Power The relative power of the interference caused by the first adjacent user specified in dB Thus when set to 0 dB the interferer will have the same power as the transmitter When set to Inf the interferer is effectively disabled chanParamsadjacentUser1f if The carrier frequency of the first interfering user after conversion to IF chanParamsadjacentUser1Chan The timeinvariant channel impulse response of the first interfering user chanParamsadjacentUser2Power The relative power of the second interfering user specified in dB chanParamsadjacentUser2f if The carrier frequency of the second interfering user after conversion to IF chanParamsadjacentUser2Chan The timeinvariant channel impulse response of the second interfering user chanParamsNBIfreq The frequency of a narrowband interferer after conversion to IF chanParamsNBIPower The relative power of the narrowband interferer speci fied in dB 458 Appendix H The B3IG Transmitter rfParamsf s The sampler frequency rfParamsT t The nominal ie expected symbol period rfParamsT t err The percentage error in the transmitters symbol period which is presumed unknown at the receiver rfParamsf if The assigned intermediate carrier frequency or frequencies rfParamsf if err The percentage error in the transmitters local oscillator which is presumed unknown at the receiver rfParamsphaseNoiseVariance The variance of the additive noise used to model phase noise in the transmitter rfParamsSRRCLength The length of the squareroot raised cosine filter rfParamsSRRCrolloff The rolloff factor of the squareroot raised cosine filter H23 Overview of the BigTransmitterm Code While the B3IG transmitter is a bit more sophisticated than the simple commu nications systems of Chapter 9 it still consists of the same basic operations This section provides a highlevel outline of the code in BigTransmitterm which can be compared with idsysm of Chapter 9 Peeking inside the B3IG transmitter code you will find many familiar operations In addition acquainting yourself with the inner workings of code will help prepare you for the receiver design challenges that await The commented sections in BigTransmitterm point to the code that implements the following operations Parse message convert to bits perform coding if requested insert preamble and generate 4PAM sequence Create adjacent user signals Add in main transmission narrowband interference adjacent users and AWGN Calculate the transmitters slightly inaccurate sample rate and IF Upsample signal perform pulseshaping Generate phase noise process Mix signal to IF while incorporating phase noise Pass signal through channel timeinvariant case Pass signal through channel timevarying case Perform downsampling and normalization ie AGC Exercise H1 Figure H7 shows a typical received signal and its spectrum as generated by B3IG The desired message is centered at 10 MHz and has an absolute bandwidth of 1 MHz As seen in the figure there is an interfering adjacent user centered at baseband with a 1 MHz absolute bandwidth Assume that the desired users signal was transmitted at a frequency of fRF 300 MHz and that the local oscillator shown in Figure H5 operates at fLO 90 MHz Assume that the preselect and IF filters are ideal bandpass filters from 250 to 350 MHz and 200 to 260 MHz respectively Complete the transmitter script in BigEx2m to generate a received signal identical to Figure H7 Note that The B3IG Transmitter 459 0 0004 0008 0012 5 0 5 a Seconds Amplitude 2 1 0 1 2 0 2 4 6 8 b Frequency x107 Magnitude x104 Figure H7 a received signal rl and b its magnitude spectrum Rf three parameters have been left incomplete as indicated by the question marks in BigEx2m 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 H7 Plot the spectrum of the signal you generate Exercise H2 The script in BigEx3m generates an ideal received signal much like idsysm from Chapter 9 This time however the transmitter sends signals for two users using TDMA where frameParamsuserDataLength 5 Mimic the receiver code in BigIdealm to accurately decode the signal for each user Write your receiver code so that it stores the message for the first user in a variable called decoded1 and the message for the second user in a variable called decoded2 H3 Notes on Debugging and Signal Measurement In experimenting with the B3IG transmitter you may find that it will be very useful to look closely at intermediate signals the are inside the transmitter func tion This can be accomplished in a variety of ways Some possibilities are listed here r Add more output arguments to BigTransmitterm so that the variables are available in the Matlab workspace r Use the debugging capabilities of Matlab including breakpoints step exe cution etc r Add plotting commands within the transmitter code Index 5 2 block code 330 333 334 6 4 block code 337 7 3 block code 336 16QAM 361 4PAM 5 30 153 202 205 208 212 223 232 258 293 326 342 4QAM 360 6PAM 307 adaptive components 191 adaptive derotation 386 adaptive element 5556 65 114 Costas phase tracking 208 CV clock recovery 256 DD equalization 288 DD for phase tracking 212 DMA equalization 291 LMS equalization 285 LMS for AGC 123 output power 261 PLL for phase tracking 203 SD for phase tracking 198 simple AGC 123 testing 355 Aeneid 314 AGC 55 120128 166 175 aliasing 28 51 52 99 102 alphabet 4 35 152 211 291 323 AM large carrier 81 419 suppressed carrier 84 419 analog vs digital 11 28 30 121 Anderson J B 39 377 380 402 angle formulas 405 automatic gain control see AGC averaging 122124 199 256 261 285 442450 averaging and LPF 442 bandlimited 18 101 418 bandpass filter see BPF bandwidth 8 18 85 101 102 155 230 414 bandwidth vs data rate 319 bandwidth vs SNR 320 Barry J R 383 396 402 baseband 9 247 251 271 285 Baum Frank 310 Bello P A 79 B3IG transmitter 187190 215 265 354 451459 binary arithmetic 329 binary to text 154 Bing B 356 Bingham J A C 356 377 392393 402 bit error rate 36 bit error vs symbol error 310 bits definition 307 bits to letters 4 153 bits to text 4 153 blind equalization 289 290 block codes 314 BPF 22 24 46 60 63 76 141 151 377 phase shift 196 197 203 Buracchini E 356 Burrus C S 151 capacity see channel capacity carrier frequency 17 20 22 recovery 9 33 192221 367 recovery tuning 351 Carroll Lewis 310 CD encoding 339 CDMA 22 cell phones 17 center spike initialization 292 Cervantes M 314 chain rule 410 channel 5 11 62 164 179 221 237 260 266 270 272 channel capacity 37 318323 CIRC encoder 339 clock recovery 33 251269 decisiondirected 256 output power 261 tuning 351 460 Index 461 cluster variance 174 251 254 256 code division multiplexing see CDMA codeword 333 coding 4 37 303340 block 314 328 channel 328 efficiency 324 instantaneous 324 majority rules 328 prefix 324 source 323327 339 variable length 325 colored noise 414 complex equalization 282 complexvalued modulation see modulation component architecture 15 compression mp3 327 uuencode 327 zip 327 computers and meaning 310 constellation diagram 174 379 convolution 23 70 72 131 142 156 158 275 408 correlation 152 157160 172 178 245 374 426 correlation vs convolution 160 Costas loop PAM 206 QAM 367374 Costas J P 225 Couch L W III 39 data rate 8 102 data rate vs bandwidth 319 DD see decisiondirected decision 35 174 directed equalization 288 directed phase tracking 211 hard 35 soft 36 176 decoder 328 delay spread 270 272 δ function 65 discrete 67 sifting property 66 131 spectrum 67 demodulation see modulation demodulation via sampling 103 dependence of English text 311 derotation 385 design methodology 345 destructive interference 339 dice 307 difference equation 65 430 differential encoding 375 digital radio 1 14 342 discrete frequencies 132 dispersion minimization 290 386 distortionless 238 DMA see dispersion minimization Don Quixote 314 Doppler effect 25 64 downconversion 25 via sampling 103 downsampling 51 109 161 173 185 dual PLLs 218 duality 23 407 dynamic range 121 efficiency 324 electromagnetic transmission 16 encoder 328 333 encoding a CD 339 energy 18 409 425 English dependency 311 frequency of letters 311 random 312 entropy 315318 324 envelope 81 416420 envelope detector 416 equalization 27 34 56 270302 387391 blind 289 290 complex 282 dispersion minimization 290 fractionally spaced 283 initialization 289 292 353 tuning 352 error measures 35 error surface 118 125 200 207 213 259 261 263 errors in transmission 308 Eulers formulas 404 exclusive OR 329 eye diagram 173 181 185 231237 241 250 435 fading 10 64 127 175 FDM 22 25 29 60 FFT 18 42 131 133141 422424 frequency estimation 194 of a sinusoid 136 phase estimation 195 vs DFT 424 filter design 76 77 130 141 146 filters 23 46 62 141 275 final value theorem 117 408 410 431 firpm see Matlab firpm fixes overview 191 flat fading 175 Fourier transform 18 41 131 405408 462 Index meaning of 422 vs DFT 421 fractionally spaced equalization 283 frame 4 Franks L E 225 frequency 16 carrier 20 content 19 20 40 discrete 132 division multiplexing see FDM domain 23 40 72 132 140 421 intermediate 29 93 130 192 measuring 18 of letters in English 311 offset 85 88 179 184 266 radio 9 resolution 140 response 23 65 74 133 432 scale 408 selectivity 27 shift 407 synchronization 85 tracking 216 218 translation 9 17 20 21 24 54 8097 103 192 freqz see Matlab freqz gain of a linear system 426 Galois fields 339 generator matrix 328 Gitlin R D 397 403 gong analysis 139 149 gradient 34 gradient descent 114 Gray code 154 361 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 highside injection 93 highpass filter see HPF Hilbert transform 407 420 hill climbing 115 HPF 24 46 141 Huffman code 37 324 human hearing 102 ideal channel 5 receiver 4 5 13 58 165 transmitter 165 important message 167 impulse response 23 65 70 74 131 141 142 270 impulse sampling 100 independence of English text 311 independent events 306 information 37 303 and complexity 308 and uncertainty 305 axioms 306 definitions 304 in a letter 308 in digits of π 308 vs meaning 310 initialization center spike 292 instantaneous code 324 325 instructor to the viii integration layer 341 interference 10 59 intermediate frequency 29 93 192 342 interpolation 11 110 257 262 intersymbol interference see ISI ISI 34 229230 241 247 266 270 273 387 435 iteration 447 Jablon N K 394 403 Jayant N 356 jitter visualizing 231 Johnson C R Jr 129 302 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 filters 59 65 70 130151 linear vs nonlinear codes 335 LMS see least mean squares local minima 118 logical AND 329 lookfor see Matlab lookfor lowside injection 93 lowpass filter see LPF LPF 23 141 171 LPF and averaging 442 M6 receiver 342356 majority rules 328 332 marker 162 172 178 344 454 matched filter 242249 mathematical prerequisites vi Index 463 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 filter 47 48 70 142 237 firpm viii 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 filter 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 maximumlength pseudonoise 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 modulation 9 17 20 complexvalued 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 inband 10 60 narrowband 61 270 412 outofband 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 openeye 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 v performance function 114 263 293 381 464 Index Costas loop 207 CV timing recovery 256 DD carrier recovery 211 DD equalization 289 DMA equalization 291 for QAM 381383 LMS equalization 284 LMS for AGC 122 LS equalization 276 output power 261 PLL carrier recovery 203 SD carrier recovery 198 simple AGC 123 period offset 185 periodicity 49 101 406 phase ambiguity 374 maximum 430 minimum 430 offset 86 87 179 183 192 shift 404 splitter 366 synchronization 86 phase tracking analysis 206 Costas loop 206 367 376 decisiondirected 210 dual algorithm 218 phaselocked loop 55 202 375 squared difference 197 PLL see phase tracking Porat B 57 power 18 76 84 120 242 409 413 425 and correlation 426 power spectral density 242 245 409 425427 PPM 362 prefix code 324 325 Proakis J G 39 379 403 probability use of vi properties of discretetime signals 132 pulse amplitude modulation see PAM pulse shaping 3032 155 160 161 172 194 226249 251 273 pulse train 68 99 pulsematched filtering 160 172 pulsephase modulation see PPM QAM 357403 Q3AM receiver 397 398 QPSK 361 377 383 quadrature phase shift keying see QPSK quantization 36 161 211 Qureshi S U H 302 radio AM 17 21 80 digital 14 342 FM 17 21 raised cosine pulse 239 240 248 406 rand see Matlab random random numbers 413 seed 414 receive filtering 160 226249 251 receiver M6 342 Q3AM 397 398 design 345 ideal 165 smart 16 testing 350 355 reconstruction 110 rectangular pulse 8 31 72 111 238 248 406 redundancy 37 304 308315 Reed J H 356 ReedSolomon codes 339 replicas 23 24 100 103 resample see Matlab resample reshape see Matlab reshape resolution in time vs frequency 140 423 Robbins T xiv sampling 11 28 33 49 98129 251 for downconversion 103 sampling theorem 28 Schafer R W 57 Schwarzs inequality 243 245 410 scrambling 162 seed for random numbers 414 Sethares W A 302 Shannon C 3 37 305 308 312 340 sifting property of impulse 410 signal 40 41 131 Signal Processing First vi signaltonoise ratio see SNR simple average 442 simulating noise 412415 sinc function 8 31 72 111 138 236 238 248 406 sine wave 21 spectrum 69 singlesideband modulation 81 sketching frequency response 432 SNR 60 76 244 SNR vs bandwidth 320 soft decision 174 softwaredefined radio 2 14 342 356 source coding 37 source recovery error 251 256 261 276 285 source vs channel coding 304 Index 465 sources of error 348 spectrum 41 132 135 δ function 67 magnitude 18 23 of a pulse sequence 227 phase 18 sine wave 69 squarelaw mixing 88 squareroot raised cosine see SRRC squared error 35 squaring 52 195 207 SRRC 113 236 240 248 344 406 steepest descent 114 Steiglitz K 151 step 1 to build a radio 1 2 basic components 15 3 idealized receiver 58 4 adaptive components 191 5 putting it all together 341 step function 407 stepsize 116 123 126 199 204 209 220 257 262 287 290 292 350 353 371 447 Stonick V 57 stopband 141 Stremler F G 39 symbol error vs bit error 310 symbol recovery error 35 271 symmetry 132 405 407 synchronization 7 3334 carrier 9 192 frame 7 34 154 161 177 344 353 454 frequency 85 phase 86 unnecessary 84 syndrome table 330 336 338 system 40 131 tappeddelay line 275 Taylor F J 56 TDM 22 temperature in Wisconsin average 443 testing the receiver 350 text to binary 154 text to bits 4 153 Through the Looking Glass 310 time 250 delay operator 428 division multiplexing see TDM domain 23 40 132 140 421 resolution 140 shift 408 410 428 timing 33 jitter 7 offset 6 179 185 recovery 251269 380384 Toeplitz matrix 276 278 tracking 124 tradeoffs 350 training sequence 273 284 344 454 transfer function 74 133 430 transition band 142 probabilities 313 transmitter B3IG 187 451 design 343 ideal 165 transpose 411 Treichler J R 394 403 trial and error 350 trigonometric identities 404 tuning the receiver 350 TV 17 uniform sampling 50 unit circle 430 unit delay 429 variable length code 323 variance 413 Vergil 314 Verne Jules 314 vestigal sideband modulation 81 wavelength 16 what if 3 167 178 whatever 344 Widrow B 129 wiener 168 Wizard of Oz 310 325 327 zip compression 327 Ztransforms 409 428434
208
Sinais e Sistemas
UFRJ
586
Sinais e Sistemas
UFRJ
1
Sinais e Sistemas
UFRJ
1
Sinais e Sistemas
UFRJ
1
Sinais e Sistemas
UFRJ
1
Sinais e Sistemas
UFRJ
1
Sinais e Sistemas
UMG
3
Sinais e Sistemas
PUC
1
Sinais e Sistemas
UMG
1
Sinais e Sistemas
FPAS
Texto de pré-visualização
i Software Receiver Design Build Your Own Digital Communications System in Five Easy Steps Have you ever wanted to understand how modern digital communication systems work What is inside your cell phone or HDTV How it is possible for grandmas voice and face to be converted into ones and zeroes transmitted across the planet through wires and through the air received in your home and reconstructed at your fingertips Chapter by chapter Software Receiver Design helps you create a Matlab R realization of the various pieces of a communications system that make this possible exploring the key ideas along the way In the final chapters you can put it all together to build fully functional software receivers 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 and immediacy to the study of communication systems Johnson Sethares and Klein have been learning researching and teaching about signals information flow and data transmission for a long time At the end of the last century they began working with engineers in the telecommuni cations industry on some problems in the transmission and reception of digital TV systems In the course of solving these problems they designed built and coded a software version of the receiver that was key in locating the source of the problems and in testing eventual solutions When it was over the authors had a startling revelation the process of building the software receiver had taught them an enormous amount Why not take this idea and use it to help others learn Software Receiver Design is the result The authors teach at Cornell University the University of Wisconsin and Worcester Polytechnic Institute and you can find out more about them if interested on the web For instance pt may be the rectangular pulse pt 1 when 0 t T 0 otherwise 12 which is plotted in Figure 12a The transmitter of Figure 11 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 11 is illustrated in Figure 12b using the rectangular pulse shape Thus the first pulse begins at some time τ and it is scaled by s0 producing s0pt τ The second pulse begins at time τ T and is scaled by s1 resulting in s1pt τ T The third pulse gives s2pt τ 2T and so on The complete output of the transmitter is the sum of all these scaled pulses yt i sipt τ iT 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 11 it is called 4PAM 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 finite 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 12b is as shown in Figure 12c 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 reflected from mountains or buildings It may be diffracted 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 different city Noises may enter and change the shape of the waveform There are two compelling reasons to consider the telecommunication system in the simplified 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 refine 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 12c and to recover the original text message This can be accomplished by an idealized receiver such as that shown in Figure 13 The first task this receiver must accomplish is to sample the signal to turn it into computerfriendly digital Software Receiver Design Build Your Own Digital Communications System in Five Easy Steps C Richard Johnson Jr William A Sethares and Andrew G Klein July 19 2011 iv cambridge university press Cambridge New York Melbourne Madrid Cape Town Singapore Sao Paulo Cambridge University Press The Edinburgh Building Cambridge CB2 2RU UK Published in the United States of America by Cambridge University Press New York wwwcambridgeorg Information on this title wwwcambridgeorg9780521XXXXXX C Cambridge university Press 2011 This publication is in copyright Subject to statutory exception and to the provisions of relevant collective licensing agreements no reproduction of any part may take place without the written permission of Cambridge University Press First published 2011 Printed in the United Kingdom at the University Press Cambridge A catalogue record for this publication is available from the British Library Library of Congress Cataloguing in Publication data ISBN13 9780521XXXXXX hardback ISBN10 0521XXXXXX hardback Cambridge University Press has no responsibility for the persistence or accuracy of URLs for external or thirdparty internet websites referred to in this publication and does not guarantee that any content on such websites is or will remain accurate or appropriate To the Instructor though its OK for the student to listen in Software Receiver Design helps the reader build a complete digital radio that includes each part of a typical digital communication system Chapter by chapter the reader creates a Matlab R realization of the various pieces of the system exploring the key ideas along the way In the final 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 empha size some topics that are often covered only superficially 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 mul tiplexing 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 finish than to halflearn the properties of many Whole Lotta Radio Our approach to building the components of the digital radio is consistent throughout Software Receiver Design For many of the tasks we define a performance function and an algorithm that optimizes this function This vi To the Instructor approach provides a unified framework for deriving the AGC clock recovery car rier 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 fine texts cited for further reading in Section 38 would be fine Software Receiver Design emphasizes two ways to assess the behavior of the components of a communication system by studying the performance func tions 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 ana lytical 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 final project challenges the digital radio that the student has built by adding many different kinds of imperfections includ ing 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 handson 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 find that the order of presentation of topics in the five easy steps is different from that used by other books Section 13 provides an overview of the flow of topics and our reasons for structuring the course as we have Finally we believe that Software Receiver Design may be of use to non traditional students Besides the many standard kinds of exercises there are many problems in the text that are selfchecking in the sense that the reader will know whenwhether they have found the correct answer These may also be useful to the selfmotivated design engineer who is using Software Receiver Design to learn about digital radio To the Instructor vii How Weve Used Software Receiver Design The authors have taught from various versions of this text for a number of years exploring different ways to fit coverage of digital radio into a standard electrical engineering elective sequence Perhaps the simplest way is via a standalone course one semester long in which the student works through the chapters and ends with the final project as outlined in Chapter 15 Students who have graduated tell us that when they get to the workplace where softwaredefined digital radio is increasingly impor tant the preparation of this course has been invaluable After having completed this course plus a rigorous course in probability other students have reported that they are well prepared for the typical introductory graduatelevel class in communications offered at research universities At Cornell University the University of Wisconsin and Worcester Polytechnic Institute the home institutions of the authors there is a twosemester sequence in communications available for advanced undergraduates We have integrated the text into this curriculum in three ways 1 Teach from a traditional text for the first semester and use Software Receiver Design in the second 2 Teach from Software Receiver Design in the first semester and use a tra ditional text in the second 3 Teach from Software Receiver Design in the first semester and teach a projectoriented extension in the second All three work well When following the first approach students often comment that by reading Software Receiver Design they finally understand what they had been doing the previous semester Because there is no probability prerequisite for Software Receiver Design the second approach can be moved earlier in the curriculum Of course we encourage students to take probability at the same time In the third approach the students were asked to extend the basic pulse amplitude modulation PAM and quadrature amplitude modulation QAM digital radios to incorporate code division multiplexing to use more advanced equalization techniques etc We believe that the increasing market penetration of broadband communica tions is the driving force behind the continuing redesign of radios wireless communications devices Digital devices continue to penetrate the market for merly occupied by analog for instance digital television has now supplanted analog television in the USA and the area of digital and softwaredefined radio is regularly reported in the mass media Accordingly it is easy for the instructor to emphasize the social and economic aspects of the wireless revolution The impact of digital radio is vast and it is an exciting time to get involved viii To the Instructor Some Extras The course website contains extra material of interest especially to the instruc tor First we have assembled a complete collection of slides in pdf format that may help in lesson planning The final 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 exploration1 Mathematical Prerequisites r G B Thomas and R L Finney Calculus and Analytic Geometry 8th edition AddisonWesley 1992 r B Kolman and D R Hill Elementary Linear Algebra 8th edition Prentice Hall 2003 r J H McClellan R W Schafer and M A Yoder Signal Processing First PrenticeHall 2003 1 The m scripts will run with either Matlab or GNU Octave which is freely available at httpwwwgnuorgsoftwareoctave When using the scripts with Matlab the Signal Pro cessing Toolbox is required all scripts have been tested with Matlab v710R2010a but are expected to work with older versions of Matlab For Octave the scripts were tested with Octave v323 and the required OctaveForge toolboxes signal v1011 specfun v109 optim v1012 miscellaneous v109 and audio v114 When using Octave the script firpm octavem can be renamed firpmm so that identical code will run in the two plat forms Contents To the Instructor page v Step 1 The Big Picture 1 1 A Digital Radio 2 11 What Is a Digital Radio 2 12 An Illustrative Design 3 13 Walk This Way 12 Step 2 The Basic Components 15 2 A Telecommunication System 16 21 Electromagnetic Transmission of Analog Waveforms 16 22 Bandwidth 18 23 Upconversion at the Transmitter 20 24 Frequency Division Multiplexing 22 25 Filters that Remove Frequencies 23 26 Analog Downconversion 24 27 Analog Core of a Digital Communication System 26 28 Sampling at the Receiver 28 29 Digital Communications Around an Analog Core 29 210 Pulse Shaping 30 211 Synchronization Good Times Bad Times 33 212 Equalization 34 213 Decisions and Error Measures 35 214 Coding and Decoding 37 215 A Telecommunication System 38 216 Stairway to Radio 38 3 The Six Elements 40 31 Finding the Spectrum of a Signal 41 32 The First Element Oscillators 44 33 The Second Element Linear Filters 46 x Contents 34 The Third Element Samplers 49 35 The Fourth Element Static Nonlinearities 52 36 The Fifth Element Mixers 53 37 The Sixth Element Adaptation 55 38 Summary 56 Step 3 The Idealized System 58 4 Modeling Corruption 59 41 When Bad Things Happen to Good Signals 59 42 Linear Systems Linear Filters 65 43 The Delta Function 65 44 Convolution in Time Its What Linear Systems Do 70 45 Convolution Multiplication 72 46 Improving SNR 76 5 Analog Demodulation 80 51 Amplitude Modulation with Large Carrier 81 52 Amplitude Modulation with Suppressed Carrier 84 53 Quadrature Modulation 90 54 Injection to Intermediate Frequency 93 6 Sampling with Automatic Gain Control 98 61 Sampling and Aliasing 99 62 Downconversion via Sampling 103 63 Exploring Sampling in MATLAB 108 64 Interpolation and Reconstruction 110 65 Iteration and Optimization 114 66 An Example of Optimization Polynomial Minimization 115 67 Automatic Gain Control 120 68 Using an AGC to Combat Fading 127 69 Summary 129 7 Digital Filtering and the DFT 130 71 Discrete Time and Discrete Frequency 130 72 Practical Filtering 141 8 Bits to Symbols to Signals 152 81 Bits to Symbols 152 82 Symbols to Signals 155 83 Correlation 157 84 Receive Filtering From Signals to Symbols 160 85 Frame Synchronization From Symbols to Bits 161 Contents xi 9 Stuff Happens 165 91 An Ideal Digital Communication System 166 92 Simulating the Ideal System 167 93 Flat Fading A Simple Impairment and a Simple Fix 175 94 Other Impairments More What Ifs 178 95 A B3IG Deal 187 Step 4 The Adaptive Components 191 10 Carrier Recovery 192 101 Phase and Frequency Estimation via an FFT 194 102 Squared Difference Loop 197 103 The PhaseLocked Loop 202 104 The Costas Loop 206 105 DecisionDirected Phase Tracking 210 106 Frequency Tracking 216 11 Pulse Shaping and Receive Filtering 226 111 Spectrum of the Pulse Spectrum of the Signal 227 112 Intersymbol Interference 229 113 Eye Diagrams 231 114 Nyquist Pulses 237 115 Matched Filtering 242 116 Matched Transmit and Receive Filters 247 12 Timing Recovery 250 121 The Problem of Timing Recovery 251 122 An Example 252 123 DecisionDirected Timing Recovery 256 124 Timing Recovery via Output Power Maximization 261 125 Two Examples 266 13 Linear Equalization 270 131 Multipath Interference 272 132 Trained LeastSquares Linear Equalization 273 133 An Adaptive Approach to Trained Equalization 284 134 DecisionDirected Linear Equalization 288 135 DispersionMinimizing Linear Equalization 290 136 Examples and Observations 294 14 Coding 303 141 What Is Information 304 142 Redundancy 308 xii Contents 143 Entropy 315 144 Channel Capacity 318 145 Source Coding 323 146 Channel Coding 328 147 Encoding a Compact Disc 339 Step 5 Putting It All Together 341 15 Make It So 342 151 How the Received Signal Is Constructed 343 152 A Design Methodology for the M6 Receiver 345 153 No Soap Radio The M6 Receiver Design Challenge 354 16 A Digital Quadrature Amplitude Modulation Radio 357 161 The Song Remains the Same 357 162 Quadrature Amplitude Modulation QAM 358 163 Demodulating QAM 363 164 Carrier Recovery for QAM 367 165 Designing QAM Constellations 378 166 Timing Recovery for QAM 380 167 Baseband Derotation 384 168 Equalization for QAM 387 169 Alternative Receiver Architectures for QAM 391 1610 The Q3AM Prototype Receiver 397 1611 Q3AM Prototype Receiver Users Manual 398 Appendices 404 A Transforms Identities and Formulas 404 A1 Trigonometric Identities 404 A2 Fourier Transforms and Properties 405 A3 Energy and Power 409 A4 ZTransforms and Properties 409 A5 Integral and Derivative Formulas 410 A6 Matrix Algebra 411 B Simulating Noise 412 C Envelope of a Bandpass Signal 416 D Relating the Fourier Transform to the DFT 421 D1 The Fourier Transform and Its Inverse 421 D2 The DFT and the Fourier Transform 422 Contents xiii E Power Spectral Density 425 F The ZTransform 428 F1 ZTransforms 428 F2 Sketching the Frequency Response from the ZTransform 432 F3 Measuring Intersymbol Interference 435 F4 Analysis of Loop Structures 438 G Averages and Averaging 442 G1 Averages and Filters 442 G2 Derivatives and Filters 443 G3 Differentiation Is a Technique Approximation Is an Art 446 H The B3IG Transmitter 451 H1 Constructing the Received Signal 453 H2 Matlab Code for the Notorious B3IG 455 H3 Notes on Debugging and Signal Measurement 459 Index 460 xiv Contents With thanks to Tom Robbins for his foresight encouragement and perseverance The professors who have taught from earlier versions of this book Mark Ander sland Marc Buchner Brian Evans Edward Doering Tom Fuja Brian Sadler Michael Thompson and Mark Yoder The classes of students who have learned from earlier versions of this book ECE436 and ECE437 at the University of Wisconsin EE467 and EE468 at Cornell University and ECE 3311 at Worcester Polytechnic Institute Teaching assistants and graduate students who have helped refine this mate rial Jai Balkrishnan Rick Brown Wonzoo Chung Qingxiong Deng Matt Gaubatz Jarvis Haupt Sean Leventhal Yizheng Liao Katie Orlicki Jason Pagnotta Adam Pierce Johnson Smith Charles Tibenderana and Nick Xenias The companies that have provided data or access to engineers and joined us in the field Applied Signal Technology Aware Fox Digital Iberium Lucent Technologies and NxtWave Communications now AMD The many talented academics and engineers who have helped hone this mate rial Raul Casas Tom Endres John Gubner Rod Kennedy Mike Larimore Rick Martin Phil Schniter John Treichler John Walsh Evans Wetmore and Robert Williamson The staff of talented editors at Cambridge University Press Phil Meyler Sarah Finlay Sarah Matthews Steven Holt and Joanna EndellCooper Where would we have been without LATEX guru Sehar Tahir Those with a welldeveloped sense of humor Ann Bell and Betty Johnson Dread Zeppelin whose 1999 performance in Palo Alto inspired the title Telecom munication Breakdown In this new improved expanded and more reveal ingly titled version the legacy continues how many malapropic Led Zeppelin song titles are there Dedicated to Samantha and Franklin Step 1 The Big Picture Software Receiver Design Build Your Own Digital Communications System in Five Easy Steps is structured like a staircase with five simple steps The first chapter presents a naive digital communications system a sketch of the digital radio as the first step The second chapter ascends one step to fill in details and demystify various pieces of the design Successive chapters then revisit the same ideas each step adding depth and precision The first functional though idealized receiver appears in Chapter 9 Then the idealizing assumptions are stripped away one by one throughout the remaining chapters culminating in sophisticated receiver designs in the final chapters Section 13 on page 12 outlines the five steps in the construction of the receiver and provides an overview of the order in which topics are discussed 1 A Digital Radio 11 What Is a Digital Radio The fundamental principles of telecommunications have remained much the same since Shannons time What has changed and is continuing to change is how those principles are deployed in technology One of the major ongoing changes is the shift from hardware to softwareand Software Receiver Design reflects this trend by focusing on the design of a digital softwaredefined radio that you will implement in Matlab Radio does not literally mean the AMFM radio in your car it represents any throughtheair transmission such as television cell phone or wireless com puter data though many of the same ideas are also relevant to wired systems such as modems cable TV and telephones Softwaredefined means that key elements of the radio are implemented in software Taking a softwaredefined approach mirrors the trend in modern receiver design in which more and more of the system is designed and built in reconfigurable software rather than in fixed hardware The fundamental concepts behind the transmission are introduced demonstrated and we hope understood through simulation For example when talking about how to translate the frequency of a signal the procedures are presented mathematically in equations pictorially in block diagrams and then concretely as short Matlab programs Our educational philosophy is that it is better to learn by doing to motivate study with experiments to reinforce mathematics with simulated examples to integrate concepts by playing with the pieces of the system Accordingly each of the later chapters is devoted to understanding one component of the transmis sion system and each culminates in a series of tasks that ask you to build a particular version of that part of the communication system In the final chapter the parts are combined to form a full receiver We try to present the essence of each system component in the simplest possi ble form We do not intend to show all the most recent innovations though our A Digital Radio 3 presentation and viewpoint are modern nor do we intend to provide a complete analysis of the various methods Rather we ask you to investigate the perfor mance of the subsystems partly through analysis and partly using the software code that you have created and that we have provided We do offer insight into all pieces of a complete transmission system We present the major ideas of com munications via a small number of unifying principles such as transforms to teach modulation and recursive techniques to teach synchronization and equalization We believe that these basic principles have application far beyond receiver design and so the time spent mastering them is well worth the effort Though far from optimal the receiver that you will build contains all the elements of a fully functional receiver It provides a simple way to ask and answer what if questions What if there is noise in the system What if the modulation frequencies are not exactly as specified What if there are errors in the received digits What if the data rate is not high enough What if there are distortion reflections or echoes in the transmission channel What if the receiver is moving The first step begins with a sketch of a digital radio 12 An Illustrative Design The first 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 refine the ideas The design is shown in Figures 11 through 15 While talking about these figures it will become clear that some ideas are being oversimplified 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 files jpg photos snippets of speech rasterscanned 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 difference between a string of zeros and no transmission at 4 Chapter 1 A Digital Radio Coder 1 τ kT Text Symbols sk Scaling factor Initiation trigger Twide analog pulse shape pt generator Baseband signal yt Figure 11 An idealized baseband transmitter all A common remedy is to send a pulse with a positive amplitude to represent a one and a pulse of the same shape but negative amplitude to represent a zero In fact if the receiver could distinguish pulses of different sizes then it would be possible to send two bits with each symbol for example by associating the amplitudes1 of 1 1 3 and 3 with the four choices 10 01 11 and 00 The four symbols 1 3 are called the alphabet and the conversion from the original message the text into the symbol alphabet is accomplished by the coder in the transmitter diagram Figure 11 The first few letters the standard ASCII binary representation of these letters and their coding into symbols are as follows letter binary ASCII code symbol string a 01 10 00 01 1 1 3 1 b 01 10 00 10 1 1 3 1 c 01 10 00 11 1 1 3 3 d 01 10 01 00 1 1 1 3 11 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 r the symbol interval T be the time between successive symbols and r the pulse shape pt be the shape of the pulse that will be transmitted 1 Many such choices are possible These particular values were chosen because they are equidis tant and so noise would be no more likely to flip a 3 into a 1 than to flip a 1 into a 1 6 Chapter 1 A Digital Radio rt τδ τδT 3g g g 3g τδ2T τδ3T τδ4T yt τ τT 3 1 1 3 τ2T τ3T τ4T pt 1 0 T a b c Figure 12 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 offset in time by τ and scaled in magnitude by the symbols sk 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 δ Decoder Quantizer Reconstructed text Reconstructed symbols Received signal η kT Sampler Figure 13 An idealized baseband receiver form But when should the samples be taken On comparing Figures 12b and 12c 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 1g 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 11 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 first pulse begins Let δ be the time it takes for the signal to move from the transmitter to the receiver Thus the k 1st 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 δ T2 As indicated in Figure 13 the receiver begins sampling at time η and then samples regularly at η kT for all integers k If η were chosen so that η τ δ T2 13 A Digital Radio 7 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 figure out when to sample Basically some extra synchronization procedure is needed in order to satisfy 13 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 trans mitter call it Ttrans is created by a separate oscillator from that creating the symbol period at the receiver call it Trec they will inevitably differ 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 andor 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 13 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 11 and 13 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 syn chronization that is needed Imagine joining a broadcast in progress or one in which the first 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 letterstosymbol code of 11 each letter of the alphabet is translated into a sequence of four symbols If the start of the frame is off by even a single sym 2 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 Thus proper decoding requires locating where the frame starts a step called frame synchronization Frame synchronization is implicit in Figure 13 in the choice of η which sets the time t η with k 0 of the first symbol of the first character frame of the message of interest How to find 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 11 require Consider transmitting a single Tsecondwide rectangular pulse Fourier transform theory shows that any such timelimited pulse cannot be truly bandlimited that is cannot have its frequency content restricted to a finite range Indeed the Fourier transform of a rectangular pulse in time is a sinc function in frequency see Equation A20 in Appendix A The magnitude of this sinc is overbounded by a function that decays as the inverse of frequency peek ahead to Figure 211 Thus to accommodate this singlepulse transmission all other transmitters must have negligible energy below some factor of B 1T For the sake of argument suppose that a factor of 5 is safe that is all other transmitters must have no significant 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 111 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 tradeoff 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 9 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 highfrequency content Similarly if other transmitters operated at high frequencies outside 5B Hz it would be sen sible to add a lowpass filter at the front end of the receiver Rejecting frequencies outside the protected 5B baseband turf also removes a bit of the higherfrequency content of the rectangular pulse The effect 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 transmit ter of Figure 11 and the receiver of Figure 13 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 simul taneously 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 different pulse shape other than the rectangle that has no lowfrequency content but the most common approach is to modulate change frequency by multiplying the pulseshaped signal by a highfrequency sinusoid Such a radiofrequency RF transmitter is shown in Figure 14 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 demod ulated by multiplying by another highfrequency sinusoid and then lowpass filtering These frequency translations are described in more detail in Section 26 where it is shown that the modulating sinusoid and the demodulating sinu soid 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 11 and 13 produces the transmitter in Figure 14 and the associated receiver in Figure 15 The new block in the transmitter is an analog component that effectively 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 Chapter 1 A Digital Radio Frequency translator Pulse shape filter Coder Passband signal Baseband signal Symbols Text Figure 14 Radiofrequency transmitter Decoder Quantizer Reconstructed text Baseband signal Sampler Frequency translator Received signal Figure 15 Radiofrequency receiver block in the receiver of Figure 15 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 13 This process of translating the spectrum of the transmitted signal to higher frequencies allows many transmitters to operate simultaneously in the same geo graphical area But there is a price Since the signals are not completely band limited to within their assigned 5Bwide 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 fix cost In fact there are many other ways in which the transmission channel can devi ate from the ideal and these will be discussed in detail later on for instance in Section 41 and throughout Chapter 9 Typically the cluttered electromagnetic spectrum results in a variety of distortions and interferences r inband within the frequency band allocated to the user of interest r outofband frequency components outside the allocated band such as the signals of other transmitters r narrowband spurious sinusoidallike components r broadband with components at frequencies across the allocated band and beyond including thermal noise introduced by the analog electronics in the receiver r fading when the strength of the received signal fluctuates r multipath when the environment contains many reflective and absorptive objects at different distances the transmission delay will differ across different paths smearing the received signal and attenuating some frequencies more than others A Digital Radio 11 Gain with delay Multipath Selfinterference Transmitted signal Interference from other sources Received signal Broadband noises Figure 16 A channel model admitting various kinds of interferences These channel imperfections are all incorporated in the channel model shown in Figure 16 which sits in the communication system between Figures 14 and 15 Many of these imperfections in the channel can be mitigated by clever use of filtering at the receiver Narrowband interference can be removed with a notch filter that rejects frequency components in the narrow range of the interferer without removing too much of the broadband signal Outofband interference and broadband noise can be reduced using a bandpass filter that suppresses the signal in the outofband frequency range and passes the inband frequency components without distortion With regard to Figure 15 it is reasonable to wonder whether it is better to perform such filtering before or after the sampler ie by an analog or a digital filter In modern receivers the trend is to minimize the amount of analog processing since digital methods are often cheaper and usually more flexible since they can be implemented as reconfigurable software rather than fixed 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 61 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 freerunning sampler Interpola tion can be used to figure out values of the signal at any desired intermediate instant such as at time η kT recall 13 for a particular η that is not an integer multiple of T Thus the timing synchronization can be incorporated into the postsampler digital signal processing box which is shown generically in Figure 17 Observe that Figure 15 is one particular version of 17 How exactly does interpolation work 12 Chapter 1 A Digital Radio Digital signal processing Analog signal processing Recovered source Received signal η kT Figure 17 A generic modern receiver using both analog signal processing ASP and digital signal processing DSP However sometimes it is more cost effective to perform certain tasks in analog circuitry For example if the transmitter modulates to a very high frequency then it may cost too much to sample fast enough Currently it is common practice to perform some frequency translation and some outofband signal reduction in the analog portion of the receiver Sometimes the analog portion may translate the received signal all the way back to baseband Other times the analog portion translates to some intermediate frequency and then the digital portion finishes the translation The advantage of this seemingly redundant approach is that the analog part can be made crudely and hence cheaply The digital processing finishes the job and simultaneously compensates for inaccuracies and flaws in the inexpensive analog circuits Thus the digital signal processing portion of the receiver may need to correct for signal impairments arising in the analog portion of the receiver as well as from impairments caused by the channel Use DSP when possible The digital signal processing portion of the receiver can perform the following tasks r downconvert the sampled signal to baseband r track any changes in the phase or frequency of the modulating sinusoid r adjust the symbol timing by interpolation r compensate for channel imperfections by filtering r convert modestly inaccurate recovered samples into symbols r perform frame synchronization via correlation r decode groups of symbols into message characters A central task in Software Receiver Design is to elaborate on the system structure in Figures 1416 to create a working softwaredefined radio that can perform these tasks This concludes the illustrative design at the first most superficial step of the radio stairway Use DSP to compensate for cheap ASP 13 Walk This Way This section provides a whirlwind tour of the complete structure of Software Receiver Design Each step presents the digital transmission system in greater depth and detail Step 1 The Naive Digital Communications System As we have just seen the first step introduced the digital transmission of data and discussed how bits of information may be coded into waveforms sent across space to the receiver and then decoded back into bits Since there is no universal clock issues of timing become important and some of the most complex issues in digital receiver design involve the synchronization of the received signal The system can be viewed as consisting of three parts 1 a transmitter as in Figure 14 2 a transmission channel 3 a receiver as in Figure 15 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 briefly 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 fixed 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 reflections diffractions or diffusions 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 Channel impairments and linear systems Chapter 4 Frequency translation and modulation Chapter 5 Sampling and gain control Chapter 6 Receive digital filtering Chapter 7 Symbols to bits to signals Chapter 8 14 Chapter 1 A Digital Radio Chapter 9 provides a complete though idealized softwaredefined digital radio system r Step 4 The Adaptive Components The fourth step describes all the practical fixes that are required in order to create a workable radio One by one the various problems are studied and solutions are proposed implemented and tested These include fixes for additive noise for timing offset problems for clock frequency mismatches and jitter and for multipath reflections Again the order in which topics are discussed is the order in which they appear in the receiver Carrier recovery Chapter 10 the timing of frequency translation Receive filtering Chapter 11 the design of pulse shapes Clock recovery Chapter 12 the timing of sampling Equalization Chapter 13 filters that adapt to the channel Coding Chapter 14 making data resilient to noise r Step 5 Putting It All Together The final steps are the projects of Chapters 15 and 16 which integrate all the fixes of the fourth step into the receiver structure of the third step to create a fully functional digital receiver The well fabricated receiver is robust with respect to distortions such as those caused by noise multipath interference timing inaccuracies and clock mismatches 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 briefly 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 fixed the ordering of the blocks in the system diagram has stabilized 2 A Telecommunication System Telecommunications technologies using electromagnetic transmission surround us television images flicker radios chatter cell phones and telephones ring allowing us to see and hear each other anywhere on the planet Email and the Internet link us via our computers and a large variety of common devices such as CDs DVDs and hard disks augment the traditional pencil and paper storage and transmittal of information People have always wished to communicate over long distances to speak with someone in another country to watch a distant sporting event to listen to music performed in another place or another time to send and receive data remotely using a personal computer In order to imple ment these desires a signal a sound wave a signal from a TV camera or a sequence of computer bits needs to be encoded stored transmitted received and decoded Why Consider the problem of voice or music transmission Send ing sound directly is futile because sound waves dissipate very quickly in air But if the sound is first transformed into electromagnetic waves then they can be beamed over great distances very efficiently Similarly the TV signal and computer data can be transformed into electromagnetic waves 21 Electromagnetic Transmission of Analog Waveforms There are some experimental physical facts that cause transmission systems to be constructed as they are First for efficient wireless broadcasting of electro magnetic energy an antenna needs to be longer than about 110 of a wavelength of the frequency being transmitted The antenna at the receiver should also be proportionally sized The wavelength λ and the frequency f of a sinusoid are inversely propor tional For an electrical signal travelling at the speed of light c 3 108 ms the relationship between wavelength and frequency is λ c f A Telecommunication System 17 For instance if the frequency of an electromagnetic wave is f 10 kHz then the length of each wave is λ 3 108 ms 104s 3 104 m Efficient transmission requires an antenna longer than 01λ which is 3 km Sinu soids 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 AM radio f 6001500 kHz λ 500200 m 01λ 20 m r VHF TV f 30300 MHz λ 101 m 01λ 01 m r UHF TV f 033 GHz λ 101 m 01λ 001 m r Cell phones USA f 824894 MHz λ 036033 m 01λ 003 m r PCS f 1819 GHz λ 01670158 m 01λ 0015 m r GSM Europe f 890960 MHz λ 03370313 m 01λ 003 m r LEO satellites f 16 GHz λ 0188 m 01λ 00188 m 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 different behaviors depending on the frequency of the waves r Below 2 MHz electromagnetic waves follow the contour of the Earth This is why shortwave and other radios can sometimes be heard hundreds or thousands of miles from their source r Between 2 and 30 MHz skywave propagation occurs with multiple bounces from refractive atmospheric layers r Above 30 MHz lineofsight propagation occurs with straightline travel between two terrestrial towers or through the atmosphere to satellites r Above 30 MHz atmospheric scattering also occurs which can be exploited for longdistance terrestrial communication Humanmade media in wired systems also exhibit frequencydependent behav ior 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 longdistance communica tions Because of its role as a carrier the AMUHFVHFPCS 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 form and its discrete counterparts the DFT and the FFT1 Fourier transforms are useful in assessing energy or power at particular frequencies The Fourier transform of a signal wt is defined as W f t wt e j 2 π f t dt F w t 21 where j 1 and f is given in Hz ie cycless or 1s Speaking mathematically W f is a function of the frequency f Thus for each f W f is a complex number and so can be plotted in several ways For instance it is possible to plot the real part of W f as a function of f and to plot the imaginary part of W f as a function of f Alternatively it is possible to plot the real part of W f versus the imaginary part of W f The most common plots of the Fourier transform of a signal are done in two parts the first graph shows the magnitude W f versus f this is called the magnitude spectrum and the second graph shows the phase angle of W f versus f this is called the phase spectrum Often just the magnitude is plotted though this inevitably leaves out information Perhaps the best way to understand the Fourier transform is to look closely at the inverse function w t f W f e j 2 π f t d f 22 The complex exponential e j 2 π f t can be interpreted as a complexvalued sinusoidal wave since it is the sum of a sine term and a cosine term both of frequency f via Eulers formula Since Wf is a complex number at each f 22 can be interpreted as describing or decomposing wt into sinusoidal elements of frequencies f weighted by the Wf 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 22 Bandwidth If at any particular frequency f0 the magnitude spectrum is strictly positive Wf0 0 then the frequency f0 is said to be present in wt 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 telephonequality speech with maximum frequency 4 kHz and audible music with maximum frequency 20 kHz 1 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 efficient method of calculating the DFT A Telecommunication System 19 f W f Halfpower BW Nulltonull BW Power BW Absolute BW 1 2 0707 2 Figure 21 Various ways to define bandwidth BW for a realvalued signal But realworld signals are never completely bandlimited and there is almost always some energy at every frequency Several alternative definitions of band width are in common use these try to capture the idea that most of the energy is contained in a specified frequency region Usually these are applied across positive frequencies with the presumption that the underlying signals are realvalued and hence have symmetric spectra Here are some of the alternative definitions 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 3dB or halfpower bandwidth is f2 f1 where for frequencies outside f1 f f2 Hf is never greater than 1 2 times its maximum value 3 Nulltonull or zerocrossing bandwidth is f2 f1 where f2 is the first null in Hf above f0 and for bandpass systems f1 is the first null in the enve lope below f0 where f0 is the frequency of maximum Hf For baseband systems f1 is usually zero 4 Power bandwidth is f2 f1 where f1 f f2 defines the frequency band in which 99 of the total power resides Occupied bandwidth is such that 05 of power is above f2 and 05 below f1 These definitions are illustrated in Figure 21 The various definitions of bandwidth refer directly to the frequency content of a signal Since the frequency response of a linear filter is the transform of its impulse response bandwidth is also used to talk about the frequency range over which a linear system or filter operates Exercise 21 TRUE or FALSE Absolute bandwidth is never less than 3dB power bandwidth Exercise 22 Suppose that a signal is complexvalued and hence has a spectrum that is not symmetric about zero frequency State versions of the various definitions of bandwidth that make sense in this situation Illustrate your definitions as in Figure 21 23 Upconversion at the Transmitter Suppose that the signal wt contains important information that must be transmitted There are many kinds of operations that can be applied to wt Linear time invariant LTI operations are those for which superposition applies but LTI operations cannot augment the frequency content of a signalno sine wave can appear at the output of a linear operation if it was not already present in the input Thus the process of modulation or upconversion which requires a change of frequencies must be either nonlinear or time varying or both One useful way to modulate is with multiplication consider the product of the message waveform wt with a cosine wave st wt cos2πf₀t 23 where f₀ 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 f₀ Hz Using one of Eulers identities A2 cos2πf₀t 12 ej2πf₀t ej2πf₀t 24 one can calculate the spectrum or frequency content of the signal st from the definition of the Fourier transform given in 21 In complete detail this is Sf Fst Fwt cos2πf₀t F wt 12 ej2πf₀t ej2πf₀t from to wt 12 ej2πf₀t ej2πf₀t ej2πft dt 12 from to wt ej2πf f₀t ej2πf f₀t dt 12 from to wtej2πf f₀t dt 12 from to wtej2πf f₀t dt 12 Wf f₀ 12 Wf f₀ 25 A Telecommunication System 21 f f f W f S f 1 f0 f0 f f0 f 05 f0 f0 f f0 f b a Figure 22 Action of a modulator If the message signal wt has the magnitude spectrum shown in part a then the modulated signal st has the magnitude spectrum shown in part b Thus the spectrum of st consists of two copies of the spectrum of wt each shifted in frequency by f0 one up and one down and each half as large This is sometimes called the frequencyshifting property of the Fourier trans form and sometimes called the modulation property Figure 22 shows how the spectra relate If wt 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 st appears as in part b This kind of modulation or upconversion or frequency shift is ideal for translating speech music or other lowfrequency signals into much higher frequencies for instance f0 might be in the AM or UHF bands so that they can be transmit ted efficiently It can also be used to convert a highfrequency signal back down to baseband when needed as will be discussed in Section 26 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 23 where the message wt is multiplied by a high frequency sinusoid with fixed 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 23 Referring to Figure 22 find which frequencies are present in Wf and not in Sf Which frequencies are present in Sf but not in Wf Exercise 24 Using 25 draw analogous pictures for the phase spectrum of st as it relates to the phase spectrum of wt Exercise 25 Suppose that st is modulated again this time via multiplication with a cosine of frequency f1 What is the resulting magnitude spectrum Hint let rt st cos2πf1t and apply 25 to find Rf 22 Chapter 2 A Telecommunication System 24 Frequency Division Multiplexing When a signal is modulated the width in Hz of the replicas is the same as the width in Hz of the original signal This is a direct consequence of Equation 25 For instance if the message is bandlimited to f and the carrier frequency is fc then the modulated signal has energy in the range from f fc to f fc and from f fc to f fc If f fc then several messages can be transmitted simultaneously by using different carrier frequencies This situation is depicted in Figure 23 where three different messages are represented by the triangular rectangular and halfoval spectra each bandlim ited to f Each of these is modulated by a different carrier f1 f2 and f3 which are chosen so that they are further apart than the width of the messages In general as long as the carrier frequencies are separated by more than 2f there will be no overlap in the spectrum of the combined signal This process of combining many different signals together is called multiplexing and because the frequencies are divided up among the users the approach of Figure 23 is called frequencydivision multiplexing FDM Whenever FDM is used the receiver must separate the signal of interest from all the other signals present This can be accomplished with a bandpass filter as in Figure 24 which shows a filter designed to isolate the middle user from the others Exercise 26 Suppose that two carrier frequencies are separated by 1 kHz Draw the magnitude spectra if a the bandwidth of each message is 200 Hz and b the bandwidth of each message is 2 kHz Comment on the ability of the bandpass filter at the receiver to separate the two signals Another kind of multiplexing is called timedivision multiplexing TDM in which two or more messages use the same carrier frequency but at alternating time instants More complex multiplexing schemes such as code division mul tiplexing overlap the messages in both time and frequency in such a way that they can be demultiplexed efficiently by appropriate filtering f3 f f2 f1 f1 f2 f3 f2 f f2 f f3 f f3 f W f Figure 23 Three different upconverted signals are assigned different frequency bands This is called frequencydivision multiplexing A Telecommunication System 23 f3 f f2 f1 f2 f f2 f Bandpass filter W f Figure 24 Separation of a single FDM transmission using a bandpass filter 25 Filters that Remove Frequencies Each time the signal is modulated an extra copy or replica of the spectrum appears When multiple modulations are needed for instance at the transmitter to convert up to the carrier frequency and at the receiver to convert back down to the original frequency of the message copies of the spectrum may proliferate There must be a way to remove extra copies in order to isolate the original message This is one of the things that linear filters do very well There are several ways of describing the action of a linear timeinvariant filter In the time domain the most common method of implementation the filter is characterized by its impulse response which is defined to be the output of the filter when the input is an impulse function Because of the linearity the output of the filter in response to any arbitrary input is the superposition of weighted copies of a timeshifted version of the impulse response a procedure known as convolution Since convolution may be difficult to understand directly in the time domain the action of a linear filter is often described in the frequency domain Perhaps the most important property of the Fourier transform is the duality between convolution and multiplication which says that r convolution in time multiplication in frequency and r multiplication in time convolution in frequency This is discussed in detail in Section 45 Thus the convolution of a linear filter can readily be viewed in the frequency Fourier domain as a pointbypoint multiplication For instance an ideal lowpass filter LPF passes all frequencies below fl which is called the cutoff frequency This is commonly plotted in a curve called the frequency response of the filter which describes the action of the filter2 If this filter is applied to a signal wt then all energy above fl is removed from wt Figure 25 shows this pictorially If wt has the magnitude spectrum shown in part a and the frequency response of the lowpass filter with cutoff frequency fl is as shown in part b then the magnitude spectrum of the output appears in part c 2 Formally the frequency response can be calculated as the Fourier transform of the impulse response of the filter 24 Chapter 2 A Telecommunication System fl fl f a fl fl f b fl fl f c W f H f Y f H f W f Figure 25 Action of a lowpass filter a shows the magnitude spectrum of the message which is input into an ideal lowpass filter with frequency response b c shows the pointbypoint multiplication of a and b which gives the spectrum of the output of the filter Exercise 27 An ideal highpass filter passes all frequencies above some given fh and removes all frequencies below Show the result of applying a highpass filter to the signal in Figure 25 with fh fl Exercise 28 An ideal bandpass filter passes all frequencies between an upper limit f and a lower limit f Show the result of applying a bandpass filter to the signal in Figure 25 with f 2fl3 and f fl3 The problem of how to design and implement such filters is considered in detail in Chapter 7 26 Analog Downconversion Because transmitters typically modulate the message signal with a high frequency carrier the receiver must somehow remove the carrier from the mes sage 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 highfrequency replicas A lowpass filter can then remove everything but the scaled copy of the original message This is how the box labelled frequency translator in Figure 15 is typically implemented To see this procedure in detail suppose that st wt cos2πf0t arrives at the receiver which multiplies st by another cosine wave of exactly the same frequency and phase to get the demodulated signal dt st cos2πf₀t wt cos22πf₀t Using the trigonometric identity A4 namely cos2x 12 12 cos2x this can be rewritten as dt wt 12 12 cos4πf₀t 12 wt 12 wt cos2π2f₀t The spectrum of the demodulated signal can be calculated to be Fdt F 12 wt 12 wt cos2π2f₀t 12 Fwt 12 Fwt cos2π2f₀t by linearity Now the frequencyshifting property 25 can be applied to show that Fdt 12 Wf 14 Wf 2f₀ 14 Wf 2f₀ 26 Thus the spectrum of this downconverted received signal has the original baseband component scaled to 50 and two matching pieces each scaled to 25 centered around twice the carrier frequency f₀ and twice its negative A lowpass filter can now be used to extract Wf and hence to recover the original message wt This procedure is shown diagrammatically in Figure 26 The spectrum of the original message is shown in a and the spectrum of the message modulated by the carrier appears in b When downconversion is done as just described the demodulated signal dt has the spectrum shown in c Filtering by a lowpass filter as in part c removes all but a scaled version of the message Now consider the FDM transmitted signal spectrum of Figure 23 This can be demodulateddownconverted similarly The frequencyshifting rule 25 with a shift of f₀ f₃ ensures that the downconverted spectrum in Figure 27 matches 26 and the lowpass filter removes all but the desired message from the downconverted signal This is the basic principle of a transmitter and receiver pair But there are some practical issues that arise What happens if the oscillator at the receiver is not completely accurate in either frequency or phase The downconverted received signal becomes st cos2πf₀ αt β This can have serious consequences for the demodulated message What happens if one of the antennas is moving The Doppler effect suggests that this corresponds to a small nonzero value of α What happens if the transmitter antenna wobbles due to the wind over a range equivalent to several wavelengths of the transmitted signal This can alter β In effect the baseband component is perturbed from 12Wf and 26 Chapter 2 A Telecommunication System f 0 f a 0 b f0 f0 c 2f0 2f0 Lowpass filter stcos2πf0t W f S f Figure 26 The message can be recovered by downconversion and lowpass filtering 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 f3f1 f3f2 2f3 f1f3 f3f2 2f3 f3f1 f2f3 f3f1 f3f2 Figure 27 The signal containing the three messages of Figure 23 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 simply lowpass filtering the downconverted signal results in distortion Carrier synchronization schemes which attempt to identify and track the phase and fre quency of the carrier are routinely used in practice to counteract such problems These are discussed in detail in Chapters 5 and 10 27 Analog Core of a Digital Communication System The signal flow in the AM communication system described in the preceding sections is shown in Figure 28 The message is upconverted for efficient trans mission summed with other FDM users for efficient use of the electromag netic spectrum subjected to possible channel noises such as thermal noise A Telecommunication System 27 Other FDM users Upconversion Message waveform Bandpass filter for FDM user selection Lowpass filter Received signal Other interference Carrier specification Downconversion Carrier synchronization Figure 28 Analog AM communication system bandpass filtered to extract the desired user downconverted requiring carrier synchronization and lowpass filtered to recover the actual message But no transmission system operates perfectly Each of the blocks in Figure 28 may be noisy may have components which are inaccurate and may be subject to fundamental limitations For instance r the bandwidth of a filter may be different from its specification eg the shoulders might not drop off fast enough to avoid passing some of the adjacent signal r the frequency of an oscillator might not be exact and hence the modulation andor demodulation might not be exact r the phase of the carrier is unknown at the receiver since it depends on the time of travel between the transmitter and the receiver r perfect filters are impossible even in principle r no oscillator is perfectly regular there is always some jitter in frequency Even within the frequency range of the message signal the medium can affect different frequencies in different ways These are called frequency selective effects For example a signal may arrive at the receiver and a moment later a copy of the same signal might arrive after having bounced off 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 difficult to reassemble the original message A special filter called the equalizer is often added to the receiver to help improve the situation An equalizer is a kind of deghosting circuit3 and equalization is addressed in detail in Chapter 13 3 We refrain from calling these ghost busters 28 Chapter 2 A Telecommunication System 28 Sampling at the Receiver Because of the proliferation of inexpensive and capable digital processors receivers often contain chips that are essentially specialpurpose comput ers In such receivers many of the functions that are traditionally han dled by discrete components such as analog oscillators and filters can be handled digitally Of course this requires that the analog received sig nal be turned into digital information a series of numbers that a com puter can process This analogtodigital conversion AD is known as sampling Sampling measures the amplitude of the waveform at regular intervals and then stores these measurements in memory Two of the chief design issues in a digital receiver are the following r Where should the signal be sampled r How often should the sampling be done The answers to these questions are intimately related to each other When taking samples of a signal they must be taken fast enough that impor tant information is not lost Suppose that a signal has no frequency content above f Hz The widely known Nyquist reconstruction principle see Section 61 says that if sampling occurs at a rate greater than 2f samples per second it is pos sible to reconstruct the original signal from the samples alone Thus as long as the samples are taken rapidly enough no information is lost On the other hand when samples are taken too slowly the signal cannot be reconstructed exactly from the samples and the resulting distortion is called aliasing Accordingly in the receiver it is necessary to sample at least twice as fast as the highest frequency present in the analog signal being sampled in order to avoid aliasing Because the receiver contains modulators that change the frequencies of the signals different parts of the system have different highest frequencies Hence the answer to the question of how fast to sample is dependent on where the samples will be taken The sampling 1 could be done at the input to the receiver at a rate proportional to the carrier frequency 2 could be done after the downconversion at a rate proportional to the rate of the symbols or 3 could be done at some intermediate rate Each of these is appropriate in certain situations For the first case consider Figure 23 which shows the spectrum of the FDM signal prior to downconversion Let f3 f be the frequency of the upper edge of the user spectrum near the carrier at f3 According to the Nyquist principle the upconverted received signal must be sampled at a rate of at least 2f3 f to avoid aliasing For highfrequency carriers this exceeds the rate of reasonably A Telecommunication System 29 f3 fI f3 fI f3 fI f3 fI Figure 29 FDM downconversion to an intermediate frequency priced AD 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 softwarebased receiver In the second case the downconversion and subsequent lowpass filtering are done in analog circuitry and the samples are taken at the output of the lowpass filter 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 29 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 filter extracts the whole FDM band at an intermediate frequency IF and then it is only necessary to sample at a rate greater than 2f3 f fI Downconversion to an intermediate frequency is common since the analog circuitry can be fixed 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 29 Digital Communications Around an Analog Core The discussion so far in this chapter has concentrated on the classical core of telecommunication systems the transmission and reception of analog waveforms In digital systems as considered in the previous chapter the original signal consists of a stream of data and the goal is to send the data from one location to another The data may be a computer program ASCII text pixels of a picture a digitized MP3 file or sampled speech from a cell phone Data consist of a 30 Chapter 2 A Telecommunication System sequence of numbers which can always be converted to a sequence of zeros and ones called bits How can a sequence of bits be transmitted The basic idea is that since transmission media such as air phone lines the ocean are analog the bits are converted into an analog signal Then this analog signal can be transmitted exactly as before Thus at the core of every digital communication system lies an analog system The output of the transmitter the transmission medium and the front end of the receiver are necessarily analog Digital methods are not new Morsecode telegraphy which consists of a sequence of dashes and dots coded into long and short tone bursts became widespread in the 1850s The early telephone systems of the 1900s were analog with digitization beginning in the 1960s Digital relative to fully analog communications have the following advan tages r digital circuits are relatively inexpensive r data encryption can be used to enhance privacy r digital realization tends to support greater dynamic range r signals from voice video and data sources can be merged for transmission over a common system r digital signals can be easily compressed r noise does not accumulate from repeater to repeater over long distances r low error rates are possible even with substantial noise r errors can be corrected via coding In addition digital receivers can easily be reconfigured or upgraded because they are essentially softwaredriven For instance a receiver built for one broadcast standard say for the American market could be transformed into a receiver for the European market with little additional hardware But there are also some disadvantages of digital relative to fully analog communications including the following r more bandwidth is generally required than with analog r synchronization is required 210 Pulse Shaping In order to transmit a digital data stream it must be turned into an analog signal The first 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 4PAM symbols 1 3 was given explicitly in 11 This was converted into an analog waveform using the rectangular pulse shape 12 which results in signals that look like Figure 210 The rectangular pulse Πt of 28 is T time units wide and centered at the origin Figure 12 In general such signals can be written yt k skpt kT 27 where the sk are the values of the symbols and the function pt is the pulse shape Thus each member of the 4PAM 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 noisefree 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 difficult to avoid having different messages interfere with each other To see this define the rectangular pulse Πt 1 if T2 t T2 0 otherwise 28 as shown in Figure 210 The shifted pulses 28 are sometimes easier to work with than 12 and their magnitude spectra are the same by virtue of the timeshifting property A37 The Fourier transform can be calculated directly from the definition 21 Wf from to Πt ej2πft dt from tT2 to T2 1 ej2πft dt ej2πft j2πf T2tT2 ejπfT ejπfTj2πf T sinπfT πfT T sincfT 29 The sinc function is illustrated in Figure 211 Thus the Fourier transform of a rectangular pulse in the time domain is a sinc function in the frequency domain Since the sinc function dies away with an envelope of 1πx the frequency content of the rectangular pulse shape is in principle infinite It is not possible to separate messages into different nonoverlapping frequency regions as is required for an FDM implementation as in Figure 23 Alternatives to the rectangular pulse are essential Consider what is really required of a pulse shape The pulse is transmitted at time kT and again at time k 1T and again at k 2T The received signal is the sum of all these 32 Chapter 2 A Telecommunication System 8 6 4 2 0 2 4 6 8 0 05 1 sincx Envelope 1πx Figure 211 The sinc function sincx sinπxπx has zeros at every integer except zero and dies away with an envelope of 1πx 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 satisfies 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 211 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 27 the shifted pulse shape is multiplied by each member of the data sequence and then added together If the channel is perfect distortionless and noisefree 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 synchroniza tion 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 A22 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 infinite 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 outofband content in fre quency and an impulse response that falls off rapidly enough to allow reason able truncation in the time domain Commonly used pulse shapes such as the squareroot 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 33 1 1 T2 T p1t 1 1 T2 T p3t 1 1 T2 T p2t Figure 212 Some alternative pulse shapes Exercise 29 Consider the three pulse shapes sketched in Figure 212 for a T spaced PAM system a Which of the three pulse shapes in Figure 212 has the largest baseband power bandwidth Justify your answer b Which of the three pulse shapes in Figure 212 has the smallest baseband power bandwidth Justify your answer Exercise 210 TRUE or FALSE The flatter the top of the pulse shape the less sensitive the receiver is to small timing offsets Explain your reasoning 211 Synchronization Good Times Bad Times Synchronization may occur in several places in the digital receiver r Symbol phase synchronizationchoosing when within each interval T to sample r Symbol frequency synchronizationaccounting for different clock oscillator rates at the transmitter and receiver r Carrier phase synchronizationaligning the phase of the carrier at the receiver with the phase of the carrier at the transmitter r Carrier frequency synchronizationaligning the frequency of the carrier at the receiver with the frequency of the carrier at the transmitter r Frame synchronizationfinding the start of each message data block In digital receivers it is important to sample the received signal at the appro priate time instants Moreover these time instants are not known beforehand rather they must be determined from the signal itself This is the problem of clock recovery A typical strategy samples several times per pulse and then uses some criterion to pick the best one to estimate the optimal time or to interpo late an appropriate value There must also be a way to deal with the situation when the oscillator defining the symbol clock at the transmitter differs from the oscillator defining the symbol clock at the receiver Similarly carrier synchroniza tion is the process of recovering the carrier in both frequency and phase from the received signal This is the same task in a digital receiver as in an analog 34 Chapter 2 A Telecommunication System design recall that the cosine wave used to demodulate the received signal in 26 was aligned in both phase and frequency with the modulating sinusoid at the transmitter though the details of implementation may differ In many applications such as cell phones messages come in clusters called packets and each packet has a header that is located in some agreedupon 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 finding a timing offset τ to maximize the energy of the received signal Solving this optimization problem via a gradient technique leads to a standard algorithm for timing recovery r The problem of carrier phase synchronization can be stated as that of finding a phase offset θ to minimize a particular function of the modulated received signal Solving this optimization problem via a gradient technique leads to the phaselocked loop a standard method of carrier recovery r Carrier phase synchronization can also be stated using an alternative per formance function that leads directly to the Costas loop another standard method of carrier recovery Our presentation focuses on solving problems using simple recursive gradient methods Once the synchronization problems are correctly stated techniques for their solution become obvious With the exception of frame synchroniza tion which is approached via correlational methods the problem of designing synchronizers is unified via one simple concept that of the minimization or maximization of an appropriate performance function Chapters 6 10 and 12 contain details 212 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 differently to arrive at the receiver at different times This intersymbol interference can garble the data The channel may also attenuate different frequencies by different amounts Thus frequency selectivity can render the data indecipherable The solution to both of these problems is to build a filter in the receiver that attempts to undo the effects of the channel This filter called an equalizer cannot be fixed in advance by the system designer however because it must be different in order to compensate for different channel paths that are encountered when the system is operating The problem of equalizer design can be stated as a simple optimization problem that of finding a set of filter parameters to minimize an appropriate function of the error given only the received data and perhaps a training sequence This problem is investigated in detail in Chapter 13 where the same kinds of adaptive techniques that are used to solve the synchronization problems can also be applied to solve the equalization problem 213 Decisions and Error Measures In analog systems the transmitted waveform can attain any value but in a digital implementation the transmitted message must be one of a small number of values defined by the symbol alphabet Consequently the received waveform in an analog system can attain any value but in a digital implementation the recovered message is meant to be one of a small number of values from the source alphabet Thus when a signal is demodulated to a symbol and it is not a member of the alphabet the difference between the demodulated value called a soft decision and the nearest element of the alphabet the hard decision can provide valuable information about the performance of the system To be concrete label the signals at various points as shown in Figure 213 The binary input message b The coded signal w is a discretetime sequence drawn from a finite alphabet The signal m at the output of the filter and equalizer is continuousvalued at discrete times is a version of that is quantized to the nearest member of the alphabet The decoded signal is the final 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 differs 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 measures the difference between the message and the soft decision The average squared error 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 difference between the message and the quantized output of the receiver can be used to measure the harddecision error The decisiondirected error replaces this with the error between the soft decisions and the associated hard decisions This error is used in Section 134 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 105 and as a way of adjusting the symbol timing in Section 123 There are other useful indicators of the performance of digital communication receivers Let be the bit duration when there are two bits per symbol 2 The indicator counts how many bits have been incorrectly received and the bit error rate is Similarly the symbol error rate sums the indicators counting the number of alphabet symbols that were transmitted incorrectly More subjective or contextdependent measures are also possible such as the 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 efficient transmission of the message 214 Coding and Decoding What is information How much can move across a particular channel in a given amount of time Claude Shannon proposed a method of measuring information in terms of bits and a measure of the capacity of the channel in terms of the bit ratethe number of bits transmitted per second This is defined quantitatively by the channel capacity which is dependent on the bandwidth of the channel and on the power of the noise in comparison with the power of the signal For most receivers however the reality is far from the capacity and this is caused by two factors First the data to be transmitted are often redundant and the redundancy squanders the capacity of the channel Second the noise can be unevenly distributed among the symbols When large noises disrupt the signal then excessive errors occur The problem of redundancy is addressed in Chapter 14 by source coding which strives to represent the data in the most concise manner possible After demon strating the redundancy and correlation of English text Chapter 14 introduces the Huffman code which is a variablelength code that assigns short bit strings to frequent symbols and longer bit strings to infrequent symbols Like Morse code this will encode the letter e with a short code word and the letter z with a long code word When correctly applied the Huffman procedure can be applied to any symbol set not just the letters of the alphabet and is nearly optimal that is it approaches the limits set by Shannon The problem of reducing the sensitivity to noise is addressed in Chapter 14 using the idea of linear block codes which cluster a number of symbols together and then add extra bits A simple example is the binary parity check which adds an extra bit to each character If there is an even number of ones then a 1 is added and if there is an odd number of ones a 0 is added The receiver can always detect that a single error has occurred by counting the number of ones received If the sum is even then an error has occurred while if the sum is odd then no single error can have occurred More sophisticated versions can not only detect errors but also correct them Like good equalization and proper synchronization coding is an essential part of the operation of digital receivers 38 Chapter 2 A Telecommunication System 215 A Telecommunication System The complete system diagram including the digital receiver that will be built in this text is shown in Figure 213 This system includes the following r A source coding that reduces the redundancy of the message r An error coding that allows detection andor correction of errors that may occur during the transmission r A message sequence of T spaced symbols drawn from a finite alphabet r Pulse shaping of the message designed in part to conserve bandwidth r Analog upconversion to the carrier frequency within a specified tolerance r Channel distortion of transmitted signal r Summation with other FDM users channel noise and other interferers r Analog downconversion to intermediate frequency including bandpass pre filtering around the desired segment of the FDM passband r AD impulse sampling preceded by antialiasing filter at a rate of 1Ts with arbitrary start time The sampling rate is assumed to be at least as fast as the symbol rate 1T r Downconversion to baseband requiring carrierphase and frequency synchro nization r Lowpass or pulseshapematched filtering for the suppression of outofband users and channel noise r Downsampling with timing adjustment to T spaced symbol estimates r Equalization filtering to combat intersymbol interference and narrowband interferers r A decision device quantizing softdecision outputs of the equalizer to the near est member of the source alphabet ie the hard decision r Source and error decoders Of course permutations and variations of this system are possible but we believe that Figure 213 captures the essence of many modern transmission sys tems 216 Stairway to Radio The path taken by Software Receiver Design is to break down the telecommu nication system into its constituent elements the modulators and demodulators the samplers and filters the coders and decoders In the various tasks within each chapter you are asked to build a simulation of the relevant piece of the sys tem 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 reflection and activity will be useful in enlarging your understanding and in training your intuition For Further Reading There are many books about various aspects of communication systems Here are some of our favorites Three basic texts that utilize probability from the outset and that also pay substantial attention to pragmatic design issues such as synchronization are the following r J B Anderson Digital Transmission Engineering IEEE Press 1999 r J G Proakis and M Salehi Digital Communications 5th edition McGraw Hill 2007 This text also has a Matlabbased companion J G Proakis M Salehi and G Bauch Contemporary Communication Systems Using Matlab 2nd edition Cengage Learning 2004 r S Haykin Communication Systems 4th edition John Wiley and Sons 2001 Three introductory texts that delay the introduction of probability until the latter chapters are the following r L W Couch III Digital and Analog Communication Systems 6th edition PrenticeHall 2001 r B P Lathi Modern Digital and Analog Communication Systems 3rd edition Oxford University Press 1998 r F G Stremler Introduction to Communication Systems 3rd edition Addison Wesley 1990 These final three references are probably the most compatible with Software Receiver Design in terms of the assumed mathematical background 3 The Six Elements At first glance block diagrams such as the communication system shown in Fig ure 213 probably appear complex and intimidating There are so many different 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 timeinvariant filters which augment or diminish the amplitude of par ticular frequencies or frequency ranges in a signal r samplers which change analog continuoustime signals into discretetime signals r static nonlinearities such as squarers and quantizers which can add frequency content to a signal r linear timevarying systems such as mixers that shift frequencies around in useful and understandable ways and 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 modified 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 213 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 The Six Elements 41 Time Amplitude Time Amplitude Frequency The magnitude spectrum shows the frequency context of the input signal Magnitude Frequency The magnitude spectrum shows the frequency content of the output signal Magnitude Input signal as a function of time Output signal as a function of time Input signal as a function of frequency Output signal as a function of frequency xt X f yt Y f Element Figure 31 The element transforms the input signal x into the output signal y The action of an element can be thought of in terms of its effect on the signals in time or via the Fourier transform in terms of its effect on the spectra of the signals by how the frequency content of the input relates to the frequency content of the output Figure 31 illustrates these two complementary ways of viewing the elements Understanding both the timedomain and frequencydomain 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 elec trical engineering degrees will recognize that the timedomain representation of a signal and its frequencydomain representation are related by the Fourier transform which is briefly reviewed in the next section 31 Finding the Spectrum of a Signal A signal st can often be expressed in analytical form as a function of time t and the Fourier transform is defined as in 21 as the integral of ste2πjft The resulting transform Sf is a function of frequency Sf is called the spectrum of the signal st and describes the frequencies present in the signal For example if the time signal is created as a sum of three sine waves the spectrum will have spikes corresponding to each of the constituent sines If the time signal contains only frequencies between 100 and 200 Hz the spectrum will be zero for all frequencies outside of this range A brief guide to Fourier transforms appears in Appendix D and a summary of all the transforms and properties that are used throughout Software Receiver Design appears in Appendix A Often however there is no analytical expression for a signal that is there is no known equation that represents the value of the signal over time Instead 42 Chapter 3 The Six Elements the signal is defined 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 filter or a sound waveform encoded as an MP3 file In all these cases it is not possible to find 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 com putable fast Fourier transform or FFT can be used to find the spectrum or fre quency content of a measured signal The Matlab function plotspecm which plots the spectrum of a signal is available on the website Its help file1 notes pl ots pec x Ts pl ots the spectrum of x Tstime in s ecs between adjacent samples The function plotspecm is easy to use For instance the spectrum of a square wave can be found using the following sequence Listing 31 specsquarem plot the spectrum of a square wave f 10 frequency of square wave time 2 length of time Ts11000 time i n t e r v a l between samples tTs Ts time cr eate a time vector xsign cos 2 pi f t square wave sign of cos wave pl ots pec x Ts c a l l pl ots pec to draw spectrum The output of specsquarem is shown2 in Figure 32 The top plot shows time2 seconds of a square wave with f10 cycles per second The bottom plot shows a series of spikes that define the frequency content In this case the largest spike occurs at 10 Hz followed by smaller spikes at all the oddinteger multiples ie at 30 50 70 etc Similarly the spectrum of a noise signal can be calculated as Listing 32 specnoisem plot the spectrum of a noise signal time 1 length of time Ts110000 time i n t e r v a l between samples xrandn 1 time Ts Ts points of noi s e f o r time seconds pl ots pec x Ts c a l l pl ots pec to draw spectrum A typical run of specnoisem is shown in Figure 33 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 specnoisem produces plots that are qualitatively similar though the details will differ 1 You can view the help file 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 appli cation If you dont know what the proper command to do a job is then use lookfor For instance to find the command that inverts a matrix type lookfor inverse You will find the desired command inv 2 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 The Six Elements 43 1 05 0 Amplitude 05 400 300 200 100 0 Frequency 100 200 300 400 1 02 04 06 08 1 Seconds 12 14 16 18 2 0 1200 800 400 0 Magnitude Figure 32 A square wave and its spectrum as calculated by using plotspecm Exercise 31 Use specsquarem to investigate the relationship between the time behavior of the square wave and its spectrum The Matlab command zoom on is often helpful for viewing details of the plots a Try square waves with different frequencies f20 40 100 300 Hz How do the time plots change How do the spectra change b Try square waves of different lengths time1 10 100 seconds How does the spectrum change in each case c Try different sampling times Ts1100 110000 seconds How does the spectrum change in each case Exercise 32 In your signals and systems course you probably calculated ana lytically the spectrum of a square wave by using the Fourier series How does this calculation compare with the discrete data version found by specsquarem Exercise 33 Mimic the code in specsquarem to find the spectrum of a an exponential pulse st et for 0 t 10 b a scaled exponential pulse st 5et for 0 t 10 c a Gaussian pulse st et2 for 2 t 2 d a Gaussian pulse st et2 for 20 t 20 e the sinusoids st sin2πft φ for f 20 100 1000 with φ 0 π4 π2 and 0 t 10 Exercise 34 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 specnoisem b Use rand and the sign function to create a signal that is 1 with probability 12 and 1 with probability 12 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 Chapter 3 The Six Elements 4 2 0 4 2 Amplitude 0 02 04 06 08 1 Seconds 300 200 100 0 Magnitude 4000 2000 0 2000 4000 Frequency Figure 33 A noise signal and its spectrum as calculated using plotspecm Exercise 35 Modify the code in plotspecm 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 differ b Plot the phase spectrum of the random signal created in Exercise 34a While plotspecm can be quite useful ultimately it will be necessary to have more flexibility which in turn requires one to understand how the FFT function inside plotspecm works This will be discussed at length in Chapter 7 The next six sections describe the six elements that are at the heart of communica tions systems The elements are described both in the time domain and in the frequency domain 32 The First Element Oscillators The Latin word oscillare means to ride in a swing It is the origin of oscillate which means to move back and forth in steady unvarying rhythm Thus a device that creates a signal that moves back and forth in a steady unvarying rhythm is called an oscillator An electronic oscillator is a device that produces a repetitive electronic signal usually a sinusoidal wave A basic oscillator is diagrammed in Figure 34 Oscillators are typically designed to operate at a specified frequency f0 and the input specifies the phase φt of the output st cos2πf0t φt The input may be a fixed number but it may also be a signal that is it may change over time In this case the output is no longer a pure sinusoid of frequency f0 For instance suppose the phase is a ramp or line with slope 2πc that is φt 2πct Then st cos2πf0t 2πct cos2πf0 ct and the actual frequency of oscillation is f0 c The Six Elements 45 cos2πf0tφt φt Figure 34 An oscillator creates a sinusoidal oscillation with a specified frequency f0 and input φt 05 0 05 1 1 0 02 04 06 08 1 12 14 16 18 2 Seconds Amplitude 80 40 0 120 50 40 30 20 10 0 10 20 30 40 50 Frequency Magnitude Figure 35 A sinusoidal oscillator creates a signal that can be viewed in the time domain as in the top plot or in the frequency domain as in the bottom plot There are many ways to build oscillators from analog components Generally there is an amplifier and a feedback circuit that returns a portion of the amplified 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 ampli fier or feedback is needed For example a digital sine wave of frequency f Hz and a phase of φ radians can be represented mathematically as skTs cos2πfkTs φ 31 where Ts is the time between samples and where k is an integer counter k 1 2 3 Equation 31 can be directly implemented in Matlab Listing 33 speccosm plot the spectrum of a cosine wave f 10 phi 0 s p e c i f y frequency and phase time 2 length of time Ts1100 time i n t e r v a l between samples tTs Ts time cr eate a time vector xcos2 pi f tphi cr eate cos wave pl ots pec x Ts draw waveform and spectrum The output of speccosm is shown in Figure 35 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 A18 The two spikes of Figure 35 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 A2 The spikes of Figure 35 represent the magnitudes of these two complexvalued exponentials 46 Chapter 3 The Six Elements Exercise 36 Mimic the code in speccosm to find the spectrum of a cosine wave a for different frequencies f1 2 20 30 Hz b for different phases φ 0 01 π8 π2 radians c for different sampling rates Ts110 11000 1100000 Exercise 37 Let x1t be a cosine wave of frequency f 10 x2t be a cosine wave of frequency f 18 and x3t be a cosine wave of frequency f 33 Let xt x1t 05 x2t 2 x3t Find the spectrum of xt What property of the Fourier transform does this illustrate Exercise 38 Find the spectrum of a cosine wave in the following cases a φ is a function of time Try φt 10πt b φ is a function of time Try φt πt2 c f is a function of time Try ft sin2πt d f is a function of time Try ft t2 33 The Second Element Linear Filters Linear timeinvariant filters shape the spectrum of a signal If the signal has too much energy in the low frequencies a highpass filter can remove them If the signal has too much highfrequency noise a lowpass filter can reject it If a signal of interest resides only between f and f then a bandpass filter tuned to pass frequencies between f and f can remove outofband interference and noise More generally suppose that a signal has frequency bands in which the magnitude of the spectrum is lower than desired and other bands in which the magnitude is greater than desired Then a linear filter can compensate by increas ing or decreasing the magnitude This section provides an overview of how to implement simple filters in Matlab More thorough treatments of the theory design use and implementation of filters are given in Chapter 7 While the calculations of a linear filter are usually carried out in the time domain filters are often specified in the frequency domain Indeed the words used to specify filters such as lowpass highpass and bandpass describe how the filter acts on the frequency content of its input Figure 36 for instance shows a noisy input entering three different filters The frequency response of the LPF shows that it allows low frequencies those below the cutoff frequency f to pass while removing all frequencies above the cutoff Similarly the HPF passes all the high frequencies and rejects those below its cutoff f The frequency response of the BPF is specified by two frequencies It will remove all frequencies below f and all frequencies above f leaving only the region between The Six Elements 47 Mag Freq White input f f f f f f f f f LPF Y1 f y1t xt Y2 f Y3 f y2t y3t BPF HPF ff f f f f f X f Figure 36 A white signal containing all frequencies is passed through a lowpass filter LPF leaving only the low frequencies a bandpass filter BPF leaving only the middle frequencies and a highpass filter HPF leaving only the high frequencies Figure 36 shows the action of ideal filters How close are actual implementa tions The Matlab code in filternoisem shows that it is possible to create digital filters that reliably and accurately carry out these tasks Listing 34 filternoisem filter a noisy signal three ways time 3 length of time Ts110000 time i n t e r v a l between samples xrandn 1 time Ts generate noi s e s i g n a l figure 1 pl ots pec x Ts draw spectrum of input f r e q s 0 02 021 1 amps1 1 0 0 bfirpm 100 freqs amps s p e c i f y the LP f i l t e r ylpf i l t e r b 1 x do the f i l t e r i n g figure 2 pl ots pec ylp Ts pl ot the output spectrum f r e q s 0 024 026 05 051 1 amps0 0 1 1 0 0 bfirpm 100 freqs amps BP f i l t e r ybpf i l t e r b 1 x do the f i l t e r i n g figure 3 pl ots pec ybp Ts pl ot the output spectrum f r e q s 0 074 076 1 amps0 0 1 1 bfirpm 100 freqs amps s p e c i f y the HP f i l t e r yhpf i l t e r b 1 x do the f i l t e r i n g figure 4 pl ots pec yhp Ts pl ot the output spectrum The output of filternoisem is shown in Figure 37 Observe that the spec tra at the output of the filters are close approximations to the ideals shown in Figure 36 There are some differences however While the idealized spectra are completely flat in the passband the actual ones are rippled While the idealized spectra completely reject the outofband frequencies the actual ones have small but nonzero energy at all frequencies Two new Matlab commands are used in filternoisem The firpm command specifies the contour of the filter as a line graph Octave and early versions of Matlab call this command remez For instance typing plot 0 024 026 05 051 1 0 0 1 1 0 0 48 Chapter 3 The Six Elements Magnitude spectrum at input Magnitude spectrum at output of lowpass filter Magnitude spectrum at output of bandpass filter 4000 2000 0 2000 4000 Magnitude spectrum at output of highpass filter Figure 37 The spectrum of a white signal containing all frequencies is shown in the top figure This is passed through three filters a lowpass a bandpass and a highpass The spectra at the outputs of these three filters are shown in the second third and bottom plots The actual filters behave much like their idealized counterparts in Figure 36 at the Matlab prompt draws a box that represents the action of the BPF designed in filternoisem over the positive frequencies The frequencies are specified as percentages of fNY Q 12Ts which in this case is equal to 5000 Hz fNY Q is discussed further in the next section Thus the BPF in filternoisem passes frequencies between 0265000 Hz and 055000 Hz and rejects all others The filter command uses the output of firpm to carry out the filtering operation on the vector specified in its third argument More details about these commands are given in the section on practical filtering in Chapter 7 Exercise 39 Mimic the code in filternoisem to create a filter 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 310 Change the sampling rate to Ts120000 Redesign the three filters from Exercise 39 Exercise 311 Let x1t be a cosine wave of frequency f 800 x2t be a cosine wave of frequency f 2000 and x3t be a cosine wave of frequency f 4500 Let xt x1t 05 x2t 2 x3t Use xt as input to each of the three filters in filternoisem Plot the spectra and explain what you see Exercise 312 TRUE or FALSE A linear timeinvariant system exists that has input a cosbt and output c sindt with a c and b d Explain Exercise 313 TRUE or FALSE Filtering a passband signal with absolute bandwidth B through certain fixed linear filters can result in an absolute band width of the filter output greater than B Explain The Six Elements 49 Exercise 314 TRUE or FALSE A linear timeinvariant finiteimpulse response filter with a frequency response having unit magnitude over all fre quencies and a straightline sloped phase curve has as its transfer function a pure delay Explain Exercise 315 TRUE or FALSE Processing a bandlimited signal through a linear timeinvariant filter can increase its halfpower bandwidth Explain 34 The Third Element Samplers Since part of any digital transmission system is analog transmissions through the air across a cable or along a wire are inherently analog and part of the system is digital there must be a way to translate the continuoustime signal into a discretetime signal and vice versa The process of sampling an analog sig nal sometimes called analogtodigital conversion is easy to visualize in the time domain Figure 38 shows how sampling can be viewed as the process of evalu ating a continuoustime signal at a sequence of uniformly spaced time intervals thus transforming the analog signal xt into the discretetime signal xkTs One of the key ideas in signals and systems is the Fourier series a signal is periodic in time it repeats every P seconds if and only if the spectrum can be written as a sum of complex sinusoids with frequencies at integer multiples of a fundamental frequency f Moreover this fundamental frequency can be written in terms of the period as f 1P Thus if a signal repeats 100 times every second P 001 s then its spectrum consists of a sum of sinusoids with frequencies 100 200 300 Hz Conversely if a spectrum is built from a sum of sinusoids with frequencies 100 200 300 Hz then it must represent a periodic signal in time that has period P 001 s Said another way the nonzero portions of the spectrum are uniformly spaced f 100 Hz apart This uniform spacing can be interpreted as a sampling in frequency of an underlying continuousvalued spectrum This is xt xkTs xk Ts a b xt Ts 2Ts 3Ts 4Ts t xTs x1 x2Ts x2 x4Ts x4 x3Ts x3 Figure 38 The sampling process is shown in b as an evaluation of the signal xt at times 2Ts Ts 0 Ts 2Ts This procedure is schematized in a as an element that has the continuoustime signal xt as input and the discretetime signal xkTs as output 50 Chapter 3 The Six Elements P f fs Ts Periodic in time Uniform sampling in frequency f 1 P fs 1 Ts 3fs 2 3fs 2 fs 2 0 fs 2 f 2f 3f 4f 5f Fourier Transform Inverse Fourier Transform Uniform sampling in time Periodic in frequency Figure 39 Fouriers result says that any signal that is periodic in time has a spectrum that consists of a collection of spikes uniformly spaced in frequency Analogously any signal whose spectrum is periodic in frequency can be represented in time as a collection of spikes uniformly spaced in time and vice versa illustrated in the top portion of Figure 39 which shows the timedomain repre sentation on the left and the corresponding frequencydomain 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 1Ts 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 fs2 to fs2 rather than from 0 to fs This makes sense because the spectra of individual realvalued sinusoidal components contain two spikes symmetrically located around 0 Hz as we saw in Section 32 Accordingly the highest frequency that can be represented unam biguously is fs2 and this frequency is often called the Nyquist frequency fNY 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 The Six Elements 51 yi xk m Figure 310 The discrete signal xk is downsampled by a factor of m by removing all but one of every m samples The resulting signal is yi which takes on values yi xk whenever k im n in the bottom right diagram of Figure 39 where the spectrum between 3fs2 and fs2 is the same as the spectrum between fs2 and 3fs2 In fact we have been observing this convention throughout Sections 32 and 33 since all of the figures of spectra Figures 32 33 35 and 37 show just one period of the complete spectrum Perhaps you noticed that plotspecm changes the frequency axis when the sampling interval Ts is changed If not go back and redo Exercise 31c By the second convention plotspecm shows exactly one period of the complete spectrum By the first convention the plots are labeled from fNY Q to fNY 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 inves tigated by simulation in the problems below Aliasing and other samplingrelated 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 yi xim n where n is an integer between 0 and m 1 For example with m 3 and n 1 yi is the sequence that consists of every third value of xk y0 x1 y1 x4 y2 x7 y3 x10 etc This is commonly drawn in block form as in Figure 310 If the spectrum of xk is bandlimited to 1m of the Nyquist rate then downsampling by m loses no information Otherwise aliasing occurs Like analogtodigital sampling down sampling is a timevarying operation Exercise 316 Mimicking the code in speccosm with the sampling interval Ts1100 find the spectrum of a cosine wave cos2πft when f30 40 49 50 51 60 Hz Which of these show aliasing Exercise 317 Create a cosine wave with frequency 50 Hz Plot the spec trum when this wave is sampled at Ts150 190 1100 1110 and 1200 Which of these show aliasing Exercise 318 Mimic the code in speccosm with sampling interval Ts1100 to find the spectrum of a square wave with fundamental f10 20 30 33 52 Chapter 3 The Six Elements 43 Hz Can you predict where the spikes will occur in each case Which of the square waves show aliasing 35 The Fourth Element Static Nonlinearities Linear systems3 such as filters cannot add new frequencies to a signal though they can remove unwanted frequencies Nonlinearities such as squaring and quan tizing can and will add new frequencies These can be useful in the communica tion system in a variety of ways Perhaps the simplest memoryless nonlinearity is the square which takes the input at each time instant and multiplies it by itself Suppose the input is a sinusoid at frequency f that is xt cos2πft Then the output is the sinusoid squared which can be rewritten using the cosinecosine product A4 as yt x2t cos22πft 1 2 1 2 cos2π2ft The spectrum of yt has a spike at 0 Hz due to the constant and a spike at 2f Hz from the doublefrequency term Unfortunately the action of a squaring element is not always as simple as this example might suggest The following exercises encourage you to explore the kinds of changes that occur in the spectra when using a variety of simple nonlinear elements Exercise 319 Mimic the code in speccosm with Ts11000 to find the spectrum of the output yt of a squaring block when the input is a xt cos2πft for f 100 Hz b xt cos2πf1t cos2πf2t for f1 100 and f2 150 Hz c a filtered noise sequence with nonzero spectrum between f1 100 and f2 300 Hz Hint generate the input by modifying filternoisem d Can you explain the large DC zerofrequency component Exercise 320 TRUE or FALSE The bandwidth of x4t cannot be greater than that of xt Explain Exercise 321 Try different values of f1 and f2 in Exercise 319 Can you predict what frequencies will occur in the output When is aliasing an issue Exercise 322 Repeat Exercise 321 when the input is a sum of three sinusoids 3 To be accurate these systems must be exponentially stable and timeinvariant Exercise 323 Suppose that the output of a nonlinear block is the rectification absolute value of the input Find the spectrum of the output when the input is a for 100 Hz b for 100 and 125 Hz c Repeat b for 110 and 200 Hz Can you predict what frequencies will be present for any and d What frequencies will be present if is the sum of three sinusoids and Exercise 324 Suppose that the output of a nonlinear block is where 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 for 100 Hz b for 100 and 150 Hz Exercise 325 Quantization of an input is another kind of common nonlinearity The MATLAB function quantalphm available on the website quantizes a signal to the nearest element of a desired set Its help file reads yquantalphxalphabet quantize the input signal x to the alphabet using nearest neighbor method input x vector to be quantized alphabet vector of discrete values that y can assume sorted in ascending order output y quantized vector Let be a random vector xrandn1n of length n Quantize to the nearest a What percentage of the outputs are 1s 3s b Plot the magnitude spectrum of and the magnitude spectrum of the output c Now let x3randn1n and answer the same questions 36 The Fifth Element Mixers One feature of most telecommunications systems is the ability to change the frequency of the signal without changing its information content For example 54 Chapter 3 The Six Elements speech occurs in the range below about 8 kHz In order to transmit this it is upconverted as in Section 23 to radio frequencies at which the energy can easily propagate over long distances At the receiver it is downconverted as in Section 26 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 311 The following Matlab code implements a simple modulation Listing 35 modulatem change the frequency of the input time 5 Ts110000 time and sampling i n t e r v a l tTs Ts time def i ne a time vector f c 1000 cmodcos 2 pi f c t cr eate cos of f r eq f c f i 100 xcos 2 pi f i t input i s cos of f r eq f i ycmod x multiply input by cmod figure 1 pl ots pec cmod Ts f i nd s pectr a and pl ot figure 2 pl ots pec x Ts figure 3 pl ots pec y Ts The first three lines of the code create the modulating sinusoid ie an oscillator The next line specifies the input in this case another cosine wave The Matlab syntax calculates a pointbypoint multiplication of the two vectors cmod and x The output of modulatem is shown in Figure 312 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 326 Mimic the code in modulatem to find the spectrum of the output yt of a modulator block with modulation frequency fc 1000 Hz when a the input is xt cos2πf1t cos2πf2t for f1 100 and f2 150 Hz b the input is a square wave with fundamental f 150 Hz c the input is a noise signal with all energy below 300 Hz d the input is a noise signal bandlimited to between 2000 and 2300 Hz e the input is a noise signal with all energy below 1500 Hz cos2πf0tφ xtcos2πf0tφ xt φ X Figure 311 The mixing operation shifts all frequencies of a signal xt by an amount defined by the frequency f0 of the modulating sinusoidal wave The Six Elements 55 Magnitude spectrum at input Magnitude spectrum of the oscillator 3000 2000 1000 0 1000 2000 3000 Magnitude spectrum at output Figure 312 The spectrum of the input sinusoid is shown in the top figure The middle figure shows the spectrum of the modulating wave The bottom shows the spectrum of the pointbypoint multiplication in time of the two which is the same as their convolution in frequency 37 The Sixth Element Adaptation Adaptation is a primitive form of learning Adaptive elements in telecommuni cation systems find approximate values for unknown parameters in an attempt to compensate for changing conditions or to improve performance A common strategy in parameterestimation problems is to guess a value assess how good the guess is and refine the guess over time With luck the guesses converge to a useful estimate of the unknown value Figure 313 shows an adaptive element containing two parts The adaptive subsystem parameterized by a changes the input into the output The quality assessment mechanism monitors the output and other relevant signals and tries to determine whether a should be increased or decreased The arrow through the system indicates that the a value is then adjusted accordingly Adaptive elements occur in a number of places in the communication system including the following r In an automatic gain control the adaptive subsystem is multiplication by a constant a The qualityassessment mechanism gauges whether the power at the output of the AGC is too large or too small and adjusts a accordingly a Input Output Quality Assessment Figure 313 The adaptive element is a subsystem that transforms the input into the output parameterized by a and a qualityassessment mechanism that evaluates how to alter a in this case whether to increase or decrease a 56 Chapter 3 The Six Elements r In a phaselocked loop the adaptive subsystem contains a sinusoid with an unknown phase shift a The qualityassessment mechanism adjusts a to maximize a filtered version of the product of the sinusoid and its input r In a timing recovery setting the adaptive subsystem is a fractional delay given by a One mechanism for assessing quality monitors the power of the output and adjusts a to maximize this power r In an equalizer the adaptive subsystem is a linear filter parameterized by a set of as The qualityassessment mechanism monitors the deviation of the output of the system from a target set and adapts the as accordingly Chapter 6 provides an introduction to adaptive elements in communication systems and a detailed discussion of their implementation is postponed until then 38 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 filters 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 howto aspects by providing a series of Matlab exercises which will be useful when creating simulations of the various parts of a receiver For Further Reading The intellectual background of the material presented here is often called signals and systems One of the most accessible books is r J H McClellan R W Schafer and M A Yoder Signal Processing First Pearson PrenticeHall 2003 Other books provide greater depth and detail about the theory and uses of Fourier transforms We recommend these as both background and supplementary reading r A V Oppenheim A S Willsky and S H Nawab Signals and Systems 2nd edition PrenticeHall 1997 r S Haykin and B Van Veen Signals and Systems Wiley 2002 4 Assuming a sixfingered hand The Six Elements 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 filter design Some of the best are the following r A V Oppenheim R W Schafer and J R Buck DiscreteTime Signal Pro cessing PrenticeHall 1999 r B Porat A Course in Digital Signal Processing Wiley 1997 r S Mitra Digital Signal Processing A ComputerBased Approach McGraw Hill 2005 Finally since Matlab is fundamental to our presentation it is worth mentioning some books that describe the uses and abuses of the Matlab language r A Gilat MATLAB An Introduction with Applications Wiley 2007 r B Littlefield and D Hanselman Mastering Matlab 7 PrenticeHall 2004 Step 3 The Idealized System 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 reflections diffractions or diffusions 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 channel frequency translation sampling Chapter 4 Chapter 5 Chapter 6 receive filtering equalization decision device decoding Chapter 7 Chapter 8 Chapter 9 provides a complete though idealized softwaredefined digital radio system 4 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 41 More important than locating the sources of the problems is fixing them The received signal can be processed using linear filters to help reduce the interferences and to undo to some extent the effects of the degradations The central question is how to specify filters that can successfully mitigate these problems and answering this requires a fairly detailed understanding of filtering Thus a discussion of linear filters occupies the bulk of this chapter which also provides a background for other uses of filters throughout the receiver such as the lowpass filters used in the demodulators of Chapter 5 the pulseshaping and matched filters of Chapter 11 and the equalizing filters of Chapter 13 41 When Bad Things Happen to Good Signals The path from the transmitter to the receiver is not simple as Figure 41 sug gests Before the signal reaches the receiver it may be subject to a series of strange events that can corrupt the signal and degrade the functioning of the receiver This section discusses five kinds of corruption that are used throughout the chapter to motivate and explain the various purposes that linear filters may serve in the receiver 60 Chapter 4 Modeling Corruption Multipath Changing gain Transmitted signal Signals from other users Broadband noise Narrowband noise Received signal Types of corruption Figure 41 Sources of corruption include multipath interference changing channel gains interference from other users broadband noise and narrowband interferences 411 Other Users Many different 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 different frequency bands to each user This was called frequencydivision multiplexing FDM in Chapter 2 and was shown diagrammatically in Figure 23 on page 22 The signals from the different users can be separated using a bandpass filter as in Figure 24 on page 23 Of course practical filters do not completely remove outofband signals nor do they pass inband signals completely without distortions Recall the three filters in Figure 37 on page 48 412 Broadband Noise When the signal arrives at the receiver it is small and must be amplified While it is possible to build highgain amplifiers the noises and interferences will also be amplified along with the signal In particular any noise in the amplifier 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 filter is applied at the front end of the receiver By applying a suitable filter the total power in the noise compared with the total power in the signal can often be reduced Figure 42 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 flat region and its power is the shaded area After applying the bandpass filter the power in the signal remains more or less unchanged while the power in the noise is greatly reduced Thus the signaltonoise ratio SNR improves Modeling Corruption 61 Power in signal Power in noise Power in signal is unchanged fc B fc B fc B fc B fc B fc B fc B fc B a b c Total power in noise is decreased fc B fc B fc B fc B 0 Figure 42 The signaltonoise ratio is depicted graphically as the ratio of the power of the signal the area under the triangles to the power in the noise the shaded area After the bandpass filter the power in the noise decreases so the SNR increases 413 Narrowband Noise Noises are not always white that is the spectrum need not always be flat Stray sine waves and other signals with narrow spectra may also impinge on the receiver These may be caused by errant transmitters that accidentally broad cast in the frequency range of the signal or they may be harmonics of a lower frequency wave as it experiences nonlinear distortion If these narrowband distur bances occur out of band they will automatically be attenuated by the bandpass filter 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 filter one designed to remove just the offending frequency can be an effective tool Figure 43 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 filter BPF the two pairs of outofband spikes are removed but the inband pair remains Applying a narrow notch filter tuned to the frequency of the interferer allows its removal although this cannot be done without also affecting the signal somewhat 414 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 trans mitted 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 reflects refracts or diffracts and the signal arriving is quite different from the one that was sent 62 Chapter 4 Modeling Corruption Signal plus three narrowband interferers Removal of outofband interferers Removal of inband interferers also modifier signals Notch filter BPF Figure 43 Three narrowband interferers are shown in the top figure the three pairs of spikes The BPF cannot remove the inband interferer though a narrow notch filter can at the expense of changing the signal in the region where the narrowband noise occurred These distortions can be thought of as a combination of scaled and delayed reflections of the transmitted signal which occur when there are different prop agation paths from the transmitter to the receiver Between two transmission towers for instance the paths may include one along the line of sight reflections from the atmosphere reflections from nearby hills and bounces from a field or lake between the towers For indoor digital TV reception there are many local timevarying reflectors including people in the receiving room nearby vehicles and the buildings of an urban environment Figure 44 for instance shows mul tiple reflections that arrive after bouncing off a cloud and off a mountain and others that are scattered by multiple bounces from nearby buildings The strength of the reflections depends on the physical properties of the reflect ing surface while the delay of the reflections is primarily determined by the length of the transmission path Let st be the transmitted signal If N delays are represented by 1 2 N and the strengths of the reflections are h1 h2 hN then the received signal rt is rt h1st 1 h2st 2 hNst N 41 As will become clear in Section 44 this model of the channel has the form of a linear filter since the expression on the righthand side is a convolution of the transmitted signal and the his This is shown in part a of Figure 45 Since this channel model is a linear filter 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 Transmitter Cloud Receiver Buildings Mountain Line of sight Figure 44 The received signal may be a combination of several copies of the original transmitted signal each with a different attenuation and delay ht Transmitted signal Received signal Fourier Transform H f Frequency a b c d Figure 45 a The channel model 41 as a filter b The frequency response of the filter c An idealized BPF and the spectrum of the signal The product of b and c gives d the distorted spectrum at the receiver If the kinds of distortions introduced by the channel are known or can some how be determined then the bandpass filter at the receiver can be modified in order to undo the effects of the channel This can be seen most clearly in the frequency domain as in Figure 46 Observe that the BPF is shaped part d to approximately invert the debilitating effects of the channel part a in the frequency band of the signal and to remove all the outofband 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 45 where no shaping was attempted 64 Chapter 4 Modeling Corruption Frequency response of channel Spectrum of signal Product of a b Product of c d BPF with shaping a b c d e Figure 46 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 filter that has been shaped to undo the effect 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 filtering in the receiver can be used to reshape the received signal within the frequency band of the transmission as well as to remove unwanted outof band frequencies 415 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 reflection from a cloud might disappear when the cloud dissipates an additional reflection 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 reflections Fading may also occur when the transmitter andor the receiver are moving The Doppler effect shifts the frequencies slightly causing interferences that may slowly change Such timevarying problems cannot be fixed by a single fixed filter rather the filter must somehow compensate differently at different times This is an ideal application for the adaptive elements of Section 37 though results from the study of linear filters will be crucial in understanding how the time variations Modeling Corruption 65 in the frequency response can be represented as timevarying coefficients in the filter that represents the channel 42 Linear Systems Linear Filters Linear systems appear in many places in communication systems The trans mission channel is often modeled as a linear system as in 41 The bandpass filters used in the front end to remove other users and to remove noises are linear Lowpass filters are crucial to the operation of the demodulators of Chap ter 5 The equalizers of Chapter 13 are linear filters that are designed during the operation of the receiver on the basis of certain characteristics of the received signal Timeinvariant linear systems can be described in any one of three equivalent ways r The impulse response ht is a function of time that defines 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 r The frequency response Hf is a function of frequency that defines how the spectrum of the input is changed into the spectrum of the output The fre quency response and the impulse response are intimately related Hf is the Fourier transform of ht r A linear difference equation with constant coefficients such as 41 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 define 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 final step is to show how the action of the linear system can be redescribed in the time domain as a difference or as a differential equation This is postponed to Chapter 7 and is also discussed in some detail in Appendix F 43 The Delta Function One way to see how a system behaves is to kick it and see how it responds Some systems react sluggishly barely moving away from their resting state while others respond quickly and vigorously Defining exactly what is meant mathematically by a kick is trickier than it seems because the kick must occur over a very short amount of time yet must be energetic in order to have any effect This section defines 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 δtdt1 42 The criterion that it occur over a very short time span is translated to the statement that for every positive ϵ δt0 tϵ 0 tϵ 43 Thus the impulse δt is explicitly defined to be equal to zero for all t0 On the other hand δt is implicitly defined when t0 by the requirement that its integral be unity Together these guarantee that δt is no ordinary function¹ The most important consequence of the definitions 42 and 43 is the sifting property wtδtt₀dtwttt₀wt₀ 44 which says that the delta function picks out the value of the function wt from under the integral at exactly the time when the argument of the δ function is zero that is when tt₀ To see this observe that δtt₀ is zero whenever tt₀ and hence wtδtt₀ is zero whenever tt₀ Thus wtδtt₀dt wt₀δtt₀dt wt₀ δtt₀dtwt₀1wt₀ Sometimes it is helpful to think of the impulse as a limit For instance define the rectangular pulse of width 1n and height n by δₙt0 t12n n 12n t 12n 0 t12n Then δtlimn δₙt fulfills both criteria 42 and 43 Informally it is not unreasonable to think of δt as being zero everywhere except at t0 where it is infinite While it is not really possible to plot the delta function δtt₀ it can be represented in graphical form as zero everywhere except for an uppointing arrow at t₀ 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 ¹ The impulse is called a distribution and is the subject of considerable mathematical investigation Figure 47 The function wtδt10 2δt1 3δt5 consisting of three weighted δ functions is represented graphically as three weighted arrows at t1015 weighted by the appropriate constants is negative the arrow is drawn pointing down For instance Figure 47 shows a graphical representation of the function wtδt102δt13δt5 What is the spectrum Fourier transform of δt This can be calculated directly from the definition by replacing wt in 21 with δt ℱδt δtej2πftdt 45 Apply the sifting property 44 with wtej2πft and t₀0 Thus ℱδtej2πftt01 Alternatively suppose that δ is a function of frequency that is a spike at zero frequency The corresponding timedomain function can be calculated analogously using the definition of the inverse Fourier transform that is by substituting δf for Wf in A16 and integrating ℱ¹δf δfej2πftdfej2πftf01 Thus a spike at frequency zero is a DC signal a constant in time The discrete time counterpart of δt is the discrete delta function δk1 k0 0 k0 While there are a few subtle differences between δt and δk for the most part δt and δk act analogously For example the program specdeltam calculates the spectrum of the discrete delta function Listing 41 specdeltam plots the spectrum of a delta function time2 length of time Ts1100 time interval between samples tTsTstime create time vector xzerossizet create signal of all zeros x11 delta function plotspecxTs draw waveform and spectrum The output of specdeltam is shown in Figure 48 As expected from 45 the magnitude spectrum of the delta function is equal to 1 at all frequencies Exercise 41 Calculate the Fourier transform of δtt₀ from the definition Now calculate it using the timeshift property A37 Are they the same Hint they had better be A discrete delta function at time 0 has a magnitude spectrum equal to 1 for all frequencies Exercise 42 Use the definition of the IFT A16 to show that δf f0 ej2πf0t Exercise 43 Mimic the code in specdeltam to find the magnitude spectrum of the discrete delta function in the following cases a The delta does not occur at the start of x Try x10 1 x100 1 and x110 1 How do the spectra differ Can you use the timeshift property A37 to explain what you see b The delta changes magnitude x Try x1 10 x10 3 and x110 01 How do the spectra differ Can you use the linearity property A31 to explain what you see Exercise 44 Modify the code in specdeltam to find the phase spectrum of a signal that consists of a delta function when the nonzero term is located at the start x1 1 in the middle x100 1 and at the end x200 1 Exercise 45 Mimic the code in specdeltam to find the spectrum of a train of equally spaced pulses For instance x120end 1 spaces the pulses 20 samples apart and x125end 1 places the pulses 25 samples apart a Can you predict how far apart the resulting pulses in the spectrum will be b Show that from k to δt kTs 1Ts from n to δf nfs where fs 1Ts Hint let wt 1 in A27 and A28 c Now can you predict how far apart the pulses in the spectrum are Your answer should be in terms of how far apart the pulses are in the time signal In Section 32 the spectrum of a sinusoid was shown to consist of two symmetric spikes in the frequency domain recall Figure 35 on page 45 The next example shows why this is true by explicitly taking the Fourier transform to find the spectrum of a sinusoid The magnitude spectrum of a sinusoid with frequency f0 and amplitude A contains two δfunction spikes one at f f0 and the other at f f0 Example 41 Let wt A sin2πf0t and use Eulers identity A3 to rewrite wt as wt A2jej2πf0t ej2πf0t Applying the linearity property A31 and the result of Exercise 42 gives 𝓕wt A2j𝓕ej2πf0t 𝓕ej2πf0t j A2δf f0 δf f0 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 49 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 410a shows the magnitude spectrum Wf of a realvalued signal wt This can be interpreted as saying that wt 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 st in Figure 410b contains all positive frequencies between fc B and fc B and no others Note that the Fourier transform in 47 is purely imaginary as it must be because wt is odd see A37 The phase spectrum is a flat line at 90 because of the factor j Exercise 46 What is the magnitude spectrum of sin2πf0t θ Hint use the frequencyshift property A34 Show that the spectrum of cos2πf0t is 12δf f0 δf f0 Compare this analytical result with the numerical results from Exercise 36 Exercise 47 Let wit ai sin2πfi t for i 1 2 3 Without doing any calculations write down the spectrum of vt w1t w2t w3t Hint use linearity Graph the magnitude spectrum of vt in the same manner as in Figure 49 Verify your results with a simulation mimicking that in Exercise 37 The magnitude spectrum of a message signal wt is shown in a When wt is modulated by a cosine at frequency fc the spectrum of the resulting signal st wt cos2πfc t ϕ is shown in b Exercise 48 Let Wf sin2πf t0 What is the corresponding time function 44 Convolution in Time Its What Linear Systems Do Suppose that a system has impulse response ht and that the input consists of a sum of three impulses occurring at times t0 t1 and t2 with amplitudes a0 a1 and a2 for example the signal wt of Figure 47 Because of the linearity of the Fourier transform property A31 the output is a superposition of the outputs due to each of the input pulses The output due to the first impulse is a0 ht t0 which is the impulse response scaled by the size of the input and shifted to begin when the first input pulse arrives Similarly the outputs to the second and third input impulses are a1 ht t1 and a2 ht t2 respectively and the complete output is the sum a0 ht t0 a1 ht t1 a2 ht t2 Now suppose that the input is a continuous function xt At any time instant λ the input can be thought of as consisting of an impulse scaled by the amplitude xλ and the corresponding output will be xλ ht λ which is the impulse response scaled by the size of the input and shifted to begin at time λ The complete output is then given by integrating over all λ yt from to xλ ht λ dλ xt ht This integral defines the convolution operator and provides a way of finding the output yt of any linear system given its impulse response ht and the input xt Matlab has several functions that simplify the numerical evaluation of convolutions The most obvious of these is conv which is used in convoleXm 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 42 convoleXm example of numerical convolution Ts1100 time10 sampling interval and total time t0Tstime create time vector hexpt define impulse response xzerossizet input sum of two delta functions Figure 411 The convolution of the input the top plot with the impulse response of the system the middle plot gives the output in the bottom plot x1Ts3 x3Ts2 at times t1 and t3 yconvhx do convolution subplot311 plottx and plot subplot312 plotth subplot313 plotty1lengtht Figure 411 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 t1 and the output is zero When the first spike occurs the system responds by jumping to 3 and then decaying slowly at a rate dictated by the shape of ht The decay continues smoothly until time t3 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 first spike Since there are no more inputs the output slowly dies away Exercise 49 Suppose that the impulse response ht of a linear system is the exponential pulse htet t0 0 t0 49 Suppose that the input to the system is 3δt12δt3 Use the definition of convolution 48 to show that the output is 3ht12ht3 where htt0ett0 t t0 0 tt0 How does your answer compare with Figure 411 72 Chapter 4 Modeling Corruption Exercise 410 Suppose that a system has an impulse response that is an expo nential pulse Mimic the code in convolexm to find its output when the input is a white noise recall specnoisem on page 42 Exercise 411 Mimic the code in convolexm to find 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 filters commute with differentiation and with each other Exercise 412 Use the definition to show that convolution is commutative ie that w1t w2t w2t w1t Hint apply the change of variables τ t λ in 48 Exercise 413 Suppose a filter has impulse response ht When the input is xt the output is yt If the input is xdt xtt the output is ydt Show that ydt is the derivative of yt Hint use 48 and the result of Exercise 412 Exercise 414 Let wt Πt be the rectangular pulse of 28 What is wt wt Hint a pulse shaped like a triangle Exercise 415 Redo Exercise 414 numerically by suitably modifying convolexm Let T 15 s Exercise 416 Suppose that a system has an impulse response that is a sinc function as shown in Figure 211 and that the input to the system is a white noise as in specnoisem on page 42 a Mimic convolexm to numerically find the output b Plot the spectrum of the input and the spectrum of the output using plotspecm What kind of filter would you call this 45 Convolution Multiplication While the convolution operator 48 describes mathematically how a linear sys tem acts on a given input timedomain approaches are often not particularly revealing about the general behavior of the system Who would guess for instance in Exercises 411 and 416 that convolution with exponentials and sinc functions would act like lowpass filters By working in the frequency domain however the convolution operator is transformed into a simpler pointbypoint multiplication and the generic behavior of the system becomes clearer The first step is to understand the relationship between convolution in time and multiplication in frequency Suppose that the two time signals w1t and w2t have Fourier transforms W1f and W2f Then Fw1tw2tW1fW2f 410 To justify this property begin with the definition of the Fourier transform 21 and apply the definition of convolution 48 to obtain Fw1tw2tintt w1tw2tej2πftdt intt intλ w1λw2tλdλ ej2πft dt Reversing the order of integration and using the timeshift property A37 produces Fw1tw2tintλ w1λ intt w2tλej2πft dt dλ intλ w1λ W2fej2πfλ dλ W2f intλ w1λ ej2πfλdλ W1fW2f Thus convolution in the time domain is the same as multiplication in the frequency domain See A40 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 A41 that is Fw1tw2tW1fW2fint W1λW2fλdλ 411 The usefulness of these convolution properties is apparent when applying them to linear systems Suppose that Hf is the Fourier transform of the impulse response ht Suppose that Xf is the Fourier transform of the input xt that is applied to the system Then 48 and 410 show that the Fourier transform of the output is exactly equal to the product of the transforms of the input and the impulse response that is YfFytFxthtFhtFxtHfXf This can be rearranged to solve for HfYfXf 412 which is called the frequency response of the system because it shows for each frequency f how the system responds For instance suppose that Hf13 at some frequency f1 Then whenever a sinusoid of frequency f1 is input into the system it will be amplified by a factor of 3 Alternatively suppose that Hf20 at some frequency f2 Then whenever a sinusoid of frequency f2 is input into 74 Chapter 4 Modeling Corruption 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 filters For example the filters of Figures 24 25 and 26 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 filter affects the input and how the frequency content of the output relates to that of the input Sometimes the frequency response Hf is called the transfer function of the system since it transfers the input xt with transform Xf into the output yt 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 72 to design filters for the manipulation augmentation or removal of specified frequencies Example 42 In Exercise 416 a system was defined 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 A22 Hence the frequency response of the system is a rectangle that passes all frequencies below fc 1T and removes all frequencies above ie the system is a lowpass filter Matlab can help to visualize the relationship between the impulse response and the frequency response For instance the system in convolexm is defined via its impulse response which is a decaying exponential Figure 411 shows its output when the input is a simple sum of delta functions and Exercise 410 explores the output when the input is a white noise In freqrespm the behavior of this system is explained by looking at its frequency response Listing 43 freqrespm numerical example of impulse and frequency response Ts1100 time 10 sampling i n t e r v a l and t o t a l time t 0Ts time cr eate time vector hexpt def i ne impulse response pl ots pec h Ts f i nd and pl ot frequency response The output of freqrespm is shown in Figure 412 The frequency response of the system which is just the magnitude spectrum of the impulse response is found using plotspecm In this case the frequency response amplifies low frequencies and attenuates other frequencies more as the frequency increases This explains for instance why the output of the convolution in Exercise 410 contained primarily lower frequencies as evidenced by the slower undulations in time Modeling Corruption 75 0 0 0 2 4 6 8 10 1 Amplitude Seconds 40 30 20 10 0 10 30 20 40 100 Magnitude Frequency Figure 412 The action of a system in time is defined by its impulse response in the top plot The action of the system in frequency is defined by its frequency response in the bottom plot a kind of lowpass filter Exercise 417 Suppose a system has an impulse response that is a sinc func tion Using freqrespm find the frequency response of the system What kind of filter does this represent Hint center the sinc in time for instance use hsinc10ttime2 Exercise 418 Suppose a system has an impulse response that is a sin func tion Using freqrespm find the frequency response of the system What kind of filter does this represent Can you predict the relationship between the fre quency of the sine wave and the location of the peaks in the spectrum Hint try hsin25t Exercise 419 Create a simulation analogous to convolexm that inputs white noise into a system with an impulse response that is a sinc function as in Exercise 417 Calculate the spectra of the input and output using plotspecm Verify that the system behaves as suggested by the frequency response in Exer cise 417 Exercise 420 Create a simulation analogous to convolexm that inputs white noise into a system with an impulse response that is a sin function as in Exercise 418 Calculate the spectra of the input and output using plotspecm Verify that the system behaves as suggested by the frequency response in Exer cise 418 So far Section 45 has emphasized the idea of finding 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 filter with some special characteristic in the frequency domain for instance in order to accomplish one of the goals of bandpass filtering in Section 41 It is easy to specify the filter in the fre quency domain Its impulse response can then be found by taking the inverse Fourier transform and the filter can be implemented using convolution Thus 76 Chapter 4 Modeling Corruption the relationship between impulse response and frequency response can be used both to study and to design systems In general this method of designing filters is not optimal in the sense that other design methods can lead to more efficient designs but it does show clearly what the filter is doing and why Whatever the design procedure the represen tation of the filter in the time domain and its representation in the frequency domain are related by nothing more than a Fourier transform 46 Improving SNR Section 41 described several kinds of corruption that a signal may encounter as it travels from the transmitter to the receiver This section shows how linear filters can help Perhaps the simplest way a linear bandpass filter can be used is to remove broadband noise from a signal Recall Section 412 and especially Figure 42 A common way to quantify noise is the signaltonoise 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 first 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 413 The signal at the input rt in part a is composed of the message signal xt and the noise signal nt and the SNR at the input is therefore SNRinput power in xt power in nt Similarly the output yt is composed of a filtered version of the message yxt in part b and a filtered version of the noise ynt in part b The SNR at the output can therefore be calculated as SNRoutput power in yxt power in ynt Observe that the SNR at the output cannot be calculated directly from yt since the two components are scrambled together But since the filter is linear yt BPFxt nt BPFxt BPFnt yx yn which effectively shows the equivalence of parts a and b of Figure 413 The Matlab program improvesnrm 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 Modeling Corruption 77 xt rt nt BPF yt a b yxt ynt yt nt xt BPF BPF Figure 413 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 xn The BPF is created using the firpm command just like the bandpass filter in filternoisem 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 413 Thus yx and yn represent the signal x filtered 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 powm available on the website Listing 44 improvesnrm using a linear filter to improve SNR time 3 Ts120000 time and sampling i n t e r v a l f r e q s 0 029 03 04 041 1 f i l t e r design bandlimited amps0 0 1 1 0 0 between 3K and 4K bfirpm 100 freqs amps BP f i l t e r n025randn 1 time Ts generate white noi s e s i g n a l xf i l t e r b 1 2randn 1 time Ts do the f i l t e r i n g yf i l t e r b 1 xn a f i l t e r the s i g n a lnoi s e yxf i l t e r b 1 x or b f i l t e r s i g n a l ynf i l t e r b 1 n and noi s e s epar atel y zyxyn add them d i f f z ymax abs zy and make sure y z snrinppow xpown SNR at input snroutpow yx pow yn SNR at output Since the data generated in improvesnrm are random the numbers are slightly different each time the program is run Using the default values the SNR at the input is about 78 while the SNR at the output is about 61 This is certainly a noticeable improvement The variable diffzy shows the largest dif ference between the two ways of calculating the output that is between parts a and b of Figure 413 This is on the order of 1015 which is effectively the numerical resolution of Matlab calculations indicating that the two are effectively the same Figure 414 plots the spectra of the input and the output of a typical run of improvesnrm Observe the large noise floor 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 effect there 78 Chapter 4 Modeling Corruption Magnitude spectrum of signal plus noise Magnitude spectrum after filtering Figure 414 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 The program improvesnrm can be thought of as a simulation of the effect of having a BPF at the receiver for the purposes of improving the SNR when the signal is corrupted by broadband noise as was described in Section 412 The following problems ask you to mimic the code in improvesnrm to simulate the benefit of applying filters to the other problems presented in Section 41 Exercise 421 Suppose that the noise in improvesnrm is replaced with nar rowband noise as discussed in Section 413 Investigate the improvements in SNR a when the narrowband interference occurs outside the 3000 to 4000 Hz pass band b when the narrowband interference occurs inside the 3000 to 4000 Hz passband Exercise 422 Suppose that the noise in improvesnrm is replaced with other users who occupy different frequency bands as discussed in Section 411 Are there improvements in the SNR Exercise 423 Consider the interference between two users x1 and x2 occupying the same frequency band as shown in Figure 415 The phases of the two mixers at the transmitter are unequal with 5π6 φ θ π3 The lowpass filter LPF has a cutoff frequency of fc a passband gain of 15 a stopband gain of zero and zero phase at zero frequency LPF cos2πfctθ cos2πfctα cos2πfctφ x2t x1t yt receiver transmitter Figure 415 The multiuser transmission system of Exercise 423 Modeling Corruption 79 a For this system Y f c1X1f c2X2f Determine c1 and c2 as functions of fc φ θ and α b With α set to maximize c1c22 find c1 and c2 as functions of fc φ and θ c With α set to minimize c1c22 find c1 and c2 as functions of fc φ and θ The other two problems posed in Section 41 were multipath interference and fading These require more sophisticated processing because the design of the filters depends on the operating circumstances of the system These situations will be discussed in detail in Chapters 6 and 13 For Further Reading An early description of the linearity of communication channels can be found in r P A Bello Characterization of Randomly TimeVariant Linear Channels IEEE Transactions on Communication Systems vol 11 no 4 pp 360393 Dec 1963 5 Analog Demodulation 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 wkT in Figure 51 is a discretetime sequence drawn from a finite alphabet The ultimate output mkT produced by the decision device or quantizer is also discretetime 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 pulseshaping filter of the transmitter to the sampler at the receiver At the transmitter in Figure 51 the digital message has already been turned into an analog signal by the pulse shaping which was discussed briefly in Section 210 and is considered in detail in Chapter 11 For efficient 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 twostep procedure is shown in Figure 51 There are many ways in which signals can be modulated Perhaps the sim plest is amplitude modulation AM which is discussed in two forms large and small carrier in the next two sections This is generalized to the simultane ous transmission of two signals using quadrature modulation in Section 53 and it is shown that quadrature modulation uses bandwidth more efficiently than amplitude modulation This gain in efficiency can also be obtained using single sideband and vestigialsideband methods which are discussed in the document Analog Demodulation 81 Analog conversion to IF Carrier synchronization Analog upconversion Interferers Noise Pulse shaping Digital down conversion to baseband f Ts Decision Reconstructed message mkT δ 3 1 1 3 Message wkT 3 1 1 3 θ Figure 51 A complete digital communication system has many parts This chapter focuses on the upconversion and the downconversion which can done in many ways including largecarrier AM as in Section 51 suppressedcarrier AM as in Section 52 and quadrature modulation as in Section 53 titled Other Modulations available on the website Demodulation can also be accomplished using sampling as discussed in Section 62 and amplitude modu lation can also be accomplished with a simple squaring and filtering operation as in Exercise 59 Throughout the chapter contains a series of exercises that prepare readers to create their own modulation and demodulation routines in Matlab These lie at the heart of the software receiver that will be assembled in Chapters 9 and 15 51 Amplitude Modulation with Large Carrier Perhaps the simplest form of analog transmission system modulates the mes sage signal by a highfrequency carrier in a twostep procedure multiply the message by the carrier then add the product to the carrier At the receiver the message can be demodulated by extracting the envelope of the received signal Consider the transmittedmodulated signal vt Acwt cos2πfct Ac cos2πfct Acwt 1 cos2πfct diagrammed in Figure 52 The process of multiplying the signal in time by a cosinusoid is called mixing This can be rewritten in the frequency domain by mimicking the development from 23 to 25 on page 20 Using the convolution property of Fourier transforms 410 the transform of vt is V f FAcwt 1 cos2πfct AcFwt 1 Fcos2πfct 51 The spectra of Fwt 1 and V f are sketched in Figure 53 a and b The vertical arrows in b represent the transform of the cosine carrier at frequency fc ie a pair of delta functions at fc and the scaling by Ac2 is indicated next to the arrowheads If wt 1 the envelope of vt is the same as wt and an envelope detector can be used as a demodulator envelopes are discussed in detail in Appendix C One way to find the envelope of a signal is to lowpass filter the absolute value 82 Chapter 5 Analog Demodulation wt Ac cos2πfct vt vt LPF mt a Transmitter b Receiver envelope detector Figure 52 A communications system using amplitude modulation with a large carrier In the transmitter a the message signal wt is modulated by a carrier wave at frequency fc and then added to the carrier to give the transmitted signal vt In b the received signal is passed through an envelope detector consisting of an absolutevalue nonlinearity followed by a lowpass filter When all goes well the output mt of the receiver is approximately equal to the original message V f f fc b fc Ac2 Ac2 Fwt1 f B a B Ac Fcos2πfct f 2fc 4fc c 2fc 4fc Fvt f 2fc 4fc d 2fc 4fc Figure 53 Spectra of the signals in the largecarrier AM system of Figure 52 Lowpass filtering d gives a scaled version of a To see this analytically observe that Fvt FAcwt 1 cos2πfct AcFwt 1 cos2πfct AcFwt 1 F cos2πfct where the absolute value can be removed from wt 1 because wt 1 0 by assumption The spectrum of Fcos2πfct shown in Figure 53c may be familiar from Exercise 323 Accordingly Fvt is the convolution shown in Figure 53d Lowpass filtering this returns wt 1 which is the envelope of vt offset by the constant unity Analog Demodulation 83 An example is given in the following Matlab program The message signal is a sinusoid with a drift in the DC offset and the carrier wave is at a much higher frequency Listing 51 AMlargem largecarrier AM demodulated with envelope time 033 Ts110000 sampling i n t e r v a l time t 0Ts time l entlength t def i ne a time vector fm20 f c 1000 ccos 2 pi f c t def i ne c a r r i e r at f r eq f c w10 l ent 1 l ent cos 2 pifm t cr eate message 1 vc wc modulate w l ar ge c a r r i e r fbe 0 005 01 1 LPF design damps1 1 0 0 f l 100 bfirpm f l fbe damps impulse response of LPF envvpi 2 f i l t e r b 1 absv f i nd envelope The output of this program is shown in Figure 54 The slowly increasing sinusoidal message wt is modulated by the carrier ct at fc 1000 Hz The heart of the modulation is the pointbypoint multiplication of the message and the carrier in the fifth line This product vt is shown in Figure 54c The enveloping operation is accomplished by applying a lowpass filter to the real part of 2vtej2πfct as discussed in Appendix C This recovers the original message signal though it is offset by 1 and delayed by the linear filter Exercise 51 Using AMlargem plot the spectrum of the message wt the spectrum of the carrier ct and the spectrum of the received signal vt What is the spectrum of the envelope How close are your results to the theoretical predictions in 51 Exercise 52 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 AMlargem a Change the phase of the transmitted signal for instance let ccos2pi fctphase with phase01 05 pi3 pi2 pi and verify that the recovered envelope remains unchanged b Change the frequency of the transmitted signal for instance let ccos2 pifcgt with g10 10 100 100 and verify that the recovered envelope remains unchanged Can g be too large Exercise 53 Create your own message signal wt and rerun AMlargem Repeat Exercise 51 with this new message What differences do you see Exercise 54 In AMlargem verify that the original message w and the recovered envelope envv are offset by 1 except at the end points where the filter does not have enough data Hint the delay induced by the linear filter is approximately fl2 84 Chapter 5 Analog Demodulation Seconds d output of envelope detector 007 006 005 004 003 002 001 0 0 2 4 b carrier 1 0 1 Amplitude c modulated signal 2 0 2 4 a message signal 0 2 4 Amplitude Amplitude Amplitude Figure 54 An undulating message top is modulated by a carrier b The composite signal is shown in c and the output of an envelope detector is shown in d The principal advantage of transmission systems that use AM with a large carrier is that exact synchronization is not needed the phase and frequency of the transmitter need not be known at the receiver as was demonstrated in Exer cise 52 This means that the receiver can be simpler than when synchronization circuitry is required The main disadvantage is that adding the carrier into the signal increases the power needed for transmission but does not increase the amount of useful information transmitted Here is a clear engineering tradeoff the value of the wasted signal strength must be balanced against the cost of the receiver 52 Amplitude Modulation with Suppressed Carrier It is also possible to use AM without adding the carrier Consider the transmit tedmodulated signal vt Acwtcos2πfct diagrammed in Figure 55a in which the message wt is mixed with the cosine carrier Direct application of the frequencyshift property of Fourier transforms A33 shows that the spectrum of the received signal is V f 1 2AcWf fc 1 2AcWf fc As with AM with a large carrier the upconverted signal vt for AM with a suppressed carrier has twice the bandwidth of the original message signal If the Analog Demodulation 85 vt cos2πfc γt φ b a xt LPF mt wt Ac cos2πfct vt Transmitter Receiver Figure 55 A communications system using amplitude modulation with a suppressed carrier In the transmitter a the message signal wt is modulated by a carrier wave at frequency fc to give the transmitted signal vt In b the received signal is demodulated by a wave with frequency fc γ and phase φ and then lowpass filtered When all goes well the output of the receiver mt 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 410 on page 70 As illustrated in 26 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 filtering 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 55b shows this downconverter which can be described by xt vt cos2πfc γt φ 52 and mt LPFxt where LPF represents a lowpass filtering of the demodulated signal xt in an attempt to recover the message Thus the downconversion described in 52 acknowledges that the receivers local oscillator might not have the same fre quency 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 significantly 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 frequencyshift property of Fourier transforms 53 on xt in 52 produces the Fourier transform Xf Ac4ejφWffcfcγWffcfcγ ejφWffcfcγWffcfcγ Ac4ejφWfγejφWf2fcγ ejφ Wf2fcγ ejφWfγ 53 If there is no frequency offset ie if γ0 then Xf Ac4ejφ ejφWfejφWf2fcejφWf2fc Because cosx12ejxejx from A2 this can be rewritten XfAc2Wfcosφ Ac4ejφWf2fcejφWf2fc Thus a perfect lowpass filtering of xt with cutoff below 2fc removes the highfrequency portions of the signal near 2fc to produce mtAc2wtcosφ 54 The factor cosφ attenuates the received signal except for the special case when φ0 2πk for integers k If φ were sufficiently close to 0 2πk 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 11 The worst case occurs as φ approaches π2 when the message is attenuated to zero A scheme for carrierphase 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 carrierphase offset is zero ie φ0 but that the frequency offset γ is not Then the spectrum of xt from 53 is XfAc4WfγWf2fcγWf2fcγWfγ and the lowpass filtering of xt produces MfAc4WfγWfγ This is shown in Figure 56 Recognizing this spectrum as a frequencyshifted version of wt it can be translated back into the time domain using A33 to give mtAc2wtcos2πγt 55 Instead of recovering the message wt the frequency offset causes the receiver to recover a lowfrequency amplitudemodulated version of it This is bad with Analog Demodulation 87 f M f W f γ W f γ 0 Ac 4 Figure 56 When there is a carrierfrequency offset in the receiver oscillator the two images of W do not align properly Their sum is not equal to Ac2W f even a small carrierfrequency offset While cosφ in 54 is a fixed scal ing cos2πγt in 55 is a timevarying scaling that will alternately recover mt when cos2πγt 1 and make recovery impossible when cos2πγt 0 Transmitters are typically expected to maintain suitable accuracy to a nominal carrierfrequency setting known to the receiver Ways of automatically tracking inevitable small frequency deviations are discussed at length in Chapter 10 The following code AMm generates a message wt and modulates it with a carrier at frequency fc The demodulation is done with a cosine of frequency fc γ and a phase offset 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 filter Figure 57 shows four plots the message wt on top followed by the upconverted signal vt wtcos2πfct followed in turn by the downconverted signal xt The lowpassfiltered version is shown in the bottom plot observe that it is nearly identical to the original message albeit with a slight delay Listing 52 AMm suppressed carrier with possible freq and phase offset time 03 Ts110000 sampling i n t e r v a l time tTs Ts time l entlength t def i ne a time vector fm20 f c 1000 ccos 2 pi f c t c a r r i e r at f r eq f c w5 l ent 1 l ent cos 2 pifm t cr eate message vc w modulate with c a r r i e r gam0 phi 0 f r eq phase o f f s e t c2cos 2 pi f cgam tphi cr eate cos i ne f o r demod xv c2 demod r ecei ved s i g n a l fbe 0 01 02 1 damps1 1 0 0 LPF design f l 100 bfirpm f l fbe damps impulse response of LPF m2 f i l t e r b 1 x LPF the demodulated s i g n a l Exercise 55 Using AMm as a starting point plot the spectra of wt vt xt and mt Exercise 56 Try different phase offsets φ π π2 π3 π6 0 π6 π3 π2 π How well does the recovered message mt match the actual message wt For each case what is the spectrum of mt Exercise 57 TRUE or FALSE A small fixed phase offset in the receiver demodulating AM with suppressed carrier produces an undesirable lowfrequency modulated version of the analog message 88 Chapter 5 Analog Demodulation Amplitude a message signal b message after modulation d recovered message is a LPF applied to c 1 0 002 004 006 008 1 3 1 1 3 1 1 3 2 c demodulated signal 2 0 Figure 57 The message signal in the top frame is modulated to produce the signal in the second plot Demodulation gives the signal in the third plot and the LPF recovers the original message with delay in the bottom plot 2 Bandpass filter Centered at fc Addition Squarelaw device A0 cos2πfct wt 2A0wtcos2πfct Figure 58 The squarelaw mixing transmitter of Exercises 59 through 511 Exercise 58 Try different frequency offsets gam 0014 01 10 10 How well does the recovered message mt match the actual message wt For each case what is the spectrum of mt Hint look over more than just the first 01 s to see the effect Exercise 59 Consider the system shown in Figure 58 Show that the output of the system is 2A0wt cos2πfct as indicated Exercise 510 Create a Matlab routine to implement the squarelaw mixing modulator of Figure 58 a Create a signal wt that has bandwidth 100 Hz b Modulate the signal to 1000 Hz c Demodulate using the AM demodulator from AMm to recover the original wt Analog Demodulation 89 wt a b c d cos2πf1t φ1 BPF xt xt rt lower cutoff f2 upper cutoff f3 rt cos2πf8t φ2 sin2πf4t cos2πf5t lower cutoff f6 cutoff f9 upper cutoff f7 BPF yt LPF BPF W f f 300 2000 300 2000 2 Figure 59 The transmission system for Exercise 512 a the magnitude spectrum of the message b the transmitter c the channel and d the receiver Exercise 511 Exercise 510 essentially creates a transmitter and receiver based on the squarelaw 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 filter is not centered at the specified frequency Exercise 512 Consider the transmission system of Figure 59 The message signal wt has the magnitude spectrum shown in part a The transmitter in part b produces the transmitted signal xt which passes through the chan nel in part c The channel scales the signal and adds narrowband interferers to create the received signal rt The transmitter and channel parameters are φ1 03 radians f1 241 kHz f2 239 kHz f3 275 kHz f4 293 kHz and f5 226 kHz The receiver processing rt is shown in Figure 59d All bandpass and lowpass filters are considered ideal with a gain of unity in the passband and zero in the stopband a Sketch Rf 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 yt and reflects the value of φ1 and the delays imposed by the two ideal bandpass filters that form the received signal rt Select the receiver parameters f6 f7 f8 and f9 so the receiver output yt is a scaled version of wt Exercise 513 An analog baseband message signal wt has all energy between B and B Hz It is upconverted to the transmitted passband signal xt via AM 90 Chapter 5 Analog Demodulation with suppressed carrier xt wt cos2πfct φc where the carrier frequency fc 10B The channel is a pure delay and the received signal r is rt xt d where the delay d nTc Tcα is an integer multiple n 0 of the carrier period Tc 1fc plus a fraction of Tc given by α 1 The mixer at the receiver is perfectly synchronized to the transmitter so that the mixer output yt is yt rt cos2πfct φr The receiver mixer phase need not match the transmitter mixer phase φc The receiver lowpass filters y to produce vt LPFyt where the lowpass filter is ideal with unity passband gain linear passband phase with zero phase at zero frequency and cutoff frequency 12B a Write a formula for the receiver mixer output yt as a function of fc φc d α φr and wt without use of x r n or Tc b Determine the amplitude of the minimum and maximum values of yt for α 4 c For α 6 n 42 φc 02 radians and Tc 20 µs determine the value of φr that maximizes the magnitude of the maximum and minimum values of vt 53 Quadrature Modulation In AM transmission where the baseband signal and its modulated passband ver sion are realvalued the spectrum of the modulated signal has twice the band width of the baseband signal As pictured in Figure 410 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 inefficiency 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 efficiently To see how this can work suppose that there are two message streams m1t and m2t Modulate one message with a cosine to create the inphase signal and the other with the negative of a sine to form the quadrature signal These Analog Demodulation 91 m1t sin2πfct cos2πfct cos2πfct Transmitter Receiver m2t x1t x2t s1t s2t LPF LPF sin2πfct Figure 510 In a quadrature modulation system two messages m1t and m2t are modulated by two sinusoids of the same frequency sin2πfct and cos2πfct The receiver then demodulates twice and recovers the original messages after lowpass filtering are summed1 to form vt m1t cos2πfct m2t sin2πfct 56 which is then transmitted A receiver structure that can recover the two messages is shown in Figure 510 The signal s1t at the output of the receiver is intended to recover the first message m1t Similarly the signal s2t at the output of the receiver is intended to recover the negative of the second message m2t To examine the recovered signals s1t and s2t in Figure 510 first evaluate the signals before the lowpass filtering Using the trigonometric identities A4 and A8 x1t becomes x1t vt cos2πfct m1t cos22πfct m2t sin2πfct cos2πfct m1t 2 1 cos4πfct m2t 2 sin4πfct Lowpass filtering x1t produces s1t m1t 2 Similarly x2t can be rewritten using A5 and A8 as x2t vt sin2πfct m1t cos2πfct sin2πfct m2t sin22πfct m1t 2 sin4πfct m2t 2 1 cos4πfct and lowpass filtering x2t produces s2t m2t 2 Thus in the ideal situation in which the phases and frequencies of the modu lation and the demodulation are identical both messages can be recovered But if the frequencies andor phases are not exact then problems analogous to those 1 These are also sometimes modeled as the real and the imaginary parts of a single complexvalued signal This complex representation is explored more fully in Appendix C 92 Chapter 5 Analog Demodulation x2t x3t x4t x5t x6t x1t cos2πf5t φ cos2πf1t cos2πf2t lower cutoff f3 cutoff f6 upper cutoff f4 BPF LPF Figure 511 The transmission system of Exercise 516 encountered with AM will occur in the quadrature modulation For instance if the phase of say the demodulator x1t is not correct then there will be some distortion or attenuation in s1t However problems in the demodulation of s1t may also cause problems in the demodulation of s2t This is called crossinterference between the two messages Exercise 514 Use AMm as a starting point to create a quadrature modulation system that implements the block diagram of Figure 510 a Examine the effect of a phase offset in the demodulating sinusoids of the receiver so that x1t vt cos2πfct φ and x2t vt sin2πfct φ for a variety of φ Refer to Exercise 56 b Examine the effect of a frequency offset in the demodulating sinusoids of the receiver so that x1t vt cos2πfc γt and x2t vt sin2πfc γt for a variety of γ Refer to Exercise 58 c Confirm that a 1 phase error in the receiver oscillator corresponds to more than 1 crossinterference Exercise 515 TRUE or FALSE Quadrature amplitude modulation can com bine two real baseband messages of absolute bandwidth B in a radiofrequency signal of absolute bandwidth B Exercise 516 Consider the scheme shown in Figure 511 The absolute band width of the baseband signal x1 is 6 MHz and that of the baseband signal x2t is 4 MHz f1 164 MHz f2 154 MHz f3 148 MHz f4 160 MHz f5 80 MHz φ π2 and f6 82 MHz a What is the absolute bandwidth of x3t b What is the absolute bandwidth of x5t c What is the absolute bandwidth of x6t d What is the maximum frequency in x3t e What is the maximum frequency in x5t Thus the inefficiency of realvalued doublesided AM transmission can be reduced using complexvalued quadrature modulation which recaptures the lost bandwidth by sending two messages simultaneously For simplicity and clarity Analog Demodulation 93 the bulk of Software Receiver Design focuses on the real PAM case and the complexvalued quadrature case is postponed until Chapter 16 There are also other ways of recapturing the lost bandwidth both singlesideband and vestigial sideband discussed in the document Other Modulations on the website send a single message but use only half the bandwidth 54 Injection to Intermediate Frequency All the modulators and demodulators discussed in the previous sections down convert to baseband in a single step that is the spectrum of the received signal is shifted by mixing with a cosine of frequency fc that matches the transmission frequency fc As suggested in Section 28 it is also possible to downconvert to some desired intermediate frequency IF fI as depicted in Figure 29 and to then later downconvert to baseband by mixing with a cosine of the intermediate frequency fI There are several advantages to such a twostep procedure r all frequency bands can be downconverted to the same IF which allows use of standardized amplifiers modulators and filters 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 filtering to extract the passband around the IF can be accomplished in two ways by a local oscillator modulating from above the carrier frequency called highside injection or from below lowside injection To see this consider the double sideband modulation from Section 52 that creates the transmitted signal vt 2wtcos2πfct from the message signal wt and the downconversion to IF via xt 2vt ntcos2πfIt where nt represents interference such as noise and spurious signals from other users By virtue of the frequencyshifting property A33 V f Wf fc Wf fc 57 and the spectrum of the IF signal is Xf V f fI V f fI Nf fI Nf fI Wf fc fI Wf fc fI Wf fc fI Wf fc fI Nf fI Nf fI 58 94 Chapter 5 Analog Demodulation 850 1780 105 a 105 850 1780 V f N f X f f kHz f kHz f kHz 1245 1385 290 1245 1385 2175 b 2175 455 290 500 500 455 455 1410 1200 2156 3085 c 475 475 2156 1410 1200 3085 455 X f Figure 512 Example of highside and lowside injection to an IF at fI 455 kHz a transmitted spectrum b lowside injected spectrum and c highside injected spectrum Example 51 Consider a message spectrum Wf that has a bandwidth of 200 kHz an upconversion carrier frequency fc 850 kHz and an objective to downconvert to an intermediate frequency of fI 455 kHz For lowside injec tion where the frequency of the local oscillator is fℓ fc the goal is to cen ter Wf fc fℓ in 58 at fI so that fℓ fc 455 395 For highside injection with fℓ fc the goal is to center Wf fc fℓ at fI so that fℓ fc 455 1305 For illustrative purposes Figure 512 supposes that the interference Nf consists of a pair of delta functions at 105 and 1780 kHz Figure 512 sketches V f and Xf for both highside and lowside injection In this example both methods end up with unwanted narrowband interferences in the passband Observe the following r Lowside injection results in symmetry in the translated message spectrum about fc on each of the positive and negative halfaxes r Highside injection separates the undesired images further from the lower frequency portion which will ultimately be retained to reconstruct the mes sage This eases the requirements on the bandpass filter r Both highside and lowside injection can place frequency interferers in unde sirable places This highlights the need for adequate outofband rejection by a bandpass filter before downconversion to IF Analog Demodulation 95 wt rt xt cos2πfct cos2πfrt nt W f f kHz 22 22 Figure 513 Transmission system for Exercise 517 Exercise 517 Consider the system described in Figure 513 The message wt 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 xt by a mixer with frequency fr a With nt 0 fr 36 kHz and fc 83 kHz indicate all frequency ranges ix that include any part of the IF passband signal xt 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 ix 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 xt c With fr 84 kHz and fc 62 kHz indicate every range ix 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 xt Exercise 518 A transmitter operates as a standard AM with suppressed carrier transmitter as in AMm Create a demodulation routine that operates in two steps by mixing with a cosine of frequency 3fc4 and subsequently mixing with a cosine of frequency fc4 Where must passreject filters be placed in order to ensure reconstruction of the message Let fc 2000 Exercise 519 Consider the scheme shown in Figure 514 The absolute band width of the baseband signal x1 is 4 kHz f1 28 kHz f2 20 kHz and f3 26 kHz a What is the absolute bandwidth of x2t b What is the absolute bandwidth of x3t c What is the absolute bandwidth of x4t d What is the maximum frequency in x2t e What is the maximum frequency in x3t Exercise 520 Using your Matlab code from Exercise 518 investigate the effect of a sinusoidal interference 96 Chapter 5 Analog Demodulation X2 Squaring nonlinearity x4t x3t x2t x1t cos2πf1t BPF lower cutoff f2 upper cutoff f3 Figure 514 Transmission system for Exercise 519 X1 f f f1 f1 1 x1t x2t x3t x4t cos2πf2t lower cutoff f5 upper cutoff f6 BPF cos2πf3t cos2πf4t x5kTs x6kTs x7kTs x8kT x4t cos2πf8t LPF M Ts1f7 cutoff f9 Figure 515 Transmission system for Exercise 521 a at frequency fc6 b at frequency fc3 c at frequency 3fc Exercise 521 Consider the PAM communication system in Figure 515 The input x1t has a triangular baseband magnitude spectrum The frequency spec ifications 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 X5f between 3000 kHz Be certain to give specific 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 522 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 yt ut cos2πfct and carrier frequencies fc of 12 MHz and 50 MHz b two linear bandpass filters 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 Figure 516 Spectrum of the received signal for Exercise 522 c two impulse samplers with input u and output y related by yt sum from k to of utδt kTs with sample periods of 115 and 112 μs d one squarelaw device with input u and output y related by yt u²t e three summers with inputs u1 and u2 and output y related by yt u1t u2t The spectrum of the received signal is illustrated in Figure 516 The desired baseband output of the receiver should be a scaled version of the triangular portion centered at zero frequency with no other signals in the range between 8 and 8 MHz Using no more than four parts from the ten available build a receiver that produces the desired baseband signal Draw its block diagram Sketch the magnitude spectrum of the output of each part in the receiver For Further Reading A friendly and readable introduction to analog transmission systems can be found in P J Nahin On the Science of Radio AIP Press 1996 6 Sampling with Automatic Gain Control As foreshadowed in Section 28 transmission systems cannot be fully digital because the medium through which the signal propagates is analog Hence whether the signal begins as analog such as voice or music or whether it begins as digital such as mpeg jpeg or wav files it will be converted into a high frequency analog signal when it is transmitted In a digital receiver the received signal must be transformed into a discretetime signal in order to allow subse quent digital processing This chapter begins by considering the sampling process both in the time domain and in the frequency domain Then Section 63 discusses how Matlab can be used to simulate the sampling process This is not completely obvious because analog signals cannot be represented exactly in the computer Two sim ple tricks are suggested The first expresses the analog signal in functional form and takes samples at the desired times The second oversamples the analog signal so that it is represented at a high data rate the sampling can then be done on the oversampled signal Sampling and quantization are important because they translate the signal from analog to digital It is equally important to be able to translate from digital back into analog and the celebrated Nyquist sampling theorem shows that this is possible for any bandlimited signal assuming the sampling rate is fast enough When the goal of this translation is to rebuild a copy of the transmitted signal this is called reconstruction When the goal is to determine the value of the signal at some particular point it is called interpolation Techniques and Matlab code for both reconstruction and interpolation appear in Section 64 Figure 61 shows the received signal passing through a BPF which removes outofband interference and isolates the desired frequency range followed by a fixed demodulation to the intermediate frequency IF at which sampling takes place The automatic gain control AGC accounts for changes in the strength of the received signal When the received signal is powerful the gain a is small when the signal strength is low the gain a is high The goal is to guarantee that the analogtodigital converter does not saturate the signal does not routinely Sampling with Automatic Gain Control 99 Analog received signal Antenna Sampler Quantizer rt skTs sk AGC a Analog conversion to IF BPF Quality Assessment Figure 61 The front end of the receiver After filtering and demodulation the signal is sampled An automatic gain control AGC is needed to utilize the full dynamic range of the quantizer 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 fifth element of Chapter 3 How can such elements be designed Software Receiver Design suggests a general method based on gradientdirected optimization First a goal and an associ ated 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 defined 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 accord ing 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 65 through 67 will also be useful in designing other adaptive elements such as the phase tracking loops of Chapter 10 the clock recovery algorithms of Chapter 12 and the equalization schemes of Chapter 13 61 Sampling and Aliasing Sampling can be modeled as a pointbypoint multiplication in the time domain by a pulse train a sequence of impulses Recall Figure 38 on page 49 While this is intuitively plausible it is not terribly insightful The effects of sampling become apparent when viewed in the frequency domain When the sampling is done correctly no information is lost However if the sampling is done too slowly aliasing artifacts are inevitable This section shows the how and why of sampling Figure 62 An analog signal wt is multiplied pointbypoint by a pulse train This effectively samples the analog signal at a rate Ts Suppose an analog waveform wt is to be sampled every Ts seconds to yield a discretetime sequence wk wkTs wt tkTs for all integers k1 This is called point sampling because it picks off the value of the function wt at the points kTs One way to model point sampling is to create a continuousvalued function that consists of a train of pulses that are scaled by the values wkTs The impulse sampling function is wst wt sum from k to of δt kTs sum from k to of wkTsδt kTs and it is illustrated in Figure 62 The effect of multiplication by the pulse train is clear in the time domain But the relationship between wst and wt is clearer in the frequency domain which can be understood by writing Wsf as a function of Wf The transform Wsf is given in A27 and A28 With fs 1Ts this is Wsf fs sum from n to of Wf nfs Thus the spectrum of the sampled signal wst differs from the spectrum of the original wt in two ways Amplitude scalingeach term in the spectrum Wsf is multiplied by the factor fs Replicasfor each n Wsf contains a copy of Wf shifted to f nfs Sampling creates an infinite sequence of replicas each separated by fs Hz Said another way the process of sampling in time creates a periodicity in frequency 1 Observe that the notation wkTs means wt evaluated at the time t kTs This is also notated wk with the square brackets where the sampling rate Ts is implicit Sampling with Automatic Gain Control 101 2fs fs B B fsB fsB B B fs 0 0 0 b a B B fs 2 fs 2 fs fs W f Ws f f f 0 B B fs 2 fs 2 W f Ws f f f fsB fsB Figure 63 The spectrum of a sampled signal is periodic with period equal to fs In case a the original spectrum W f is bandlimited to less than fs2 and there is no overlapping of the replicas When W f is not bandlimited to less than fs2 as in b the overlap of the replicas is called aliasing where the period is defined 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 62 shows why the relationships in Figure 39 on page 50 hold Figure 63 shows these replicas in two possible cases In a fs 2B where B is the bandwidth of wt and the replicas do not overlap Hence it is possible to extract the one replica centered at zero by using a lowpass filter Assuming that the filtering is without error Wf is recovered from the sampled version Wsf Since the transform is invertible this means that wt can be recovered from wst Therefore no loss of information occurs in the sampling process2 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 wt is sampled to give wst which is nonzero only at the sampling instants kTs If wst is then input into a perfect analog lowpass filter its output is the same as the original wt Such filtering cannot be done with any digital filter operating at the sampling rate fs In terms of Figure 63 the digital filter can remove and reshape the frequencies between the bumps but can never remove the periodic bumps 102 Chapter 6 Sampling with Automatic Gain Control Nyquist Sampling Theorem If the signal wt is bandlimited to B Wf 0 for all f B and the sampling rate is faster than fs 2B then wt can be reconstructed exactly from its samples wkTs On the other hand in part b of Figure 63 the replicas overlap because the repetitions are narrower than the width of the spectrum Wf In this case it is impossible to recover the original spectrum perfectly from the sampled spectrum and hence it is impossible to exactly recover the original waveform from the sampled version The overlapping of the replicas and the resulting distortions in the reconstructed waveform are called aliasing Bandwidth can also be thought of as limiting the rate at which data can flow over a channel When a channel is constrained to a bandwidth 2B then the output of the channel is a signal with bandwidth no greater than 2B Accordingly the output can contain no frequencies above fs and symbols can be transmitted no faster than one every Ts seconds where 1Ts fs Exercise 61 Human hearing extends up to about 20 kHz What is the min imum sampling rate needed to fully capture a musical performance Compare this with the CD sampling rate of 441 kHz Some animal sounds such as the singing of dolphins and the chirping of bats occur at frequencies up to about 50 kHz What does this imply about CD recordings of dolphin or bat sounds Exercise 62 US highdefinition digital television HDTV is transmitted in the same frequency bands as conventional television for instance Channel 2 is at 54 MHz and each channel has a bandwidth of about 6 MHz What is the minimum sampling rate needed to fully capture the HDTV signal once it has been demodulated to baseband Exercise 63 An analog signal has nonzero values in its magnitude spectrum at every frequency between B and B This signal is sampled with period T where 1T B TRUE or FALSE The discretetime signal can have components in its spectrum at frequencies between B and 1T Exercise 64 The triangularly shaped magnitude spectrum of a real message signal wt is shown in Figure 64 where B 02 MHz The received signal rt 015wt cos2πft is modulated by an AM with suppressed carrier with f 145 MHz and atten tuated With 1f T1 12B select T1 T2 T3 and β so that the magnitude spectrum of x3k matches the magnitude spectrum of T1spaced samples of wt Justify your answer by drawing the magnitude spectra of x1 x2 and x3 between f and f Sampling with Automatic Gain Control 103 W f f B B 4 x1k x2k x3k rt β cos2πkT2 LPF kT1 cutoff frequency 1T3 passband gain 1 stopband gain 0 Figure 64 The triangularly shaped magnitude spectrum of the real message signal wt is shown on the left The receiver structure in Exercise 64 is shown on the right X f f v2kTs v3kTs v4kTs v1t xt cos400πkTs LPF Ts 0001 s 450 400 350 350 400 450 X2 square law Figure 65 The signal xt with spectrum Xf is input into this communication system Exercise 65 asks for the absolute bandwidth of the signal at each point as it moves through the system Exercise 65 The signal xt with magnitude spectrum shown in the left part of Figure 65 is input to the transmission system on the right The lowpass filter with output v4kTs has a cutoff 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 V1f V2f V3f and V4f have nonzero values 62 Downconversion via Sampling The processes of modulation and demodulation which shift the frequencies of a signal can be accomplished by mixing with a cosine wave that has a fre quency equal to the amount of the desired shift as was demonstrated repeatedly throughout Chapter 5 But this is not the only way Since sampling creates a collection of replicas of the spectrum of a waveform it changes the frequencies of the signal When the message signal is analog and bandlimited to B sampling can be used as a step in the demodulation process Suppose that the signal is transmitted with a carrier at frequency fc Direct sampling of this signal creates a collection of replicas one near DC This procedure is shown in Figure 66 for fs fc2 though beware when fs and fc are not simply related the replica might not land exactly at DC This demodulation by sampling is diagrammed in Figure 67 with fs fcn where n is a small positive integer and can be thought of as an alternative to mixing with a cosine that must be synchronized in frequency and phase with the transmitter oscillator The magnitude spectrum Wf of a message wt Figure 66 Spectra in a sampling downconverter such as Figure 67 The bandlimited analog signal Wf shown in a is upconverted to the transmitted signal in b Directly sampling this at a rate equal to fs fc2 results in the spectrum shown in the bottom plot is shown in Figure 66a and the spectrum after upconversion is shown in part b this is the transmitted signal st At the receiver st is sampled which can be modeled as a multiplication with a train of delta functions in time yt st sum from n to of δt nTs where Ts is the sample period Using 62 this can be transformed into the frequency domain as Yf 1Ts sum from n to of Sf nfs where fs 1Ts The magnitude spectrum of Yf is illustrated in Figure 66c for the particular choice fs fc2 and Ts 2fc with B fc4 fs2 There are three ways in which the sampling can proceed 1 sample faster than the Nyquist rate of the IF frequency 2 sample slower than the Nyquist rate of the IF frequency and then downconvert the replica closest to DC and 3 sample so that one of the replicas is directly centered at DC The first is a direct imitation of the analog situation where no aliasing will occur This may be expensive because of the high sample rates required to achieve Nyquist sampling The third is the situation depicted in Figures 66 and 67 which permit downconversion to baseband without an additional oscillator This may be sensitive to small deviations in frequency for instance when fs is not Sampling with Automatic Gain Control 105 LPF wt st yt cos2πfct mt Ts fcutoff B Figure 67 System diagram showing how sampling can be used to downconvert a signal The spectra corresponding to wt st and yt are shown in Figure 66 The output of the LPF contains only the Mshaped portion nearest zero exactly fc2 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 66 Create a simulation of a samplingbased 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 reflects 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 sine100hzsampm What choices have you made for these two sampling rates Exercise 67 Implement the procedure diagrammed in Figure 67 Comment on the choice of sampling rates How have you specified the LPF Exercise 68 Using your code from Exercise 67 examine the effect of incor rect 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 54 Exercise 69 Consider the part of a communication system shown in Figure 68 a Sketch the magnitude spectrum X1f of x1t wtcos1500πt Be certain to give specific values of frequency and magnitude at all significant points in the sketch b Draw the magnitude spectrum X2f of x2t wtx1t Be certain to give specific values of frequency and magnitude at all significant points in the sketch Chapter 6 Sampling with Automatic Gain Control Wf 02 220 220 f cos1500πt Figure 68 Input spectrum and system diagram for Exercise 69 wt x1t x2k x3k LPF x4k kTs cutoff frequency f2 cos2πfct cos2πfIt cos2πfIkTs Figure 69 The digital receiver used in Exercise 610 c Between 3750 Hz and 3750 Hz draw the magnitude spectrum X3f of x3t x2t k δtkTs for Ts 400 μs Be certain to give specific values of frequency and magnitude at all significant points in the sketch Exercise 610 Consider the digital receiver shown in Figure 69 The baseband signal wt 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 filter has a cutoff frequency of f2 For the following designs you are to decide whether they are successful ie whether or not the magnitude spectrum of the lowpass filter output x4 is the same up to a scale factor as the magnitude spectrum of the sampled wt with a sample period of Ts a Candidate System A B 7 kHz fc 34 kHz fI 49 kHz Ts 134 ms f1 0 and f2 16 kHz b Candidate System B B 11 kHz fc 39 kHz fI 130 kHz Ts 152 ms f1 13 kHz and f2 12 kHz Sampling with Automatic Gain Control Rf 15 15 6 4 2 2 4 6 fMHz rt BPF yt Ts cos2πfo t Figure 610 The digital receiver used in Exercise 611 four ideal linear bandpass filters with passband fL fU of 05 MHz 6 MHz 12 MHz 62 MHz 34 MHz 72 MHz and 42 MHz 83 MHz four impulse samplers with input u and output y related by yt k ut δtkTs with sample periods of 17 15 14 and 135 microseconds The magnitude spectrum Rf of the received signal rt is shown on the left in Figure 610 The objective is to specify the bandpass filter sampler and mixer so that the Mshaped segment of the magnitude spectrum is centered at f 0 in the output Yf with no other signals within 15 MHz of the upper and lower edges a Specify the three parts from the 12 provided i bandpass filter passband range fL fU in MHz ii sampler period Ts in μs iii mixer oscillator frequency fo in MHz b For the three components selected in part a sketch the magnitude spectrum of the sampler output between 20 and 20 MHz Be certain to give specific values of frequency and magnitude at all significant points in the spectra c For the three components selected in part a sketch the magnitude spectrum of yt between between the frequencies 12 and 12 MHz for your design Be certain to give specific values of frequency and magnitude at all significant points in the spectra d Is the magnitude spectrum of yt identical to the Mshaped segment of Rf first downconverted to baseband and then sampled Exercise 612 The message signal ut and additive interferer wt with magnitude spectra shown in Figure 611a are applied to the system in Figure 611b The analog mixer frequencies are fc 1600 kHz and fd 1240 kHz The BPF with output xt is assumed ideal is centered at fc and has lower cutoff frequency fL upper cutoff frequency fU and zero phase at fc The period of the sampler is Ts 17 104 s The phase β of the discretetime mixer is assumed to be adjusted to the value that maximizes the ratio of signal to interferer noise power in ykTs The LPF with output ykTs is assumed ideal with cutoff frequency 108 Chapter 6 Sampling with Automatic Gain Control W f 860 720 720 860 U f f kHz f kHz 40 40 ykTs ut wt xt cos2παkTsβ cos2πfdt LPF cos2πfct BPF Ts a b c Figure 611 Magnitude spectra of a the message and b the interference signals considered in Exercise 612 The receiver structure is shown schematically in c ykTs rt xt cos2πfckTs cos2πfct LPF kTs Figure 612 Digital receiver considered in Exercise 613 γ The design objective is for the spectrum of ykTs to estimate the spectrum of a sampled ut You are to select the upper and lower cutoff frequencies of the BPF the frequency α of the discretetime mixer and the cutoff frequency of the LPF in order to meet this objective a Design the desired BPF by specifying its upper fU and lower fL cutoff fre quencies b Compute the desired discretetime mixer frequency α c Design the desired LPF by specifying its cutoff frequency γ Exercise 613 Consider the digital receiver in Figure 612 producing ykTs which is intended to match the input xt sampled every Ts seconds The abso lute bandwidth of xt is B The carrier frequency fc is 10 times B The sample frequency 1Ts is 25 times fc Note that the sample frequency 1Ts is above the Nyquist frequency of the received signal rt Determine the maximum cutoff frequency as a function of the input bandwidth B for the lowpass filter produc ing ykTs so the design objective of matching samples of xt with a sample frequency of 1Ts is achieved 63 Exploring Sampling in MATLAB It is not possible to capture all of the complexities of analogtodigital conversion inside a computer program because all signals within a digital computer are already sampled Nonetheless most of the key ideas can be illustrated by using two tricks to simulate the sampling process Sampling with Automatic Gain Control 109 r evaluate a function at appropriate values or times r represent a data waveform by a large number of samples and then reduce the number of samples The first is useful when the signal can be described by a known function while the second is necessary whenever the procedure is datadriven that is when no functional form is available This section explores both approaches via a series of Matlab experiments Consider representing a sine wave of frequency f 100 Hz The sampling theorem asserts that the sampling rate must be greater than the Nyquist rate of 200 samples per second But in order to visualize the wave clearly it is often useful to sample considerably faster The following Matlab code calculates and plots the first 110 second of a 100 Hz sine wave with a sampling rate of fs 1Ts 10000 samples per second Listing 61 sine100hzm generate 100 Hz sine wave with sampling rate fs1Ts f 100 frequency of wave time 01 t o t a l time in seconds Ts110000 sampling i n t e r v a l tTs Ts time def i ne a time vector wsin 2 pi f t def i ne the s i ne wave plot t w pl ot the s i ne vs time xlabel seconds ylabel amplitude Running sine100hzm plots the first 10 periods of the sine wave Each period lasts 001 s and each period contains 100 points as can be verified by looking at w1100 Changing the variable time or Ts displays different numbers of cycles of the same sine wave while changing f plots sine waves with different underlying frequencies Exercise 614 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 615 Let Ts1500 How does the plot of the sine wave appear Let Ts1100 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 different When the sampling is rapid compared with the underlying frequency of the sig nal for instance the program sine100hzm 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 discretetime 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 310 on page 51 110 Chapter 6 Sampling with Automatic Gain Control Amplitude Seconds 1 0 1 0 001 002 003 004 Figure 613 Removing all but one of each N points from an oversampled waveform simulates the sampling process Listing 62 sine100hzsampm simulated sampling of the 100 Hz sine wave f 100 time 005 Ts110000 tTs Ts time s et time vector s wsin 2 pi f t cr eate s i ne wave w t s s 10 take 1 in s s samples wkw 1 s s end the sampled sequence wszeros size w ws 1 s s endwk sampled waveform ws t plot t w pl ot the waveform hold on plot t ws r hold o f f pl ot sampled wave Running sine100hzsampm results in the plot shown in Figure 613 where the continuous sine wave w is downsampled by a factor of ss10 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 effective sampling interval ssTs The spiky signal ws corresponds to the sampled signal wst while the sequence wk contains just the amplitude values at the tips of the spikes Exercise 616 Modify sine100hzsampm to create an oversampled sinc wave and then sample this with ss10 Repeat this exercise with ss30 ss100 and ss200 Comment on what is happening Hint in each case what is the effective sampling interval Exercise 617 Plot the spectrum of the 100 Hz sine wave when it is created with different downsampling rates ss10 ss11 ss30 and ss200 Explain what you see 64 Interpolation and Reconstruction The previous sections explored how to convert analog signals into digital signals The central result is that if the sampling is done faster than the Nyquist rate then no information is lost In other words the complete analog signal wt can be recovered from its discrete samples wk When the goal is to find the complete waveform this is called reconstruction when the goal is to find values of the waveform at particular points between the sampling instants it is called interpolation This section explores bandlimited interpolation and reconstruction in theory and practice The samples wkTs form a sequence of numbers that represent an underlying continuousvalued function wt at the time instants t kTs The sampling interval Ts is presumed to have been chosen so that the sampling rate fs 2B where B is the highest frequency present in wt The Nyquist sampling theorem presented in Section 61 states that the values of wt can be recovered exactly at any time τ The formula which is justified subsequently for recovering wτ from the samples wkTs is wτ t wst sinc τt dt where wst defined in 61 is zero everywhere except at the sampling instants t kTs Substituting 61 into wτ shows that this integral is identical to the sum wτ k wkTs sinc τkTsTs 63 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 finite time window To see why interpolation works note that the formula 63 is a convolution in time of the signal wkTs and the sinc function Since convolution in time is the same as multiplication in frequency by A40 the transform of wτ is equal to the product of FwskTs and the transform of the sinc By A22 the transform of the sinc function in time is a rect function in frequency This rect function is a lowpass filter since it passes all frequencies below fs2 and removes all frequencies above Since the process of sampling a continuoustime signal generates replicas of the spectrum at integer multiples of fs by 62 the lowpass filter removes all but one of these replicas In effect the sampled data are passed through an analog lowpass filter to create a continuoustime 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 63 combines them to recover wτ To see how 63 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 five 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 sininterpm shows that it is also possible in practice The plot in Figure 614 shows the original wave which appears choppy because it is sampled only five times per period and the reconstructed or smoothed waveform which looks just like a sine wave The variable intfac specifies how many extra Figure 614 A convincing sine wave can be reconstructed from its samples using sinc interpolation The choppy wave represents the samples and the smooth wave shows the reconstruction Sampling with Automatic Gain Control 113 it is a lowpass filter since the frequency response is a rect function The delay τ is proportional to the phase of the frequency response Exercise 618 In sininterpm 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 619 In sininterpm what happens when the window is reduced Make over smaller and find out What happens when too few points are inter polated Make intfac smaller and find out Exercise 620 Create a more interesting more complex wave wt Answer the above questions for this wt Exercise 621 Let wt be a sum of five sinusoids for t between 10 and 10 s Let wkT represent samples of wt with T 001 s Use interpsincm to inter polate the values w0011 w0013 and w0015 Compare the interpolated values with the actual values Explain any discrepancies Observe that sinct 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 convo lution ie why the variable over is large A simple way to reduce the num ber of terms is to use a function that dies away more quickly than the sinc a common choice is the squareroot 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 118 The SRRC can easily be incorporated into the interpolation code by replacing the code interpsincwtnowiover with interpsincwtnowioverbeta Exercise 622 With beta0 the SRRC is exactly the sinc Redo the above exercises trying various values of beta between 0 and 1 The function srrcm is available on the website Its help file is ss r r c syms beta P t o f f Generate a SquareRoot Raised Cosine Pulse syms i s 12 the length of s r r c pulse in symbol durations beta i s the r o l l o f f f a c t o r beta0 gi ves the s i nc f uncti on P i s the oversampling f a c t o r t o f f i s the phase or timing o f f s e t Matlab also has a builtin function called resample which has the following help file Change the sampling r ate of a s i g n a l Y resample XPQ resamples the sequence in vector X at PQ times the o r i g i n a l sample 114 Chapter 6 Sampling with Automatic Gain Control r ate using a polyphase implementation Y i s PQ times the length of 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 different from that used in 63 It is more efficient numer ically at reconstructing entire waveforms but it works only when the desired resampling rate is rationally related to the original The method of 63 is far more efficient when isolated not necessarily evenly spaced interpolating points are required which is crucial for synchronization tasks in Chapter 12 65 Iteration and Optimization An important practical part of the sampling procedure is that the dynamic range of the signal at the input to the sampler must remain within bounds This can be accomplished using an automatic gain control which is depicted in Figure 61 as multiplication by a scalar a along with a quality assessment block that adjusts a in response to the power at the output of the sampler This section discusses the background needed to understand how the quality assessment works The essential idea is to state the goal of the assessment mechanism as an optimization problem Many problems in communications and throughout engineering can be framed in terms of an optimization problem Solving such problems requires three basic steps 1 setting a goalchoosing a performance or objective function 2 choosing a method of achieving the goalminimizing or maximizing the objec tive function and 3 testing to make sure the method works as anticipated Setting the goal usually consists of finding a function that can be minimized or maximized and for which locating the minimum or maximum value pro vides useful information about the problem at hand Moreover the function must be chosen carefully so that it and its derivative can be calculated from quantities that are known or that can be derived from signals that are easily obtainable Sometimes the goal is obvious and sometimes it is not There are many ways of carrying out the minimization or maximization pro cedure Some of these are direct For instance if the problem is to find the point at which a polynomial function achieves its minimum value this can be solved directly by finding the derivative and setting it equal to zero Often however such direct solutions are impossible and even when they are possible recursive or adaptive approaches often have better properties when the signals are noisy This chapter focuses on a recursive method called steepest descent which is the basis of many adaptive elements used in communications systems and of all the elements used in Software Receiver Design Sampling with Automatic Gain Control 115 The final 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 con tour 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 mathemat ically where the mountainside is defined 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 66 An Example of Optimization Polynomial Minimization This first example is too simple to be of practical use but it does show many of the ideas starkly Suppose that the goal is to find the value at which the polynomial Jx x2 4x 4 64 achieves its minimum value Thus step 1 is set As any calculus book will suggest the direct way to find the minimum is to take the derivative set it equal to zero and solve for x Thus dJxdx 2x 4 0 is solved when x 2 This is indeed the value of x for which the parabola Jx 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 Jx are extremely nonlinear Or maybe the derivative of Jx 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 loca tion of the minimum evaluates which direction from this estimate is most steeply downhill and then makes a new estimate along the downhill direction Simi larly 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 Figure 615 Steepest descent finds the minimum of a function by always pointing in the direction that leads downhill Sampling with Automatic Gain Control 117 2 1 0 1 2 3 4 5 0 50 100 150 200 250 300 350 400 Starting values Time Figure 616 The program polyconvergem attempts to locate the smallest value of Jx x2 4x 4 by descending the gradient Fifty different starting values all converge to the same minimum at x 2 mu01 algorithm s t e p s i z e xzeros 1 N i n i t i a l i z e x to zero x13 s t a r t i n g point x 1 for k1N1 xk112mu x k4mu update equation end Figure 616 shows the output of polyconvergem for 50 different x1 starting values superimposed all converge smoothly to the minimum at x 2 Exercise 623 Explore the behavior of steepest descent by running polyconvergem with different parameters a Try mu 001 0 00001 002 003 005 10 100 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 x1 Can x1 be too large or too small As an alternative to simulation observe that the process 66 is itself a linear timeinvariant system of the general form xk 1 axk b 67 which is stable as long as a 1 For a constant input the finalvalue theorem of ztransforms see A55 can be used to show that the asymptotic convergent output value is limk xk b1 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 xk 1 xk x so 67 implies that x ax b which implies that x b1 a This holds assuming that a 1 For example for 66 x 4µ1 1 2µ 2 which is indeed the minimum Thus both simulation and analysis suggest that the iteration 66 is a viable way to find the minimum of the function Jx 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 Jx is differentiable Similarly it is usually quite straightforward to simulate the algorithm to examine its behavior in specific cases though it is not always so easy to carry out a theoretical analysis By their nature steepestdescent and hillclimbing methods use only local information This is because the update from a point xk depends only on the value of xk and on the value of its derivative evaluated at that point This can be a problem since if the objective function has many minima the steepestdescent algorithm may become trapped at a minimum that is not globally the smallest These are called local minima To see how this can happen consider the problem of finding the value of x that minimizes the function Jx e01x sinx Applying the chain rule the derivative is e01x cosx 01e01x sinx signx where signx 1 for x0 1 for x0 is the formal derivative of x Solving directly for the minimum point is nontrivial try it Yet implementing a steepestdescent search for the minimum can be done in a straightforward manner using the iteration xk1 xk μe01xk cosxk 01 sinxksignx To be concrete replace the update equation in polyconvergem with xk1 xk mu exp01 absxk cosxk 01 sinxk signxk Exercise 624 Implement the steepestdescent strategy to find the minimum of Jx in 68 modeling the program after polyconvergem Run the program for different values of mu N and x1 and answer the same questions as in Exercise 623 One way to understand the behavior of steepestdescent algorithms is to plot the error surface which is basically a plot of the objective as a function of the variable that is being optimized Figure 617a displays clearly the single global minimum of the objective function 64 while Figure 617b shows the many minima of the objective function defined by 68 As will be clear to anyone who has attempted Exercise 624 initializing within any one of the valleys causes the algorithm to descend to the bottom of that valley Although true steepestdescent algorithms can never climb over a peak to enter another valley even if the minimum there is lower it can sometimes happen in practice when there is a significant amount of noise in the measurement of the downhill direction Essentially the algorithm gradually descends the error surface by moving in the locally downhill direction and different initial estimates may lead to Sampling with Automatic Gain Control 119 20 15 10 5 0 5 10 15 20 05 05 0 10 20 30 40 4 2 0 2 4 6 8 Jx Jx x x Figure 617 Error surfaces corresponding to a the objective function 64 and b the objective function 68 different minima This underscores one of the limitations of steepestdescent methodsif there are many minima then it is important to initialize near an acceptable one In some problems such prior information may easily be obtained while in others it may be truly unknown The examples of this section are somewhat simple because they involve static functions Most applications in communication systems deal with signals that evolve over time and the next section applies the steepestdescent idea in a dynamic setting to the problem of automatic gain control AGC The AGC provides a simple setting in which all three of the major issues in optimization must be addressed setting the goal choosing a method of solution and verifying that the method is successful Exercise 625 Consider performing an iterative maximization of Jx 8 6x 6 cos6x via 65 with the sign on the update reversed so that the algorithm will maxi mize rather than minimize Suppose the initialization is x0 07 a Assuming the use of a suitably small stepsize µ determine the convergent value of x b Is the convergent value of x in part a the global maximum of Jx Justify your answer by sketching the error surface Exercise 626 Suppose that a unimodal singlevariable performance function has only one point with zero derivative and that all points have a positive second derivative TRUE or FALSE A gradientdescent method will converge to the global minimum from any initialization Exercise 627 Consider the modulated signal rt wt cos2πfct φ where the absolute bandwidth of the baseband message waveform wt is less than fc2 The signals x and y are generated via xt LPFrt cos2pi fc t heta yt LPFrt sin2pi fc t heta where the LPF cutoff frequency is fc2 a Determine xt in terms of wt fc phi and heta b Show that fracdd heta leftfrac12 x2tright xt yt using the fact that derivatives and filters commute as in G5 c Determine the values of heta maximizing x2t Exercise 628 Consider the function Jx1x22 a Sketch Jx for 5 leq x leq 5 b Analytically determine all local minima and maxima of Jx for 5 leq x leq 5 Hint fracdfbdb signfb fracdfbdb where signa is defined in 69 c Is Jx unimodal as a function of x Explain your answer d Develop an iterative gradientdescent algorithm for updating x to minimize J e For an initial estimate of x12 what is the convergent value of x determined by an iterative gradientdescent algorithm with a satisfactorily small stepsize f Compute the direction either increasing x or decreasing x of the update from d for x12 g Does the direction determined in part f point from x12 toward the convergent value of part e Should it for a correct answer to e Explain your answer 67 Automatic Gain Control Any receiver is designed to handle signals of a certain average magnitude most effectively The goal of an AGC is to amplify weak signals and to attenuate strong signals so that they remain as much as possible within the normal operating range of the receiver Typically the rate at which the gain varies is slow compared with the data rate though it may be fast by human standards The power in a received signal depends on many things the strength of the broadcast the distance from the transmitter to the receiver the direction in which the antenna is pointed and whether there are any geographical features such as mountains or tall buildings that block reflect or absorb the signal Figure 618 The goal of the AGC is to maintain the dynamic range of the signal by attenuating it when it is too large as in a and by increasing it when it is too small as in b Figure 619 An automatic gain control adjusts the gain parameter a so that the average energy at the output remains roughly fixed despite fluctuations in the average received energy While more power is generally better from the point of view of trying to decipher the transmitted message there are always limits to the powerhandling 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 amplified Figure 618 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 effectively 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 619 The input rt is multiplied by the gain a to give the normalized signal st This is then sampled to give the output sk The assessment block measures sk and determines whether a must be increased or decreased The goal is to choose a so that the power or average energy of st is approximately equal to some specified S2 Since a2 avg r2ttkT approx avgs2kT approx avg s2k it would be ideal to choose a2 approx fracS2avgr2kT because this would imply that avgs2kT approx S2 The averaging operation in this case a moving average over a block of data of size N is defined by avgxk frac1N sumikN1k xi and is discussed in Appendix G in amazing detail Unfortunately neither the analog input rt nor its power is directly available to the assessment block in the DSP portion of the receiver so it is not possible to directly implement 611 Is there an adaptive element that can accomplish this task As suggested at the beginning of Section 65 there are three steps to the creation of a viable optimization approach setting a goal choosing a solution method and testing As in any reallife engineering task a proper mathematical statement of the goal can be tricky and this section proposes two slightly different possibilities for the AGC By comparing the resulting algorithms essentially alternative forms for the AGC design it may be possible to trade off among various design considerations One sensible goal is to try to minimize a simple function of the difference between the power of the sampled signal sk and the desired power S2 For instance the averaged squared error in the powers of s and S JLSa avgleftfrac14 lefts2k S2right2right frac14 avga2r2kTS22 penalizes values of a that cause s2k to deviate from S2 This formally mimics the parabolic form of the objective 64 in the polynomial minimization example of the previous section Applying the steepestdescent strategy yields ak1 ak mu leftfracdJLSadarightaak which is the same as 65 except that the name of the parameter has changed from x to a To find the exact form of 613 requires the derivative of JLSa with respect to the unknown parameter a This can be approximated by swapping the derivative and the averaging operations as formalized in G12 to give fracdJLSada frac14 davga2r2kT S22 approx frac14 avg leftfracda2r2kT S22daright avga2r2kT S2ar2kT The term a2r2kT inside the parentheses is equal to s2k The term ar2kT outside the parentheses is not directly available to the assessment mechanism though it can reasonably be approximated by s2ka Substituting the derivative into 613 and evaluating at a ak gives the algorithm ak 1 ak μ avgs2k S2 s2kak 614 Care must be taken when implementing 614 that ak does not approach zero Of course JLSa of 612 is not the only possible goal for the AGC problem What is important is not the exact form of the performance function but where the performance function has its optimal points Another performance function that has a similar error surface peek ahead to Figure 621 is JNa avgas2k3 S2 avgaa2r2kT3 S2 615 Taking the derivative gives dJNada d avgaa2r2kT3 S2da avgdaa2r2kT3 S2da avgsgnaks2k S2 where the approximation arises from swapping the order of the differentiation and the averaging recall G12 and the derivative of is the signum or sign function which holds as long as the argument is nonzero Evaluating this at a ak and substituting into 613 gives another AGC algorithm ak 1 ak μ avgsgnaks2k S2 616 Consider the logic of this algorithm Suppose that a is positive Since S is fixed avgsgnaks2k S2 avgs2k S2 avgs2k S2 Thus if the average energy in sk exceeds S2 a is decreased If the average energy in sk is less than S2 a is increased The update ceases when avgs2k S2 that is where a2 S2r2 as desired An analogous logic applies when a is negative The two performance functions 612 and 615 define the updates for the two adaptive elements in 614 and 616 JLSa minimizes the square of the deviation of the power in sk from the desired power S2 This is a kind of leastsquare performance function hence the subscript LS Such squarederror objectives are common and will reappear in phasetracking algorithms in Chapter 10 in clock recovery algorithms in Chapter 12 and in equalization algorithms in Chapter 13 On the other hand the algorithm resulting from JNa has a clear logical interpretation the N stands for naive and the update is simpler since 616 has fewer terms and no divisions To experiment concretely with these algorithms agcgradm provides an implementation in MATLAB It is easy to control the rate at which ak changes by 124 Chapter 6 Sampling with Automatic Gain Control choice of stepsize a larger µ allows ak to change faster while a smaller µ allows greater smoothing Thus µ can be chosen by the system designer to trade off the bandwidth of ak the speed at which ak 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 specified by the parameter lenavg will also influence the speed of adaptation longer averages imply slowermoving smoother estimates while shorter averages imply fastermoving more jittery esti mates Listing 66 agcgradm minimize the performance function Ja avga13a2r2 ds by choice of a n10000 number of s teps in simulation vr 10 power of the input rsqrt vr randnn 1 generate random inputs ds 015 des i r ed power of output mu0001 algorithm s t e p s i z e lenavg 10 length over which to average azeros n 1 a 11 i n i t i a l i z e AGC parameter szeros n 1 i n i t i a l i z e outputs aveczeros 1 lenavg vector to s tor e averaging terms for k1n1 s ka k r k normalize by a k add to avec avec sign a k s kˆ2 ds avec 1 lenavg 1 a k1a kmumean avec average adaptive update of a k end Typical output of agcgradm is shown in Figure 620 The gain parameter a adjusts automatically to make the overall power of the output s roughly equal to the specified parameter ds Using the default values above where the average power of r is approximately 1 we find that a converges to about 038 since 0382 015 S2 The objective JLSa can be implemented similarly by replacing the avec calculation inside the for loop with avec s kˆ2 ds s k ˆ2 a k avec 1 end 1 In this case with the default values a converges to about 022 which is the value that minimizes the leastsquare objective JLSa Thus the answer which minimizes JLSa is different from the answer which minimizes JNa More on this later As it is easy to see when playing with the parameters in agcgradm the size of the averaging parameter lenavg is relatively unimportant Even with lenavg1 the algorithms converge and perform approximately the same This is because the algorithm updates are themselves in the form of a lowpass filter See Appendix G for a discussion of the similarity between averagers and lowpass filters Removing the averaging from the update gives the simpler form for JNa a k1a kmusign a k s kˆ2 ds or for JLSa a k1a kmu s kˆ2 ds s k ˆ2 a k Sampling with Automatic Gain Control 125 0 2000 4000 6000 8000 10000 Iterations Amplitude Output sk Input rk Adaptive gain parameter 5 0 5 5 0 5 0 1 2 15 05 Figure 620 An automatic gain control adjusts the parameter a in the top panel automatically to achieve the desired output power 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 JLSa or JNa since they depend on the data sequence sk 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 steepestdescent algorithm for instance the objectives 64 and 68 dictates the evolution of the algorithms 66 and 610 The following code agcerrorsurfm shows how to calculate the error surface for JNa The variable n specifies the number of terms to average over and tot sums up the behavior of the algorithm for all n updates at each possible param eter value a The average of these totn is a close numerical approximation to JNa of 615 Plotting over all a gives the error surface Listing 67 agcerrorsurfm draw the error surface for the AGC n10000 number of s teps in simulation rrandnn 1 generate random inputs ds 015 des i r ed power of output range 0 7 0 0 2 0 7 s p e c i f y range of values of a Jagczeros size range j 0 for arange f o r each value a jj 1 tot 0 t o t a l cost for i 1n over a l l p o s s i b i l i t i e s tottotabs a 13 aˆ2 r i ˆ2 ds end Jagc j tot n take average value end 126 Chapter 6 Sampling with Automatic Gain Control 06 04 02 0 02 04 06 0 0005 0015 0025 cost JLSa 004 002 0 002 cost JNa Adaptive gain a 06 04 02 0 02 04 06 Adaptive gain a Figure 621 The error surface for the AGC objective functions 612 and 615 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 JLSa can be plotted using tottot 025aˆ2 r i ˆ2 ds ˆ2 er r or s ur f ace f o r JLS The output of agcerrorsurfm for both objective functions is shown in Figure 621 Observe that zero which is a critical point of the error surface is a local maximum in both cases The final converged answers a 038 for JNa and a 022 for JLSa occur at minima Were the algorithm to be initialized improperly to a negative value then it would converge to the negative of these values As with the algorithms in Figure 617 examination of the error surfaces shows why the algorithms converge as they do The parameter a descends the error surface until it can go no further But why do the two algorithms converge to different places The facile answer is that they are different because they minimize different performance functions Indeed the error surfaces in Figure 621 show minima in different locations The convergent value of a 038 for JNa is explicable because 0382 015 S2 The convergent value of a 022 for JLSa is calculated in closed form in Exercise 630 and this value does a good job minimizing its cost but it has not solved the problem of making a2 close to S2 Rather JLSa calculates a smaller gain that makes avgs2 S2 The minima are different The moral is this be wary of your performance functionsthey might do what you ask Exercise 629 Use agcgradm to investigate the AGC algorithm a What range of stepsize mu works Can the stepsize be too small Can the stepsize be too large b How does the stepsize mu affect the convergence rate c How does the variance of the input affect the convergent value of a d What range of averages lenavg works Can lenavg be too small Can lenavg be too large e How does lenavg affect the convergence rate Exercise 630 Show that the value of a that achieves the minimum of JLSa can be expressed as S2 k rk2 k rk4 Is there a way to use this closedform solution to replace the iteration 614 Exercise 631 Consider the alternative objective function Ja 12 a2 s2k6 S2 Calculate the derivative and implement a variation of the AGC algorithm that minimizes this objective How does this version compare with the algorithms 614 and 616 Draw the error surface for this algorithm Which version is preferable Exercise 632 Try initializing the estimate a12 in agcgradm Which minimum does the algorithm find What happens to the data record Exercise 633 Create your own objective function Ja 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 614 and 616 Draw the error surface for your algorithm Which version do you prefer Exercise 634 Investigate how the error surface depends on the input signal Replace randn with rand in agcerrorsurfm and draw the error surfaces for JNa and JLSa 68 Using an AGC to Combat Fading One of the impairments encountered in transmission systems is the degradation due to fading when the strength of the received signal changes in response to changes in the transmission path Recall the discussion in Section 415 on page 64 This section shows how an AGC can be used to counteract the fading assuming the rate of the fading is slow and provided the signal does not disappear completely Suppose that the input consists of a random sequence undulating slowly up and down in magnitude as in the top plot of Figure 622 The adaptive AGC compensates for the amplitude variations growing small when the power of the input is large and large when the power of the input is small This is shown in the middle graph The resulting output is of roughly constant amplitude as shown in the bottom plot of Figure 622 This figure was generated using the following code 128 Chapter 6 Sampling with Automatic Gain Control 5 x104 0 5 0 1 2 3 4 5 5 0 5 Input rk Adaptive gain parameter 05 1 0 15 Output sk Iterations Figure 622 When the signal fades top the adaptive parameter compensates middle allowing the output to maintain nearly constant power bottom Listing 68 agcvsfadingm compensating for fading with an AGC n50000 s teps in simulation rrandnn 1 generate random inputs env075abs sin 2 pi 1 n n the fading p r o f i l e rr env apply to raw input r k ds 05 des i r ed power of output azeros 1 n a 11 i n i t i a l i z e AGC parameter szeros 1 n i n i t i a l i z e outputs mu001 algorithm s t e p s i z e for k1n1 s ka k r k normalize by a to get s a k1a kmu s kˆ2 ds adaptive update of a k end The fading profile defined 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 635 Mimic the code in agcvsfadingm to investigate what happens when the input signal dies away Try removing the abs command from the fading profile variable Can you explain what you see Exercise 636 Mimic the code in agcvsfadingm 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 637 Would the answers to the previous two problems change on using algorithm 614 instead of 616 Sampling with Automatic Gain Control 129 69 Summary Sampling transforms a continuoustime analog signal into a discretetime 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 effectively The same AGC when adaptive can also provide a protection against signal fades The AGC can be designed using a steepestdescent optimization algorithm that updates the adaptive parameter by moving in the direction of the negative of the derivative This steepestdescent approach to the solution of optimization problems will be used throughout Software Receiver Design For Further Reading Details about resampling procedures are available in the published works of r Smith J O Bandlimited interpolationinterpretation and algorithm 1993 httpccrmawwwstanfordedujosresample A general introduction to adaptive algorithms centered around the steepest descent approach can be found in r B Widrow and S D Stearns Adaptive Signal Processing PrenticeHall 1985 One of our favorite discussions of adaptive methods is r C R Johnson Jr Lectures on Adaptive Parameter Estimation PrenticeHall 1988 7 Digital Filtering and the DFT Once the received signal is sampled the real story of the digital receiver begins An analog bandpass filter at the front end of the receiver removes extraneous signals for instance it removes televisionfrequency 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 filters are complicated and expensive to implement Digital filters 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 outof band 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 filters in the receiver and this chapter focuses on how to build digital filters The discussion begins by considering the digital impulse response and the related notion of discretetime 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 fluency in the spectral analysis of discrete data signals The final section on practical filter ing shows how to design digital filters with more or less any desired frequency response by using special Matlab commands 71 Discrete Time and Discrete Frequency The study of discretetime digital signals and systems parallels that of continuoustime analog signals and systems Many digital processes are fun damentally simpler than their analog counterparts though there are a few sub tleties unique to discretetime implementations This section begins with a brief overview and comparison and then proceeds to discuss the DFT which is the discrete counterpart of the Fourier transform Just as the impulse function δt plays a key role in defining signals and systems in continuous time the discrete pulse δk 1 k 0 0 k 0 71 can be used to decompose discrete signals and to characterize discretetime systems Any discretetime signal can be written as a linear combination of discrete impulses For instance if the signal wk is the repeating pattern 1 1 2 1 1 1 2 1 it can be written wk δk δk 1 2δk 2 δk 3 δk 4 δk 5 2δk 6 δk 7 In general the discretetime signal wk can be written wk j wj δk j This is the discrete analog of the sifting property 44 simply replace the integral with a sum and replace δt with δk Like their continuoustime counterparts discretetime systems map input signals into output signals Discretetime LTI linear timeinvariant systems are characterized by an impulse response hk which is the output of the system when the input is an impulse though of course 71 is used instead of 42 When an input xk is more complicated than a single pulse the output yk can be calculated by summing all the responses to all the individual terms and this leads directly to the definition of discretetime convolution yk j xjhk j xk hk 72 Observe that the convolution of discretetime sequences appears in the reconstruction formula 63 and that 72 parallels continuoustime convolution in 48 with the integral replaced by a sum and the impulse response ht replaced by hk The discretetime 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 informationpreserving transformation The pulse in discrete time is considerably more straightforward than the implicit definition of the continuoustime impulse function in 42 and 43 The DFT differs from the Fourier transform in three useful ways First it applies to discretetime 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 finite data record rather than an integration over all time Given a data record or vector wk of length N the DFT is defined by Wn k0N1 wkej2πNnk 73 for n 012 N1 For each value n 73 multiplies each term of the data by a complex exponential and then sums Compare this with the Fourier transform for each frequency f 21 multiplies each point of the waveform by a complex exponential and then integrates Thus Wn is a kind of frequency function in the same way that Wf is a function of frequency The next section will make this relationship explicit by showing how ej2πNnk can be viewed as a discretetime sinusoid with frequency proportional to n Just as a plot of the frequency function Wf is called the spectrum of the signal wt plots of the frequency function Wn are called the discrete spectrum of the signal wk One source of confusion is that the frequency f in the Fourier transform can take on any value while the frequencies present in 73 are all integer multiples n of a single fundamental with frequency 2πN This fundamental is precisely the sine wave with period equal to the length N of the window over which the DFT is taken Thus the frequencies in 73 are constrained to a discrete set these are the discrete frequencies of the section title The most common implementation of the DFT is called the fast Fourier transform FFT which is an elegant way to rearrange the calculations in 73 so that it is computationally efficient For all purposes other than numerical efficiency the DFT and the FFT are synonymous Like the Fourier transform the DFT is invertible Its inverse the IDFT is defined by wk 1N n0N1 Wnej2πNnk 74 for k 012 N1 The IDFT takes each point of the frequency function Wn multiplies by a complex exponential and sums Compare this with the IFT D2 takes each point of the frequency function Wf multiplies by a complex exponential and integrates Thus the Fourier transform and the DFT translate from the time domain into the frequency domain while the inverse Fourier transform and the IDFT translate from frequency back into time Many other aspects of continuoustime signals and systems have analogs in discrete time Here are some that will be useful in later chapters Symmetryif the time signal wk is real then Wn WNn This is analogous to A35 Parsevals theorem holds in discrete timek w²k 1N n Wn² This is analogous to A43 The frequency response Hn of an LTI system is the DFT of the impulse response hk This is analogous to the continuoustime result that the frequency response Hf is the Fourier transform of the impulse response ht Timedelay property in discrete timewkl Wnej2πNl This is analogous to A37 Modulation propertythis frequencyshifting property is analogous to A34 If wk sin2πfkT is a periodic sine wave then the spectrum is a sum of two delta impulses This is analogous to the result in Example 41 Convolution² in discrete time is the same as multiplication in discrete frequency This is analogous to 410 Multiplication in discrete time is the same as convolution in discrete frequency This is analogous to 411 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 412 Exercise 71 Show why Parsevals theorem is true in discrete time Exercise 72 Suppose a filter has impulse response hk When the input is xk the output is yk Show that if the input is xdk xk xk1 then the output is ydk yk yk1 Compare this result with Exercise 413 Exercise 73 Let wk sin2πkN for k 12 N1 Use the definitions 73 and 74 to find the corresponding values of Wn 711 Understanding the DFT Define a vector W containing all N frequency values and a vector w containing all N time values w w0 w1 w2 wN1T W W0 W1 W2 WN1T 2 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 discretetime convolution in the time and frequency domains in a concrete way using waystofiltm on page 143 and let M1 be a matrix with columns of complex exponentials 1 1 1 1 1 1 ej2πN ej4πN ej6πN ej2πN1N 1 ej4πN ej8πN ej12πN ej4πN1N 1 ej6πN ej12πN ej18πN ej6πN1N 1 ej2πN1N ej4πN1N ej6πN1N ej2πN12N Then the IDFT equation 74 can be rewritten as a matrix multiplication w 1N M1 W 75 and the DFT is W NMw 76 Since the inverse of an orthonormal matrix is equal to its own complex conjugate transpose M in 76 is the same as M1 in 75 with the signs on all the exponents flipped The matrix M1 is highly structured Let Cn be the nth column of M1 On multiplying both sides by N 75 can be rewritten as Nw W0C0 W1C1 WN1CN1 n0N1 WnCn 77 This form displays the time vector w as a linear combination³ of the columns Cn What are these columns They are vectors of discrete complexvalued sinusoids each at a different frequency Accordingly the DFT reexpresses the time vector as a linear combination of these sinusoids The complex scaling factors Wn define how much of each sinusoid is present in the original signal wk To see how this works consider the first few columns C0 is a vector of all ones it is the zerofrequency sinusoid or DC C1 is more interesting The ith element of C1 is ej2πiN which means that as i goes from 0 to N1 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 lowestfrequency sinusoid that can be represented other than DC it is the sinusoid that fits exactly one period in the time interval NTs where Ts is the distance in time between adjacent samples C2 is similar except that the ith element is ej4πiN Again the magnitude is unity and the phase is 4iπN radians Thus as i goes from 0 to N1 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 fits exactly two periods into 3 Those familiar with advanced linear algebra will recognize that M1 can be thought of as a change of basis that reexpresses w in a basis defined by the columns of M1 the time interval N Ts Similarly Cn represents a complex sinusoid of frequency n times that of C1 it orbits the circle n times and is the sinusoid that fits exactly n periods in the time interval N Ts One subtlety that can cause confusion is that the sinusoids in Ci are complexvalued yet most signals of interest are real Recall from Eulers identities 24 and A3 that the realvalued sine and cosine can each be written as a sum of two complexvalued exponentials that have exponents with opposite signs The DFT handles this elegantly Consider CN1 This is 1 ej2N1πN ej4N1πN ej6N1πN ej2N12 πNT which can be rewritten as 1 ej2πN ej4πN ej6πN ej2πN1NT since ej2π 1 Thus the elements of CN1 are identical to the elements of C1 except that the exponents have the opposite sign implying that the angle of the ith entry in CN1 is 2iπN radians Thus as i goes from 0 to N 1 the exponential assumes N uniformly spaced points around the unit circle in the opposite direction from C1 This is the meaning of what might be interpreted as negative frequencies that show up when taking the DFT The complex exponential proceeds in a negative clockwise manner around the unit circle rather than in a positive counterclockwise direction But it takes both to make a realvalued sine or cosine as Eulers formula shows For realvalued sinusoids of frequency 2πnN both Wn and WN n are nonzero and they are equal in magnitude⁴ Exercise 74 Which column Ci represents the highest possible frequency in the DFT What do the elements of this column look like Hint look at CN2 and think of a square wave This square wave is the highest frequency that can be represented by the DFT and occurs at exactly the Nyquist rate 712 Using the DFT Fortunately MATLAB makes it easy to do spectral analysis with the DFT by providing a number of simple commands that carry out the required calculations and manipulations It is not necessary to program the sum 73 or the matrix multiplication 75 The singleline commands W fftw and w ifftW invoke efficient FFT and IFFT routines when possible and relatively inefficient DFT and IDFT calculations otherwise The numerical idiosyncrasies are completely transparent with one annoying exception In MATLAB all vectors including W and w must be indexed from 1 to N instead of from 0 to N 1 ⁴ The discrete version of the symmetry property A35 shows that Wn WN n Hence the magnitudes are equal but the phases have opposite signs 136 Chapter 7 Digital Filtering and the DFT 0 200 400 600 800 1000 1200 What do these mean Magnitude N 210 0 500 1000 1500 2000 2500 Magnitude N 211 Figure 71 Naive and deceptive plots of the spectrum of a sine wave in which the frequency of the analyzed wave appears to depend on the size N of the analysis window The top figure has N 210 while the bottom uses N 211 While the FFTIFFT commands are easy to invoke their meaning is not always instantly transparent The intent of this section is to provide some exam ples that show how to interpret and how not to interpret the frequencyanalysis commands in Matlab Begin with a simple sine wave of frequency f sampled every Ts seconds as is familiar from previous programs such as speccosm The first step in any frequency analysis is to define the window over which the analysis will take place since the FFTDFT must operate on a finite data record The program specsin0m defines the length of the analysis with the variable N powers of two make for fast calculations and then analyzes the first N samples of w It is tempting to simply invoke the Matlab commands fft and to plot the results Typing plotfftw1N 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 first use the abs command as shown in specsin0m Listing 71 specsin0m naive and deceptive spectrum of a sine wave via the FFT f 100 Ts11000 time 50 freq sampling i nter val time tTs Ts time def i ne a time vector wsin 2 pi f t def i ne the s i nus oi d N2ˆ10 s i z e of a n a l y s i s window fwabs f f t w 1 N f i nd magnitude of DFTFFT plot fw pl ot the 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 71 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 71 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 Digital Filtering and the DFT 137 0 100 200 300 400 500 Magnitude 500 400 300 200 100 0 100 200 300 400 500 Magnitude Frequency Figure 72 Proper use of the FFT command can be done as in specsin1m the top graph which plots only the positive frequencies or as in specsin2m the bottom graph which shows the full magnitude spectrum symmetric about f 0 There are two problems First specsin0m plots the magnitude data against the index of the vector fw and this index by itself is meaningless The dis cussion surrounding 77 shows that each element of Wn represents a scaling of the complex sinusoid with frequency ej2πnN 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 76 the frequencies represented by the WN n are the negative of the frequencies represented by Wn There are two solutions The first is appropriate only when the original sig nal is realvalued In this case the Wns 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 specsin1m Listing 72 specsin1m spectrum of a sine wave via the FFTDFT f 100 Ts11000 time 50 freq sampling i nter val time tTs Ts time def i ne a time vector wsin 2 pi f t def i ne the s i nus oi d N2ˆ10 s i z e of a n a l y s i s window s s f 0N2 1TsN frequency vector fwabs f f t w 1 N f i nd magnitude of DFTFFT plot s s f fw 1 N2 pl ot f o r p o s i t i v e f r eq only The output of specsin1m is shown in the top plot of Figure 72 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 continuoustime intuition and graphs specsin2m exploits the builtin function fftshift which shuffles the output of the FFT com mand so that the negative frequencies occur on the left the positive frequencies on the right and DC in the middle 138 Chapter 7 Digital Filtering and the DFT Listing 73 specsin2m spectrum of a sine wave via the FFTDFT f 100 Ts11000 time 100 freq sampling i nter val time tTs Ts time def i ne a time vector wsin 2 pi f t def i ne the s i nus oi d N2ˆ10 s i z e of a n a l y s i s window s s f N2N2 1 TsN frequency vector fwf f t w 1 N do DFTFFT fwsf f t s h i f t fw s h i f t i t f o r p l o t t i n g plot s s f abs fws pl ot magnitude spectrum Running this program results in the bottom plot of Figure 72 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 75 Explore the limits of the FFTDFT 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 1500 1250 150 Comment on the rela tionship 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 76 Replace the sin function with sin2 Use wsin2piftˆ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 77 Replace the sin function with sinc What is the spectrum of the sinc function What is the spectrum of sinc2 Exercise 78 Plot the spectrum of wt sint jet Should you use the technique of specsin1m or of specsin2m Hint think symmetry Exercise 79 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 wsin2piftphi For phi 0 02 04 08 15 314 find the phase of the FFT output at the frequencies f b Find the phase of the output of the FFT when wsin2piftphiˆ2 These are all examples of simple functions which can be investigated in principle anyway analytically The greatest strength of the FFTDFT is that it can also be used for the analysis of data when no functional form is known Digital Filtering and the DFT 139 There is a data file on the website called gongwav which is a sound recording of an Indonesian gong a large struck metal plate The following code reads in the waveform and analyzes its spectrum using the FFT Make sure that the file gongwav is in an active Matlab path or you will get a file not found error If there is a sound card and speakers attached the sound command plays the wav file at the sampling rate fs 1Ts Listing 74 specgongm find spectrum of the gong sound filenamegongwav name of wave f i l e x s r wavread filename read in w avef i l e Ts1 s r sample i n t e r v a l of samples N2ˆ15 xx 1 N length f o r a n a l y s i s soundx 1 Ts play sound i f p o s s i b l e timeTs 0 length x 1 time base f o r p l o t t i n g subplot 2 1 1 plot time x and pl ot top f i g u r e magxabs f f t x take FFT magnitude s s f 0N2 1TsN f r eq base f o r p l o t t i n g subplot 2 1 2 plot s s f magx 1 N2 pl ot mag spectrum Running specgongm results in the plot shown in Figure 73 The top figure shows the time behavior of the sound as it rises very quickly when the gong is struck and then slowly decays over about 15 s The variable N defines the window over which the frequency analysis occurs The lowerleft plot shows the complete spectrum and the bottomright plot zooms in on the lowfrequency 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 specgongm analyzes approximately 15 s TsN seconds to be precise It is reasonable to suppose that the gong sound might undergo important transients during the first few milliseconds This can be investigated by decreasing N and applying the DFT to different segments of the data record Exercise 710 Determine the spectrum of the gong sound during the first 01 s What value of N is needed Compare this with the spectrum of a 01 s segment chosen from the middle of the sound How do they differ Exercise 711 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 specgongm What extra details can you see Exercise 712 The waveform of the sound produced by another much larger gong is given in gong2wav 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 713 Choose a wav file from the website in the Sounds folder or download a wav file of a song from the Internet Conduct a FFT analysis of the first few seconds of sound and then another analysis in the middle of the song 140 Chapter 7 Digital Filtering and the DFT 0 05 1 Time in seconds Frequency in Hertz 15 1 0 1 Amplitude 0 05 2 15 1 25 0 1 2 3 4 Magnitude Frequency in Hertz 400 450 500 750 800 600 650 700 550 0 1 2 3 4 x104 Figure 73 Time and frequency plots of the gong waveform The top figure shows the decay of the signal over 15 s The bottom left figure shows the magnitude spectrum and the right figure zooms in on the lowfrequency 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 FFTbased frequency analysis are as follows r The sampling interval Ts is the time resolution the shortest time over which any event can be observed The sampling rate fs 1Ts is inversely propor tional r The total time is T NTs where N is the number of samples in the analysis r The frequency resolution is 1T 1NTs fsN Sinusoids closer together in frequency than this value are indistinguishable For instance in the analysis of the gong conducted in specgongm the sampling interval Ts 144100 is defined by the recording With N 216 the total time is NTs 148 s and the frequency resolution is 1NTs 067 Hz Sometimes the total absolute time T is fixed Sampling faster decreases Ts and increases N but cannot give better resolution in frequency Sometimes it is pos sible to increase the total time Assuming a fixed Ts this implies an increase in N and better frequency resolution Assuming a fixed 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 res olution in frequency If this is still confusing or if you would like to see it from a different perspective check out Appendix D The DFT is a key tool in analyzing and understanding the behavior of com munications systems Whenever data flow 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 Digital Filtering and the DFT 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 72 Practical Filtering Filtering can be viewed as the process of emphasizing or attenuating certain frequencies within a signal Linear timeinvariant filters are common because they are easy to understand and straightforward to implement Whether in discrete or continuous time an LTI filter is characterized by its impulse response ie 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 filtering operation Thus while implementing the filter in the time domain as a convolution it is normal to specify design and understand it in the frequency domain as a pointbypoint multiplication of the spectrum of the input and the frequency response of the filter In principle this provides a method not only of understanding the action of a filter but also of designing a filter 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 filter that removes the noisy frequencies and passes the signal frequencies This intuitive notion translates directly into a mathematical specification for the frequency response The impulse response can then be calculated directly by taking the inverse transform and this impulse response defines the desired filter While this is the basic principle of filter design a number of subtleties can arise and sophisticated routines are available in Matlab that make the filter design process flexible even if they are not foolproof Filters are classified in several ways r Lowpass filters LPF try to pass all frequencies below some cutoff frequency and remove all frequencies above r Highpass filters try to pass all frequencies above some specified value and remove all frequencies below r Notch or bandstop filters try to remove particular frequencies usually in a narrow band and to pass all others r Bandpass filters try to pass all frequencies in a particular range and to reject all others 142 Chapter 7 Digital Filtering and the DFT The region of frequencies allowed to pass through a filter 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 filter specifications can be implemented as sums and concatenations of the above basic filter types For instance if h1k is the impulse response of a bandpass filter that passes only frequencies between 100 and 200 Hz and h2k is the impulse response of a bandpass filter that passes only frequencies between 500 and 600 Hz then hk h1k h2k passes only frequencies between 100 and 200 Hz or between 500 and 600 Hz Similarly if hlk is the impulse response of a lowpass filter that passes all frequencies below 600 Hz and hhk is the impulse response of a highpass filter that passes all frequencies above 500 Hz then hk hlk hhk is a bandpass filter that passes only frequencies between 500 and 600 Hz where represents convolution Filters are also classified by the length of their impulse response If the output of a filter depends only on a specified number of samples the filter is said to have a finite impulse response abbreviated FIR Otherwise it is said to have an infinite impulse response abbreviated IIR The bulk of the filters in Software Receiver Design are FIR filters with a flat passband because these are the most common filters in a typical receiver But other filter profiles are possible and the techniques of filter design are not restricted to flat passbands Section 721 shows several ways that digital FIR filters can be implemented in Matlab IIR filters arise whenever there is a loop such as in a phaselocked loop and one special case the integrator is an intrinsic piece of the adaptive elements Section 722 shows how to implement IIR filters Section 723 shows how to design filters with specific properties and how they behave on a number of test signals 721 Implementing FIR Filters Suppose that the impulse response of a discretetime filter is hi i 0 1 2 N 1 If the input to the filter is the sequence xi i 0 1 M 1 then the output is given by the convolution Equation 72 There are four ways to implement this filtering in Matlab r conv directly implements the convolution equation and outputs a vector of length N M 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 differences is to play with the four methods Digital Filtering and the DFT 143 Listing 75 waystofiltm conv vs filter vs freq domain vs time domain h1 1 2 2 3 3 impulse response h k x1 2 3 4 5 6 5 4 3 2 1 input data x k yconvconvh x convolve x k h k y f i l tf i l t e r h 1 x f i l t e r x k with h k nlength hlength x 1 pad length f o r FFT f f t hf f t h zeros 1 nlength h FFT of h k i s H n f f t xf f t x zeros 1 nlength x FFT of input i s X n f f t yf f t h f f t x product of H n and X n yfreqreal i f f t f f t y IFFT of product gi ves y k zzeros 1 length h 1 x i n i t i a l f i l t e r s tate 0 for k1 length x timedomain method ytim k f l i p l r h z k klength 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 first M terms of yconv yfilt yfreq and ytim are the same but that both yconv and yfreq have N1 extra values at the end For both the timedomain method and the filter command the output values are aligned in time with the input values one output for each input Effectively the filter command is a singleline implementation of the timedomain for loop For the FFT method the two vectors input and convolution must both have length NM1 The raw output has complex values due to numerical roundoff and the command real is used to strip away the imaginary parts Thus the FFTbased method requires more Matlab commands to implement Observe also that convhx and convxh are the same whereas filterh1x is not the same as filterx1h To view the frequency response of the filter h Matlab provides the command freqz which automatically zero pads5 the impulse response and then plots both the magnitude and the phase Type f r eqz h to see that the filter with impulse response h1 1 1 1 1 is a poor lowpass filter with two dips at 04 and 08 of the Nyquist frequency as shown in Figure 74 The command freqz always normalizes the frequency axis so that 10 corresponds to the Nyquist frequency fs2 The passband of this filter all frequencies less than the point where the magnitude drops 3 dB below the maximum ends just below 02 The maximum magnitude in the stopband occurs at about 06 where it is about 12 dB down from the peak at zero Better ie closer to the ideal lowpass filters would attenuate more in the stopband would be flatter across the passband and would have narrower transition bands 5 By default the Matlab command freqz creates a vector of length 512 that contains the specified 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 In discrete time crosscorrelation is a function of the time shift j between two sequences wk and vk j Rwvj limT 1T kT2T2 wkvk j 83 For finite data records the sum need only be accumulated over the nonzero elements and the normalization by 1T is often ignored This is how MATLABs xcorr function works While this may look like the convolution Equation 72 it is not identical since the indices are different 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 crosscorrelation quantifies the similarity of two signals In many communication systems each message is parcelled into segments or frames each having a predefined 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 predefined 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 82 correxm correlation can locate the header within the data header1 1 1 1 1 1 1 1 1 1 header is predefined string loc30 r25 place header in position loc datasignrandn1loc 1 header signrandn1r make signal sd025 datadatasdrandnsizedata add noise yxcorrheader data do crosscorrelation mindmaxy find largest correlation headstartlengthdataind1 place where header starts Running correxm results in a trio of figures much like those in Figure 82 Details will differ each time it is run because the actual data are randomly generated with MATLABs randn function The top plot in Figure 82 shows the 10sample 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 82 Observe that it is difficult 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 82 as a function of the lag index The index for which the correlation attains its largest value defines where the best match between the data and the header occurs Most likely this will be at index ind35 as in Figure 82 Because of the way MATLAB orders its output the calculations represent sliding the first vector the header term by term across the second vector the Digital Filtering and the DFT 145 z1 b a yk1 xk xk yk yk b Σ Delay Figure 75 The LTI system yk 1 ayk bxk with input xk and output yk is represented schematically using the delay z1 in this simple block diagram The special case when a 1 is called a summer because it effectively adds up all the input values and it is often drawn more concisely as on the right side of the figure where a a0 a1 anT b b0 b1 bmT are column vectors of the parameters of the filter and where xk xk xk 1 xk mT yk yk yk 1 yk nT are vectors of past input and output data The symbol zT 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 imple ments a complex conjugate as well as transpose Matlab has a number of functions that make it easy to explore IIR filtering For example the function impz plots the impulse response of a discrete IIR or FIR filter The impulse response of the system 78 is found by entering b1 a1 08 impz b a The parameters are the vectors bb0 b1 bm and a1 a0 a1 an Hence the above code gives the response when a of 78 is 08 Similarly the command freqzba displays the frequency response for the IIR filter where b and a are constructed in the same way The routine waystofiltIIRm explores ways of implementing IIR filters The simplest method uses the filter command For instance filterbad filters the data d through the IIR system with parameters b and a defined as above This gives the same output as first calculating the impulse response h and then using filterh1d The fastest and most general way to implement the filter is in the for loop at the end which mimics the timedomain method for FIR filters but includes the additional parameters a Listing 76 waystofiltIIRm ways to implement IIR filters a1 08 lenalength a 1 a u t o r e g r e s s i v e c o e f f i c i e n t s b 1 lenblength b moving average c o e f f i c i e n t s drandn 1 2 0 data to f i l t e r 146 Chapter 7 Digital Filtering and the DFT i f lenalenb dimpulse needs lenalenb himpz b a impulse response of f i l t e r y f i l tf i l t e r h 1 d f i l t e r x k with h k end y f i l t 2f i l t e r b a d f i l t e r using a and b yzeros lena 1 xzeros lenb 1 i n i t i a l s t a t e s in f i l t e r for k1length dlenb timedomain method xd k x 1 lenb 1 past values of inputs ytim ka 2 lena 1ybx d i r e c t l y c a l c u l a t e y k yytim k y 1 lena 1 past values of outputs end Like FIR filters IIR filters can be lowpass bandpass and highpass or can have almost any imaginable effect on the spectrum of their input Exercise 714 Some IIR filters can be used as inverses to some FIR filters Show that the FIR filter xk 1 brk a b rk 1 is an inverse of the IIR filter 78 Exercise 715 FIR filters can be used to approximate the behavior of IIR filters by truncating the impulse response Create a FIR filter with impulse response given by the first 10 terms of 79 for a 09 and b 2 Simulate the FIR filter and the IIR filter 78 in Matlab using the same random input to both Verify that the outputs are approximately the same 723 Filter Design This section gives an extended explanation of how to use Matlab to design a bandpass filter to fit a specified frequency response with a flat passband The same procedure with suitable modification also works for the design of other basic filter types A bandpass filter is intended to scale but not distort signals with frequen cies that fall within the passband and to reject signals with frequencies in the stopband An ideal distortionless response for the passband would be perfectly flat 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 pos sible In the stopband the frequency response magnitude should be sufficiently small and the phase is of no concern These objectives are captured in Figure 76 Recall from A35 for a real wt that Wf is even and Wf is odd as illustrated in Figure 76 Matlab has several commands that carry out filter design The firpm com mand6 provides a linear phase impulse response with real symmetric coefficients 6 Some early versions of Matlab use remez instead of firpm Digital Filtering and the DFT 147 H f H f Transition region Transition region Passband Stopband f Lower band edge Upper band edge Figure 76 Specifications of a realvalued bandpass filter in terms of magnitude and phase spectra hk that has the best approximation of a specified piecewiseflat frequency response7 The syntax of the firpm command for the design of a bandpass filter as in Figure 76 is b firpm f l fbe damps which has inputs fl fbe and damps and output b r fl specifies one fewer than the number of terms in the impulse response of the desired filter Generally more is better in terms of meeting the design specifications 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 r fbe is a vector of frequency band edge values as a fraction of the prevailing Nyquist frequency For example the filter specified in Figure 76 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 r 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 r b is the output vector containing the impulse response of the specified filter 7 There are many possible meanings of the word best for the firpm algorithm best is defined in terms of maintaining an equal ripple in the flat portions 148 Chapter 7 Digital Filtering and the DFT 80 60 40 20 0 20 Magnitude Response dB 0 01 02 03 04 05 06 07 08 09 1 Normalized frequency Nyquist 1 1500 1000 500 0 500 Phase degrees Figure 77 Frequency response of the bandpass filter designed by the firpm command in bandexm The variable fbe specifies a set of frequencies as a fraction of the Nyquist rate and damps specifies the corresponding amplitudes The freqz command plots both the magnitude and phase spectra of the filter The following Matlab script designs a filter that mimics Figure 76 Listing 77 bandexm design a bandpass filter and plot frequency response fbe 0 024 026 074 076 1 f r eq band edges as a f r a c t i o n of the Nyquist frequency damps0 0 1 1 0 0 des i r ed amplitudes at band edges f l 30 f i l t e r s i z e bfirpm f l fbe damps b i s the designed impulse response figure 1 f r eqz b pl ot f r eq response to check design The frequency response of the resulting finite impulse response FIR filter is shown in Figure 77 Observe that the stopband is about 14 dB lower than the passband a marginal improvement over the naive lowpass filter of Figure 74 but the design is much flatter in the passband The equiripple nature of this filter is apparent in the slow undulations of the magnitude in the passband Designing IIR filters is also straightforward For example the code b acheby1 1 0 5 0 2 5 designs a 10thorder lowpass filter with 5 dB of ripple in the passband which extends from DC to 025 times the Nyquist rate While commands such as firpm and cheby1 make filter design easy be warnedstrange things can happen even to nice filters Whenever using any of the filter design tools always check freqzba to verify that the output of the design behaves as anticipated There are many other ways to design LTI filters and Matlab includes several commands that design filter coefficients cfirpm firls fir1 fir2 butter cheby2 and ellip The subject of filter design is vast and each of these is useful in certain applications For simplic ity we have chosen to present most examples throughout Software Receiver Design by using firpm Digital Filtering and the DFT 149 Exercise 716 Rerun bandexm with very narrow transition regions for instance fbe 0 024 02401 06 0601 1 What happens to the ripple in the passband Compare the minimum magnitude in the passband with the max imum value in the stopband Exercise 717 Returning to the filter specified in Figure 76 try using different numbers of terms in the impulse response fl 5 10 100 500 1000 Comment on the resulting designs in terms of flatness of the frequency response in the passband attenuation from the passband to the stopband and the width of the transition band Exercise 718 Specify and design a lowpass filter with cutoff at 015 What values of fl fbe and damps work best Exercise 719 Specify and design a filter that has two passbands one between 02 03 and another between 05 06 What values of fl fbe and damps work best Exercise 720 Use the filter designed in bandexm to filter a white noise sequence generated by randn using the timedomain method from waystofiltm Verify that the output has a bandpass spectrum The preceding filter 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 filter design task Exercise 721 In Exercise 710 the program specgongm was used to ana lyze 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 filter using firpm that will remove the two highest partials from this sound without affecting the lowest partial b Use the filter command to process the gongwav file with your filter c Take the FFT of the resulting signal the output of your filter 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 filtered gong sound by using Matlabs sound command Comment on what you hear The next set of problems examines how accurate digital filters really are Exercise 722 With a sampling rate of 44100 Hz let xk be a sinusoid of frequency 3000 Hz Design a lowpass filter with a cutoff frequency fl of 1500 Hz and let yk LPFxk be the output of the filter 150 Chapter 7 Digital Filtering and the DFT a How much does the filter attenuate the signal Express your answer as the ratio of the power in the output yk to the power in the input xk b Now use an LPF with a cutoff of 2500 Hz How much does the filter attenuate the signal c Now use an LPF with a cutoff of 2900 Hz How much does the filter attenuate the signal Exercise 723 Repeat Exercise 722 without using the filter command implement the filtering using the timedomain method in waystofiltm Exercise 724 With the same setup as in Exercise 722 generate xk as a bandlimited noise signal containing frequencies between 3000 Hz and the Nyquist rate a Use an LPF with cutoff frequency fl of 1500 Hz How much does the filter attenuate the signal b Now use an LPF with a cutoff of 2500 Hz How much does the filter attenuate the signal c Now use an LPF with a cutoff of 3100 Hz How much does the filter attenuate the signal d Now use an LPF with a cutoff of 4000 Hz How much does the filter attenuate the signal Exercise 725 Let f1 f2 f3 Suppose xk has no frequencies above f1 Hz while zk has no frequencies below f3 If an LPF has cutoff frequency f2 in principle LPFxk zk LPFxk LPFzk xk 0 xk Explain how this is and is not consistent with the results of Exercises 722 and 724 Exercise 726 Let the output yk of an LTI system be created from the input xk according to the formula yk 1 yk µxk where µ is a small constant This is drawn in Figure 75 a What is the impulse response of this filter b What is the frequency response of this filter c Would you call this filter lowpass highpass or bandpass Exercise 727 Using one of the alternative filter design routines cfirpm firls fir1 fir2 butter cheby1 cheby2 or ellip repeat Exercises 716 721 Comment on the subtle and the notsosubtle differences in the resulting designs Digital Filtering and the DFT 151 Exercise 728 The effect of bandpass filtering can be accomplished by a modulating to DC b lowpass filtering and c modulating back Repeat the task given in Exercise 721 the Indonesian gong filter design problem by modulating with a 520 Hz cosine lowpass filtering and then remodulating Compare the final output of this method with the direct bandpass filter design For Further Reading Here are some of our favorite books on signal processing r K Steiglitz A Digital Signal Processing Primer AddisonWesley 1996 r J H McClellan R W Schafer and M A Yoder DSP First A Multimedia Approach PrenticeHall 1998 r C S Burrus and T W Parks DFTFFT and Convolution Algorithms Theory and Implementation WileyInterscience 1985 8 Bits to Symbols to Signals 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 efficiently these symbols are then translated again into short analog waveforms called pulse shapes that are com bined 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 sym bols back into binary digits from which the original message can with luck be reconstructed This chapter briefly 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 patternmatching tool for discovering key locations within the signal stream Section 83 shows how correlation can be viewed as a kind of linear filter and hence its properties can be readily understood both in the time and in the frequency domain 81 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 flow of electrons in a wire a digitized image or sound file the text in a book If the information is in analog form then it can be sampled as in Chapter 6 For instance an analogtodigital 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 flow The sound file which is already digital contains a long list of numbers that correspond to the instantaneous amplitude of the sound Similarly the picture file contains a list of numbers that describe the intensity and color of the pixels in the image Bits to Symbols to Signals 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 re expressed 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 efficient 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 difference 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 twoelement 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 fourlevel signal For example the binary sequence might be paired thus 000010110101 00 00 10 11 01 01 81 Then the pairs might be encoded as 11 3 10 1 01 1 00 3 82 to produce the symbol sequence 00 00 10 11 01 01 3 3 1 3 1 1 Of course there are many ways in which such a mapping between bits and symbols might be made and Exercise 82 explores one simple alternative called the Gray code The binary sequence may be grouped in many ways into triplets for an 8level signal into quadruplets for a 16level scheme into inphase and quadrature parts for transmission through a quadrature system The values assigned to the groups 1 3 in 82 are called the alphabet of the given system Example 81 Text is commonly encoded using ASCII and Matlab automat ically represents any string file as a list of ASCII numbers For instance let strI am text be a text string This can be viewed in its internal form by typing realstr 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 Chapter 8 Bits to Symbols to Signals in binary using dec2basestr28 which returns the binary base 2 repre sentation of the decimal numbers each with eight digits The Matlab function letters2pamm provided on the website changes a text string into the fourlevel alphabet 1 3 Each letter is represented by a sequence of four elements for instance the letter I is 1 3 1 1 The func tion is invoked with the syntax letters2pamstr The inverse operation is pam2lettersm Thus pam2lettersletters2pamstr returns the original string One complication in the decoding procedure is that the receiver must figure out when the groups begin in order to parse the digits properly For example if the first element of the sequence in 81 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 patternmatching technique This is discussed in detail in Section 83 Example 82 There are many ways to translate data into binary equiva lents Example 81 showed one way to convert text into 4PAM and then into binary Another way exploits the Matlab function text2binm and its inverse bin2textm which use the 7bit version of the ASCII code rather than the 8bit version This representation is more efficient since each pair of text letters can be represented by 14 bits or seven 4PAM symbols rather than 16 bits or eight 4PAM symbols On the other hand the 7bit version can encode only half as many characters as the 8bit version Again it is important to be able to correctly identify the start of each letter when decoding Exercise 81 The Matlab code in naivecodem which is on the website implements the translation from binary to 4PAM and back again suggested in 82 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 82 A Gray code has the property that the binary representation for each symbol differs from its neighbors by exactly one bit A Gray code for the Bits to Symbols to Signals 155 translation of binary into 4PAM is 01 3 11 1 10 1 00 3 Mimic the code in naivecodem to implement this alternative and plot the num ber of errors as a function of the noise variance v Compare your answer with Exercise 81 Which code is better 82 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 ie multiplied by 1 to represent the element 1 This is called a polar nonreturntozero line code The problem with such simple codes is that they use bandwidth inefficiently Recall that the Fourier transform of the rectangular pulse in time is the sincf function in frequency A20 which dies away slowly as f increases Thus simple codes like the nonreturntozero are compact in time but wide in frequency limiting the number of simultaneous nonoverlapping users in a given spectral band More generally consider the fourlevel signal of 82 This can be turned into an analog signal for transmission by choosing a pulse shape pt that is not necessarily rectangular and not necessarily of duration T and then transmitting pt kT if the kth symbol is 1 pt kT if the kth symbol is 1 3pt kT if the kth symbol is 3 3pt kT if the kth symbol is 3 Thus the sequence is translated into an analog waveform by initiating a scaled pulse at the symbol time kT where the amplitude scaling is proportional to the associated symbol value Ideally the pulse would be chosen so that r the value of the message at time k does not interfere with the value of the message at other sample times the pulse shape causes no intersymbol inter ference r the transmission makes efficient use of bandwidth and r the system is resilient to noise Unfortunately these three requirements cannot all be optimized simultaneously and so the design of the pulse shape must consider carefully the tradeoffs that are needed The focus in Chapter 11 is on how to design the pulse shape pt and the 156 Chapter 8 Bits to Symbols to Signals 0 01 02 03 04 05 06 07 08 09 The pulse shape 0 02 04 06 08 1 0 10 20 30 40 50 60 70 80 90 100 The waveform representing Transmit this text 3 2 1 0 1 2 3 Figure 81 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 consequences of that choice in terms of possible interference between adjacent symbols and in terms of the signaltonoise properties of the transmission For now to see concretely how pulse shaping works lets pick a simple non rectangular shape and proceed without worrying about optimality Let pt be the symmetric blip shape shown in the top part of Figure 81 and defined in pulseshapem by the hamming command The text string in str is changed into a fourlevel signal as in Example 81 and then the complete transmitted wave form is assembled by assigning an appropriately scaled pulse shape to each data value The output appears at the bottom of Figure 81 Looking at this closely observe that the first letter T is represented by the four values 1 1 1 and 3 which correspond exactly to the first four negative blips three small and one large The program pulseshapem represents the continuoustime or analog signal by oversampling both the data sequence and the pulse shape by a factor of M This technique was discussed in Section 63 where an analog sine wave sine100hzsampm was represented digitally at two sampling intervals a slow digital interval Ts and a faster rate shorter interval TsM representing the underlying analog signal The pulse shaping itself is carried out by the filter command which convolves the pulse shape with the data sequence Listing 81 pulseshapem applying a pulse shape to a text string s t rTransmit this text string message to be transmitted mletters2pam s t r Nlength m 4 l e v e l s i g n a l of length N Bits to Symbols to Signals 157 M10 mupzeros 1 NM mup 1 MNMm oversample by M pshammingM bl i p pulse of width M xf i l t e r ps 1 mup convolve pulse shape data Exercise 83 Assume the sampling period is T 01 and then plot the spec trum of the output x What is the bandwidth of this signal Exercise 84 Again with T 01 plot the spectrum of the output x when the pulse shape is changed to a rectangular pulse Change the definition of ps in the nexttolast line of pulseshapem What is the bandwidth of this signal Exercise 85 Can you think of a pulse shape that will have a narrower band width than either of the above but that will still be time limited by T Implement it by changing the definition of ps and check to see whether you are correct Thus the raw message is prepared for transmission by r encoding into an alphabet in this case 1 3 and then r pulse shaping the elements of the alphabet using pt The receiver must undo these two operations it must examine the received signal and recover the elements of the alphabet and then decode these to reconstruct the message Both of these tasks are made easier using correlation which is discussed in the next section The actual decoding processes used in the receiver are then discussed in Section 84 83 Correlation Suppose there are two signals or sequences Are they similar or are they differ ent 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 find appropriate sampling times and it can be applied at the frame level when it is necessary to find the start of a message for instance the beginning of each frame of a television signal This section discusses various techniques of cross correlation and autocorrelation which can be viewed in either the time domain or the frequency domain Figure 74 The frequency response of the filter with impulse response h1 1 1 1 1 has a poor lowpass character It is easier to see this in the frequency domain than directly in the time domain 722 Implementing IIR Filters At first glance it might seem counterintuitive that a useful filter could have an impulse response that is infinitely long To see how this infiniteness might arise in a specific case suppose that the output yk of an LTI system is created from the input xk according to the formula yk 1 ayk bxk 78 where a and b are constants This is shown in the lefthand portion of Figure 75 where the time delay between successive terms between k and k 1 for instance is represented by z¹ This is an example of the Ztransform and is described more fully in Appendix F If the initial value is y0 0 the response of the system 78 to an impulse xk δk where δk is the discrete impulse function 71 is bbaba²ba³ba⁴ 79 If a 1 this impulse response increases towards infinity 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 infinitely long and so the system 78 is IIR The special case when a 1 is called a summer or in analogy with continuous time an integrator because yk y0 b i0k1 xi sums up all the inputs The summer is often represented symbolically as in the righthand part of Figure 75 The general form of an IIR filter is yk 1 a0 yk a1 yk 1 an yk n b0 xk b1 xk 1 bm xk m which can be rewritten more concisely as yk 1 aᵀ yk bᵀ xk Bits to Symbols to Signals 159 1 2 3 4 5 6 7 8 9 10 1 05 0 05 1 Header 2 1 0 1 2 0 20 40 60 80 100 120 140 10 5 0 5 10 Correlation of header with data Data with embedded header 0 10 20 30 40 50 60 70 Figure 82 The correlation can be used to locate a known header within a long signal The predefined 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 different lengths The start of the header is given by lengthdataind1 One way in which the correlation might fail to find 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 86 Rerun correxm with differentlength data vectors try loc100 r100 and loc10 r10 Observe how the location of the peak changes Exercise 87 Rerun correxm with differentlength 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 different convention with the xcorr command If you find that the string of zeros occurs at the beginning try reversing the order of the arguments 160 Chapter 8 Bits to Symbols to Signals Exercise 88 Rerun correxm with different amounts of noise Try sd0 01 03 05 1 2 How large can the noise be made if the correlation is still to find the true location of the header Exercise 89 The code in corrvsconvm explores the relationship between the correlation and convolution The convolution of two sequences is essentially the same as the crosscorrelation of the timereversed 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 83 corrvsconvm comparing correlation and convolution h1 1 2 2 3 3 def i ne sequence h k x1 2 3 4 5 6 5 4 3 2 1 def i ne sequence x k yconvconvx h convolve x k h k ycorrxcorr h f l i p l r x c o r r e l a t e f l i p p e d x and h 84 Receive Filtering From Signals to Symbols Suppose that a message has been coded into its alphabet pulseshaped into an analog signal and transmitted The receiver must then unpulseshape the analog signal back into the alphabet which requires finding where in the received signal the pulse shapes are located Correlation can be used to accomplish this task because it is effectively the task of locating a known sequence in this case the sampled pulse shape within a longer sequence the sampled received signal This is analogous to the problem of finding the header within the received signal although some of the details have changed While optimizing this procedure is somewhat involved and is therefore postponed until Chapter 11 the gist of the method is reasonably straightforward and is shown by continuing the example begun in pulseshapem The code in recfiltm below begins by repeating the pulseshaping code from pulseshapem using the pulse shape ps defined in the top plot of Figure 81 This creates an analog signal x that is oversampled by a factor M The receiver begins by correlating the pulse shape with the received signal using the xcorr function2 After appropriate scaling this is downsampled to the symbol rate by choosing one out of each M regularly spaced samples These values are then quantized to the nearest element of the alphabet using the function quantalph which was introduced in Exercise 325 The function quantalph has two vector arguments the elements of the first vector are quantized to the 2 Because of the connections between crosscorrelation convolution and filtering this process is often called pulsematched filtering because the impulse response of the filter is matched to the shape of the pulse Bits to Symbols to Signals 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 pam2lettersm rebuilds the message from the received signal The final line of the program calculates how many symbol errors have occurred how many of the 1 3 differ between the message m and the reconstructed message mprime Listing 84 recfiltm undo pulse shaping using correlation run pulseshape m cr eate x yxcorr x ps c o r r e l a t e pulse s i g n a l zyNMMNM pow ps M downsample to symbol r ate mprimequantalph z 3 1 1 3 quantize to alphabet pam2letters mprime r econs tr uct message sumabs sign mprimem c a l c u l a t e number of e r r o r s In essence pulseshapem from page 156 is a transmitter and recfiltm is the corresponding receiver Many of the details of this simulation can be changed and the message will still arrive intact The following exercises encourage exploration of some of the options Exercise 810 Other pulse shapes may be used Try a a sinusoidal shaped pulse pssin01pi0M1 b a sinusoidal shaped pulse pscos01pi0M1 c a rectangular pulse shape psones1M Exercise 811 What happens if the pulse shape used at the transmitter differs from the pulse shape used at the receiver Try using the original pulse shape from pulseshapem at the transmitter but using the following a pssin01pi0M1 at the receiver What percentage errors occur b pscos01pi0M1 at the receiver What percentage errors occur Exercise 812 The received signal might not always arrive at the receiver unchanged Simulate a noisy channel by including the command xx10randnsizex before the xcorr command in recfiltm What percent age errors occur What happens as you increase or decrease the amount of noise by changing the 10 to a larger or smaller number 85 Frame Synchronization From Symbols to Bits In many communication systems the data in the transmitted signal are separated into chunks called frames In order to correctly decode the text at the receiver it is necessary to locate the boundary the start of each chunk This was done by fiat in the receiver of recfiltm by correctly indexing into the received signal 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 predefined symbols embedded at some specified location within each frame The receiver can locate the marker by crosscorrelating 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 84 where the marker M is used to indicate a frame transition A sevensymbol marker is to be used Consider two candidates marker A 1 1 1 1 1 1 1 marker B 1 1 1 1 1 1 1 1 The correlation of the signal with each of the markers can be performed as indicated in Figure 83 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 sevensymbol marker we want the flag 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 maximumlength pseudonoise PN sequence One property of a maximumlength PN sequence ci of plus and minus ones is that its autocorrelation is quite peaked Rck 1N sumcncnk 1 kℓN 1N kℓN 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 flatter 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 Bits to Symbols to Signals 163 Sum products of corresponding values Data sequence with embedded marker m1 m2 m3 m4 m5 m6 m7 1 1 1 1 1 1 1 1 m1 m2 m3 m4 m5 m6 m7 1 1 1 Shift marker to right and repeat m1 m2 m3 m4 m5 m6 m7 1 1 1 1 1 1 1 1 m1 m2 m3 m4 m5 m6 m7 1 1 1 sum m1 m2 m3 m4 m5 m6 m7 sum m1 m2 m3 m4 m5 m6 m7 Shift marker to right and repeat m1 m2 m3 m4 m5 m6 m7 1 1 1 1 1 1 1 1 m1 m2 m3 m4 m5 m6 m7 1 1 1 sum m1 m2 m3 m4 m5 m6 m1m7 Shift marker to right and repeat m1 m2 m3 m4 m5 m6 m7 1 1 1 1 1 1 1 1 m1 m2 m3 m4 m5 m6 m7 1 1 1 sum m1 m2 m3 m4 m5 m1m6 m2m7 Shift marker to right and repeat m1 m2 m3 m4 m5 m6 m7 1 1 1 1 1 1 1 1 m1 m2 m3 m4 m5 m6 m7 1 1 1 sum m1m1m2m2m3m3m4m4m5m5m6m6m7m7 Figure 83 The binary signal from 84 is shown with a sevensymbol embedded marker m1 m2 m7 The process of correlation multiplies successive elements of the signal by the marker and sums The marker shifts to the right and the process repeats The sum is largest when the marker is aligned with itself because all the terms are positive as shown in the bottom part of the diagram Thus the shift with the largest correlation sum points towards the embedded marker in the data sequence Correlation can often be useful even when the data are noisy 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 Chapter 8 Bits to Symbols to Signals appropriate additions at the transmitter The alignment can be accomplished using correlation Exercise 813 Redo the example of this section using Matlab Exercise 814 Add a channel with impulse response 1 0 0 a 0 0 0 b to this example Convolve the impulse response of the channel with the data sequence a For a 01 and b 04 how does the channel change the likelihood that the correlation correctly locates the marker Try using both markers A and B b Answer the same question for a 05 and b 09 c Answer the same question for a 12 and b 04 Exercise 815 Generate a long sequence of binary random data with the marker embedded every 25 points Check that marker A is less robust on average than marker B by counting the number of times marker A misses the frame start compared with the number of times marker B misses the frame start Exercise 816 Create your own marker sequence and repeat the previous prob lem Can you find one that does better than marker B Exercise 817 Use the 4PAM alphabet with symbols 1 3 Create a marker sequence and embed it in a long sequence of random 4PAM data Check to make sure it is possible to correctly locate the markers Exercise 818 Add a channel with impulse response 1 0 0 a 0 0 0 b to this 4PAM example a For a 01 and b 04 how does the channel change the likelihood that the correlation correctly locates the marker b Answer the same question for a 05 and b 09 Exercise 819 Choose a binary scrambling sequence s that is 17 bits long Create a message that is 170 bits long and scramble it using bitbybit mod 2 addition a Assuming the receiver knows where the scrambling begins add s to the scram bled data and verify that the output is the same as the original message b Embed a marker sequence in your message Use correlation to find the marker and to automatically align the start of the scrambling 9 Stuff 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 pro vided 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 disturbancefree 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 samples the received signal r demodulates to baseband r filters the signal to remove unwanted portions of the spectrum r correlates with the pulse shape to help emphasize the peaks of the pulse train r downsamples to the symbol rate and r decodes the symbols back into the character string 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 ele ments into a full simulation of a transmitter and receiver pair that can function successfully in an ideal setting 166 Chapter 9 Stuff Happens 91 An Ideal Digital Communication System The system is illustrated in the block diagram of Figure 91 This system is described in great detail in Section 92 which also provides a Matlab version of the transmitter and receiver Once everything is pieced together it is easy to verify that messages can be sent reliably from transmitter to receiver Unfortunately some of the assumptions made in the ideal setting are unlikely to hold in practice for example the presumption that there is no interference from other transmitters that there is no noise that the gain of the channel is always unity that the signal leaving the transmitter is exactly the same as the signal at the input to the digital receiver All of these assumptions will almost certainly be violated in practice Stuff happens Section 93 begins to accommodate some of the nonidealities encountered in real systems by addressing the possibility that the channel gain might vary with time For example a large metal truck might abruptly move between a cell phone and the antenna at the base station causing the channel gain to drop precipi tously If the receiver cannot react to such a change it may suffer debilitating errors when reconstructing the message Section 93 examines the effectiveness of incorporating an automatic gain control AGC adaptive element as described in Section 68 at the front end of the receiver With care the AGC can accom modate the varying gain The success of the AGC is encouraging Perhaps there are simple ways to compensate for other common impairments Section 94 presents a series of what if questions concerning the various assumptions made in the construction of the ideal system focusing on perfor a Transmitter Pulse filter Coder Tspaced symbol sequence Baseband signal Passband signal Message character string Mixer cos2πfct b Receiver Lowpass filter Tsspaced passband signal Tsspaced baseband signal Received signal Mixer Demodulator Downsampler kTs k 0 1 2 nMTs lTs n 0 1 2 Sampler cos2πfckTs Pulse correlator filter Decoder Quantizer MTsspaced soft decisions MTsspaced hard decisions Recovered character string Figure 91 Block diagram of an ideal communication system Stuff Happens 167 mance degradations caused by synchronization loss and various kinds of distor tions What if there is channel noise The ideal system is noisefree What if the channel has multipath interference There are no reflections or echoes in the ideal system What if the phase of the oscillator at the transmitter is unknown or guessed incorrectly at the receiver The ideal system knows the phase exactly What if the frequency of the oscillator at the transmitter is off just a bit from its specification In the ideal system the frequency is known exactly What if the sample instant associated with the arrival of topdeadcenter of the leading pulse is inaccurate so that the receiver samples at the wrong times The sampler in the ideal system is never fooled What if the number of samples between symbols assumed by the receiver is different from that used at the transmitter These are the same in the ideal case These questions are investigated via a series of experiments that require only modest modification of the ideal system simulation These simulations will show as with the timevarying channel gain that small violations of the idealized assumptions can often be tolerated However as the operational conditions become more severe as more stuff happens the receiver must be made more robust Of course it is not possible to fix all these problems in one chapter Thats what the rest of the book is for Chapter 10 deals with methods to acquire and track changes in the carrier phase and frequency Chapter 11 describes better pulse shapes and corresponding receive filters that perform well in the presence of channel noise Chapter 12 discusses techniques for tracking the symbol clock so that the samples can be taken at the best possible times Chapter 13 designs a symbolspaced filter that undoes multipath interference and can reject certain kinds of inband interference Chapter 14 describes simple coding schemes that provide protection against channel noise 92 Simulating the Ideal System The simulation of the digital communication system in Figure 91 divides into two parts just as the figure does The first part creates the analog transmitted signal and the second part implements the discretetime receiver The message consists of the character string 01234 I wish I were an Oscar Meyer wiener 56789 In order to transmit this important message it is first translated into the 4PAM symbol set 1 3 which is designated mi for i 1 2 N using the subroutine letters2pamm This can be represented formally as the analog pulse train miδt iT where T is the time interval between symbols The simulation operates with an oversampling factor M which is the speed at which the analog portion of the system evolves The pulse train enters a filter with pulse shape pt The sifting property A56 shows that the output of the pulseshaping filter is the analog signal mipt iT which is then modulated by multiplication with a cosine at the carrier frequency fc to form the transmitted signal mipt iTcos2πfct Since the channel is assumed to be ideal this is equal to the received signal rt This ideal transmitter is simulated in the first part of idsysm Listing 91 idsysm part 1 idealized transmission system the transmitter encode text string as Tspaced 4PAM sequence str01234 I wish I were an Oscar Meyer wiener 56789 mletters2pamstr Nlengthm 4level signal of length N zero pad Tspaced symbol sequence to create upsampled TMspaced sequence of scaled Tspaced pulses T1 M100 oversampling factor mupzeros1NM Hamming pulse filter with mup1MNMm TMspaced impulse response phammingM blip pulse of width M xfilterp1mup convolve pulse shape with data figure1 plotspecx1M baseband AM modulation t1M1M lengthxM TMspaced time vector fc20 carrier frequency ccos2pifct carrier rcx modulate message with carrier Since MATLAB cannot deal directly with analog signals the analog signal rt is sampled at M times the symbol rate and rttkTs the signal rt 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 first sampling block in the receiver of Figure 91 is implicit in the way MATLAB emulates the analog signal To be specific 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 MTs kTs iT ρTs Thus the received signal sampled at t kTs is rttkTs mipt iTcos2πfcttkTsiTρTs mipkTs iTcos2πfckTs The receiver performs downconversion in the second part of idsysm with a mixer that uses a synchronized cosine wave followed by a lowpass filter that removes outofband signals A quantizer makes hard decisions that are then decoded back from symbols to the characters of the message When all goes well the reconstructed message is the same as the original Listing 92 idsysm part 2 idealized transmission system the receiver AM demodulation of received signal sequence r c2cos2pifct synchronized cosine for mixing x2rc2 demod received signal fl50 fbe0 01 02 1 LPF parameters damps1 1 0 0 bfirpmflfbedamps create LPF impulse response x32filterb1x2 LPF and scale signal extract upsampled pulses using correlation implemented as a convolving filter filter with pulse and normalize yfilterfliplrppowpM1x3 set delay to first symbolsample and increment by M zy05flMMNM downsample to symbol rate figure2 plot1lengthzz plot soft decisions decision device and symbol matching performance assessment mprimequantalphz3113 quantize alphabet cvarmprimezmprimezlengthmprime cluster variance lmplengthmprime pererr100sumabssignmprimem1lmplmp symbol error decode decision device output to text string reconstructedmessagepam2lettersmprime This ideal system simulation is composed primarily of code recycled from previous chapters The transformation from a character string to a fourlevel Tspaced sequence to an upsampled TMspaced Twide Hamming pulseshape filter output sequence mimics pulseshapem from Section 82 This sequence of TMspaced pulse filter outputs and its magnitude spectrum are shown in Figure 92 type plotspecx1M after running idsysm Each pulse is one time unit long so successive pulses can be initiated without any overlap The unit duration of the pulse could be a millisecond for a pulse frequency of 1 kHz or a microsecond for a pulse frequency of 1 MHz The magnitude spectrum in Figure 92 has little apparent energy outside bandwidth 2 the meaning of 2 in Hz is dependent on the units of time This oversampled waveform is upconverted by multiplication with a sinusoid This is familiar from AMm of Section 52 The transmitted passband signal and its spectrum created using plotspecv1M are shown in Figure 93 The default carrier frequency is fc20 Nyquist sampling of the received signal occurs as long 170 Chapter 9 Stuff Happens 3 1 2 0 2 1 3 Amplitude 0 0 40 80 120 160 200 Seconds 8000 6000 4000 2000 Magnitude 50 40 30 20 10 0 10 20 30 40 50 Frequency Figure 92 The transmitter of idsysm creates the message signal x in the top plot by convolving the 4PAM data in m with the pulse shape p The magnitude spectrum Xf is shown at the bottom 3 1 2 0 2 1 3 Amplitude 0 20 40 60 80 100 120 140 160 180 Seconds 4000 3000 2000 1000 0 Magnitude 50 40 30 20 10 0 10 20 30 40 50 Frequency Figure 93 The received signal r and its spectrum Rf after upconversion as the sample frequency 1TM M for T 1 is twice the highest frequency in the received signal which will be the carrier frequency plus the baseband signal bandwidth of approximately 2 Thus M should be greater than 44 to prevent aliasing of the received signal This allows reconstruction of the analog received signal at any desired point which could prove valuable if the times at which the samples were taken were not synchronized with the received pulses The transmitted signal reaches the receiver portion of the ideal system in Figure 91 Downconversion is accomplished by multiplying the samples of the received signal by an oscillator that miraculously has the same frequency and phase as was used in the transmitter This produces a signal with the spectrum shown in Figure 94 type plotspecx21M after running idsysm a spec trum that has substantial nonzero components that must be removed at about twice the carrier frequency Stuff Happens 171 3 1 2 0 2 1 3 Amplitude 0 20 40 60 80 100 120 140 160 180 Seconds 4000 3000 2000 1000 0 Magnitude 50 40 30 20 10 0 10 20 30 40 50 Frequency Figure 94 Downconversion in idsysm mixes the received signal r with a cosine wave c2 to generate x2 The figure shows x2 in time in the top plot and its spectrum in the bottom plot Magnitude response dB Phase degrees 0 01 02 03 04 05 06 07 08 09 1 Normalized frequency Nyquist 1 1000 800 600 400 200 0 100 80 60 40 20 0 20 Figure 95 The frequency response of the lowpass filter designed using firpm in idsysm To suppress the components centered around 40 in Figure 94 and to pass the baseband component without alteration except for possibly a delay the lowpass filter is designed with a cutoff near 10 For M 100 the Nyquist frequency is 50 Section 723 details the use of firpm for filter design The frequency response of the resulting FIR filter from freqzb is shown in Figure 95 To make sense of the horizontal axes observe that the 1 in Figure 95 corresponds to the 50 in Figure 94 Thus the cutoff between normalized frequencies 01 and 02 corresponds to an unnormalized frequency near 10 as desired The output of the lowpass filter in the demodulator is a signal with the spec trum shown in Figure 96 drawn using plotspecx31M The spectrum in Figure 96 should compare quite closely to that of the transmitter baseband in Figure 92 as indeed it does It is easy to check the effectiveness of the low pass filter design by attempting to use a variety of different lowpass filters as suggested in Exercise 94 Recall the discussion in Section 84 of matching two scaled pulse shapes View ing the pulse shape as a kind of marker it is reasonable to correlate the pulse 172 Chapter 9 Stuff Happens 3 1 2 0 2 1 3 Amplitude 0 20 40 60 80 100 120 140 160 180 Seconds 8000 6000 4000 2000 0 Magnitude 50 40 30 20 10 0 10 20 30 40 50 Frequency Figure 96 After demodulation and lowpass filtering the signal x3 in idsysm is approximately the same as the baseband transmitted signal and spectrum in Figure 92 3 2 1 0 1 2 30 50 100 150 Best times to take samples Tsspaced samples Tspaced samples Amplitude of received signal Delay 200 250 300 350 400 0 T 2T 3T 4T Figure 97 The first four symbol periods recall that the oversampling factor was M 100 of the signal at the receiver after the demodulation LPF and pulse correlator filter The first three symbol values are 3 3 3 which can be deciphered from the signal assuming that the delay can be selected appropriately shape with the received signal in order to locate the pulses More justifica tion for this procedure is forthcoming in Chapter 11 This appears in Figure 91 as the block labelled pulse correlation filter The code in idsysm imple ments 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 corrvsconvm in Exercise 89 to see how the two functions are related The first 4M samples of the resulting signal y are plotted in Figure 97 via ploty14M The first three symbols of the message ie m13 are 3 3 and 3 and Figure 97 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 filter 05fl plus half the length of the correlator filter 05M plus half a symbol period 05M which accounts for the delay from the start of each pulse to its peak Stuff Happens 173 3 2 1 0 1 2 3 0 50 100 150 200 250 300 350 400 Figure 98 Repeatedly overlaying a time width of four symbols yields an eye diagram Selecting this delay and the associated downsampling are accomplished in the code zy 0 5 f lMM end downsample to symbol r ate in idsysm which recovers the T spaced samples z With reference to Figure 91 the parameter l in the downsampling block is 125 A revealing extension of Figure 97 is to plot the oversampled waveform y for the complete transmission in order to see whether the subsequent peaks of the pulses occur at regular intervals precisely on source alphabet symbol values as we would hope However even for small messages such as the wiener jingle squeezing such a figure onto one graph makes a detailed visual examination of the peaks fruitless This is precisely why we plotted Figure 97to see the detailed timing information for the first few symbols One idea is to plot the next four symbol periods on top of the first four by shifting the start of the second block to time zero Continuing this approach throughout the data record mimics the behavior of a welladjusted oscilloscope that triggers at the same point in each symbol group This operation can be implemented in Matlab by first determining the maximum number of groups of 4M samples that fit inside the vector y from the lth sample on Let ulfloor length yl 14M then the reshape command can be used to form a matrix with 4M rows and ul columns This is easily plotted using plot reshape y l ul 4M124 4M ul and the result is shown in Figure 98 Note that the first element plotted in Figure 98 is the lth element of Figure 97 This type of figure 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 imple mented in letters2pamm and pam2lettersm One idiosyncrasy is that each character starts off with a negative symbol Another is that the second symbol in 174 Chapter 9 Stuff Happens 40 20 40 60 80 100 120 140 160 180 200 3 2 1 0 1 3 2 4 Figure 99 Values of the reconstructed symbols called the soft decisions are plotted in this constellation diagram time history each character is never 1 in our chosen message These are not generic effects they are a consequence of the particular coding and message used in idsysm Had we chosen to implement a scrambling scheme recall Exercise 819 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 plot1lengthzz produces a time history of the output of the down sampler as shown in Figure 99 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 99 cluster tightly about the alphabet values 1 and 3 How tightly they cluster can be quantified using the cluster variance which is the average of the square of the difference between the decoded symbol values the soft decisions in z and the nearest member of the alphabet the final hard decisions The Matlab function quantalphm is used in idsysm to calculate the hard decisions which are then converted back into a text character string using pam2lettersm If all goes well this reproduces the original message The only flaw is that the last symbol of the message has been lost due to the inherent delay of the lowpass filtering and the pulseshape 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 pam2lettersm 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 91 Using idsysm examine the effect of using different carrier fre quencies Try fc 50 30 3 1 05 What are the limiting factors that cause some to work and others to fail Stuff Happens 175 Exercise 92 Using idsysm examine the effect of using different oversampling frequencies Try M 1000 25 10 What are the limiting factors that cause some to work and others to fail Exercise 93 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 94 What are the limits to the LPF design at the beginning of the receiver What is the lowest cutoff frequency that works The highest Exercise 95 Using the same specifications fbe0 01 02 1 damps 1 1 0 0 how short can you make the LPF Explain 93 Flat Fading A Simple Impairment and a Simple Fix Unfortunately a number of the assumptions made in the simulation of the ideal system idsysm are routinely violated in practice The designer of a receiver must somehow compensate by improving the receiver This section presents an impairment flat fading for which we have already developed a fix an AGC Later sections describe misbehavior due to a wider variety of common impair ments that we will spend the rest of the book combating Flat fading occurs when there are obstacles moving in the path between the transmitter and receiver or when the transmitter and receiver are moving with respect to each other It is most commonly modeled as a timevarying channel gain that attenuates the received signal The modifier flat implies that the loss in gain is uniform over all frequencies In communications jargon it is not frequencyselective This section begins by studying the loss of performance caused by a timevarying channel gain using a modified version of idsysm and then examines the ability of an adaptive element the automatic gain control AGC to make things right In the ideal system of the preceding section the gain between the transmit ter and the receiver was implicitly assumed to be unity What happens when this assumption is violated when flat fading is experienced in midmessage To examine this question suppose that the channel gain is unity for the first 20 of the transmission but that for the last 80 it drops by half This flat fade can easily be studied by inserting the following code between the transmitter and the receiver parts of idsysm Listing 93 idsysmod1m modification of idsysm with timevarying fading channel l rlength r length of transmitted s i g n a l vector fp ones 1 floor 0 2 l r 0 5 ones 1 lr floor 0 2 l r f l a t fading p r o f i l e rr fp apply p r o f i l e to transmitted s i g n a l 176 Chapter 9 Stuff Happens 40 20 40 60 80 100 120 140 160 180 200 3 2 1 0 1 2 3 Figure 910 Soft decisions with uncompensated flat fading The resulting plot of the soft decisions in Figure 910 obtained via plot1lengthz z shows the effect 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 68 has already introduced an adaptive element designed to compen sate for flat 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 agcvsfadingm on page 128 and combining it with the fading channel just dis cussed 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 94 idsysmod2m modification of idsysm with fading plus automatic gain control dspow r des i r ed average power of s i g n a l l rlength r length of transmitted s i g n a l fp ones 1 floor 0 2 l r 05 ones 1 lr floor 0 2 l r f l a t fading p r o f i l e rr fp apply to transmitted s i g n a l gzeros 1 l r g 11 i n i t i a l i z e gain nrzeros 1 l r mu00003 s t e p s i z e for i 1 lr 1 adaptive AGC element nr i g i r i AGC output g i 1g i mu nr i ˆ2 ds adapt gain end rnr r ecei ved s i g n a l i s s t i l l c a l l e d r Inserting this segment into idsysm immediately after the timevarying fading channel modification 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 plot1lengthzz in Figure 911 shows how quickly after the abrupt fade the soft decisions return Stuff Happens 177 0 20 40 60 80 100 120 140 160 180 200 4 3 2 1 0 1 2 3 4 Figure 911 Soft decisions with an AGC compensating for an abrupt flat fade 26 22 18 14 1 0 04 08 12 16 2 x104 AGC gain parameter Iteration Figure 912 Trajectory of the AGC gain parameter as it moves to compensate for the fade to the appropriate sector Look for where the larger soft decisions exceed a magnitude of 2 Figure 912 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 longterm average Exercise 96 Another idealized assumption made in idsysm is that the receiver knows the start of each frame that is it knows where each four symbol group begins This is a kind of frame synchronization problem and was absorbed into the specification of a parameter l which appears in the code as 05flM With the default settings l is 125 This problem poses the following question What if this is not known and how can it be fixed a Verify using idsysm that the message becomes scrambled if the receiver is mistaken about the start of each group of four Add a random number of 4PAM symbols before the message sequence but do not tell the receiver 178 Chapter 9 Stuff Happens that you have done so ie do not change l What value of l would fix the problem Can l really be known beforehand b Section 85 proposed the insertion of a marker sequence as a way to synchro nize the frame Add a sevensymbol marker sequence just prior to the first character of the text In the receiver implement a correlator that searches for the known marker Demonstrate the success of this modification 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 98 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 find the start of the frames d The previous two exercises showed two possible solutions to the frame synchronization problem Explain the pros and cons of each method and argue which is a better solution 94 Other Impairments More What Ifs Of course a fading channel is not the only thing that can go wrong in a telecom munication system Think back to the what if questions in the first section of this chapter This section considers a range of synchronization and interfer ence impairments that violate the assumptions of the idealized system Though each impairment is studied separately ie assuming that everything functions ideally except for the particular impairment of interest a single program is written to simulate any of the impairments The program impsysm leaves both the transmitter and the basic operation of the receiver unchanged the primary impairments are to the sampled sequence that is delivered to the receiver The rest of this chapter conducts a series of experiments dealing with stuff that can happen to the system Interference is added to the received signal as additive Gaussian channel noise and as multipath interference The oscillator at the transmitter is no longer presumed to be synchronized with the oscillator at the receiver The best sample times are no longer presumed to be known exactly in either phase or period Listing 95 impsysm impairments to the receiver cnginput channel noise gain try 0 06 or 2 cdiinput channel multipath 0 for none 1 for mild or 2 for harsh foinput tranmsitter mixer freq offset in percent try 0 or 001 poinput tranmsitter mixer phase offset in rad try 0 07 or 09 toperinput baud timing offset as percent of symb period try 0 20 or 30 soinput symbol period offset try 0 or 1 Stuff Happens 179 INSERT TRANSMITTER CODE FROM IDSYS M HERE i f cdi 0 5 channel ISI mc1 0 0 di s tor ti on f r e e channel e l s e i f cdi 15 mild multipath channel mc1 zeros 1 M 028 zeros 1 2 3M 0 1 1 else harsh multipath channel mc1 zeros 1 M 028 zeros 1 1 8M 0 4 4 end mcmc sqrt mcmc normalize channel power dvf i l t e r mc 1 r f i l t e r s i g n a l through channel nvdvcng randn size dv add Gaussian channel noi s e tofloor 001 toper M f r a c t i o n a l period delay rnvnv1 to NM delay in onsymbol des i gnati on r t1to M1M length nvM time vector with delayed s t a r t rMMso r e c e i v e r sampler timing o f f s e t INSERT RECEIVER CODE FROM IDSYS M HERE The first few lines of impsysm prompt the user for parameters that define 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 06 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 different delay and amplitude This is implemented by passing the transmitted signal through a filter whose impulse response is specified 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 first If the largest path gain were not first this could be interpreted as a delay between the receipt of the first sample of the first 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 first sample of the message In the ideal system this assumption was correct In impsysm 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 offset 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 differ by a small amount The user specifies the frequency offset 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 difference 180 Chapter 9 Stuff Happens 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 transmit ter oscillator the symbol clock at the receiver need not be properly synchronized with the transmitter symbol period clock Effectively 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 first sample time was read ily calculated using the parameter l But l cannot be known in a real system because the first sample depends for instance on when the receiver is turned on Thus the phase of the symbol clock is unknown at the receiver This impair ment is simulated in impsysm using the timing offset parameter toper which is specified 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 final impairment is specified by the symbol period offset which sets the symbol period at the transmitter to so less than that at the receiver Using impsysm it is now easy to investigate how each impairment degrades the performance of the system 941 Additive Channel Noise Whenever the channel noise is greater than half the gap between two adjacent symbols in the source constellation a symbol error may occur For the constel lation of 1s and 3s if a noise sample has magnitude larger than 1 then the output of the quantizer may be erroneous Suppose that a white broadband noise is added to the transmitted sig nal The spectrum of the received signal which is plotted in Figure 913 via plotspecnv1rM shows a nonzero noise floor compared with the ideal noisefree spectrum in Figure 93 A noise gain factor of cng06 leads to a cluster variance of about 002 and no symbol errors A noise gain of cng2 leads to a cluster variance of about 02 and results in approximately 2 symbol errors When there are 10 symbol errors the reconstructed text becomes undecipher able for the particular coding used in letters2pamm and pam2lettersm Thus as should be expected the performance of the system degrades as the noise is increased It is worthwhile taking a closer look to see exactly what goes wrong The eye diagram for the noisy received signal is shown in Figure 914 which should be compared with the noisefree eye diagram in Figure 98 This is plotted using the following Matlab commands ulfloor length x3 1244rM plot reshape x3 125 ul 4rM124 4rM ul Stuff Happens 181 5 0 50 20 40 60 80 100 Seconds 120 140 160 180 200 Amplitude 5000 4000 3000 2000 1000 050 40 30 20 10 0 Frequency 10 20 30 40 50 Magnitude Figure 913 When noise is added the received signal appears jittery The spectrum has a noticeable noise floor 5 4 3 2 1 0 1 2 3 4 50 50 100 150 200 250 300 350 400 Figure 914 The eye diagram of the received signal x3 repeatedly overlays foursymbolwide segments The channel noise is not insignificant It should be clear from the noisy eye diagram that it would be very difficult to correctly decode the symbols directly from this signal Fortunately the correla tion filter reduces the noise significantly as shown in the eye diagram in Figure 915 This is plotted as before substituting y for x3 Comparing Figures 914 and 915 closely observe that the whole of the latter is shifted over in time by about 50 samples This is the effect of the time delay of the correlator filter which is half the length of the filter Clearly it is much easier to correctly decode using y than using x3 though the pulse shapes of Figure 915 are still blurred when compared with the ideal pulse shapes in Figure 98 Exercise 97 The correlation filter in impsysm is a lowpass filter with impulse response given by the pulse shape p a Plot the frequency response of this filter What is the bandwidth of this filter 182 Chapter 9 Stuff Happens 4 3 2 1 0 1 2 3 40 50 100 150 200 250 300 350 400 Figure 915 The eye diagram of the received signal y after the correlation filter The noise is reduced significantly b Design a lowpass filter using firpm that has the same length and the same bandwidth as the correlation filter c Use your new filter in place of the correlation filter in impsysm Has the performance improved or worsened Explain in detail what tests you have used No peeking ahead to Chapter 11 942 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 different delays and attenuations multipath interference can be modeled as a linear filter Since filters can have complicated frequency responses some frequencies may be attenuated more than others and so this is called frequencyselective fading The mild multipath interference in impsysm has three nonzero paths between the transmitter and the receiver Its frequency response has numer ous 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 916 from plot1lengthzz which should be compared with the ideal con stellation diagram in Figure 99 The effect 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 impsysm also has three paths between the transmitter and receiver but the later reflections 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 effects are considerably more severe The effect of this channel can be seen directly by looking at the constellation diagram of the soft decisions in Figure 917 The constellation diagram is smeared and it is Stuff Happens 183 4 3 2 1 0 1 2 3 40 20 40 60 80 100 120 140 200 160 180 Figure 916 With mild multipath interference the soft decisions can readily be segregated into four stripes that correspond to the four symbol values 4 3 2 1 0 1 2 3 40 20 40 60 80 100 120 140 200 160 180 Figure 917 With harsher multipath interference the soft decisions smear and it is no longer possible to see which points correspond to which of the four symbol values 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 943 Carrier Phase Offset For the receiver in Figure 91 the difference between the phase of the modulating sinusoid at the transmitter and the phase of the demodulating sinusoid at the receiver is the carrier phase offset The effect of a nonzero offset is to scale the received signal by a factor equal to the cosine of the offset as was shown in 54 of Section 52 Once the phase offset is large enough the demodulated signal contracts so that its maximum magnitude is less than 2 When this happens the quantizer always produces a 1 Symbol errors abound 184 Chapter 9 Stuff Happens 2 15 1 05 0 05 1 15 20 20 40 60 80 100 120 140 200 160 180 Figure 918 Soft decisions for harsh carrier phase offset are never greater than 2 The quantizer finds no 3s and many symbol errors occur When running impsysm there are two suggested nonzero choices for the phaseoffset parameter po With po09 cos09 062 and 3 cos09 2 This is shown in the plot of the softdecision errors in Figure 918 For the milder carrier phase offset po07 the soft decisions result in no symbol errors because the quantizer will still decode values at 3 cos07 23 as 3 As long as the constellation diagram retains distinct horizontal stripes all is not lost In Figure 918 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 signal tonoise ratio A better approach is to identify the unknown phase offset as discussed in Chapter 10 Exercise 98 Using impsysm as a basis implement an AGCstyle adaptive element to compensate for a phase offset Verify that your method works for a phase offset of 09 and for a phase offset of 12 Show that the method fails when the phase offset is π2 944 Carrier Frequency Offset The receiver in Figure 91 has a carrier frequency offset when the frequency of the carrier at the transmitter differs from the assumed frequency of the carrier at the receiver As was shown in 55 in Section 52 this impairment is like a modulation by a sinusoid with frequency equal to the offset This modulat ing effect is catastrophic when the lowfrequency modulator approaches a zero crossing since then the gain of the signal approaches zero This effect is apparent for a 001 frequency offset in impsysm in the plot of the soft decisions via plot1lengthzz in Figure 919 This experiment suggests that the receiver mixer frequency must be adjusted to track that of the transmitter Stuff Happens 185 3 2 1 0 1 2 30 20 40 60 80 100 120 140 200 160 180 Figure 919 Soft decisions for 001 carrier frequency offset 945 Downsampler Timing Offset As shown in Figure 97 there is a sequence of best times at which to down sample When the starting point is correct and no intersymbol interference ISI is present as in the ideal system the sample times occur at the top of the pulses When the starting point is incorrect all the sample times are shifted away from the top of the pulses This was set in the ideal simulation using the parameter l with its default value of 125 The timingoffset parameter toper in impsysm is used to offset the received signal Essentially this means that the best value of l has changed though the receiver does not know it This is easiest to see by drawing the eye diagram Figure 920 shows an overlay of foursymbol wide segments of the received signal using the reshape command as in the code on page 173 The receiver still thinks the best times to sample are at l nT but this is clearly no longer true In fact whenever the sample time begins between 100 and 140 and lies in this or any other shaded region there will be errors when quantizing For example all samples taken at 125 lie between 1 and hence no symbols will ever be decoded at their 3 value In fact some even have the wrong sign This is a far worse situation than in the carrier phase impairment because no simple amplitude scaling will help Rather a solution must correct the problem it must slide the times so that they fall in the unshaded regions Because these unshaded regions are wide open this is often called the openeye region The goal of an adaptive element designed to fix the timingoffset problem is to open the eye as wide as possible 946 Downsampler Period Offset When the assumed period of the downsampler is in error there is no hope As mentioned in the previous impairment the receiver believes that the best times 186 Chapter 9 Stuff Happens 3 0 2 50 100 150 200 250 300 350 400 1 0 1 2 3 Assumed best times to take samples Figure 920 Eye diagram with downsampler timing offset of 50 Sample times used by the ideal system are no longer valid and lead to numerous symbol errors to sample are at l nT When there is a period offset it means that the value of T used at the receiver differs from the value actually used at the transmitter The prompt in impsysm for symbol period offset 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 filter 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 offset recall Figure 919 For an offset of 1 the soft decisions are plotted in Figure 921 Can you connect the value of the period of this periodic collapse to the parameters of the simulated example 947 Repairing Impairments When stuff 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 filtering Chapter 11 are intended primarily to counter the effects of noise Equalization Chapter 13 compensates for multipath interference and can reject narrowband interferers Carrier recov ery 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 offset All of these fixes can be viewed as digital signal processing DSP solutions to the impairments explored in impsysm Stuff Happens 187 3 2 1 0 2 3 1 400 350 300 250 200 150 100 50 0 3 2 1 0 2 3 1 200 0 20 40 60 80 100 120 140 160 180 Figure 921 When there is a 1 downsampler period offset all is lost as shown by the eye diagram in the top plot and the soft decisions in the bottom Each of these fixes will be designed separately as if the problem it is intended to counter were the only problem in the world Fortunately somehow they can all work together simultaneously Examining possible interactions between the various fixes which is normally a part of the testing phase of a receiver design will be part of the receiver design project of Chapter 15 95 A B3IG Deal While the idealized communication systems in idsysm and impsysm 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 B3IG as shown in Figure 922 Signal r as it enters the receiver Basic Black Box Impairment Generator MATLAB script defining transmitter parameters Figure 922 The Basic Black Box Impairment Generator or B3IG inputs a Matlab script that specifies the operation of the transmitter along with any desired impairments The output is the received signal r that enters the receiver You can find out how the system operates by peering ahead to Appendix H but we really shouldnt mention it at this point 188 Chapter 9 Stuff Happens The B3IG transmitter is a soupedup version of the idealized transmitters in idsysm and impsysm It allows easy incorporation of a number of impairments singly or in combination and is especially useful when examining possible inter actions between the various receiver strategies and fixes that are discussed in forthcoming chapters Though a complete description of the B3IG transmitter is presented in Appendix H it is probably not useful to jump ahead at this point Better to think of B3IG as a tool for exploration for generating noisy received signals with various userspecified and usercontrolled impairments In keeping with the theme of this chapter there is nothing genuinely new in B3IG the basic building blocks are the same as those in the previous chapters Using the B3IG transmitter is easy just type the command in Listing 96 Listing 96 This code calls the B3IG transmitter The received signal is in r and the transmitted encoded symbols are in s r s BigTransmitter m frameParams rfParams chanParams There are four inputs to the B3IG The message that is to be transmitted is spec ified in the variable m The frame parameters frameParams include a specification 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 idsysm and impsysm 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 97 Listing 97 Parameters in the script BigIdealm allow the B3IG transmission to mimic the idealized system idsysm and impsysm Message Generation m01234 I wish I were an Oscar Meyer wiener 56789 Frame parameters frameParams userDataLength1 frameParams preamble frameParams chanCodingFlag 0 frameParams bitEncodingFlag 0 Channel parameters Adj Users Int chanParams c1 1 0 0 chanParams c2 1 0 0 chanParams randomWalkVariance0 chanParams SNRInf chanParams adjacentUser1PowerInf chanParams a d j a c e n t U s e r 1 f i f 0 chanParams adjacentUser1Chan1 0 0 chanParams adjacentUser2PowerInf chanParams a d j a c e n t U s e r 2 f i f 0 chanParams adjacentUser2Chan1 0 0 chanParams NBIfreq 0 chanParams NBIPowerInf RF Parameters Stuff Happens 189 rfParams f i f e r r 0 rfParams T t er r 0 rfParams phaseNoiseVariance 0 rfParams SRRCLength4 rfParams SRRCrolloff 03 rfParams f s 100 rfParams T t 1 rfParams f i f 20 The channel parameters chanParams specify how the message is distorted as it moves from the transmitter to the receiver Intersymbol interference additive noise and interference from other users can all be modeled by changing these values Finally the RF parameters rfParams specify the parameters used the frequency of the transmitter the symbol rate the size of the pulse shape the intermediate frequency etc All frequency values are specified in Hz and all time values are given in seconds As before the values in BigIdealm of Listing 97 mimic the idealized transmission Exercise 99 One difference between BigIdealm and the received signal in impsysm is that the pulse shape is a squareroot raised cosine pulse instead of a Hamming pulse Run the script and plot the spectrum of the received signal in BigIdealm Compare this with the spectrum of the received signal from impsysm How do the spectra change when the SNR of the additive channel noise is decreased Exercise 910 A rudimentary receiver is provided in Listing 98 Observe that the code makes errors when noise is added because the gain the parameter receiver gain has not been chosen appropriately Find a new choice of gain that permits the receiver to operate errorfree even with the level of noise present How did you find this choice of gain Listing 98 BigIdealm part 2 idealized B3IG receiver Adjustable r e c e i v e r parameters r e c e i v e r g a i n 1 data s tar t 5 Fixed r e c e i v e r parameters M100 upsampling r a t i o f c 20 c a r r i e r frequency s r r c l e n g t h 4 length of pulse shape am demodulation of r ecei ved s i g n a l sequence r c2cos 2 pi f c 1M1M length r M cos i ne f o r mixing x2r c2 demod r ecei ved s i g n a l c o r r e l a t e f i l t e r to extr act upsampled pul s es yf i l t e r s r r c s r r c l ength 0 3 1 0 0 1 x2 f i l t e r with pulse s et delay to f i r s t symbolsample and increment by M zy s r r c l e n g t h MM end downsample to symbol r ate tos s out f i r s t few symbols s c a l e by gain zz data s tar t data s tar tlength m4 1 r e c e i v e r g a i n plot 1 length z z pl ot s o f t d e c i s i o n s d e c i s i o n device and symbol matching performance assessment 190 Chapter 9 Stuff Happens mprimequantalph z 3 1 1 3 quantize to alphabet cvarmprimez mprimez length mprime c l u s t e r variance lmplength mprime per er r 100sum abs sign mprimeletters2pam m lmp symb er r decode d e c i s i o n device output to text s t r i n g reconstructed messagepam2letters mprime Exercise 911 Use the AGC code from agcgradm to find the proper gain for the receiver in BigIdealm If the AGC converges slowly you may wish to use a longer message m Exercise 912 Observe that when the parameter dstart is specified 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 913 How would you change the frame channel or RF parameters to reproduce Figures 916 and 917 Exercise 914 How would you change the frame channel or RF parameters to reproduce Figure 919 Step 4 The Adaptive Components The fourth step describes all the practical fixes 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 fixes for additive noise for timing offset problems for clock frequency mismatches and jitter and for multipath reflections The order in which topics are discussed is the order in which they appear in the receiver Carrier recovery Chapter 10 the timing of frequency translation Receive filtering Chapter 11 the design of pulse shapes Clock recovery Chapter 12 the timing of sampling Equalization Chapter 13 filters that adapt to the channel Coding Chapter 14 making data resilient to noise 10 Carrier Recovery Figure 101 shows a generic transmitter and receiver pair that emphasizes the modulation and corresponding demodulation Even assuming that the transmis sion path is ideal as in Figure 101 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 figure out both the frequency and the phase of the modulating sinusoid used in the transmitter as was shown in 54 and 55 and graphically illustrated in Figures 918 and 919 This chapter discusses a variety of strategies that can be used to estimate the phase and frequency of the carrier and to fix the gain problem of 54 and Figure 918 and the problem of vanishing amplitudes in 55 and Figure 919 This process of estimating the frequency and phase of the carrier is called carrier recovery Figure 101 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 ana log 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 expen sive 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 offset 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 193 Pulse shaping Message mkT Modulation Received signal Ts Analog conversion to IF Digital down conversion to baseband Resampling Decision Reconstructed message mkT T Timing synchronization τ Frequency and phase tracking f0 θ fc φ Figure 101 Diagram of a communications system emphasizing the need for synchronization with the frequency fc and phase φ of the carrier The frequencytracking element adjusts the parameter f0 in an attempt to match fc and the phasetracking element adjusts the parameter θ in an attempt to match φ the transmitter with the frequency of the oscillator at the receiver Since the goal is to find the frequency and phase of a signal why not use a Fourier transform or more properly an FFT Section 101 shows how to isolate a sinusoid that is at twice the frequency of the carrier by squaring and filtering 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 esti mated 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 dis cussed in Section 102 is the square of the difference between the received signal and a locally generated sinusoid Another performance function leads to the wellknown phaselocked loop which is discussed in depth in Section 103 and yet another performance function leads to the Costas loop of Section 104 An alternative approach uses the decisiondirected method detailed in Section 105 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 appro priate error surface This approach should be familiar from Chapter 6 where it was used in the design of the AGC Section 106 then shows how to modify the adaptive elements to attack the frequencyestimation problem Three ways are shown The first tries unsuc cessfully 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 1062 uses two loops Since the phase of a sinusoid is the derivative of its frequency the first loop tracks a line the frequency offset and the second loop finetunes the estimation of the phase The third technique in Section 1063 shows how 194 Chapter 10 Carrier Recovery the dualloop method can be simplified and generalized by using an integrator within a single phaselocked loop This forms the basis for an effective adaptive frequencytracking element 101 Phase and Frequency Estimation via an FFT As indicated in Figure 101 the received signal consists of a message mkT modulated by the carrier In the simplest case when the modulation uses AM with a large carrier as in Section 51 it may be quite easy to locate the carrier and its phase More generally however the carrier will be well hidden within the received signal and some kind of extra processing will be needed to bring it to the foreground To see the nature of the carrierrecovery problem explicitly the following code generates two different received signals the first is AM modulated with large carrier and the second is AM modulated with suppressed carrier The phase and frequencies of both signals can be recovered using an FFT though the suppressedcarrier scheme requires additional processing before the FFT can successfully be applied Drawing on the code in pulseshapem on page 156 and modulating with the carrier c pulrecsigm creates the two different received signals The pam command creates a random sequence of symbols drawn from the alphabet 1 3 and then uses hamming to create a pulse shape1 The oversampling factor M is used to simulate the analog portion of the transmission and MTs is equal to the symbol time T Listing 101 pulrecsigm make pulseshaped signal N10000 M20 Ts0001 symbols oversampling f a c t o r timeTsNM tTs Ts time sampling i n t e r v a l time vector mpamN 4 5 4 l e v e l s i g n a l of length N mupzeros 1 NM mup 1 MNMm oversample by i n t e g e r length M pshamming M bl i p pulse of width M sf i l t e r ps 1 mup convolve pulse shape with data f c 1000 phoff 10 c a r r i e r f r eq and phase ccos 2 pi f c tphoff construct c a r r i e r r s cs c modulated s i g n a l small c a r r i e r r l c s 1c modulated s i g n a l l ar ge c a r r i e r Figure 102 plots the spectra of the large and suppressedcarrier 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 cf f t r l c spectrum of r l c m imaxmax abs f f t r l c 1 end 2 index of max peak s s f 0 length t 1Tslength t frequency vector 1 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 195 0 1000 2000 3000 4000 5000 0 1000 2000 3000 4000 5000 0 1000 2000 3000 4000 5000 Figure 102 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 suppressedcarrier method in the middle plot the carrier is not clearly visible After preprocessing of the suppressedcarrier signal using the scheme in Figure 103 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 freqLs s f imax f r eq at the peak phaseLangle f f t r l c imax phase at the peak Changing the default phase offset 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 suppressed carrier signal does not recover the phase offset In fact the maximum often occurs at frequencies other than the carrier and the phase values reported bear no resemblance to the desired phase offset 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 filter as shown in Figure 103 When the received signal rt consists of the pulse modulated data signal st times the carrier cos2πfct φ the output of the squaring block is r2t s2t cos22πfct φ 101 This can be rewritten using the identity 2 cos2x 1 cos2x in A4 to pro duce r2t 12s2t1 cos4πfct 2φ Rewriting s2t as the sum of its positive average value and the variation about this average yields s2t s2 avg vt 196 Chapter 10 Carrier Recovery Thus r2t 12s2 avg vt s2 avg cos4πfct 2φ vt cos4πfct 2φ A narrow bandpass filter centered near 2fc passes the pure cosine term in r2 and suppresses the DC component the presumably lowpass vt and the upcon verted vt The output of the bandpass filter is approximately rpt BPFr2t 1 2s2 avg cos4πfct 2φ ψ 102 where ψ is the phase shift added by the BPF at frequency 2fc Since ψ is known at the receiver rpt can be used to find the frequency and phase of the carrier Of course the primary component in rpt 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 rpt undulates slowly as s2 avg changes The following Matlab code carries out the preprocessing of Figure 103 First run pulrecsigm to generate the suppressed carrier signal rsc Listing 102 pllpreprocessm send received signal through square and BPF rr s c suppressed c a r r i e r r qr ˆ 2 square n o n l i n e a r i t y f l 500 f f 0 38 39 41 42 1 BPF center frequency at 4 fa 0 0 1 1 0 0 which i s twice f c hfirpm f l f f fa BPF design via firpm rpf i l t e r h 1 q f i l t e r gi ves preprocessed r Then the phase and frequency of rp can be found directly by using the FFT recover unknown f r eq and phase using FFT fftrBPFf f t rp spectrum of rBPF m imaxmax abs fftrBPF 1 end 2 f i nd f r eq of max peak s s f 0 length rp Tslength rp frequency vector freqSs s f imax f r eq at the peak phasepangle fftrBPF imax phase at the peak IR f f r eqz h 1 length rp 1Ts f r eq response of f i l t e r mi immin abs ffreqS f r eq where peak occurs phaseBPFangle IR im of BPF at peak f r eq phaseSmod phasepphaseBPF pi 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 estima tion The intent of this section is to clearly depict the problem of recovering the fre quency and phase of the carrier even when it is buried within the datamodulated 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 197 X2 BPF rt r2t Squaring nonlinearity Center frequency 2fc rpt cos4π fc t 2φ ψ Figure 103 Preprocessing the input to a PLL via a squaring nonlinearity and BPF results in a sinusoidal signal at twice the frequency with a phase offset equal to twice the original plus a term introduced by the known bandpass filtering Exercise 101 The squaring nonlinearity is only one possibility in the pllpreprocessm routine a Try replacing the r2t with rt Does this result in a viable method of emphasizing the carrier b Try replacing the r2t with r3t Does this result in a viable method of emphasizing the carrier c Can you think of other functions that will result in viable methods of empha sizing the carrier d Will a linear function work Why or why not Exercise 102 Determine the phase shift ψ at the frequency 2fc caused by the BPF when a fl490 496 502 b Ts00001 0000101 c M19 20 21 Explain why ψ should depend on fl Ts and M 102 Squared Difference Loop The problem of phase tracking is to determine the phase φ of the carrier and to follow any changes in φ using only the received signal The frequency fc of the carrier is assumed known though ultimately it too must be estimated The received signal can be preprocessed as in the previous section to create a signal that strips away the data in essence fabricating a sinusoid which has twice the frequency at twice the phase of the unmodulated carrier This can be idealized to rpt cos4πfct 2φ 103 which suppresses2 the dependence on the known phase shift ψ of the BPF and sets the constant s2 avg2 to unity compare with 102 The form of rpt 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 103 What can be done to recover φ modulo π from rpt 2 An example that takes ψ into account is given in Exercise 108 Is there some way to use an adaptive element Section 65 suggested that there are three steps to the creation of a good adaptive element setting a goal finding a method and then testing As a first try consider the goal of minimizing the average of the squared difference between rpt and a sinusoid generated using an estimate of the phase that is seek to minimize JSDθ avge²θ k 14 avgrpkTs cos4πf0kTs 2θ² 104 by choice of θ where rpkTs is the value of rpt sampled at time kTs and where f0 is presumed equal to fc The subscript SD stands for squared difference 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 rpkTs cos4πf0kTs 2θ eθ k 0 and so JSDθ 0 Hence 104 is minimized when θ has correctly identified the phase offset modulo the inevitable π ambiguity While there are many methods of minimizing 104 an adaptive element that descends the gradient of the performance function JSDθ leads to the algorithm³ θk 1 θk μ dJSDθdθ θθk 105 which is the same as 65 with the variable changed from x to θ Using the approximation detailed in G12 which holds for small μ the derivative and the average commute Thus dJSDθdθ d avge²θ kdθ avgde²θ kdθ 12 avgeθ k deθ kdθ avgrpkTs cos4πf0kTs 2θ sin4πf0kTs 2θ 106 Substituting this into 105 and evaluating at θ θk gives⁴ θk 1 θk μ avgrpkTs cos4πf0kTs 2θk sin4πf0kTs 2θk 107 This is implemented in pllsdm for a phase offset of phoff08 ie ϕ of 103 is 08 though this value is unknown to the algorithm Figure 104 plots the estimates theta for 50 different initial guesses theta1 Observe that many converge to the correct value at 08 Others converge to 08 π about 23 and to 08 π about 4 Listing 103 pllsdm phase tracking minimizing SD Ts110000 time1 t0TstimeTs time interval vector ³ Recall the discussion surrounding the AGC elements in Chapter 6 ⁴ Recall the convention that θk θkTs θttkTs Carrier Recovery 199 1 2 Phase offset 3 4 5 Time 6 7 8 9 10 0 3 2 1 0 1 2 3 Figure 104 The phasetracking algorithm 107 converges to the correct phase offset in this case 08 or to some multiple 08 nπ depending on the initial estimate f c 100 phoff 08 c a r r i e r f r eq and phase rpcos 4 pi f c t2 phoff s i m p l i f i e d rec s i g n a l mu001 algorithm s t e p s i z e thetazeros 1 length t theta 10 i n i t i a l i z e estimates f l 25 hones 1 f l f l averaging c o e f f i c i e n t s zzeros 1 f l f0f c b u f f e r f o r avg for k1 length t1 run algorithm f i l t i n rp kcos 4 pi f0 t k2 theta k sin 4 pi f0 t k2 theta k zz 2 f l f i l t i n z contains past inputs theta k1theta kmu f l i p l r h z update z convolve h end Observe that the averaging a kind of lowpass filter as discussed in Appendix G is not implemented using the filter or conv commands because the complete input is not available at the start of the simulation Instead the timedomain method is used and the code here may be compared to the fourth method in waystofiltm on page 143 At each time k there is a vector z of past inputs These are multiplied point by point with the impulse response h which is flipped in time so that the sum properly implements a convolution Because the filter is just a moving average the impulse response is constant 1fl over the length of the filtering Exercise 103 Use the preceding code to play with the SD phasetracking algorithm a How does the stepsize mu affect the convergence rate b What happens if mu is too large say mu10 c Does the convergence speed depend on the value of the phase offset d How does the final converged value depend on the initial estimate theta1 Exercise 104 Investigate these questions by making suitable modifications to pllsdm 200 Chapter 10 Carrier Recovery a What happens if the phase slowly changes over time Consider a slow small amplitude undulation in phoff b Consider a slow linear drift in phoff c What happens if the frequency f0 used in the algorithm is slightly different from the frequency fc used to construct the carrier d What happens if the frequency f0 used in the algorithm is greatly different from the frequency fc used to construct the carrier Exercise 105 How much averaging is necessary Reduce the length of the averaging filter Is it possible to make the algorithm work with no averaging Why does this work Hint yes it is possible Consider the relationship between 107 and G4 Exercise 106 Derive 106 following the technique used in Example G3 The performance function JSDθ of 104 provides a mathematical statement of the goal of an adaptive phasetracking element The method is defined by the algorithm 107 and simulations such as pllsdm suggest that the algorithm can function as desired But why does it work One way to understand adaptive elements as discussed in Section 66 and shown in Figure 617 on page 119 is to draw the error surface for the per formance 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 rpkTs as well as the estimate θ Recognizing that the averaging operation acts as a kind of lowpass filter see Appendix G if this makes you nervous allows considerable simplification of JSDθ Rewrite 104 as JSDθ 1 4 LPFrpkTs cos4πf0kTs 2θ2 108 Substituting rpkTs from 103 and assuming fc f0 this can be rewritten JSDθ 1 4 LPFcos4πf0kTs 2φ cos4πf0kTs 2θ2 Expanding the square gives JSDθ 1 4 LPFcos24πf0kTs 2φ 2 cos4πf0kTs 2φ cos4πf0kTs 2θ cos24πf0kTs 2θ Using the trigonometric formula A4 for the square of a cosine and the formula A13 for the cosine angle sum ie expand cosx y with x 4πf0kTs and y 2φ and then again with y 2θ yields JSDθ 1 8 LPF2 cos8πf0kTs 4φ 2 cos2φ 2θ 2 cos8πf0kTs 2φ 2θ cos8πf0kTs 4θ Carrier Recovery 201 4 04 04 04 0 08 0 2 0 2 Phase estimates θ JPLL 0 08 04 JSD JC 4 6 8 Figure 105 The error surface 109 for the SD phasetracking algorithm is shown in the top plot Analogous error surfaces for the phaselocked loop 1011 and the Costas loop 1013 are shown in the middle and bottom plots All have minima or maxima at the desired locations in this case 08 plus nπ offsets Since the LPF is linear 1 4 1 8 LPFcos8πf0kTs 4φ 1 4 LPFcos2φ 2θ 1 4 LPFcos8πf0kTs 2φ 2θ 1 8 LPFcos8πf0kTs 4θ Assuming that the cutoff frequency of the lowpass filter is less than 4f0 this simplifies to JSDθ 1 41 cos2φ 2θ 109 which is shown in the top plot of Figure 105 for φ 08 The algorithm 107 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 θ 08 nπ for some n Thus Figure 105 provides evidence that the algorithm can successfully locate the unknown phase assuming that the preprocessed signal rpt has the form of 103 Figure 106 shows the algorithm 107 with the averaging operation replaced by the more general LPF In fact this provides a concrete answer to Exercise 105 the averaging the LPF and the integral block all act as lowpass filters All that was required of the filtering in order to arrive at 109 from 108 was that it remove frequencies above 4f0 This mild requirement is accomplished even by the integrator alone Exercise 107 The code in pllsdm is simplified in the sense that the received signal rp contains just the unmodulated carrier Implement a more realistic scenario by combining pulrecsigm to include a binary message sequence pllpreprocessm to create rp and pllsdm to recover the unknown phase offset of the carrier 202 Chapter 10 Carrier Recovery LPF 2 µΣ sin4πf0kTs 2θk cos4πf0kTs 2θk θk rpkTs Figure 106 A block diagram of the squareddifference phasetracking algorithm 107 The input rpkTs is a preprocessed version of the received signal as shown in Figure 103 The integrator block Σ has a lowpass character and is equivalent to a sum and delay as shown in Figure 75 Exercise 108 Using the default values in pulrecsigm and pllpreprocessm results in a ψ of zero Exercise 102 provided several situations in which ψ 0 Modify pllsdm to allow for nonzero ψ and verify the code for the cases suggested in Exercise 102 Exercise 109 Investigate how the SD algorithm performs when the received signal contains pulseshaped 4PAM data Can you choose parameters so that θ φ Exercise 1010 Consider the sampled cosine wave xkTs cos2πf0kTs α where the frequency f0 is known but the phase α is not Form vkTs xkTs cos2πf0kTs βk using the current ie at the kth sample instant estimate βk of α and define the candidate performance function Jβ LPFv2kTs where the cutoff frequency of the ideal lowpass filter is 08f0 a Does minimizing or maximizing Jβ result in β α Justify your answer b Develop a smallstepsize gradientdescent algorithm for updating βk to esti mate α Be certain that all of the signals needed to implement this algorithm are measurable quantities For example x is directly measurable but α is not c Determine the range of the initial guesses for βk in the algorithm of part b that will lead to the desired convergence to α given a suitably small stepsize 103 The PhaseLocked Loop Perhaps the bestloved method of phase tracking is known as the phaselocked loop PLL This section shows that the PLL can be derived as an adaptive element ascending the gradient of a simple performance function The key idea is to modulate the processed received signal rpt of Figure 103 down to DC using a cosine of known frequency 2f0 and phase 2θ ψ After filtering to remove the highfrequency 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 rpt To be specific let JPLLθ 12 LPFrpkTs cos4πf0kTs 2θ ψ 1010 Using the cosine product relationship A9 and the definition of rpt from 103 under the assumption that fc f0 JPLLθ 12 LPFcos4πf0kTs 2ϕ ψ cos4πf0kTs 2θ ψ 14 LPFcos2ϕ 2θ cos8πf0kTs 2θ 2ϕ 2ψ 14 LPFcos2ϕ 2θ 14 LPFcos8πf0kTs 2θ 2ϕ 2ψ 14 cos2ϕ 2θ 1011 assuming that the cutoff frequency of the lowpass filter is well below 4f0 This is shown in the middle plot of Figure 105 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 find the correct answer JPLLθ needs to be maximized The substantive difference 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 1010 with respect to θ at time k can be approximated using G12 as dLPFrpkTs cos4πf0kTs 2θ ψdθ θθk LPF drpkTs cos4πf0kTs 2θ ψdθ θθk LPFrpkTs sin4πf0kTs 2θk ψ The corresponding adaptive element θk 1 θk μ LPFrpkTs sin4πf0kTs 2θk ψ 1012 is shown in Figure 107 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 difference between the PLL and SD algorithms is clear from a comparison of Figures 106 and 107 The PLL requires one fewer oscillator and one fewer addition block Since the performance functions JSDθ and JPLLθ are effectively the same the performance characteristics of the two are roughly equivalent 204 Chapter 10 Carrier Recovery sin4πf0kTs 2θk ψ LPF Fz 2 µΣ θk rpkTs ek Figure 107 A block diagram of the digital phaselockedloop algorithm 1012 The input signal rpkTs has already been preprocessed to emphasize the carrier as in Figure 103 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 lowfrequency energy Suppose that fc is the frequency of the transmitter and f0 is the assumed frequency at the receiver with f0 close to fc The following program simulates 1012 for time seconds Note that the firpm filter creates an h with a zero phase at the center frequency and so ψ is set to zero Listing 104 pllconvergem simulate PhaseLocked Loop Ts110000 time 1 tTs Ts time time vector f c 1000 phoff 08 c a r r i e r f r eq and phase rpcos 4 pi f c t2 phoff s i m p l i f i e d rec d s i g n a l f l 100 f f 0 01 02 1 fa 1 1 0 0 hfirpm f l f f fa LPF design mu003 algorithm s t e p s i z e f0 1000 f r eq at r e c e i v e r thetazeros 1 length t theta 10 i n i t i a l i z e estimates zzeros 1 f l 1 i n i t i a l i z e LPF for k1length t1 z contains past inputs zz 2 f l 1 rp k sin 4 pi f0 t k2 theta k updatef l i p l r h z new output of LPF theta k1 theta kmuupdate algorithm update end Figures 108a 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 offset φ 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 definite trend the simulation in Figure 108b used f0 1000 Hz and fc 1001 Hz Can you figure out how the slope of θ relates to the frequency offset The caption in Figure 108b provides a hint Can you imagine how the PLL might be used to estimate the frequency as well as to find the phase offset These questions and more will be answered in Section 106 Exercise 1011 Use the preceding code to play with the phaselockedloop algorithm How does µ affect the convergence rate How does µ affect the oscil lations in θ What happens if µ is too large say µ 1 Does the convergence speed depend on the value of the phase offset Carrier Recovery 205 08 0 02 04 Time a b 06 08 1 06 Phase offset 04 02 0 80 2 4 Time 6 8 10 6 4 2 0 Figure 108 Using the PLL the estimates θ in a converge to a region about the phase offset φ and then oscillate When the frequency estimate is incorrect as in b θ becomes a line whose slope is proportional to the frequency difference Exercise 1012 In pllconvergem how much filtering is necessary Reduce the length of the filter Does the algorithm still work with no LPF Why How does your filter affect the convergent value of the algorithm How does your filter affect the tracking of the estimates when f0 fc Exercise 1013 The code in pllconvergem is simplified in the sense that the received signal rp contains just the unmodulated carrier Implement a more real istic scenario by combining pulrecsigm to include a binary message sequence pllpreprocessm to create rp and pllconvergem to recover the unknown phase offset of the carrier Exercise 1014 Using the default values in pulrecsigm and pllpreprocessm results in a ψ of zero Exercise 102 provided several situations in which ψ 0 Modify pllconvergem to allow for nonzero ψ and verify the code on the cases suggested in Exercise 102 Exercise 1015 TRUE or FALSE The optimum settings of phase recovery for a PLL operating on a preprocessed ie squared and narrowly bandpassfiltered at twice the carrier frequency received PAM signal are unaffected by the channel transfer function outside a narrow band around the carrier frequency Exercise 1016 Investigate how the PLL algorithm performs when the received signal contains pulseshaped 4PAM data Can you choose parameters so that θ φ Exercise 1017 Many variations on the basic PLL theme are possible Let ting ukTs rpkTs cos4πf0kTs θ the preceding PLL corresponds to a per formance function of JP LLθ LPFukTs Consider the alternative Jθ LPFu²kTs which leads directly to the algorithm⁵ θk 1 θk μ LPF ukTs dukTsdθ θθk which is θk 1 θk μLPFr²pkTs sin4πf0kTs 2θk cos4πf0kTs 2θk a Modify the code in pllconvergem to play with this variation on the PLL Try a variety of initial values theta1 Are the convergent values always the same as with the PLL b How does μ affect the convergence rate c How does μ affect the oscillations in θ d What happens if μ is too large say μ 1 e Does the convergence speed depend on the value of the phase offset f What happens when the LPF is removed set equal to unity g Draw the corresponding error surface Exercise 1018 Consider the alternative performance function Jθ ukTs where ukTs is defined in Exercise 1017 Derive the appropriate adaptive element and implement it by imitating the code in pllconvergem In what ways is this algorithm better than the standard PLL In what ways is it worse The PLL can be used to identify the phase offset of the carrier It can be derived as a gradient descent on a particular performance function and can be investigated via simulation with variants of pllconvergem for instance When the phase offset changes the PLL can track the changes up to some maximum rate Conceptually tracking a small frequency offset is identical to tracking a changing phase and Section 106 investigates how to use the PLL as a building block for the estimation of frequency offsets Section 1063 also shows how a linearized analysis of the behavior of the PLL algorithm can be used to concretely describe the convergence and tracking performance of the loop in terms of the implementation of the LPF ⁵ This is sensible because values of θ that minimize u²kTs also minimize ukTs received signal rkTs skTs cos2πfckTs ϕ by reversing the order of the processing first modulating to DC then lowpass filtering and finally squaring This reversal of operations leads to the performance function JCθ avgLPFrkTs cos2πf0kTs θ2 1013 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 103 To see why this works suppose that fc f0 and substitute rkTs into 1013 JCθ avgLPFskTs cos2πf0kTs ϕ cos2πf0kTs θ2 Assuming that the cutoff of the LPF is larger than the absolute bandwidth of skTs and following the same logic as in 1011 but with ϕ instead of 2ϕ θ in place of 2θ and 2πf0kTs replacing 4πf0kTs shows that LPFskTs cos2πf0kTs ϕ cos2πf0kTs θ 12 LPFskTs cosϕ θ 1014 Substituting 1014 into 1013 yields JCθ avg12 skTs cosϕ θ2 14 avgs2kTs cos2ϕ θ 14 savg2 cos2ϕ θ where savg2 is the fixed average value of the square of the data sequence skTs Thus JCθ is proportional to cos2ϕ θ This performance function is plotted for an unknown phase offset of ϕ 08 in the bottom part of Figure 105 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 JPLL because cos2ϕ θ 121 cos2ϕ 2θ as shown using A4 The Costas loop can be implemented as a standard adaptive element 105 The derivative of JCθ is approximated by swapping the order of the differentiation and the averaging as in G12 applying the chain rule and then swapping the derivative with the LPF Thus dJCθdθ can be approximated as avgdLPFrkTs cos2πf0kTs θ2dθ 2 avgLPFrkTs cos2πf0kTs θ dLPFrkTs cos2πf0kTs θdθ 2 avgLPFrkTs cos2πf0kTs θ LPFdrkTs cos2πf0kTs θdθ 2 avgLPFrkTs cos2πf0kTs θ LPFrkTs sin2πf0kTs θ Accordingly an implementable version of the Costas loop can be built as θk 1 θk μ dJCθdθ θθk θk μ avgLPFrkTs cos2πf0kTs θk LPFrkTs sin2πf0kTs θk This is diagrammed in Figure 109 leaving off the first or outer averaging operation as is often done since it is redundant given the averaging effect of the two LPFs and the averaging effect inherent in the smallstepsize update With this averaging removed the algorithm is θk 1 θk μLPFrkTs cos2πf0kTs θk LPFrkTs sin2πf0kTs θk 1015 Basically there are two paths The upper path modulates by a cosine and then lowpass filters to create 1014 while the lower path modulates by a sine wave and then lowpass filters to give skTs 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 4PAM transmitted signal r is created as in pulrecsigm from page 194 with carrier frequency fc1000 The Costasloop phasetracking method 1015 can be implemented in much the same way that the PLL is implemented in pllconvergem Listing 105 costasloopm simulate the Costas loop with input from pulrecsigm rrsc rsc from pulrecsigm fl500 ff0 01 02 1 fa1 1 0 0 hfirpmflfffa LPF design mu003 algorithm stepsize f01000 freq at receiver thetazeros1lengtht theta10 estimate vector zszeros1fl1 zczeros1fl1 buffers for LPFs for k1lengtht1 z contains past inputs Carrier Recovery 209 0 04 08 12 16 Time 4 3 2 1 0 1 2 3 Phase offset Figure 1010 Depending on where it is initialized the estimates made by the Costasloop algorithm converge to φ nπ For this plot the unknown φ was 08 and there were 50 different initializations zs zs 2 f l 1 2 r k sin 2 pi f0 t ktheta k zc zc 2 f l 1 2 r k cos 2 pi f0 t ktheta k l p f sf l i p l r h zs l p f cf l i p l r h zc output of f i l t e r s theta k1theta kmu l p f s l p f c algorithm update end Typical output of costasloopm is shown in Figure 1010 which shows the evolution of the phase estimates for 50 different starting values theta1 Some of these converge to φ 08 and others converge to nearby π multiples These stationary points occur at all the maxima of the error surface the bottom plot in Figure 105 When the frequency is not exactly known the phase estimates of the Costas algorithm try to follow For example in Figure 1011 the frequency of the carrier is fc 1000 while the assumed frequency at the receiver was f0 10001 Fifty different starting points are shown and in all cases the estimates converge to a line Section 106 shows how this linear phase motion can be used to estimate the frequency difference Exercise 1019 Use the preceding code to play with the Costasloop algo rithm a How does the stepsize mu affect the convergence rate b What happens if mu is too large say mu1 c Does the convergence speed depend on the value of the phase offset d When there is a small frequency offset what is the relationship between the slope of the phase estimate and the frequency difference Exercise 1020 How does the filter h influence the performance of the Costas loop 210 Chapter 10 Carrier Recovery 0 04 08 12 16 2 Time Phase offset 6 4 2 0 2 4 Figure 1011 When the frequency of the carrier is unknown at the receiver the phase estimates converge to a line a Try fl1000 30 10 3 b Remove the LPFs completely from costasloopm How does this affect the convergent values and the tracking performance Exercise 1021 Oscillators that can adjust their phase in response to an input signal are more expensive than freerunning oscillators Figure 1012 shows an alternative implementation of the Costas loop a Show that this is actually carrying out the same calculations albeit in a different order as the implementation in Figure 109 b Write a simulation or modify costasloopm to implement this alternative Exercise 1022 Reconsider the modified PLL of Exercise 1017 This algorithm also incorporates a squaring operation Does it require the preprocessing step of Figure 103 Why Exercise 1023 TRUE or FALSE Implementing a Costasloop phaserecovery scheme on the preprocessed version ie squared and narrowly bandpassfiltered at twice the carrier frequency of a received PAM signal results in one and only one local minimum in any 179 window of the adjusted phase In some applications the Costas loop is considered a better solution than the standard PLL because it can be more robust in the presence of noise 105 DecisionDirected Phase Tracking A method of phase tracking that works only in digital systems exploits the error between the received value and the nearest symbol For example suppose that Carrier Recovery 211 LPF LPF cosθk cosθk sinθk µΣ 2cos2πf0kT 2sin2πf0kT θk rkTs 1 Figure 1012 An alternative implementation of the Costas loop trades off less expensive oscillators for a more complex structure as discussed in Exercise 1021 a 09 is received in a binary 1 system suggesting that a 1 was transmitted Then the difference between the 09 and the nearest symbol 1 provides infor mation that can be used to adjust the phase estimate This method is called decisiondirected DD because the decisions the choice of the nearest allow able symbol direct or drive the adaptation To see how this works let st be a pulseshaped signal created from a message in which the symbols are chosen from some finite alphabet At the transmitter st is modulated by a carrier at frequency fc with unknown phase φ creating the signal rt st cos2πfct φ At the receiver this signal is demodulated by a sinusoid and then lowpass filtered to create xt 2 LPFst cos2πfct φ cos2πf0t θ 1016 As shown in Chapter 5 when the frequencies f0 and fc and phases φ and θ are equal then xt st In particular xkTs skTs at the sample instants t kTs where the skTs are elements of the alphabet On the other hand if φ θ then xkTs will not be a member of the alphabet The difference between what xkTs is and what it should be can be used to form a performance function and hence a phasetracking algorithm A quantization function Qx is used to find the nearest element of the symbol alphabet The performance function for the decisiondirected method is JDDθ 1 4 avgQxk xk2 1017 This can be used as the basis of an adaptive element by using the approximation G12 to calculate dJDDθdθ 14 avgdQxk xk2dθ 12 avgQxk xk dxkdθ which assumes that the derivative of Q with respect to θ is zero The derivative of xk can similarly be approximated as recall that xk xkTs xttkTs is defined in 1016 dxkdθ 2 LPFrk sin2πfckTs θ Thus the decisiondirected algorithm for phase tracking is θk 1 θk μ avgQxk xk LPFrk sin2πf0kTs θk Suppressing the redundant outer averaging operation gives θk 1 θk μQxk xk LPFrk sin2πf0kTs θk 1018 which is shown in block diagram form in Figure 1013 Suppose that a 4PAM transmitted signal rsc is created as in pulrecsigm from page 194 with oversampling factor M20 and carrier frequency fc1000 Then the DD phasetracking method 1018 can be simulated Listing 106 pllddm decisiondirected phase tracking fl100 fbe0 2 3 1 LPF parameters damps1 1 0 0 hfirpmflfbedamps impulse response fzczeros1fl1fzszeros1fl1 initialize filters thetazeros1N theta109 initial phase mu03 j1 f0fc algorithm stepsize for k1lengthrsc cc2cos2pif0tkthetaj cosine for demod ss2sin2pif0tkthetaj sine for demod rcrsckcc rsrsckss do the demods fzcfzc2fl1rc states for LPFs fzsfzs2fl1rs Carrier Recovery 213 xk f l i p l r h fzc LPF gi ves x xderf l i p l r h fzs i t s d e r i v a t i v e i f mod0 5 f lM2k M0 downsample f o r timing qxquantalph xk 3 1 1 3 quantize to alphabet theta j 1theta j mu qxxk xder algorithm update jj 1 end end The same lowpass filter is used after demodulation with the cosine to create x and with the sine to create its derivative xder The filtering is done using the timedomain method the fourth method presented in waystofiltm on page 143 because the demodulated signals are unavailable until the phase estimates are made One subtlety in the decisiondirected phasetracking 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 1018 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 Tsrate sampled data points The output of pllddm for many different starting values is shown in Figure 1014 For initializations near the correct answer φ 10 the estimates con verge to 10 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 N1000 symbols drawn from the 4PAM alphabet Listing 107 plldderrsysm error surface for decisiondirected phase tracking N1000 average over N symbols mpamN 4 5 use 4PAM symbols phi 10 unknown phase o f f s e t phi theta 2016 gr i d f o r phase estimates for k1 length theta f o r each p o s s i b l e theta xmcos phitheta k f i nd x with t h i s theta qxquantalph x 3 1 1 3 q x f o r t h i s theta j theta kqxx qxx N J f o r t h i s theta end plot theta j theta The output of plldderrsysm is shown in Figure 1015 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 φ 10 2nπ and the other at φ 10 π 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 214 Chapter 10 Carrier Recovery 0 1 2 3 4 5 4 3 2 1 0 1 2 Time Phase estimates 5 Figure 1014 The decisiondirected tracking algorithm is adapted to locate a phase offset of φ 10 Many of the different initializations converge to φ 10 nπ but there are also other convergent values 2 1 0 1 2 3 4 5 6 0 02 04 06 08 1 Phase estimates θ Cost JDDθ Figure 1015 The error surface for the DD phasetracking algorithm 1018 has several minima within each 2π repetition The phase estimates will typically converge to the closest of these minima of 1 This inverts each data symbol 1 is mapped to 1 and 3 is mapped to 3 The other four occur near π multiples of 3π8 10 and 5π8 10 which correspond to values of the cosine that jumble the data sequence in various ways The implication of this error surface is clear there are many values to which the decisiondirected method may converge Only some of these correspond to desirable answers Thus the DD method is local in the same way that the steepest descent minimization of the function 68 in Section 66 depends on the initial value of the estimate If it is possible to start near the desired answer then convergence can be assured However if no good initialization is possible the method may converge to one of the undesirable minima This suggests that the decisiondirected method can perform acceptably in a tracking mode when following a slowly varying phase but would perform worse than the alternatives at startup when nothing is known about the correct value of the phase Carrier Recovery 215 Exercise 1024 Use the code in pllddm 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 fre quency fc of the carrier Exercise 1025 The direct calculation of dxkTsdθ as a filtered version of 1016 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 pllddm Exercise 1026 Consider the DD phasetracking algorithm when the message alphabet is binary 1 a Modify pllddm to simulate this case b Modify plldderrsysm to draw the error surface Is the DD algorithm better or worse suited to the binary case than the 4PAM case Exercise 1027 Consider the DD phasetracking algorithm when the message alphabet is 6PAM a Modify pllddm to simulate this case b Modify plldderrsysm to draw the error surface Is the DD algorithm better or worse suited to 6PAM than to 4PAM Exercise 1028 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 1029 Investigate how the error surface depends on the input signal a Draw the error surface for the DD phasetracking algorithm when the inputs are binary 1 b Draw the error surface for the DD phasetracking algorithm when the inputs are drawn from the 4PAM constellation for the case in which the symbol 3 never occurs Exercise 1030 TRUE or FALSE Decisiondirected phase recovery can exhibit local minima of different depths Exercise 1031 This problem uses the B3IG to test the carrierrecovery algo rithm of your choice a Currently the receiver portion of the script in BigIdealm knows the phase of the carrier Add a carrierrecovery algorithm of your choice to BigIdealm 216 Chapter 10 Carrier Recovery so that the receiver can accommodate unknown carrier phases Run the mod ified code and use the carrierrecovery algorithm to estimate the phase offset φ State the carrierrecovery method used and plot the tracking of φ If the receiver employs preprocessing take care to design the BPF appropriately b Modify the B3IG so that a phase offset is introduced In BigTransmitterm set the variable phi05 and add a phase offset xrfxcos2pirfParamsfiftx 1lengthxrfParamsTttxMpnoisephi where upconversion is performed Rerun the code How does the behavior of your algorithm differ Include plots to justify your claim c Repeat part b for the case when phi12 106 Frequency Tracking The problems inherent in even a tiny difference in the frequency of the carrier at the transmitter and the assumed frequency at the receiver are shown in 55 and illustrated graphically in Figure 919 on page 185 Since no two independent oscillators are ever exactly aligned it is important to find ways of estimating the frequency from the received signal The direct method of Section 1061 derives an algorithm based on a performance function that uses a square difference in the time domain Unfortunately this does not work well and its failure can be traced to the shape of the error surface Section 1062 begins with the observation familiar from Figures 108b and 1011 that the estimates of phase made by the phasetracking algorithms over time lie on a line whose slope is proportional to the difference 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 dualloop 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 1063 1061 Direct Frequency Estimation Perhaps the simplest setting in which to begin frequency estimation is to assume that the received signal is rt cos2πfct where fc is unknown By analogy with the squareddifference method of phase estimation in Section 102 a rea sonable strategy is to try to choose f0 so as to minimize Jf0 1 2 LPFrt cos2πf0t2 1019 Carrier Recovery 217 Frequency estimates f0 Frequency Time Figure 1016 The frequencyestimation algorithm 1020 appears to function well at first But over time the estimates diverge from the desired answer Following a gradient strategy for updating the estimates leads to the algorithm How well does this algorithm work First observe that the update is multiplied by This arises from application of the chain rule when taking the derivative of with respect to 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 offending term and go ahead and simulate the methodAt first glance it might seem that the method works well Figure 1016 shows 20 different starting values All 20 appear to converge nicely within one second to the unknown frequency value at But then something strange happens one by one the estimates diverge In the figure one peels off 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 simplified and idealized simulations function poorly it is a safe bet that the algorithm is somehow flawed What is the flaw in this case Recall that error surfaces are often a good way of picturing the behavior of gradientdescent algorithms Expanding the square and using the standard identities A4 and A9 can be rewritten The code is available in the program pllfreqestm on the website 218 Chapter 10 Carrier Recovery 05 0 fc Frequency estimate f0 J f0 Figure 1017 The error surface corresponding to the frequency estimation performance function 1019 is flat everywhere except for a deep crevice at the correct answer f0 fc assuming that the cutoff frequency of the lowpass filter is less than fc and that f0 fc At the point where f0 fc Jf0 0 For any other value of f0 how ever as time progresses the cosine term undulates up and down with an average value of zero Hence Jf0 averages to 1 2 for any f0 fc This pathological situ ation is shown in Figure 1017 When f0 is far from fc this analysis does not hold because the LPF no longer removes the first two cosine terms in 1021 Somewhat paradoxically the algo rithm behaves well until the answer is nearly correct Once f0 fc the error surface flattens and the estimates wander around There is a slight possibil ity that it might accidently fall into the exact correct answer but simulations suggest that such luck is rare Oh well never mind 1062 Indirect Frequency Estimation Because the direct method of the previous section is unreliable this section pursues an alternative strategy based on the observation that the phase estimates of the PLL converge to a line that has a slope proportional to the difference between the actual frequency of the carrier and the frequency that is assumed at the receiver Recall Figures 108b and 1011 The indirect method cascades two PLLs the first finds this line and hence indirectly specifies the frequency the second converges to a constant appropriate for the phase offset The scheme is pictured in Figure 1018 Suppose that the received signal has been preprocessed to form rpt cos4πfct 2φ This is applied to the inputs of two PLLs8 The top PLL functions exactly as expected from previous sections if the frequency of its oscillator is 2f0 then the phase estimates 2θ1 converge to a ramp with slope 2πf0 fc that is θ1t 2πfc f0t b 8 Or two SD phasetracking algorithms or two Costas loops though in the latter case the squaring preprocessing is unnecessary Carrier Recovery 219 LPF F1z LPF F2z 2 2 X X µ1Σ sin4πf0kTs2θ1k 2θ2k sin4πf0kTs2θ1k θ1k θ2k θ1k µ2Σ θ2k rpkTs e1k e2k Figure 1018 A pair of PLLs can efficiently estimate the frequency offset at the receiver The parameter θ1 in the top loop converges to a slope that corrects the frequency offset and the parameter θ2 in the bottom loop corrects the residual phase offset The sum θ1 θ2 is used to drive the sinusoid in the carrierrecovery scheme where b is the yintercept 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 sin4πf0t 2θ1t 2θ2t sin4πf0t 4πfc f0t 2b 2θ2t sin4πfct 2b 2θ2t Effectively the top loop has synthesized a signal that has the correct frequency for the bottom loop Accordingly θ2t φ b Since a sinusoid with frequency 2πf0t and phase θ1t θ2t is indistinguishable from a sinusoid with fre quency 2πfct and phase θ2t these values can be used to generate a sinusoid that is aligned with rpt 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 dualpllsm Listing 108 dualpllsm estimation of carrier via dualloop structure Ts110000 time 5 t 0Ts timeTs time vector f c 1000 phoff 2 c a r r i e r f r eq and phase rpcos 4 pi f c t2 phoff preprocessed s i g n a l rBPF mu101 mu2003 algorithm s t e p s i z e s f0 1001 assumed f r eq at r e c e i v e r l entlength t th1zeros 1 l ent i n i t i a l i z e estimates th2zeros 1 l ent car es tzeros 1 l ent for k1 lent 1 combine top PLL th1 th1 k1th1 kmu1rp k sin 4 pi f0 t k2 th1 k th2 k1th2 kmu2rp k sin 4 pi f0 t k2 th1 k2 th2 k with bottom PLL th2 to form estimate of preprocessed s i g n a l car es t kcos4 pi f0 t k2 th1 k2 th2 k end The output of this program is shown in Figure 1019 The upper graph shows that θ1 the phase estimate of the top PLL converges to a ramp The middle plot 220 Chapter 10 Carrier Recovery 20 0 20 01 0 01 02 03 0 1 2 3 4 5 1 0 1 Time error θ1 θ2 Figure 1019 The output of Matlab program dualpllsm shows the output of the first PLL converging to a line which allows the second PLL to converge to a constant The bottom figure shows that this estimator can be used to construct a sinusoid that is very close to the preprocessed carrier 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 1019 that θ1 converges to a line What line does it converge to Looking carefully at the data generated by dualpllsm the line can be calculated explicitly The two points at 2 1136 and 4 2393 fit a line with slope m 628 and an intercept b 121 Thus 2πfc f0 628 or fc f0 1 Indeed this was the value used in the simulation Reading the final converged value of θ2 from the simulation shown in the middle plot gives 00627 b 00627 is 1147 which is almost exactly π away from 2 the value used in phoff Exercise 1032 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 effect 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 pulseshaped data instead of by a simple sinusoid Exercise 1033 Build a frequency estimator using two SD phasetracking algo rithms rather than two PLLs How does the performance change Which do you think is preferable Carrier Recovery 221 Exercise 1034 Build a frequency estimator that incorporates the preprocess ing of the received signal from Figure 103 as coded in pllpreprocessm Exercise 1035 Build a frequency estimator using two Costas loops rather than two PLLs How does the performance change Which do you think is preferable Exercise 1036 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 1037 Repeat Exercise 1036 for the dual SD algorithm Exercise 1038 Repeat Exercise 1036 for the dual Costasloop algorithm Exercise 1039 Repeat Exercise 1036 for the dual DD algorithm Exercise 1040 Investigate via simulation how the PLL functions when there is intersymbol interference caused by a nonunity channel Pick a channel for instance chan1 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 1041 Repeat Exercise 1040 for the dual Costas loop Exercise 1042 Repeat Exercise 1040 for the Costasloop algorithm Exercise 1043 Repeat Exercise 1040 for the DD algorithm 1063 Generalized PLL Section 1062 showed that two loops can be used in concert to accomplish the carrierrecovery task the first loop estimates frequency offset and the second loop estimates the phase offset This section shows an alternative structure that folds one of the loops into the lowpass filter in the form of an IIR filter and accomplishes both estimations at once This is shown in Figure 1020 which looks the same as Figure 107 but with the FIR lowpass filter Fz replaced by an IIR lowpass filter Gz GNzGDz To see the operation of the generalized PLL concretely pllgeneralm imple ments the system of Figure 1020 with GNz 2 µ 2z and GDz z 1 The implementation of the IIR filter follows the timedomain method in waystofiltIIRm on page 145 When the frequency offset is zero when f0fc 222 Chapter 10 Carrier Recovery sin4πf0kTs 2θk Gz 2 rpkTs µ z1 θk θk1 Figure 1020 The general PLL can track both phase and frequency offsets using an IIR LPF Gz This figure is identical to Figure 107 except that the FIR lowpass filter is replaced by a suitable IIR lowpass filter Linearizing this structure gives Figure 1022 Appendix F presents conditions on Gz under which the tracking occurs theta converges to phoff When there is a frequency offset as in the default values with f0fc01 theta converges to a line Essentially this θ value con verges to θ1 θ2 in the dualloop structure of Figure 1019 Listing 109 pllgeneralm the PLL with an IIR LPF Ts110000 time 1 tTs Ts time time vector f c 1000 phoff 08 c a r r i e r f r eq and phase rpcos 4 pi f c t2 phoff s i m p l i f i e d rec d s i g n a l mu003 algorithm s t e p s i z e a1 1 lenalength a 1 a u t o r e g r e s s i v e terms b2 2mu lenblength b moving average terms xveczeros lena 1 i n i t i a l i z e f i l t e r s eveczeros lenb 1 f0 10000 f r eq at r e c e i v e r thetazeros 1 length t theta 10 i n i t i a l i z e estimates for k1length t1 erp k sin 4 pi f0 t k2 theta k input to f i l t e r evec e evec 1 lenb 1 past values of inputs xa 2 lena 1 xvecb evec output of f i l t e r xvec x xvec 1 lena 1 1 past values of outputs theta k1 theta kmux algorithm update end 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 non linear components with nearby linear elements A linearization is valid only for a small range of values For example the nonlinear function sinx is approxi mately x for small values This can be seen by looking at sinx 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 107 are the oscillators and the mixers Consider a nonideal lowpass filter Fz with impulse response fk that has a cutoff frequency below 2f0 The output of the LPF is ek fk sin2θk 2φk where represents convolution With φ θ φ and φ θ sin2φk 2φk Thus the linearization is fk sin2φk fk 2φk 1022 Carrier Recovery 223 In words applying an LPF to sinx is approximately the same as applying the LPF to x at least for sufficiently small x There are two ways to understand why the general PLL structure in Figure 1020 works both of which involve linearization arguments The first method lin earizes Figure 1020 and applies the finalvalue theorem for Ztransforms Details can be found in Section F4 The second method is to show that a linearization of the generalized singleloop structure of Figure 1020 is the same as a lineariza tion of the dualloop method of Figure 1019 at least for certain values of the parameters Exercise 1050 shows that for certain special cases the two strate gies the dualloop and the generalized singleloop behave similarly in the sense that both have the same linearization Exercise 1044 What is the largest frequency offset that pllgeneralm can track How does theta behave when the tracking fails Exercise 1045 Examine the effect of different filters in pllgeneralm a Show that the filter used in pllgeneralm has a lowpass character b Let a1 0 What kind of IIR filter does this represent How does the loop behave for a frequency offset c Can you choose b so that the loop fails d Design an IIR a and b pair using cheby1 or cheby2 Test whether the loop functions to track small frequency offsets Exercise 1046 Design the equivalent squareddifference loop combining the IIR structure of pllgeneralm with the squareddifference objective function as in pllsdm Exercise 1047 Design the equivalent general Costasloop structure Hint replace the FIR LPFs in Figure 109 with suitable IIR filters Create a simu lation to verify the operation of the method Exercise 1048 The code in pllgeneralm is simplified in the sense that the received signal rp contains just the unmodulated carrier Implement a more real istic scenario by combining pulrecsigm to include a binary message sequence pllpreprocessm to create rp and pllgeneralm to recover the unknown phase offset of the carrier Demonstrate that the same system can track a frequency offset Exercise 1049 Investigate how the method performs when the received signal contains pulseshaped 4PAM data Verify that it can track both phase and frequency offsets 224 Chapter 10 Carrier Recovery µ z1 θ1k 2φk θ1k1 2θ1k 2θ2k µ z1 θ2k θ2k1 e1k e2k F1z F2z 2 2 Figure 1021 A linearization of the dualloop frequency tracker of Figure 1018 For small offsets this linear structure closely represents the behavior of the system µ z1 θk 2φk θk1 ek GDz GNz 2 Figure 1022 This is the linearization of Figure 1020 A B C A B B C Figure 1023 The lefthand block diagram with overlapping loops can be redrawn as the righthand split diagram Exercise 1050 This exercise outlines the steps needed to show the conditions under which the general PLL of Figure 1020 and the dualloop structure of Figure 1018 are the same in the sense of having the same linearization a Show that Figure 1021 is the linearization of Figure 1018 b Show that Figure 1022 is the linearization of the general PLL of Figure 1020 c Show that the two block diagrams in Figure 1023 are the same d Suppose that the lowpass filters are ideal F1z F2z 1 for all frequencies below the cutoff and F1z F2z 0 at all frequencies above Make the following assignments A µ z 1 2µ B µ z 1 and C 2 Carrier Recovery 225 Using the blockdiagram manipulation of part c show that Figures 1021 and 1022 are the same when GNz µ2z 2 2µ and GDz z 1 For Further Reading r J P Costas Synchronous Communications Proceedings of the IRE vol 44 no 12 pp 17131718 Dec 1956 r L E Franks Carrier and Bit Synchronization in Data Communication A Tutorial Review IEEE Transactions on Communications vol 28 no 8 pp 11071120 Aug 1980 11 Pulse Shaping and Receive Filtering 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 pulseshaping filter which changes each symbol in the digital message into a suitable analog pulse After transmission the receive filter assists in recapturing the digital values from the received pulses This chapter focuses on the design and specifi cation of these filters The symbols in the digital input sequence wkT are chosen from a finite set of values For instance they might be binary 1 or they may take values from a larger set such as the fourlevel alphabet 1 3 As suggested in Figure 111 the sequence wkT is indexed by the integer k and the data rate is one symbol every T seconds Similarly the output mkT assumes values from the same alphabet as wkT and at the same rate Thus the message is fully specified at times kT for all integers k But what happens between these times between kT and k 1T The analog modulation of Chapter 5 operates continuously and some values must be used to fill in the digital input between the samples This is the job of the pulseshaping filter to turn a discretetime sequence into an analog signal Each symbol wkT 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 112 shows how this happens and the eye diagram is used in Section 113 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 wave form 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 Pulse Shaping and Receive Filtering 227 Noise Interferers Message 3 1 1 3 Reconstructed message 3 1 1 3 Figure 111 System diagram of a baseband communication system emphasizing the pulse shaping at the transmitter and the corresponding receive filtering at the receiver Section 114 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 filter 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 signaltonoise ratio that can be maximized by choice of the pulse shape This is discussed in Section 115 The chapter concludes in Section 116 by considering pulse shaping and receive filters that both provide a Nyquist pulse and maximize the signaltonoise ratio The transmit and receive filter 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 111 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 111 Spectrum of the Pulse Spectrum of the Signal Probably the major reason why the design of the pulse shape is important is because the shape of the spectrum of the pulse dictates the spectrum of the whole transmission To see this suppose that the discretetime message sequence is turned into the analog pulse train as it enters the pulseshaping filter The response of the filter with impulse response is the convolution 228 Chapter 11 Pulse Shaping and Receive Filtering 1 08 06 04 02 0 Pulse shape 01 02 03 04 05 06 07 08 09 0 Sample periods a 102 100 102 104 Spectrum of the pulse shape 01 02 03 04 05 06 07 08 09 1 0 Normalized frequency b Figure 112 The Hamming pulse shape and its magnitude spectrum as suggested by Figure 111 Since the Fourier transform of a convolution is the product of the Fourier transforms from A40 it follows that Xf WafPf Though Waf is unknown this shows that Xf can have no energy at fre quencies at which Pf vanishes Whatever the spectrum of the message the transmission is directly scaled by Pf In particular the support of the spec trum Xf is no larger than the support of the spectrum Pf As a concrete example consider the pulse shape used in Chapter 9 which is the blip function shown in the top plot of Figure 112 The spectrum of this pulse shape can readily be calculated using freqz and this is shown at the bottom plot of Figure 112 It is a kind of mild lowpass filter The following code generates a sequence of N 4PAM symbols and then carries out the pulse shaping using the filter command Listing 111 pulsespecm spectrum of a pulse shape N1000 wpamN 4 5 4 l e v e l s i g n a l of length N M10 wupzeros 1 NM oversampling f a c t o r wup 1 MNMw oversample by M pshamming M bl i p pulse of width M xf i l t e r ps 1 wup convolve pulse shape with data The program pulsespecm represents the continuoustime or analog sig nal by oversampling both the data sequence and the pulse shape by a fac tor of M This technique was discussed in Section 63 where an analog sine wave sine100hzsampm was represented digitally at two sampling intervals a slow symbol interval T MTs and a faster rate shorter interval Ts represent ing 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 convo lution of the oversampled pulse shape and the oversampled data sequence is accomplished by the filter command Typical output is shown in the top plot Pulse Shaping and Receive Filtering 229 3 2 1 0 1 2 3 0 5 10 15 20 25 Symbols Output of pulse shaping filter 104 102 100 102 104 0 01 02 03 04 05 06 07 08 09 1 Normalized frequency Spectrum of the output Figure 113 The top plot shows a segment of the output x of the pulseshaping filter 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 112 of Figure 113 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 113 As expected from the previous discussion the spectrum Xf has the same contour as the spectrum of the individual pulse shape in Figure 112 112 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 first 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 Example 111 Suppose that the pulse shape in pulsespecm is stretched so that its width is 3T This triplewidth Hamming pulse shape is shown in Figure 114 along with its spectrum Observe that the spectrum has roughly onethird the nulltonull bandwidth of the singlesymbolwide Hamming pulse Since the 230 Chapter 11 Pulse Shaping and Receive Filtering 1 08 06 04 02 0 The pulse shape 0 05 1 15 2 25 3 Sample periods a 102 100 102 104 Spectrum of the pulse shape 0 01 02 03 04 05 06 07 08 09 1 Normalized frequency b Figure 114 The triplewidth Hamming pulse shape and its magnitude spectrum which is drawn using freqz 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 115 shows the output of the pulseshaping filter 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 tradeoff 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 111 Modify pulsespecm to reproduce Figures 114 and 115 for the doublewidth pulse shape Exercise 112 Modify pulsespecm 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 Pulse Shaping and Receive Filtering 231 0 0 5 10 15 20 25 5 5 Symbols 01 02 03 04 05 06 07 08 09 1 0 Normalized frequency Output of pulseshaping filter 102 100 102 104 Spectrum of the output Figure 115 The top plot shows a segment of the output x of the pulseshaping filter 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 114 113 Eye Diagrams While the differences between the pulseshaped sequences in Figures 113 and 115 are apparent it is difficult to see directly whether the distortions are seri ous that is whether they cause errors in the reconstructed data ie 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 briefly in Chapter 9 refer back to Figure 98 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 wave form In the ideal case the trace begins with n pulses each of which is a scaled copy of pt Then the n 1st to 2nth pulses arrive and overlay the first n though each is scaled according to its symbol value When there is noise channel distortion and timing jitter the overlays will differ 232 Chapter 11 Pulse Shaping and Receive Filtering 3 2 1 0 1 2 3 Optimum sampling times Sensitivity to timing error Distortion at zero crossings The eye Noise margin kT k 1T Figure 116 Interpreting eye diagrams a T wide Hamming blip is used to pulse shape a 4PAM data sequence As the number of superimposed traces increases the eye diagram becomes denser and gives a picture of how the pulse shape channel and other factors combine to determine the reliability of the recovered message Consider the n 2symbol eye diagram shown in Figure 116 In this figure the message is taken from the 4PAM alphabet 1 3 and the Hamming pulse shape is used The center of the eye gives the best times to sample since the openings ie the difference between the received pulse shape when the data value is 1 and the received pulse shape when the data value is 1 or between the received pulse shape when the data value is 1 and the received pulse shape when the data value is 3 are the largest The width marked sensitivity to timing error shows the range of time over which the samples quantize correctly The noise margin is the smallest vertical distance between the bands and is proportional to the amount of additive noise that can be resisted by the system without reporting erroneous values Thus eye diagrams such as Figure 116 give a clear picture of how good or how bad a pulse shape may be Sometimes the smearing in this figure is so great that the open segment in the center disappears The eye is said to be closed and this indicates that a simple quantizer slicer decision device will make mistakes in recovering the data stream This is not good For example reconsider the 4PAM example of the previous section that used a triplewidth Hamming pulse shape The eye diagram is shown in Figure 117 No noise was added when drawing this picture In the left two plots there are clear regions about the symbol locations where the eye is open Samples taken in these regions will be quantized correctly though there are also regions where mistakes will occur The other plots show the closed eye diagrams using 3T Pulse Shaping and Receive Filtering 233 4 2 0 2 4 Eye diagram for the Twide Hamming pulse shape 4 2 0 2 4 Eye diagram for the 2Twide Hamming pulse shape 4 2 0 2 4 Eye diagram for the 3Twide Hamming pulse shape 5 0 5 Eye diagram for the 5Twide Hamming pulse shape Symbols 0 1 2 3 4 5 Symbols 0 1 2 3 4 5 Figure 117 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 defined by the variable ps As in the pulseshaping 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 reshapexab command changes a vector x of size ab 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 112 eyediagm plot eye diagrams for a pulse shape N1000 mpamN 2 1 random s i g n a l of length N M20 mupzeros 1 NM oversampling f a c t o r of M mup 1 MNMm oversample by M pshammingM hamming pulse of width M xf i l t e r ps 1 mup convolve pulse shape neye 5 s i z e of groups cfloor length x neye M number of eyes to pl ot xpxNMneyeMc 1NM ignore t r a n s i e n t s at s t a r t plot reshape xp neye M c pl ot in groups Typical output of eyediagm is shown in Figure 118 The rectangular pulse shape in the top plot uses psones1M the Hamming pulse shape in the middle uses pshammingM and the bottom plot uses a truncated sinc pulse shape pssrrcL0M for L10 that is normalized so that the largest value is one The rectangular pulse is insensitive to timing errors since sampling almost anywhere except right at the transition boundaries will return the correct values The Hamming pulse shape has a wide eye but may suffer from a loss of SNR if the 234 Chapter 11 Pulse Shaping and Receive Filtering 0 Eye diagram for rectangular pulse shape 1 1 0 Eye diagram for Hamming pulse shape 1 1 2 0 Eye diagram for sinc pulse shape 2 Optimum sampling times Figure 118 Eye diagrams for rectangular Hamming and sinc pulse shapes with binary data 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 113 Modify eyediagm 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 114 Modify eyediagm to add noise to the pulseshaped signal x Use the Matlab command vrandn for different 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 115 Combine the previous two exercises Modify eyediagm as in Exercise 113 so that the data sequence is drawn from the alphabet 1 3 5 Add noise and answer the same question as in Exercise 114 Which alphabet is more susceptible to noise Exercise 116 TRUE or FALSE For two rectangular impulse responses with the same maximum magnitude but different time widths with T1 T2 the half power bandwidth of the frequency response of the pulse with width T1 exceeds that of the pulse with width T2 Pulse Shaping and Receive Filtering 235 uk yk kT equalizer receive filter channel pulse shape filter mk Figure 119 The baseband communications system of Exercise 119 Exercise 117 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 halfpower bandwidth of the sequence using the triangular pulse exceeds that of the rectangular pulse Exercise 118 Exercise 210 asked the following question TRUE or FALSE The flatter the top of the pulse shape the less sensitive the receiver is to small timing offsets In the absence of noise and without matched filtering this is TRUE Describe a noisy situation and a matched filtering that might cause the answer to be FALSE Exercise 119 Consider the baseband communication system in Figure 119 The difference equation relating the symbols mk to the T spaced equalizer input uk for the chosen baudtiming factor ǫ is uk 004mk ρ 100mk 1 ρ 060mk 2 ρ 038mk 3 ρ where ρ is a nonnegative integer The finiteimpulseresponse equalizer filter is described by the difference equation yk uk αuk 1 a Suppose α 04 and the message source is binary 1 Is the system from the source symbols mk to the equalizer output yk openeye Justify your answer b If the message source is 4PAM 1 3 can the system from mk to the equalizer output yk be made openeye by selection of α If so provide a successful value of α If not explain It is now easy to experiment with various pulse shapes pulseshape2m applies a sincshaped pulse to a random binary sequence Since the sinc pulse extends infinitely in time both backward and forward it cannot be represented exactly in the computer or in a real communication system and the parameter L spec ifies the duration of the sinc in terms of the number of symbol periods Listing 113 pulseshape2m pulse shape a random sequence N2000 mpamN 2 1 2PAM s i g n a l of length N M10 mupzeros 1 NM oversampling f a c t o r mup 1 MNMm oversample by M L10 pss r r c L 0 M s i nc pulse shape 2L symbols wide scsum ps M normalizing constant xf i l t e r ps sc 1 mup convolve pulse shape with data 236 Chapter 11 Pulse Shaping and Receive Filtering 04 03 02 01 0 01 Using a sinc pulse shape 10 8 6 4 2 0 2 4 6 8 10 3 2 1 0 1 2 Pulseshaped data sequence Symbol number Symbol interval 0 2 4 6 8 10 12 14 16 18 20 Figure 1110 A binary 1 data sequence is pulse shaped using a sinc pulse Figure 1110 plots the output of pulseshape2m The left figure shows the pulse shape while the right plot shows the analog pulseshaped signal xt over a duration of about 25 symbols The function srrcm first appeared in the discussion of interpolation in Section 64 and again in Exercise 622 and is used here to generate the sinc pulse shape The sinc function that srrcm produces is actually scaled and this effect is removed by normalizing with the variable sc Changing the second input argument from beta0 to other small positive numbers changes the shape of the curve each with a sinclike shape called a squareroot raised cosine This will be discussed in greater detail in Sections 114 and 116 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 Fig ure 113 each binary value was clearly delineated With the sinc pulse of Figure 1110 the analog waveform is more complicated However at the correct sam pling 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 1110 In pulseshape2m examine the effect of using different over sampling rates M Try M 1 5 100 Exercise 1111 Change pulseshape2m so that the data sequence is drawn from the alphabet 1 3 5 Can you visually identify the correct values in the pulseshaped signal Exercise 1112 In pulseshape2m examine the effect of using sinc approxi mations of different lengths L Try L 1 5 100 1000 Exercise 1113 In pulseshape2m examine the effect 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 Pulse Shaping and Receive Filtering 237 Exercise 1114 The goal is to design a frequencydivision multiplexed FDM system with a squareroot raised cosine as the transmitter pulse shape The symbol period is T 137 ms The design uses T4 sampling pulse lengths of 8T and a rolloff factor of 09 but it does not work since only three modulated carrier signals fit into the allotted bandwidth without multiuser interference Five are needed What parameters in the design would you change and why Exercise 1115 Using the code from Exercise 1111 examine the effects of adding noise in pulseshape2m Does the same amount of noise in the sixlevel data have more or less effect than in the twolevel data Exercise 1116 Modify pulseshape2m to include the effect of a nonunity channel Try both a highpass channel and a bandpass channel Which appears worse What are reasonable criteria for better and worse in this context Exercise 1117 A Matlab question in pulseshape2m examine the effect of using the filtfilt command for the convolution instead of the filter com mand Can you figure out why the results are different Exercise 1118 Another Matlab question in pulseshape2m examine the effect of using the conv command for the convolution instead of the filter command Can you figure out how to make this work 114 Nyquist Pulses Consider a multilevel signal drawn from a finite alphabet with values wkT where T is the sampling interval Let pt be the impulse response of the linear filter representing the pulse shape The signal just after pulse shaping is xt wat pt where wat is the pulsetrain signal 111 The corresponding output of the received filter is yt wat pt hct hRt as depicted in Figure 111 where hct is the impulse response of the channel and hRt is the impulse response of the receive filter Let hequivt pt hct hRt be the overall equivalent impulse response Then the equivalent overall frequency response ie Fhequivt is Hequivf PfHcfHRf 112 One approach would be to attempt to choose HRf so that Hequivf attained a desired value such as a pure delay for all f This would be a specification of Chapter 11 Pulse Shaping and Receive Filtering 238 the impulse response at all 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 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 spaced sample instants is formalized by saying that is a Nyquist pulse if there is a such that for all integers where is some nonzero constant The timing offset in will need to be found by the receiver A rectangular pulse with timewidth less than certainly satisfies as does any pulse shape that is less than 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 efficiently But if just any wide shape is used such as the multiplewide Hamming pulses then the eye may close What is needed is a signal that is wide in time and narrow in frequency that also fulfills the Nyquist condition One possibility is the sinc pulse with This has the narrowest possible spectrum since it forms a rectangle in frequency ie the frequency response of a lowpass filter Assuming that the clocks at the transmitter and receiver are synchronized so that the sinc pulse is Nyquist because and for all integers But there are several problems with the sinc pulse It has infinite duration In any real implementation the pulse must be truncated It is noncausal In any real implementation the truncated pulse must be delayed The steep band edges of the rectangular frequency function are difficult to approximate The sinc function decays slowly at a rate proportional to The slow decay recall the plot of the sinc function in Figure 211 on page 32 means that samples that are far apart in time can interact with each other when there are even modest clocksynchronization errors 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 off time and frequency behaviors can be tricky Desirable pulse shapes 1 have appropriate zero crossings ie 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 profile in the frequency domain One popular option is called the raised cosinerolloff or raised cosine filter It is defined by its Fourier transform where B is the absolute bandwidth f0 is the 6 dB bandwidth equal to 12T half the symbol rate fΔ B f0 and f1 f0 fΔ The corresponding timedomain function is Define the rolloff factor β fΔ f0 Figure 1111 shows the magnitude spectrum HRCf of the raised cosine filter on the right and the associated time response hRCt on the left for a variety of rolloff factors With T 12f0 hRCkT 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 hRCt becomes a sinc The raised cosine pulse hRCt with nonzero β has the following characteristics zero crossings at desired times band edges of HRCf that are less severe than with a sinc pulse an envelope that falls off at approximately 1t3 for large t look at 114 This is significantly faster than 1t As the rolloff factor β increases from 0 to 1 the significant part of the impulse response gets shorter Thus we have seen several examples of Nyquist pulses rectangular Hamming sinc and raised cosine with a variety of rolloff factors What is the general principle that distinguishes Nyquist pulses from all others A necessary and sufficient condition for a signal vt with Fourier transform Vf to be a Nyquist pulse is that the sum over all n of Vf nf0 be constant To see this use the Figure 1111 Raised cosine pulse shape in the time and frequency domains sifting property of an impulse A56 to factor Vf from the sum Given that convolution in the frequency domain is multiplication in the time domain A40 on applying the definition of the Fourier transform and using the transform pair from A28 with wt 1 and Wf δf where f0 1T this becomes If vt is a Nyquist pulse the only nonzero term in the sum is v0 and Thus the sum of the Vf nf0 is a constant if vt is a Nyquist pulse Conversely if the sum of the Vf nf0 is a constant then only the DC term in 115 can be nonzero and so vt is a Nyquist pulse Exercise 1119 Write a MATLAB routine that implements the raised cosine impulse response 114 with rolloff parameter β Hint 1 if you have trouble with divide by zero errors imitate the code in srrcm Plot the output of your program for a variety of β Hint 2 there is an easy way to use the function srrcm Pulse Shaping and Receive Filtering 241 3 3 15 15 pt t ms 02 06 10 Figure 1112 Pulse shape for Exercise 1123 Exercise 1120 Use your code from the previous exercise along with pulseshape2m to apply raised cosine pulse shaping to a random binary sequence Can you spot the appropriate times to sample by eye Exercise 1121 Use the code from the previous exercise and eyediagm to draw eye diagrams for the raised cosine pulse with rolloff parameters r 0 05 09 10 50 Compare these with the eye diagrams for rectangular and sinc functions Consider a sensitivity to timing errors b peak distortion c distortion of zero crossings and d the noise margin Exercise 1122 TRUE or FALSE The impulse response of a series combination of any αsecondwide pulseshape filter and its matched filter form a Nyquist pulse shape for a T spaced symbol sequence for any T α Exercise 1123 Consider the pulse shape pt of width 12 ms shown in Figure 1112 a Is pt a Nyquist pulse for the symbol period T 035 ms Justify your answer b Is pt a Nyquist pulse for the symbol period T 070 ms Justify your answer Exercise 1124 Neither s1t nor s2t is a Nyquist pulse a Can the product s1ts2t be a Nyquist pulse Explain b Can the convolution s1t s2t be a Nyquist pulse Explain Intersymbol interference occurs when data values at one sample instant inter fere with the data values at another sampling instant Using Nyquist shapes such as the rectangle sinc and raised cosine pulses removes the interference at least at the correct sampling instants when the channel is ideal The next sections parlay this discussion of isolated pulse shapes into usable designs for the pulse shaping and receive filters 115 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 filtering is aimed at reducing the sensitivity to noise which can be specified in terms of the power spectral density this is reviewed in some detail in Appendix E Consider the filtering problem in which a message signal is added to a noise signal and then both are passed through a linear filter This occurs for instance when the signal gt of Figure 111 is the output of the pulseshaping filter ie no interferers are present the channel is the identity and there is noise nt present Assume that the noise is white that is assume that its power spectral density Pnf is equal to some constant η for all frequencies The output yt of the linear filter with impulse response hRt can be described as the superposition of two components one driven by gt and the other by nt that is where This is shown in blockdiagram form in Figure 1113 In both components the processing and the output signal are the same The bottom diagram separates out the component due to the signal vkT which contains the message filtered through the pulse shape and the receive filter and the component due to the noise wkT which is the noise filtered through the receive filter The goal of this section is to find the receive filter that maximizes the ratio of the power in the signal vkT to the power in the noise wkT at the sample instants Consider choosing hRt so as to maximize the power of the signal vt at time t τ compared with the power in wt ie to maximize v2τ relative to the total power of the noise component wt This choice of hRt tends to emphasize the signal vt and suppress the noise wt The argument proceeds by finding the transfer function HRf that corresponds to this hRt From E2 the total power in wt is From the inverse Fourier transform Figure 1113 The two block diagrams result in the same output The top shows the data flow in a normal implementation of pulse shaping and receive filtering The bottom shows an equivalent that allows easy comparison between the parts of the output due to the signal ie vkT and the parts due to the noise ie wkT where Vf HRfGf Thus v2τ HRfGfej2πτf df2 Recall E3 which says that for Y f HRfUf Pyf HRf2Puf Thus Pwf HRf2Pnf ηHRf2 The quantity to be maximized can now be described by v2τPw HRfGfej2πτf df2 ηHRf2df 116 Schwarzs inequality A57 says that axbxdx2 ax2dx bx2dx and equality occurs only when ax kbx This converts 116 to v2τPw HRf2df Gfej2πτf 2df η HRf2df 117 which is maximized with equality when HRf kGfej2πτf 244 Chapter 11 Pulse Shaping and Receive Filtering HRf must now be transformed to find the corresponding impulse response hRt Since Y f Xf when yt xt use the frequencyscaling prop erty of Fourier transforms A38 with a scale factor of 1 F1W f wt F1W f wt Applying the timeshift property A37 yields F1Wfej2πfTd wt Td Combining these two transform pairs yields F1Wfej2πfTd wt Td wTd t Thus when gt is real F1kGfej2πfτ kgτ t kgτ t Observe that this filter has the following characteristics r This filter results in the maximum signaltonoise ratio of v2tPw at the time instant t τ for a noise signal with a flat power spectral density r Because the impulse response of this filter is a scaled time reversal of the pulse shape pt it is said to be matched to the pulse shape and is called a matched filter r The shape of the magnitude spectrum of the matched filter HRf is the same as the magnitude spectrum Gf r The shape of the magnitude spectrum of Gf is the same as the shape of the frequency response of the pulse shape Pf for a broadband mkT as in Section 111 r The matched filter for any filter with an even symmetric about some t time limited impulse response is a delayed replica of that filter The minimum delay is the upper limit of the timelimited range of the impulse response The following code allows handson exploration of this theoretical result The pulse shape is defined by the variable ps the default is the sinc function srrcL0M for L10 The receive filter is analogously defined by recfilt As usual the symbol alphabet is easily specified by the pam subroutine and the system operates at an oversampling rate M The noise is specified in n and the ratio of the powers is output as powvpoww Observe that for any pulse shape the ratio of the powers is maximized when the receive filter is the same as the pulse shape the fliplr command carries out the time reversal This holds no matter what the noise no matter what the symbol alphabet and no matter what the pulse shape Listing 114 matchfiltm test of SNR maximization N2ˆ15 mpamN 2 1 2PAM s i g n a l of length N M10 mupzeros 1 NM oversampling f a c t o r mup 1 MNMm oversample by M L10 pss r r c L 0 M def i ne pulse shape pspssqrtsumps2 and normalize n05randnsizemup noise gfilterps1mup convolve ps with data recfiltsrrcL0M receive filter H sub R recfiltrecfiltsqrtsumrecfilt2 normalize pulse shape vfilterfliplrrecfilt1g matched filter with data wfilterfliplrrecfilt1n matched filter with noise vdownsampv1MNM downsample to symbol rate wdownsampw1MNM downsample to symbol rate powvpowvdownsamp power in downsampled v powwpowwdownsamp power in downsampled w powvpoww ratio In general when the noise power spectral density is flat ie Pnf η the output of the matched filter may be realized by correlating the input to the matched filter with the pulse shape pt To see this recall that the output is described by the convolution xα sλhαλdλ of the matched filter with the impulse response ht Given the pulse shape pt and the assumption that the noise has flat power spectral density it follows that ht pα t 0 t T 0 otherwise where α is the delay used in the matched filter Because ht 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 xα λααT sλpα α λdλ λααT sλpλdλ This is the crosscorrelation of p with s as defined in 83 When Pnf is not a constant 116 becomes v2τPw HfGfej2πτf df2 PnfHf2df To use the Schwarz inequality A57 associate a with HPn and b with Gej2πτf Pn Then 117 can be replaced by v2τPw Hf2Pnfdf Gfej2πτf 2Pnfdf Hf2Pnfdf and equality occurs when a kb that is Hf kGfej2πτf Pnf When the noise power spectral density Pnf is not flat it shapes the matched filter Recall that the power spectral density of the noise can be computed from its autocorrelation as is shown in Appendix E 246 Chapter 11 Pulse Shaping and Receive Filtering Transmit filter Receive filter yk si k iN σ wk mk f k gk Figure 1114 Baseband communication system considered in Exercise 1129 Exercise 1125 Let the pulse shape be a T wide Hamming blip Use the code in matchfiltm to find the ratio of the power in the downsampled v to that in the downsampled w when a the receive filter is an SRRC with beta 0 01 05 b the receive filter is a rectangular pulse and c the receive filter is a 3T wide Hamming pulse When is the ratio largest Exercise 1126 Let the pulse shape be an SRRC with beta 025 Use the code in matchfiltm to find the ratio of the power in the downsampled v to that in the downsampled w when a the receive filter is an SRRC with beta 0 01 025 05 b the receive filter is a rectangular pulse and c the receive filter is a T wide Hamming pulse When is the ratio largest Exercise 1127 Let the symbol alphabet be 4PAM a Repeat Exercise 1125 b Repeat Exercise 1126 Exercise 1128 Create a noise sequence that is uniformly distributed using rand with zero mean a Repeat Exercise 1125 b Repeat Exercise 1126 Exercise 1129 Consider the baseband communication system in Figure 1114 The symbol period T is an integer multiple of the sample period Ts ie T NTs The message sequence is nonzero only each Nth k ie k NTs δTs where the integer δ is within the range 0 δ N and δTs is the onsample baudtiming offset at the transmitter a Suppose that fk 02 0 0 10 10 0 0 02 for k 0 1 2 3 4 5 6 7 and zero otherwise Determine the causal gk that is the matched filter to fk Arrange gk so that the final nonzero element is as small as possible Pulse Shaping and Receive Filtering 247 b For the gk specified in part a determine the smallest possible N so the path from mk to yk forms an impulse response that would qualify as a Nyquist pulse for some wellchosen baudtiming offset σ when y is downsampled by N c For the gk chosen in part a and the N chosen in part b determine the downsampler offset σ for si to be the nonzero entries of mk when wk 0 for all k 116 Matched Transmit and Receive Filters While focusing separately on the pulse shaping and the receive filtering makes sense pedagogically the two are intimately tied together in the communication system This section notes that it is not really the pulse shape that should be Nyquist but rather the convolution of the pulse shape with the receive filter Recall the overall block diagram of the system in Figure 111 where it was assumed that the portion of the system from upconversion to passband to final downconversion back to baseband is done perfectly and that the channel is just the identity Thus the central portion of the system is effectively transparent except for the intrusion of noise This simplifies the system to the baseband model in Figure 1115 The task is to design an appropriate pair of filters a pulse shape for the transmitter and a receive filter that is matched to the pulse shape and the presumed noise description It is not crucial that the transmitted signal itself have no intersymbol interference Rather the signal after the receive filter should have no ISI Thus it is not the pulse shape that should satisfy the Nyquist pulse condition but the combination of the pulse shape and the receive filter The receive filter should simultaneously 1 allow no intersymbol interference at the receiver and 2 maximize the signaltonoise ratio Hence it is the convolution of the pulse shape and the receive filter that should be a Nyquist pulse and the receive filter should be matched to the pulse shape Con sidering candidate pulse shapes that are both symmetric and even about some time t the associated matched filter modulo the associated delay is the same as the candidate pulse shape What symmetric pulse shapes when convolved with themselves form a Nyquist pulse Previous sections examined several Nyquist Pulse shape Receive filter Noise Signal Figure 1115 Noisy baseband communication system 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 filter 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 122 The convolution of a sinc function with itself is more easily viewed in the frequency domain as the pointbypoint 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 effectively and because its impulse response dies away quickly One possibility is to define 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 filter SRRC By definition the square in frequency of the SRRC which is the raised cosine is a Nyquist pulse The timedomain 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 vt 1 β 4βπT t 0 βπ22Tπ sin π4β βπ22Tπ cos π4β t T4β sinπ1βtT4βtTcosπ13 tT TπtT14βtT2 otherwise 118 Exercise 1130 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 srrcm 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 squareroot raised cosine is the most commonly used pulse in bandwidthconstrained communication systems Exercise 1131 Consider the baseband communication system with a symbolscaled impulse train input st i siδt iT ε where T is the symbol period in seconds and 0 ε 025 ms The system contains a pulseshaping filter Pf a channel transfer function Cf with additive Pulse Shaping and Receive Filtering 249 1 1 xt t ms 1 2 3 4 5 yk kT P f C f V f st yt nt Figure 1116 The system of Exercise 1131 and the time signal xt corresponding to the inverse Fourier transform of Xf noise nt and a receive filter V f as shown in Figure 1116 In addition con sider the time signal xt shown in the left part of Figure 1116 where each of the arcs is a halfcircle Let Xf be the Fourier transform of xt a If the inverse of PfCfV f is Xf what is the highest symbol frequency with no intersymbol interference supported by this communication system when 0 b If the inverse of PfCfV f is Xf select a sampler time offset T2 T2 to achieve the highest symbol frequency with no intersymbol inter ference What is this symbol rate c Consider designing the receive filter under the assumption that a symbol period T can be and will be chosen so that samples yk of the receive filter output suffer no intersymbol interference If the inverse of PfCf is Xf and the power spectral density of nt is a constant plot the impulse response of the causal minimumdelay matched receive filter 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 timingoffset experiments of Section 945 showed that one kind of stuff 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 deter mine 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 find performance functions that have their maximum or mini mum at the optimal point ie at the correct sampling instants when the eye is open widest These performance functions are then used to define adaptive elements that iteratively estimate the sampling times As usual all other aspects of the system are presumed to operate flawlessly the up and down conversions are ideal there are no interferers and the channel is benign The discussion of timing recovery begins in Section 121 by showing how a sampled version of the received signal xk can be written as a function of the timing parameter τ which dictates when to take samples Section 122 gives several examples that motivate several different possible performance functions functions of xk which lead to different 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 agreedupon header or training sequence An alternative is to use the cluster variance which takes the square of the difference between the received data values and the nearest element of the source alphabet This is analogous to the decisiondirected approach to carrier recovery from Section 105 and an adaptive element based on the cluster variance is derived and studied in Section 123 A popular alternative is to measure the power of the T spaced output of the matched filter Maximizing this power by choice of τ also leads to a good 252 Chapter 12 Timing Recovery Transmit filter Receive filter Sampler Channel si wt xt xkTM τ ht gRtctgTt gTt ct gRt Figure 121 The transfer function h combines the effects of the transmitter pulse shaping gT the channel c and the receive filter gR ASP DSP Sampler a ASP DSP DSP Sampler b ASP Sampler c Figure 122 Three generic structures for timing recovery In a an analog processor determines when the sampling instants will occur In b a digital postprocessor is used to determine when to sample In c the sampling instants are chosen by a freerunning clock and digital postprocessing is used to recover the values of the received signal that would have occurred at the optimal sampling instants There are three ways in which timingrecovery algorithms can be implemented and these are shown in Figure 122 In the first an analog processor determines when the sampling instants will occur In the second a digital postprocessor is used to determine when to sample In the third the sampling instants are chosen by a freerunning clock and digital postprocessing interpolation is used to recover the values of the received signal that would have occurred at the optimal sampling instants The adaptive elements of the next sections can be implemented in any of the three ways though in digital radio systems the trend is to remove as much of the calculation from analog circuitry as possible 122 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 255 3T2 T T2 T2 T 3T2 05 Timing offset τ avgQx x2 Figure 124 Cluster variance as a function of offset timing τ 3T2 T T2 T2 T 3T2 05 10 Timing offset τ avgx2 Figure 125 Average squared output as a function of timing offset τ Example 122 Another measure of the quality of the timing parameter τ is given by the power average energy of the xk Using the four formulas 123 and observing that analogous formulas also apply when τ0 0 the average energy can be calculated for any k by avgx2k 1412 1 2τT 2 1 2τT 2 12 142 21 2τT 2 1 2τT 2τ2T 2 assuming that the four symbol pairs are equally likely The average of x2k is plotted in Figure 125 as a function of τ Over T2 τ T2 this average is maximized with τ 0 Thus the problem of timing recovery can also be viewed as a onedimensional search for the τ that maximizes avgx2k Thus at least in the simple case of binary transmission with ht a triangular pulse the optimal timing offset for the plots in Figures 124 and 125 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 there is channel noise r the source alphabet is multilevel r more common pulse shapes are used and r there is intersymbol interference The next two sections show how to design adaptive elements that carry out these minimizations and maximizations The error surfaces corresponding to Timing Recovery 257 µΣ xt τk Resample xkTM τk xkTM τk δ xkTM τk δ Q Sampler Resample Resample xk Figure 126 One implementation of the adaptive element 129 uses three digital interpolations resamplers After the τk converge the output xk is a sampled version of the input xt with the samples taken at times that minimize the cluster variance where the stepsize µ µδ As usual this algorithm acts as a lowpass filter to smooth or average the estimates of τ and it is common to remove the explicit outer averaging operation from the update which leads to τk 1 τk µQxk xk x kTM τk δ x kTM τk δ 129 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 129 is easy to implement though it requires samples of the waveform xt at three different points xkTM τk δ xkTM τk and xkTM τk δ One possibility is to straightforwardly sample three times Since sampling is done by hardware this is a hardwareintensive solu tion 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 xkTM τk δ and at xkTM τk δ can be interpolated from the nearby samples xk Recall that interpolation was discussed in Sec tion 64 and the Matlab routine interpsincm on page 112 makes it easy to implement bandlimited interpolation and reconstruction Of course this requires extra calculations so it is a more softwareintensive solution This strategy is diagrammed in Figure 126 The following code prepares the transmitted signal that will be used subse quently to simulate the timingrecovery methods The user specifies the signal constellation the default is 4PAM the number of data points n and the over sampling factor m The channel is allowed to be nonunity and a squareroot raised cosine pulse with width 2l1 and rolloff beta is used as the default transmit pulseshaping filter An initial timing offset is specified in toffset and the 258 Chapter 12 Timing Recovery code implements this delay with an offset in the srrcm function The matched filter is implemented using the same SRRC but without the time delay Thus the timing offset is not known at the receiver Listing 121 clockrecDDm part 1 prepare transmitted signal n10000 number of data points m2 oversampling f a c t o r beta 03 r o l l o f f parameter f o r s r r c l 50 12 length of pulse shape chan 1 Tm channel t o f f s e t 03 i n i t i a l timing o f f s e t pulshaps r r c l beta m t o f f s e t pulse shape with o f f s e t spamn 4 5 random data sequence var5 supzeros 1 nm upsample the data pl aci ng sup 1 m nms m1 zer os between data points hhconv pulshap chan and pulse shape rconvhh sup to get r ecei ved s i g n a l m atchf i l ts r r c l beta m 0 matched f i l t e rs r r c xconv r m atchf i l t convolve with matched f i l t e r The goal of the timing recovery in clockrecDDm is to find the negative of the value of toffset using only the received signalthat is to have tau converge to toffset The adaptive element is implemented in clockrecDDm using the iterative cluster variance algorithm 129 The algorithm is initialized with an offset estimate of tau0 and stepsize mu The received signal is sampled at m times the symbol rate and the while loop runs though the data incrementing i once for each symbol and incrementing tnow by m for each symbol The offsets tau and taum are indistinguishable from the point of view of the algorithm The update term contains the interpolated value xs as well as two other interpolated values to the left and right that are used to approximate the derivative term Listing 122 clockrecDDm part 2 clock recovery minimizing cluster variance tnowl m1 tau 0 xszeros 1 n i n i t i a l i z e v a r i a b l e s tausavezeros 1 n tausave 1 tau i 0 mu001 algorithm s t e p s i z e del ta 01 time f o r d e r i v a t i v e while tnowlength x2 l m run i t e r a t i o n ii 1 xs i i n t e r p s i n c x tnowtau l i nter p value at tnowtau x deltapi n t e r p s i n c x tnowtaudelta l value to r i ght x deltami n t e r p s i n c x tnowtaudelta l value to l e f t dxx deltap x deltam numerical d e r i v a t i v e qxquantalph xs i 3 1 1 3 quantize to alphabet tautaumudxqxxs i alg update DD tnowtnowm tausave i tau save f o r p l o t t i n g end Typical output of the program is plotted in Figure 127 which shows the 4 PAM constellation diagram along with the trajectory of the offset estimation as it converges towards the negative of the unknown value 03 Observe that initially the values are widely dispersed about the required 4PAM values but as the algorithm nears its convergent point the estimated values of the symbols converge nicely Timing Recovery 259 Constellation history 0 1000 2000 3000 4000 5000 4 0 4 2 2 Iterations 0 1000 2000 3000 4000 5000 01 03 0 2 Symbol estimates Offset estimates Figure 127 Output of the program clockrecDDm shows the symbol estimates in the top plot and the trajectory of the offset estimation in the bottom As usual a good way to conceptualize the action of the adaptive element is to draw the error surfacein this case to plot JCV τ of 125 as a function of the timing offset τ In the examples of Section 122 the error surface was drawn by exhaustively writing down all the possible input sequences and evalu ating the performance function explicitly in terms of the offset τ In the binary setup with an identity channel where the pulse shape is only 2T long and with M 1 oversampling there were only four cases to consider But when the pulse shape and channel are long and the constellation has many elements the num ber of cases grows rapidly Since this can get out of hand an experimental method can be used to approximate the error surface For each timing offset the code in clockrecDDcostm chooses n random input sequences evaluates the performance function and averages Listing 123 clockrecDDcostm error surfaces for cluster variance performance function l 10 12 duration of pulse shape beta 05 r o l l o f f f o r pulse shape m20 evaluate at m d i f f e r e n t points pss r r c l beta m make s r r c pulse shape psrcconv ps ps convolve 2 srrc s to get rc psrcpsrc l m13 l m1 truncate to same length as ps costzeros 1 m n20000 experimental performance xzeros 1 n for i 1m f o r each o f f s e t ptpsrc i m end rc i s s h i f t e d i m of a symbol for k1n do i t n times rdpam length pt 4 5 random 4PAM vector x ksum rd pt r ecei ved data point w ISI end er rquantalph x 3 1 1 3 x quantize to alphabet cost i sum er r ˆ2 length er r DD performance f uncti on end The output of clockrecDDcostm is shown in Figure 128 The error surface is plotted for the SRRC with five different rolloff factors For all β the correct 260 Chapter 12 Timing Recovery 0 01 02 03 04 05 Value of performance function 0 T2 T Timing offset τ β 04 β 06 β 08 β 02 β 0 Figure 128 The performance function 125 is plotted as a function of the timing offset τ for five different pulse shapes characterized by different rolloff factors β The correct answer is at the global minimum at τ 0 answer at τ 0 is a minimum For small values of β this is the only minimum and the error surface is unimodal over each period In these cases no matter where τ is initialized it should converge to the correct answer As β is increased however the error surface flattens across its top and gains two extra minima These represent erroneous values of τ to which the adaptive element may con verge Thus the error surface can warn the system designer to expect certain kinds of failure modes in certain situations such as certain pulse shapes Exercise 121 Use clockrecDDm to play with the clockrecovery algorithm a How does mu affect the convergence rate What range of stepsizes works b How does the signal constellation of the input affect the convergent value of tau Try 2PAM and 6PAM Remember to quantize properly in the algo rithm update Exercise 122 Implement a rectangular pulse shape Does this work better or worse than the SRRC Exercise 123 Add noise to the signal add a zeromean noise to the received signal using the Matlab randn function How does this affect the convergence of the timingoffset parameter tau Does it change the final converged value Exercise 124 Modify clockrecDDm by setting toffset08 This starts the iteration in a closedeye situation How many iterations does it take to open the eye What is the convergent value Exercise 125 Modify clockrecDDm by changing the channel How does this affect the convergence speed of the algorithm Do different channels change the convergent value Can you think of a way to predict given a channel what the convergent value will be Timing Recovery 263 Constellation history Symbol estimates Iterations Offset estimates 0 1000 2000 3000 4000 5000 0 15 1 1 02 04 0 Figure 1210 Output of the program clockrecOPm shows the estimates of the symbols in the top plot and the trajectory of the offset estimates in the bottom tausavezeros 1 n tausave 1 tau i 0 mu005 algorithm s t e p s i z e del ta 01 time f o r d e r i v a t i v e while tnowlength x l m run i t e r a t i o n ii 1 xs i i n t e r p s i n c x tnowtau l i nter p at tnowtau x deltapi n t e r p s i n c x tnowtaudelta l value to r i ght x deltami n t e r p s i n c x tnowtaudelta l value to l e f t dxx deltap x deltam numerical d e r i v a t i v e tautaumudxxs i alg update energy tnowtnowm tausave i tau save f o r p l o t t i n g end Typical output of the program is plotted in Figure 1210 For this plot the message was drawn from a 2PAM binary signal which is recovered nicely by the algorithm as shown in the top plot The bottom plot shows the trajectory of the offset estimation as it converges to the unknown value at toffset The error surface for the outputpowermaximization algorithm can be drawn using the same experimental method as was used in clockrecDDcostm Replacing the line that calculates the performance function with cost i sumx ˆ2 length x calculates the error surface for the output power algorithm 1213 Figure 1211 shows this along with three variants 1 the average value of the absolute value of the output of the sampler avgxk 2 the average of the fourth power of the output of the sampler avgx4k and 3 the average of the dispersion avgx2k 12 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 figure 264 Chapter 12 Timing Recovery 0 T T2 0 02 04 06 08 1 12 Timing offset τ Dispersion Fourth Power Output Power Abs Value Value of performance functions Figure 1211 Four performance functions that can be used for timing recovery plotted as a function of the timing offset τ In this figure the optimal answer is at τ 0 Some of the performance functions must be minimized and some must be maximized shows the 2PAM case with an SRRC pulse shape with beta05 the maxima or minima may occur at different values of τ in more extreme settings Exercise 129 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 1210 Use the code in clockrecOPm to play with the output power clockrecovery algorithm How does mu affect the convergence rate What range of stepsizes works How does the signal constellation of the input affect the convergent value of tau try 4PAM and 8PAM Exercise 1211 Implement a rectangular pulse shape Does this work better or worse than the SRRC Exercise 1212 Add noise to the signal add a zeromean noise to the received signal using the Matlab randn function How does this affect the convergence of the timingoffset parameter tau Does it change the final converged value Exercise 1213 Modify clockrecOPm by setting toffset1 This starts the iteration in a closedeye 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 final convergent value will be Try toffset23 Now let the oversampling factor be m 4 and answer the same questions Exercise 1214 Redo Figure 1211 using a sinc pulse shape What happens to the output power performance function Exercise 1215 Redo Figure 1211 using a T wide Hamming pulse shape Which of the four performance functions need to be minimized and which need to be maximized 266 Chapter 12 Timing Recovery b Add a timingrecovery algorithm to the receiver so that the receiver samples at the appropriate time State the timingrecovery method used and plot the tracking of τ c Add an AGC to the code and decode the message Does the code recover the message appropriately Calculate the error rate of the receiver 125 Two Examples This section presents two examples in which timing recovery plays a significant role The first 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 ISIfree setting This happens because the ISI of the channel causes an effective delay in the energy that the algorithm measures The sec ond example shows how the timingrecovery algorithms can be used to estimate slow changes in the optimal sampling time When these changes occur linearly they are effectively a change in the underlying period and the timingrecovery algorithms can be used to estimate the offset of the period in the same way that the phase estimates of the PLL in Section 106 can be used to find a small frequency offset in the carrier Example 123 Modify the simulation in clockrecDDm by changing the channel chan1 07 0 0 5 Tm channel With an oversampling of m2 2PAM constellation and beta05 the output of the outputpowermaximization algorithm clockrecOPm is shown in Figure 1212 With these parameters the iteration begins in a closedeye situation Because of the channel no single timing parameter can hope to achieve a perfect 1 outcome Nonetheless by finding a good compromise position in this case converging to an offset of about 06 the hard decisions are correct once the eye has opened which first occurs around iteration 500 Example 123 shows that the presence of ISI changes the convergent value of the timingrecovery algorithm Why is this Suppose first that the channel was a pure delay For instance set chan0 1 in Example 123 Then the timing algorithm will change the estimates tau in this case by one to maximize the output power to account for the added delay When the channel is more complicated the timing recovery again moves the estimates to that position which maximizes the output power but the actual value attained is a weighted version of all the taps For example with chan1 1 the energy is maximized halfway between the two taps and the answer is offset by 05 Similarly with chan3 1 the energy is located a quarter of the way between the taps and the answer is offset by 025 In general the offset is roughly proportional to the size of the taps and their delay Timing Recovery 267 Constellation diagram Iterations 0 1000 2000 3000 4000 5000 3 0 3 2 1 1 2 04 08 0 Symbol estimates Offset estimates Figure 1212 Output of the program clockrecOPm modified for Example 123 shows the constellation history in the top plot The trajectory of the offset estimation is shown in the bottom plot To see the general situation consider the received analog signal due to a single symbol triggering the pulseshape filter and passing through a channel with ISI An adjustment in the baudtiming setting at the receiver will sample at slightly different points on the received analog signal A change in τ is effectively equiv alent to a change in the channel ISI This will be dealt with in Chapter 13 when designing equalizers Example 124 With the signal generated as in clockrecDDm 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 125 clockrecperiodm resample to change the period f ac 10001 zzeros size x percent change in period tl 1 f ac length x2 l vector of new times for il 1length t resample x at new r ate z i i n t e r p s i n c x t i l to cr eate r ecei ved s i g n a l end with period o f f s e t xz r e l a b e l s i g n a l If this code is followed by one of the timingrecovery schemes then the timing parameter τ follows the changing period For instance in Figure 1213 the timing estimation converges rapidly to a line with slope that is proportional to the difference in period between the assumed value of the period at the receiver and the actual value used at the transmitter Thus the standard timingrecovery algorithms can handle the case in which the clock periods at the transmitter and receiver are somewhat different More accurate estimates could be made using two timingrecovery algorithms anal ogous to the dualcarrier recovery structure of Section 1062 or by mimicking the secondorder filter 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 timingrecovery algorithms such as the earlylate method the method of Mueller and Muller and bandedge timing algorithms 268 Chapter 12 Timing Recovery Constellation history Iterations 0 05 1 15 2 x104 15 0 15 1 05 05 1 4 1 0 1 3 2 Symbol estimates Offset estimates Figure 1213 Output of clockrecperiodm as modified for Example 124 shows the constellation history in the top plot and the trajectory of the offset estimation in the bottom The slope of the estimates is proportional to the difference between the nominal and the actual clock period Exercise 1220 Modify clockrecOPm to implement one of the alternative performance functions of Figure 1211 avgxk avgx2k or avgx2k 12 Exercise 1221 Modify clockrecOPm by changing the channel as in Exam ple 123 Use different values of beta in the SRRC pulseshape routine How does this affect the convergence speed of the algorithm Do different pulse shapes change the convergent value Exercise 1222 Investigate how the error surface depends on the input signal a Draw the error surface for the outputenergymaximization timingrecovery algorithm when the inputs are binary 1 b Draw the error surface when the inputs are drawn from the 4PAM constel lation for the case in which the symbol 3 never occurs Exercise 1223 Imitate Example 123 using a channel of your own choosing Do you expect that the eye will always be able to open Exercise 1224 Instead of the ISI channel used in Example 123 include a whitenoise channel How does this change the timing estimates Exercise 1225 Explore the limits of the period tracking in Example 124 How large can fac be made and still have the estimates converge to a line What happens to the cluster variance when the estimates cannot keep up Does it help to increase the size of the stepsize mu For Further Reading A comprehensive collection of timing and carrierrecovery schemes can be found in the following two texts Timing Recovery 269 r H Meyr M Moeneclaey and S A Fechtel Digital Communication Receivers Wiley 1998 r J A C Bingham The Theory and Practice of Modem Design Wiley Inter science 1988 13 Linear Equalization When all is well in the receiver there is no interaction between successive sym bols 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 difficult to decipher the message from such a received signal This impairment is called intersym bol interference and was discussed in Chapter 11 in terms of nonNyquist pulse shapes overlapping in time This chapter considers another source of interference between symbols that is caused by multipath reflections or frequencyselective 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 inter ference 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 finiteimpulseresponse linear filter C and the delay spread is the total time interval during which reflec tions with significant energy arrive The idea of the equalizer is to build another filter in the receiver that counteracts the effect 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 chan nel 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 Decision device Linear digital equalizer Digital source Received analog signal Sampled received signal Noise and interferers Ts Figure 131 The baseband linear digital equalizer is intended to automatically cancel out unwanted effects of the channel and to cancel out certain kinds of additive interferences the system designer in advance The second job of the equalizer is to reject such additive narrowband interferers by designing appropriate linear notch filters on thefly 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 Fig ure 131 which emphasizes the role of the equalizer in trying to counteract the effects 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 car rier synchronization all those parts of the receiver that are not shown in Figure 131 are assumed to be flawless and unchanging Modeling the channel as a time invariant FIR filter the next section focuses on the task of selecting the coeffi cients in the block labeled linear digital equalizer with the goal of removing the intersymbol interference and attenuating the additive interferences These coeffi cients are to be chosen using the sampled received signal sequence and possibly knowledge of a prearranged training sequence While the channel may actually be timevarying the variations are often much slower than the data rate and the channel can be viewed as effectively timeinvariant over small time scales This chapter suggests several different ways in which the coefficients of the equalizer can be chosen The first procedure in Section 1321 minimizes the square of the symbolrecovery 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 133 When there is no training sequence other performance functions are appropriate and these lead to equalizers such as the decisiondirected approach in Section 134 and the dispersionminimization method in Section 135 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 sufficiently slow 1 This is the error between the equalizer output and the transmitted symbol and is known whenever there is a training sequence 272 Chapter 13 Linear Equalization 131 Multipath Interference The villains of this chapter are multipath and other additive interferers Both should be familiar from Section 41 The distortion caused by an analog wireless channel can be thought of as a combination of scaled and delayed reflections of the original transmitted signal These reflections occur when there are different 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 reflections from nearby hills and bounces from a field or lake between the towers For indoor digital TV reception there are many local timevarying reflectors including people in the receiving room and nearby vehicles The strength of the reflections depends on the physical properties of the reflecting objects while the delay of the reflections is primarily determined by the length of the transmission path Let ut be the transmitted signal If N delays are represented by 1 2 N and the strength of the reflections is α1 α2 αN then the received signal is yt α1ut 1 α2ut 2 αNut N ηt 131 where ηt represents additive interferences This model of the transmission chan nel has the form of a finiteimpulseresponse filter 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 fixed sam pling period Ts Thus 131 is approximated by ykTs a0ukTs a1uk 1Ts anuk nTs ηkTs 132 In order for the model 132 to closely represent the system 131 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 filter ie larger n For example consider a sampling interval of Ts 40 ns ie a transmission rate of 25 MHz A delay spread of approximately 4 µs would correspond to 100 taps in the model 132 Thus at any time instant the received signal would be a combination of up to 100 data values If Ts were increased to 04 µs ie 25 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 ie 025 MHz only one term would be needed in the discretetime impulse response In this case adjacent sampled symbols would not interfere Such finiteduration impulseresponse models as 132 can also be used to represent the frequency selective dynamics that occur in the wired local endloop in telephony and other approximately linear finitedelayspread channels The design objective of the equalizer is to undo the effects of the channel and to remove the interference Conceptually the equalizer attempts to build a system that is a delayed inverse of 132 removing the intersymbol interference while Linear Equalization 273 simultaneously rejecting additive interferers uncorrelated with the source If the interference ηkTs is unstructured for instance white noise then there is little that a linear equalizer can do to remove it But when the interference is highly structured such as narrowband interference from another user then the linear filter can often notch out the offending frequencies As shown in Example 123 of Section 125 the solution for the optimal sam pling times found by the clockrecovery algorithms depends on the ISI in the channel Consequently the digital model such as 132 formed by sampling an analog transmission path such as 131 depends on when the samples are taken within each period Ts To see how this can happen in a simple case consider a twopath transmission channel δt 06δt where is some fraction of Ts For each transmitted symbol the received signal will contain two copies of the pulse shape pt the first undelayed and the second delayed by and attenuated by a factor of 06 Thus the receiver sees ct pt 06pt This is shown in Figure 132 for 07Ts The clockrecovery algorithms cannot separate the individual copies of the pulse shapes Rather they react to the complete received shape which is their sum The power maximization will locate the sampling times at the peak of this curve and the lattice of sampling times will be different from what would be expected without ISI The effective digital channel model is thus a sampled version of ct This is depicted in Figure 132 by the small circles that occur at Tsspaced intervals In general an accurate digital model for a channel depends on many things the underlying analog channel the pulse shaping used and the timing of the sampling process At first glance this seems like it might make designing an equalizer for such a channel almost impossible But there is good news No matter what timing instants are chosen no matter what pulse shape is used and no matter what the underlying analog channel may be as long as it is linear there is an FIR linear representation of the form 132 that closely models its behavior The details may change but it is always a sampling of the smooth curve like ct in Figure 132 that defines the digital model of the channel As long as the digital model of this channel does not have deep nulls ie a frequency response that practically zeroes out some important band of frequencies there is a good chance that the equalizer can undo the effects of the channel 132 Trained LeastSquares Linear Equalization When there is a training sequence available for instance in the known frame information that is used in synchronization this can also be used to help build or train an equalizer The basic strategy is to find a suitable function of the 274 Chapter 13 Linear Equalization 0 Lattice of Tsspaced optimal sampling times with ISI pt 06 pt ct pt 06 pt Lattice of Tsspaced optimal sampling times with no ISI Sum of received pulses The digital channel model is given by Tsspaced samples of ct Figure 132 The optimum sampling times as found by the energymaximization algorithm differ when there is ISI in the transmission path and change the effective digital model of the channel Source sk Channel Equalizer Additive interferers Delay Impulse response f Received signal rk Training signal Error ek Equalizer output yk Figure 133 The problem of linear equalization is to find a linear system f that undoes the effects of the channel while minimizing the effects of the interferences unknown equalizer parameters that can be used to define an optimization prob lem Then applying the techniques of Chapters 6 10 and 12 the optimization problem can be solved in a variety of ways 1321 A Matrix Description The linear equalization problem is depicted in Figure 133 A prearranged train ing sequence sk is assumed known at the receiver The goal is to find an FIR filter 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 yk sk δ for some specific δ Linear Equalization 277 Given 138 and 139 JLS in 1310 can be written as JLS ETE S RFTS RF STS RFTS STRF RFTRF 1311 Because JLS is a scalar RFTS and STRF are also scalars Since the transpose of a scalar is equal to itself RFTS STRF and 1311 can be rewritten as JLS STS 2STRF RFTRF 1312 The issue is now one of choosing the n 1 entries of F to make JLS as small as possible 1323 The LeastSquares Solution Define the matrix Ψ F RTR1RTSTRTRF RTR1RTS F TRTRF STRF F TRTS STRRTR1RTS The purpose of this definition is to rewrite 1312 in terms of Ψ JLS Ψ STS STRRTR1RTS Ψ STI RRTR1RTS 1313 Since STI RRTR1RTS is not a function of F the minimum of JLS occurs at the F that minimizes Ψ This occurs when F RTR1RTS 1314 assuming that RTR1 exists2 The corresponding minimum achievable by JLS at F F is the summed squared delayed source recovery error This is the remaining term in 1313 that is Jmin LS STI RRTR1RTS 1315 The formulas for the optimum F in 1314 and the associated minimum achievable JLS in 1315 are for a specific δ To complete the design task it is also necessary to find the optimal delay δ The most straightforward approach is to set up a series of S RF calculations one for each possible δ to compute the associated values of Jmin LS and pick the delay associated with the smallest one This procedure is straightforward to implement in Matlab and the program LSequalizerm allows you to play with the various parameters to get a feel for their effect Much of this program will be familiar from openclosedm The first 2 A matrix is invertible as long as it has no eigenvalues equal to zero Since RTR is a quadratic form it has no negative eigenvalues Thus all eigenvalues must be positive in order for it to be invertible 278 Chapter 13 Linear Equalization three lines define 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 131 LSequalizerm find a LS equalizer f for the channel b b05 1 06 def i ne channel m1000 ssign randn 1 m binary source of length m rf i l t e r b 1 s output of channel n3 length of e q u a l i z e r 1 del ta 3 use delay n length b plength r del ta Rtoeplitz r n1p r n1 11 build matrix R Ss n1del ta pdel ta and vector S finv R RR S c a l c u l a t e e q u a l i z e r f JminS SS Rinv R RR S Jmin f o r t h i s f and del ta yf i l t e r f 1 r e q u a l i z e r i s a f i l t e r decsign y quantize and f i nd e r r o r s er r 05sum abs dec del ta 1ms 1 mdel ta The variable n defines the length of the equalizer and delta defines the delay that will be used in constructing the vector S defined in 138 observe that delta must be positive and less than or equal to n The Toeplitz matrix R is defined in 135 and 136 and the equalizer coefficients f are computed as in 1314 The value of minimum achievable performance is Jmin which is calculated as in 1315 To demonstrate the effect of the equalizer the received signal r is filtered by the equalizer coefficients and the output is then quantized If the equalizer has done its job ie if the eye is open then there should be some shift sh at which no errors occur For example using the default channel b 05 1 06 and length4 equalizer n3 four values of the delay delta give delay delta Jmin equalizer f 0 832 033 0027 0070 001 1 134 066 036 016 008 2 30 028 065 030 014 3 45 01 027 064 03 1316 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 131 Plot the frequency response using freqz of the channel b in LSequalizerm Plot the frequency response of each of the four equalizers found by the program For each channelequalizer pair form the product of the magnitude of the frequency responses How close are these products to unity Exercise 132 Add uncorrelated normally distributed noise into the simula tion using the command rfilterb1ssdrandnsizes 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 133 Use LSequalizerm to find an equalizer that can open the eye for the channel b 1 1 08 03 1 1 a What equalizer length n is needed b What delays delta give zero error at the output of the quantizer c What is the corresponding Jmin d Plot the frequency response of this channel e Plot the frequency response of your equalizer f Calculate and plot the product of the two Exercise 134 Modify LSequalizerm to generate a source sequence from the alphabet 1 3 For the default channel 05 1 06 find an equalizer that opens the eye a What equalizer length n is needed b What delays delta give zero error at the output of the quantizer c What is the corresponding Jmin d Is this a fundamentally easier or more difficult task than when equalizing a binary source e Plot the frequency response of the channel and of the equalizer 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 sα 1 sα s1 sα 2 sα 1 s2 sp sp 1 sp α 1317 where α specifies the number of delays δ that will be searched from δ 0 to δ α The p α n 1 matrix of received data is R rα 1 rα rα n 1 rα 2 rα 1 rα n 2 rp rp 1 rp n 1318 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 Linear Equalization 283 in the document A Digital Quadrature Amplitude Modulation Radio which can be found on the website The same basic strategy for equalizer design can also be used in the complex case Consider a complex delayed source recovery error ek eRk jeIk where j 1 Consider its square e2k e2 Rk 2jeRkeIk e2 Ik which is typically complexvalued and potentially realvalued and negative when eR 0 Thus a sum of e2 is no longer a suitable measure of performance since e might be nonzero but its squared average might be zero Instead consider the product of a complex e with its complex conjugate e eR jeI that is ekek e2 Rk jeRkeIk jeRkeIk j2e2 Ik e2 Rk e2 Ik In vector form the summed squared error of interest is EHE rather than the EHE of 1311 where the superscript H denotes the operations of both transposition and complex conjugation Thus 1314 becomes F RHR1RHS Note that in implementing this refinement in the Matlab code the symbol pair implements a transpose while alone implements a conjugate transpose 1326 Fractionally Spaced Equalization The preceding development assumes that the sampled input to the equalizer is symbol spaced with the sampling interval equal to the symbol interval of T seconds Thus the unit delay in realizing the tappeddelayline equalizer is T seconds Sometimes the input to the equalizer is oversampled such that the sample interval is shorter than the symbol interval and the resulting equalizer is said to be fractionally spaced The same kinds of algorithms and solutions can be used to calculate the coefficients in fractionally spaced equalizers as are used for T spaced equalizers Of course details of the construction of the matrices corresponding to S and R will necessarily differ due to the structural differences The more rapid sampling allows greater latitude in the ordering of the blocks in the receiver This is discussed at length in Equalization on the website Exercise 135 Consider the multiuser system shown in Figure 135 Both users transmit binary 1 PAM signals that are independent and equally probable sym bols The signal from the first user is distorted by a frequencyselective channel with impulse response h1k δk bδk 1 286 Chapter 13 Linear Equalization f k Sign rk yk ek sk training signal Equalizer Adaptive algorithm Performance evaluation Decision device Sampled received signal Figure 136 A trained adaptive linear equalizer uses the difference between the received signal and a prespecified training sequence to drive the adaptation of the coefficients of the equalizer LSequalizerm 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 difference between the prediction and the reality This is the calculation of ek from 1323 The equalizer coefficients f are then updated as in 1327 Listing 132 LMSequalizerm find a LMS equalizer f for the channel b b05 1 06 def i ne channel m1000 spamm 2 1 binary source of length m rf i l t e r b 1 s output of channel n4 fzeros n 1 i n i t i a l i z e e q u a l i z e r at 0 mu01 del ta 2 s t e p s i z e and delay del ta for in1m i t e r a t e r rr i 1 i n1 vector of r ecei ved s i g n a l es i del ta rr f c a l c u l a t e er r or ffmue r r update e q u a l i z e r c o e f f i c i e n t s end As with the matrix approach the default channel b05 1 06 can be equalized easily with a short equalizer one with a small n The convergent val ues of the f are very close to the final values of the matrix approach that is for a given channel the value of f given by LMSequalizerm is very close to the value found using LSequalizerm 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 timevarying Similarly if the explicit averaging operation is retained longer averages imply smoother estimates but slower convergence Similar trade offs 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 EqualizerTestm shows one way to verify that the equal izer has or has not done a good job The code generates a new received signal and passes it through the same channel and the final converged equalizer from LMSequalizerm 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 133 EqualizerTestm verify the operation of an equalizer f for the channel b F i r s t run LMSequalizer m to s et channel b and e q u a l i z e r f f i n a l e qf t e s t f i n a l f i l t e r f m1000 new data points spamm 2 1 new binary source of length m rf i l t e r b 1 s output of channel ytf i l t e r f 1 r use f i n a l f i l t e r f to t e s t decsign real yt quantization for sh0n i f e q u a l i z e r i s working one er r sh 105sum abs dec sh1ms 1 msh end of these delays has zero er r or This trained adaptive approach along with several others is implemented in the program daem which is available on the website Simulated examples of LMS with training and other adaptive equalization methods are presented in Section 136 Exercise 136 Verify that by proper choice of n and delta the convergent values of f in LMSequalizerm are close to the values shown in 1316 Exercise 137 What happens in LMSequalizerm when the stepsize parameter mu is too large What happens when it is too small Exercise 138 Add uncorrelated normally distributed noise into the simula tion using the command rfilterb1ssdrandnsizes a For the equalizer with delay 2 what is the largest sd you can add and still have no errors How does this compare with the result from Exercise 132 Hint it may be necessary to simulate for more than the default m data points b Now try the equalizer with delay 1 What is the largest sd you can add and still have no errors c Which is a better equalizer Exercise 139 Use LMSequalizerm to find an equalizer that can open the eye for the channel b 1 1 08 03 1 1 a What equalizer length n is needed b What delays delta give zero error in the output of the quantizer c How does the answer compare with the design in Exercise 133 Exercise 1310 Modify LMSequalizerm and EqualizerTestm to generate a source sequence from the alphabet 1 3 For the default channel 05 1 06 find an equalizer that opens the eye Linear Equalization 289 Sign Equalizer Adaptive algorithm Performance evaluation Decision device f k rk yk ek Sampled received signal Figure 137 A decisiondirected adaptive linear equalizer uses the difference between the received signal and the output of the decision device to drive the adaptation of the coefficients of the equalizer When the signal sk is multilevel instead of binary the sign function in 1328 can be replaced with a quantizer Exercise 1312 Show that the decisiondirected LMS algorithm 1328 can be derived as an adaptive element with performance function 12avgsignyk yk2 Hint suppose that the derivative of the sign func tion dsignxdx is zero everywhere Observe that the source signal sk does not appear in 1328 Thus no train ing signal is required for its implementation and the decisiondirected LMS equal izer adaptation law of 1328 is called a blind equalizer Given its genesis one should expect decisiondirected LMS to exhibit poor behavior when the assump tion regarding perfect decisions is violated The basic rule of thumb is that 5 or so decision errors can be tolerated before decisiondirected LMS fails to converge properly The Matlab program DDequalizerm has a familiar structure The only code changed from LMSequalizerm is the calculation of the error term which imple ments ek signyk yk rather than the LMS error 1323 and the ini tialization of the equalizer Because the equalizer must begin with an open eye f0 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 centerspike ini tialization 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 finding good initial values for the equal izer parameters As with the LMS equalizer the code in EqualizerTestm can be used to test the operation of the converged equalizer Listing 134 DDequalizerm find a DD equalizer f for the channel b b05 1 06 def i ne channel m1000 ssign randn 1 m binary source of length m rf i l t e r b 1 s output of channel n4 f 0 1 0 0 i n i t i a l i z e e q u a l i z e r mu1 s t e p s i z e for in1m i t e r a t e r rr i 1 i n1 vector of r ecei ved s i g n a l 290 Chapter 13 Linear Equalization esign f r r f r r c a l c u l a t e er r or ffmue r r update e q u a l i z e r c o e f f i c i e n t s end Exercise 1313 Try the initialization f0 0 0 0 in DDequalizerm With this initialization can the algorithm open the eye Try increasing m Try changing the stepsize mu What other initializations will work Exercise 1314 What happens in DDequalizerm when the stepsize parameter mu is too large What happens when it is too small Exercise 1315 Add uncorrelated normally distributed noise into the simu lation using the command rfilterb1ssdrandnsizes What is the largest sd you can add and still have no errors Does the initial value for f influence this number Try at least three initializations Exercise 1316 Use DDequalizerm to find an equalizer that can open the eye for the channel b1 1 08 03 1 1 a What equalizer length n is needed b What initializations for f did you use c How does the converged answer compare with the design in Exercises 133 and 139 Exercise 1317 Modify DDequalizerm to generate a source sequence from the alphabet 1 3 For the default channel 05 1 06 find an equalizer that opens the eye a What equalizer length n is needed b What initializations for f did you use c Is this a fundamentally easier or more difficult task than when equalizing a binary source d How does the answer compare with the design in Exercises 134 and 1310 Section 136 provides the opportunity to view the simulated behavior of the decisiondirected equalizer and to compare its performance with the other meth ods 135 DispersionMinimizing Linear Equalization This section considers an alternative performance function that leads to another kind of blind equalizer Observe that for a binary 1 source the square of the source is known even when the particular values of the source are not Thus s2k 1 for all k This suggests creating a performance function that penalizes 292 Chapter 13 Linear Equalization 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 DMAequalizerm The first few lines define the channel create the binary source and pass the input through the channel The last few lines implement the equal izer 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 LSequalizerm The new part of the code is in the center which defines the length n of the equalizer the stepsize mu of the algorithm and the initialization of the equalizer which defaults to a centerspike initialization The coefficients of the equalizer are updated as in 1329 As with the other equalizers the code in EqualizerTestm can be used to test the operation of the converged equalizer Listing 135 DMAequalizerm find a DMA equalizer f for the channel b b05 1 06 def i ne channel m1000 ssign randn 1 m binary source of length m rf i l t e r b 1 s output of channel n4 f 0 1 0 0 center spike i n i t i a l i z a t i o n mu01 algorithm s t e p s i z e for in1m i t e r a t e r rr i 1 i n1 vector of r ecei ved s i g n a l ef r r 1 f r r ˆ 2 c a l c u l a t e er r or ffmue r r update e q u a l i z e r c o e f f i c i e n t s end Running DMAequalizerm results in an equalizer that is numerically similar to the equalizers of the previous two sections Initializing with the spike at dif ferent locations results in equalizers with different effective delays The following exercises are intended to encourage you to explore the DMA equalizer method Exercise 1318 Try the initialization f0 0 0 0 in DMAequalizerm With this initialization can the algorithm open the eye Try increasing m Try changing the stepsize mu What other nonzero initializations will work Exercise 1319 What happens in DMAequalizerm when the stepsize parame ter mu is too large What happens when it is too small Exercise 1320 Add uncorrelated normally distributed noise into the simu lation using the command rfilterb1ssdrandnsizes What is the largest sd you can add and still have no errors Does the initial value for f influence this number Try at least three initializations Linear Equalization 293 Exercise 1321 Use DMAequalizerm to find an equalizer that can open the eye for the channel b1 1 08 03 1 1 a What equalizer length n is needed b What initializations for f did you use c How does the converged answer compare with the designs in Exercises 133 139 and 1316 Exercise 1322 Modify DMAequalizerm to generate a source sequence from the alphabet 1 3 For the default channel 05 1 06 find an equalizer that opens the eye a What equalizer length n is needed b What is an appropriate value of γ c What initializations for f did you use d Is this a fundamentally easier or more difficult task than when equalizing a binary source e How does the answer compare with the designs in Exercises 134 1310 and 1317 Exercise 1323 Consider a DMAlike performance function J 1 2 avg1 y2k Show that the resulting gradient algorithm is fik 1 fik µavgsign1 y2kykrk i Hint assume that the derivative of the absolute value is the sign function Imple ment the algorithm and compare its performance with the DMA of 1329 in terms of a speed of convergence b number of errors in a noisy environment recall Exercise 1320 and c ease of initialization Exercise 1324 Consider a DMAlike performance function J avg1 yk What is the resulting gradient algorithm Implement your algorithm and compare its performance with the DMA of 1329 in terms of a speed of convergence of the equalizer coefficients f b number of errors in a noisy environment recall Exercise 1320 and c ease of initialization 294 Chapter 13 Linear Equalization 136 Examples and Observations This section uses the Matlab program daem which is available on the website The program demonstrates some of the properties of the leastsquares solution to the equalization problem and its adaptive cousins LMS decisiondirected LMS and DMA6 The default settings in daem are used to implement the equalizer designs for three channels The source alphabet is a binary 1 signal Each channel has an FIR impulse response and its output is summed with a sinusoidal interference and some uniform white noise before reaching the receiver The user is prompted for the 1 choice of channels 0 1 or 2 2 maximum delay of the equalizer 3 number of samples of training data 4 gain of the sinusoidal interferer 5 frequency of the sinusoidal interferer in radians and 6 magnitude of the white noise The program returns plots of the 1 received signal 2 optimal equalizer output 3 impulse response of the optimal equalizer and the channel 4 recovery error at the output of the decision device 5 zeros of the channel and the combined channelequalizer pair and 6 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 1391314 The program also prints the condition number of RT R the minimum average squared recovery error ie 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 condition number 1302631 minimum value of performance function 00534 optimum delay 16 percentage of errors 0 6 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 295 0 05 1 05 0 1000 2000 3000 4000 1 08 04 0 0 10 20 30 40 12 0 1 2 1 0 1000 2000 3000 4000 2 Decision device recovery error 0 1 1 2 0 1000 2000 3000 4000 Combined channel and optimal equalizer impulse response Optimal equalizer output Received signal Figure 139 Trained leastsquares 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 sufficient separation to open the eye The bottomleft figure 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 bottomright plot shows that the message signal is recovered without error r Channel 1 condition number 14795 minimum value of performance function 00307 optimum delay 12 percentage of errors 0 r Channel 2 condition number 1641081 minimum value of performance function 00300 optimum delay 10 percentage of errors 0 To see what these figures mean consider the eight plots contained in Figures 139 and 1310 The first plot is the received signal which contains the trans mitted 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 296 Chapter 13 Linear Equalization 30 50 60 10 20 40 0 0 1 2 3 4 10 0 05 05 1 1 1 0 1 0 10 20 10 0 1 2 3 4 20 Freq Resp Phase 05 0 05 1 1 05 0 05 1 1 Zeros of channelequalizer combination Freq Resp Magnitude Normalized frequency FIR channel zeros Imaginary part Imaginary part db radians Real part Normalized frequency Real part Figure 1310 Trained leastsquares equalizer for channel 0 singularities and frequency responses The large circles show the locations of the zeros of the channel in the upperleft plot and the locations of the zeros of the combined channelequalizer pair in the lowerleft 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 0 1000 2000 3000 4000 1 05 0 05 1 Received signal 0 1000 2000 3000 4000 Optimal equalizer output 15 1 05 0 05 15 1 0 10 20 30 40 Combined channel and optimal equalizer impulse response 0 1000 2000 3000 4000 Decision device recovery error 1 05 0 05 1 02 02 06 0 04 08 1 12 Figure 1311 Trained leastsquares equalizer for channel 1 time responses As in Figure 139 the equalizer is able to effectively undo the effects of the channel Linear Equalization 297 1 0 1 FIR channel zeros 0 1 2 3 4 Freq Resp Magnitude Zeros of channelequalizer combination 0 1 2 3 4 Freq Resp Phase Normalized frequency radians db Normalized frequency Real part Real part Imaginary part Imaginary part 40 30 20 10 0 1 05 05 0 1 20 10 0 10 20 2 4 0 2 4 10 8 6 4 2 0 Figure 1312 Trained leastsquares equalizer for channel 1 singularities and frequency responses The large circles show the locations of the zeros of the channel in the upperleft plot and the locations of the zeros of the combined channelequalizer pair in the lowerleft 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 signal7 The width of these stripes is related to the cluster variance The difference 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 1310 show the same situation but in the frequency domain The zeros of the channel are depicted in the upperleft plot This con stellation of zeros corresponds to the darkest of the frequency responses drawn in the second plot The primarily lowpass character of the channel can be intu ited directly from the zero plot with the technique of Section F2 The T spaced equalizer accordingly has a primarily highpass character as can be seen from the dashed frequency response in the upperright plot of Figure 1310 Combin ing these two gives the response in the middle This middle response plotted with the solid line is mostly flat except for a large dip at 14 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 Chapter 13 Linear Equalization 15 1 05 0 05 1 150 1000 2000 3000 4000 Received signal 12 1 08 06 02 04 0 1 05 0 05 1 020 0 1000 2000 3000 4000 10 20 30 40 50 Combined channel and optimal equalizer impulse response 15 1 05 0 05 15 1 20 1000 2000 3000 4000 Optimal equalizer output Decision device recovery error Figure 1313 Trained leastsquares equalizer for channel 2 time responses Even for this fairly severe channel the equalizer is able to effectively undo the effects of the channel as in Figures 139 and 1311 second major use of the equalizer it is capable of removing uncorrelated interfer ences Observe that the equalizer design is given no knowledge of the frequency of the interference nor even that any interference exists Nonetheless it auto matically compensates for the narrowband interference by building a notch at the offending frequency The plot labeled Zeros of channelequalizer combina tion 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 flat But observe that one pair of zeros at 14 radi ans 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 notch8 The eight plots for each of the other channels are displayed in similar fashion in Figures 1311 to 1314 Figures 13151317 demonstrate equalizer design using the various recursive methods of Sections 133 to 135 on the same problem After running the least squares design in daem the script asks whether you wish to simulate a recursive solution If yes then you can choose r which algorithm to run trained LMS decisiondirected LMS or blind DMA r the stepsize and 8 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 299 15 1 05 0 05 1 15 1 0 1 2 FIR channel zeros Real part Imaginary part db 0 10 15 5 20 25 30 350 1 2 3 4 Zeros of channelequalizer combination 30 20 10 0 10 30 20 0 1 2 3 4 Freq Resp Magnitude Normalized frequency Normalized frequency Freq Resp Phase 15 1 05 0 05 1 15 1 0 1 2 Real part Imaginary part radians Figure 1314 Trained leastsquares equalizer for channel 2 singularities and frequency responses The large circles show the locations of the zeros of the channel in the upperleft plot and the locations of the zeros of the combined channelequalizer pair in the lowerleft 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 specifies 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 13151317 all three adaptive schemes are suc cessful with the recommended default values which were used in equalizing channel 0 All three exhibit in the upperleft plots of Figures 13151317 decay ing averaged squared parameter error relative to their respective trained least squares equalizer for the data block This means that all are converging to the vicinity of the trained leastsquares equalizer about which daem initializes the algorithms The collapse of the squared prediction error is apparent from the upperright plot in each of these figures An initially closed eye appears for a short while in each of the lowerleft plots of equalizer output history in the fig ures The match of the magnitudes of the frequency responses of the trained block leastsquares equalizer plotted with the solid line and the last adaptive equalizer setting plotted with asterisks from the datablock stream is quite striking in the lowerright plots in these figures As expected we find 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 leastsquares solution exhibits peaks valleys where the channel response has valleys peaks so that the combined response is nearly flat The phase of the trained leastsquares equalizer adds with the channel phase so 300 Chapter 13 Linear Equalization 5 10 15 0 0 1 2 3 4 5 Normalized frequency 0 1 2 3 1 0 1000 2000 3000 4000 2 Iterations dB Adaptive equalizer output 2 15 1 05 0 25 0 1000 2000 3000 4000 3 Iterations Combined magnitude response 100 101 0 1000 2000 3000 101 Iterations Squared prediction error Summed squared parameter error Figure 1315 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 meansquareerror solution that their combination approximates a linear phase curve Refer to plots in the right columns of Figures 1310 1312 and 1314 r With modest channel noise and interferers as the length of the equalizer increases the zeros of the combined channel and equalizer form rings The rings are denser the nearer the channel zeros are to the unit circle There are many ways in which the program daem 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 leastsquares 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 leastsquares equalizer at the frequency of the interferer 3 DMA is considered slower than trained LMS Do you find that DMA takes longer to converge Can you think of why it might be slower 4 DMA typically accommodates larger initialization error than decisiondirected LMS Can you find cases where with the same initialization DMA converges to an errorfree solution but the decisiondirected LMS does not Do you think there are cases in which the opposite holds Linear Equalization 301 5 10 15 0 0 1 2 3 4 5 Normalized frequency 1 0 1 2 3 2 0 1000 2000 3000 4000 3 Iterations dB Adaptive equalizer output 1 05 0 15 0 1000 2000 3000 4000 2 Iterations Combined magnitude response 100 101 0 1000 2000 3000 101 Iterations Squared prediction error Summed squared parameter error Figure 1316 Decisiondirected 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 meansquareerror solution 5 10 15 0 0 1 2 3 4 5 Normalized frequency 1 0 1 2 3 2 0 1000 2000 3000 4000 3 Iterations dB Adaptive equalizer output 2 1 0 3 0 1000 2000 3000 4000 4 Iterations Combined magnitude response 100 101 0 1000 2000 3000 101 Iterations Squared prediction error Summed squared parameter error Figure 1317 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 meansquareerror solution 302 Chapter 13 Linear Equalization 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 appro priate delay is implicit in the initialization of the equalizer coefficients Can you find a case in which with the delay poorly specified DMA outperforms trained LMS from the same initialization For Further Reading A comprehensive survey of trained adaptive equalization can be found in r S U H Qureshi Adaptive Equalization Proceedings of the IEEE vol 73 no 9 pp 13491387 Sept 1985 An overview of the analytical tools that can be used to analyze LMSstyle adap tive algorithms can be found in r W A Sethares The LMS Family in Efficient System Identification and Sig nal Processing Algorithms Eds N Kalouptsidis and S Theodoridis Prentice Hall 1993 A copy of this paper can also be found on the accompanying website One of our favorite discussions of adaptive methods is r C R Johnson Jr Lectures on Adaptive Parameter Estimation PrenticeHall 1988 This whole book can be found in pdf form on the website An extensive discussion of equalization can also be found in Equalization on the website 14 Coding The underlying purpose of any communication system is to transmit information But what exactly is information How is it measured Are there limits to the amount of data that can be sent over a channel even when all the parts of the system are operating at their best This chapter addresses these fundamental questions using the ideas of Claude Shannon 19162001 who defined a measure of information in terms of bits The number of bits per second that can be transmitted over the channel taking into account its bandwidth the power of the signal and the noise is called the bit rate and can be used to define the capacity of the channel Unfortunately Shannons results do not give a recipe for how to construct a system that achieves the optimal bit rate Earlier chapters have highlighted several problems that can arise in communication systems including synchro nization errors such as intersymbol interference This chapter assumes that all of these are perfectly mitigated Thus in Figure 141 the inner parts of the communication system are assumed to be ideal except for the presence of chan nel noise Even so most systems still fall far short of the optimal performance promised by Shannon There are two problems First most messages that people want to send are redundant and the redundancy squanders the capacity of the channel A solu tion is to preprocess the message so as to remove the redundancies This is called source coding and is discussed in Section 145 For instance as demonstrated in Section 142 any natural language such as English whether spoken or written is repetitive Information theory as Shannons approach is called quantifies the repetitiveness and gives a way to judge the efficiency of a source code by com paring the information content of the message with the number of bits required by the code The second problem is that messages must be resistant to noise If a message arrives at the receiver in garbled form then the system has failed A solution is to preprocess the message by adding extra bits which can be used to determine whether an error has occurred and to correct errors when they do occur For 304 Chapter 14 Coding Source coding Channel coding Undo channel coding Undo source coding Transmitter Channel Receiver Inherently redundant message to be transmitted Compressed redundancy removed Structured redundancy removed Structured redundancy added Reconstructed message Noise Figure 141 Source and channel coding techniques manage redundancies in digital communication systems by first removing inherent redundancies in the message then adding structured redundancies which aid in combatting noise problems and finally restoring the original message example one simple system would transmit each bit three times Whenever a singlebit error occurs in transmission then the decoder at the receiver can figure out by a simple voting rule that the error has occurred and what the bit should have been Schemes for finding and removing errors are called errorcorrecting codes or channel codes and are discussed in Section 146 At first glance this appears paradoxical source coding is used to remove redundancy while channel coding is used to add redundancy But it is not really selfdefeating 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 141 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 141 What Is Information Like many common English words information has many meanings The Amer ican Heritage Dictionary catalogs six 1 Knowledge derived from study experience or instruction 2 Knowledge of a specific event or situation intelligence 3 A collection of facts or data 4 The act of informing or the condition of being informed communication of knowledge 5 Computer Science A nonaccidental signal or character used as an input to a computer or communication system 6 A numerical measure of the uncertainty of an experimental outcome Coding 305 It would clearly be impossible to capture all of these senses in a technical defini tion that would be useful in transmission systems The final definition 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 sim ple relationship between the amount of information conveyed in a message and the probability of the message being sent This does not apply directly to mes sages such as sentences images or wav files 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 send ing H is 09 while the probability of sending T is 01 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 informa tion 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 first 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 first 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 pos sible outcome of an experiment such as the flipping of a coin or the transmission of a symbol across a communication channel Let pxi be the probability that the ith event occurs and suppose that some event must occur1 This means that 1 When flipping the coin it cannot roll into the corner and stand on its edge each flip results in either H or T 308 Chapter 14 Coding percentage of the time is 5 transmitted What is the information conveyed by each of the symbols Exercise 143 The 8bit binary ASCII representation of any letter or any character of the keyboard can be found using the Matlab command dec2bintext where text is any string Using ASCII how much information is contained in the letter a assuming that all the letters are equally probable Exercise 144 Consider a decimal representation of π 31415926 Calcu late the information number of bits required to transmit successive digits of π assuming that the digits are independent Identify N xi and pxi How much information is contained in the first million digits of π There is an alternative definition of information in common usage in the mathematicallogic and computerscience communities in which information is defined in terms of the complexity of representation rather than in terms of the reduction in uncertainty Informally speaking this alternative defines the complexity or information content of a message by the length of the shortest computer program that can replicate the message For many kinds of data such as a sequence of random numbers the two measures agree because the shortest program that can represent the sequence is just a listing of the sequence But in other cases they can differ dramatically Consider transmitting the first million digits of the number π Shannons definition gives a large information content as in Exercise 144 while the complete sequence can in principle be transmitted with a very short computer program 142 Redundancy All the examples in the previous section presume that there is no relationship between successive symbols This was the independence assumption in 142 This section shows by example that real messages often have significant corre lation 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 8bit binary ASCII character set recognized by computers as the text format which translates the char acter 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 flipped from one to zero or from zero to one Then about 35 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 deci pher 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 exten sive 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 hwav3p dhat by sending phc hformatIon if a rEdundaft fnre thd prkbahity 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 hAed At by sjdafd th hfFoPmati f a pd5jdan fLbe thd rabDITy o drkp1 aa bE rdued These examples were all generated using the following Matlab program redundantm which takes the text textm translates it into a binary string and then causes per percent of the bits to be flipped The program then gathers statistics on the resulting numbers of bit errors and symbol errors how many letters were changed Listing 141 redundantm redundancy of written english in bits and letters textmIt is clear however that by sending the 310 Chapter 14 Coding information in a redundant form the probability of errors can be reduced 8bi t a s c i i binary equi val ent of text ascmdec2bin double textm 8 turn i nto one long binary s t r i n g binmreshape ascm 1 8 length textm per 01 p r o b a b i l i t y of bi t er r or for i 18 length textm rrand swap 0 and 1 with p r o b a b i l i t y per i f r1per binm i0 binm i 1 end i f r1per binm i1 binm i 0 end end ascrreshape binm 8 length textm to a s c i i binary textrsetstr bin2dec ascr to text b i t e r r o rsumsumabs ascr ascm of bi t e r r o r s symerrrorsum sign abs textmtextr of symbol e r r o r s numwordssum sign find textm321 of words in textm l e t t e r r o rsymerrror length textm of l e t t e r e r r o r s Exercise 145 Read in a large text file using the following Matlab code Use one of your own or use one of the included text files2 Make a plot of the symbol error rate as a function of the bit error rate by running redundantm 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 142 readtextm read in a text document and translate to character string fid messagei fopen OZtxt r f i l e must be text fdatafread f i d read text as a vector textchar fdata to character s t r i n g Thus for English text encoded as ASCII characters a significant number of errors can occur about 10 of the letters can be arbitrarily changed without altering the meaning of the sentence While these kinds of errors can be corrected by a human reader the redundancy is not in a form that is easily exploited by a computer Even imagining that the computer could look up words in a dictionary the person knows from context that It is clear is a more likely phrase than It is clean when correcting Shannons sentence with 1 errors The person can figure out from context that cAf from the phrase with 2 bit errors must have had two errors by using the longterm correlation of the sentence ie its meaning Computers do not deal readily with meaning3 In the previous section the information contained in a message was defined to depend on two factors the number of symbols and their probability of occurrence But this assumes that the symbols do not interactthat the letters are indepen 2 Through the Looking Glass by Lewis Carroll carrolltxt and The Wonderful Wizard of Oz by Frank Baum OZtxt are available on the website 3 A more optimistic rendering of this sentence Computers do not yet deal readily with mean ing 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 20345 times and t appears 14811 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 647 h 575 o 649 v 059 b 109 i 463 p 101 w 249 c 177 j 008 q 007 x 007 d 419 k 090 r 471 y 191 e 1029 l 342 s 451 z 013 f 161 m 178 t 749 g 160 n 490 u 205 144 Space is the most frequent character occurring 20 of the time It was easier to use the following Matlab code in conjunction with readtextm than to count the letters by hand Listing 143 freqtextm frequency of occurrence of letters in text l i t t l elength find t e x t s t r i n gt how many times t occurs biglength find t e x t s t r i n gT how many times T occurs f r eq l i t t l ebig length t e x t s t r i n g percentage If English letters were truly independent then it should be possible to generate Englishlike text using this table of probabilities Here is a sample Od m shous t ad schthewe be amalllingod ongoutorend youne he Any bupecape tsooa w beves p le t ke teml ley une weg rloknd which does not look anything like English How can the nonindependence of the text be modeled One way is to consider the probabilities of successive pairs of letters instead of the probabilities of individual letters For instance the pair th is quite frequent occurring 11014 times in the Wizard of Oz while sh occurs 861 times Unlikely pairs such as wd occur in only five places4 and pk not at all For example suppose that He was chosen first The next pair would be e followed by something with the probability of the something dictated by the entries in the table Following this procedure results in output like this Her gethe womfor if you the to had the sed th and the wention At th youg the yout by and a pow eve cank i as saing paill 4 In the words crowd and sawdust 312 Chapter 14 Coding Observe that most of the twoletter combinations are actual words as well as many threeletter words Longer sets of symbols tend to wander improbably While in principle it would be possible to continue gathering probabilities of all threeletter combinations then four etc the table begins to get rather large a matrix with 26n elements would be needed to store all the nletter 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 textsimm which allows specification of any text with the default being The Wizard of Oz and any num ber of terms for the probabilities For instance with m1 the letters are chosen completely independently with m2 the letters are chosen from successive pairs and with m3 they are chosen from successive triplets Thus the probabilities of clusters of letters are defined implicitly by the choice of the source text Listing 144 textsimm use large text to simulate transition probabilities m1 terms f o r t r a n s i t i o n l i n e l e n g t h 60 l e t t e r s in each l i n e load OZ mat f i l e f o r input ntext 1 m nl i nen nl etx i n i t i a l i z e v a r i a b l e s for i 1100 l i n e s in output j 1 while jl i n e l e n g t h nl et scan through f i l e kfindstr text n a l l occurrences of seed indround length k1rand1 pick one nl ettext k indm i f abs nl et 13 tr eat c a r r i a g e r etur ns nl et as spaces end nl i ne nline nl et add next l e t t e r nn 2 m nl et new seed jj 1 end disp nl i ne setstr 1 3 format output add CRs nl i ne i n i t i a l i z e next l i n e end Typical output of textsimm depends heavily on the number of terms m used for the transition probabilities With m1 or m2 the results appear much as above When m3 Be end claime armed yes a bigged wenty for me fearabbag girl Humagine ther mightmarkling the 5 C E Shannon A Mathematical Theory of Communication The Bell System Technical Journal vol 27 nos 7 and 10 pp 379423 and 623656 July and October 1948 Coding 313 many the scarecrow pass and I havely and lovery wine end at then only we pure never many words appear and many combinations of letters that might be words but arent quite Humagine is suggestive though it is not clear exactly what mightmarkling might mean When m4 Water of everythinkies friends of the scarecrow no head we She time toto be well as some although to they would her been Them became the small directions and have a thing woodman the vast majority of words are actual English though the occasional conjunction of words such as everythinkies is not uncommon The output also begins to strongly reflect the text used to derive the probabilities Since many fourletter combinations occur only once there is no choice for the method to continue spelling a longer word this is why the scarecrow and the woodman figure prominently For m5 and above the random output is recognizably English and strongly dependent on the text used Four trouble and to taken until the bread hastened from its Back to you over the emerald city and her in toward the will Trodden and being she could soon and talk to travely lady Exercise 146 Run the program textsimm using the input file carrollmat 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 147 Run the program textsimm using the input file foreignmat 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 148 The program textsimm operates at the level of letters and the probabilities of transition between successive sets of mlength letter sequences Write an analogous program that operates at the level of words and the prob abilities of transition between successive sets of mlength word sequences Does your program generate plausiblesounding phrases or sentences 314 Chapter 14 Coding Exercise 149 There is nothing about the technique of textsimm that is inherently limited to dealing with text sequences Consider a piece of notated music as a sequence of symbols labeled so that each C note is 1 each C note is 2 each D note is 3 etc Create a table of transition probabilities from a piece of music and then generate new melodies in the same way that textsimm generates new sentences Observe that this procedure can be automated using standard MIDI files as input Because this method derives the multiletter probabilities directly from a text there is no need to compile transition probabilities for other languages Using Vergils Aeneid with m3 gives Aenere omnibus praeviscrimus habes ergemio nam inquae enies Media tibi troius antis igna volae subilius ipsis dardatuli Cae sanguina fugis ampora auso magnum patrix quis ait longuin which is not real Latin Similarly Que todose remosotro enga tendo en guinada y ase aunque lo Se dicielos escubra la no fuerta pare la paragales posa derse Y quija con figual se don que espedios tras tu pales del is not Spanish the input file was Cervantes Don Quijote also with m3 and Seule sontagne trait homarcher de la t au onze le quance matices Maississait passepart penaient la ples les au cherche de je Chamain peut accide bien avaien rie se vent puis il nez pande is not French the source was Le Tour du Monde en Quatre Vingts Jours a translation of Jules Vernes Around the World in Eighty Days The input file to the program textsimm is a Matlab mat file that has been preprocessed to remove excessive line breaks spaces and capitalization using textmanm which is why there is no punctuation in these examples A large assortment of text files is available for downloading at the website of Project Gutenberg at httpwwwgutenbergorg Text in a variety of languages retains some of the character of its language with correlations of 3 to 5 letters 2135 bits when coded in ASCII Thus mes sages written in those languages are not independent except possibly at lengths greater than this A result from probability theory suggests that if the letters are clustered into blocks that are longer than the correlation then the blocks may be nearly independent This is one strategy to pursue when designing codes 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 defines 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 four level data is generated by calling the pamm routine Noise is then added with power specified by p and the number of errors caused by this amount of noise is calculated in err Listing 145 noisychanm generate 4level data and add noise m1000 length of data sequence p115 s 10 power of noi s e and s i g n a l xpamm 4 s 4PAM input with power 1 Lsqrt 1 5 with amp l e v e l s L nsqrt prandn 1 m noi s e with power p yxn output adds noi s e to data qyquantalph y 3LL L3L quantize to 3LL L3L er rsum abs sign qyx m percent transmission e r r o r s Typical outputs of noisychanm are shown in Figure 144 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 righthand case is the maximum noise allowable in the plausibility argument used to derive 147 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 1412a the noise was chosen to be independent and normally distributed with power P to ensure that 4 1 P P The middle plot used a noise with power P3 and the lefthand plot had noise power P6 As can be seen from the plots there were essentially no errors when using the smallest noise a handful of errors in the middle and about 6 errors when the power of the noise matched the Shannon capacity Thus this naive transmission of fourlevel data ie with no coding has many more errors than the Shannon limit suggests Exercise 1412 Find the amplitudes of the Nlevel equally spaced signal with unity power when a N 4 b N 6 c N 8 Exercise 1413 Use noisychanm to compare the noise performance of two level fourlevel and sixlevel transmissions 322 Chapter 14 Coding 2 1 1 2 2000 4000 0 16 max noise 2000 0 0 4000 13 max noise 2000 0 4000 max noise Amplitude Figure 144 Each plot shows a fourlevel PAM signal the four solid lines the signal plus noise the scattered dots and the error between the data and the quantized output the dark stars The noise in the righthand plot was at the Shannon limit N S P P the noise in the middle plot was at onethird the power and the noise in the lefthand plot was at onesixth the power a Modify the program to generate two and sixlevel signals b Make a plot of the noise power versus the percentage of errors for two four and six levels Exercise 1414 Use noisychanm to compare the power requirements for two level fourlevel and sixlevel transmissions Fix the noise power at p001 and find the error probability for fourlevel transmission Experimentally find the power S that is required to make the twolevel and sixlevel transmissions have the same probability of error Can you think of a way to calculate this Exercise 1415 Consider the asymmetric nonuniformly spaced alphabet con sisting of the symbols 1 1 3 4 a Find the amplitudes of this fourlevel signal with unity power b Use noisychanm to examine the noise performance of this transmission by making a plot of the noise power versus the percentage of errors c Compare this alphabet with 4PAM using the standard alphabet 1 3 Which would you prefer There are two different problems that can keep a transmission system from reaching the Shannon limit The first is that the source might not be coded with maximum entropy and this will be discussed next in Section 145 The second is when different symbols experience different amounts of noise Recall that the plausibility argument for the channel capacity rested on the idea of the average 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 righthand plot of Figure 144 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 146 145 Source Coding The results from Section 143 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 142 for English and other natural languages There are two basic approaches The first 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 variable length code words assigning short codes to common letters like e and long codes to infrequent letters like x Perhaps the most common variablelength 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 144a in which px1 05 px2 025 and px3 px4 0125 As shown earlier the entropy of this source is 175 bitssymbol which means that there must be some way of coding the source so that on average 175 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 148 An alternative representation is x1 1 x2 01 x3 001 and x4 000 149 where moreprobable symbols use fewer bits and lessprobable 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 148 175 bits per symbol so this coding is as good as possible since it equals the entropy 324 Chapter 14 Coding In contrast the naive code of 148 requires 16 bits to represent the eight sym bols for an average of 2 bits per symbol One feature of the variablelength code in 149 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 first symbol begins For example the string 01 10 11 00 1 is very different 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 prefix codes Since the entropy defines the smallest number of bits that can be used to encode a source it can be used to define the efficiency of a code efficiency entropy average of bits per symbol 1410 Thus the efficiency of the naive code 148 is 1752 0875 while the effi ciency of the variablerate code 149 is 1 Shannons source coding theorem says that if an independent source has entropy H then there exists a pre fix 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 aver age length Thus if N symbols each with entropy H are compressed into fewer than NH bits information is lost while information need not be lost if NH 1 bits are used Shannon has defined the goal towards which all codes aspire but provides no way of finding good codes for any particular case Fortunately D A Huffman proposed an organized procedure to build variable length codes that are as efficient 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 defines 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 first N 4 code from Example 144 in which the symbols have probabilities px1 05 px2 025 and px3 px4 0125 Following the foregoing procedure leads to the chart shown in Figure 145 In the first step x3 and x4 are combined to form a new node with probability equal to 025 the sum px3 px4 Then this new node is combined with x2 to form a new node with probability 05 Finally this is combined with x1 to form the rightmost node Coding 325 1 1 0 1 0 0 025 05 Symbol Probability x1 05 x3 0125 x2 025 x4 0125 Figure 145 The Huffman code for the source defined in the first part of Example 144 can be read directly from this chart which is constructed using the procedure 1 to 4 in the text Each branch is now labeled The convention used in Figure 145 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 Huffman code for this source can be read from the chart Reading from the righthand side x1 corresponds to 1 x2 to 01 x3 to 001 and x4 to 000 This is the same code as in 149 The Huffman procedure with a consistent branchlabeling convention always leads to a prefix code because all the symbols end the same except for the maximallength symbol x4 More importantly it always leads to a code that has average length very near the optimal Exercise 1416 Consider the source with N 5 symbols with probabilities px1 116 px2 18 px3 14 px4 116 and px5 12 a What is the entropy of this source b Build the Huffman chart c Show that the Huffman code is x1 0001 x2 001 x3 01 x4 0000 and x5 1 d What is the efficiency of this code e If this source were encoded naively how many bits per symbol would be needed What is the efficiency Exercise 1417 Consider the source with N 4 symbols with probabilities px1 03 px2 03 px3 02 and px4 02 a What is the entropy of this source b Build the Huffman code c What is the efficiency of this code d If this source were encoded naively how many bits per symbol would be needed What is the efficiency Exercise 1418 Build the Huffman chart for the source defined by the 26 English letters plus space and their frequency in the Wizard of Oz as given in 144 326 Chapter 14 Coding The Matlab program codexm demonstrates how a variablelength code can be encoded and decoded The first step generates a 4PAM sequence with the probabilities used in the first part of Example 144 In the code the symbols are assigned numerical values 1 3 The symbols their probabilities the numerical values and the variablelength Huffman code are as follows symbol probability value Huffman code x1 05 1 1 x2 025 1 01 x3 0125 3 001 x4 0125 3 000 This Huffman code was derived in Figure 145 For a lengthm input sequence the second step replaces each symbol value with the appropriate binary sequence and places the output in the vector cx Listing 146 codexm step 2 encode the sequence using Huffman code j 1 cx for i 1m i f x i 1 cx j 1 jj 1 e l s e i f x i 1 cx j j 10 1 jj 2 e l s e i f x i 3 cx j j 20 0 1 jj 3 e l s e i f x i 3 cx j j 20 0 0 jj 3 end end 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 147 codexm step 3 decode the variablelength sequence j 1 i 1 y while ilength cx i f cx i i 1 y j 1 ii 1 jj 1 e l s e i f cx i i 10 1 y j 1 ii 2 jj 1 e l s e i f cx i i 20 0 1 y j 3 ii 3 jj 1 e l s e i f cx i i 20 0 0 y j 3 ii 3 jj 1 end end Indeed running the program codexm which contains all three steps gives a perfect decoding Exercise 1419 Mimicking the code in codexm create a Huffman encoder and decoder for the source defined in Example 1416 Exercise 1420 Use codexm to investigate what happens when the probabili ties 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 01 x2 01 x3 01 and x4 07 1411 b Without changing the Huffman encoding to account for these changed prob abilities compare the average length of the coded data vector cx with the average length of the naive encoder 148 Which does a better job compress ing 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 Huffman chart for the probabilities defined in 1411 e Implement this new Huffman code and compare the average length of the coded data cx with the previous results Which does a better job compressing the data Exercise 1421 Using codexm implement the Huffman code from Exer cise 1418 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 Huffman coding in Exer cise 1421 would be optimal no other coding method could achieve a better com pression 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 stud ies in Section 142 there is a lot that can be gained by exploiting higherorder relationships between the symbols Exercise 1422 Zipped files 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 files Note the file size when the file is in its compressed form and the file size after decompressing unzipping the file How does this compare with the compression ratio achieved in Exercise 1421 Exercise 1423 Using the routine writetextm this file which can be found on the website uses the Matlab command fwrite write the Wizard of Oz text to a file OZdoc Use a compression routine uuencode on a Unix or Linux machine zip on a Windows machine or stuffit on a Mac to compress OZdoc Note the file size when the file is in its compressed form and the file size after decompressing How does this compare with the compression ratio achieved in Exercise 1421 Coding 329 Table 141 Modulo 2 arithmetic 0 1 0 0 1 1 1 0 0 1 0 0 0 1 0 1 and paritycheck matrix HT 1 0 1 0 1 1 1 0 0 0 1 0 0 0 1 1414 This code bundles the bits into pairs and the four corresponding code words are x1 00 c1 x1G 00000 x2 01 c2 x2G 01011 x3 10 c3 x3G 10101 and x4 11 c4 x4G 11110 There is one subtlety The arithmetic used in the calculation of the code words and indeed throughout the linearblockcode method is not standard Because the input source is binary the arithmetic is also binary Binary addition and multiplication are shown in Table 141 The operations of binary arithmetic may be more familiar as exclusive OR binary addition and logical AND binary multiplication In effect at the end of every calculation the answer is taken modulo 2 For instance in standard arithmetic x4G 11112 The correct code word c4 is found by reducing each calculation modulo 2 In Matlab this is done with modx4g2 where x411 and g is defined as in 1413 In modulo 2 arith metic 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 HT If there were no errors in transmission then y is equal to one of the four code words ci With H defined as in 1414 c1HT c2HT c3HT c4HT 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 yHT 0 and the received signal is one of the code words However when there are errors yHT 0 and the value can be used to deter mine the most likely error to have occurred To see how this works rewrite y c y c c e 330 Chapter 14 Coding Table 142 Syndrome table for the binary 5 2 code with generator matrix 1413 and paritycheck matrix 1414 Syndrome eHT Most likely error e 000 00000 001 00001 010 00010 011 01000 100 00100 101 10000 110 11000 111 10010 where e represents the errors that have occurred in the transmission Note that yHT c eHT cHT eHT eHT since cHT 0 The value of eHT is used by looking in the syndrome table Table 142 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 paritycheck matrix gives yHT eHT 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 find 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 paritycheck matrix gives yHT eHT 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 eHT for each As long as the columns of H are nonzero and distinct each error pattern corresponds to a different syndrome To fill out the remainder of the table take each of the possible double errors each of the es with exactly two 1s and calculate eHT Pick two that correspond to the remaining unused syndromes Since there are many more possible double errors nn 1 20 than there are syndromes 2nk 8 these are beyond the ability of the code to correct The Matlab program blockcode52m shows details of how this encoding and decoding proceeds The first part defines the relevant parameters of the 5 2 binary linear block code the generator g the paritycheck matrix h and the Coding 331 syndrome table syn The rows of syn are ordered so that the binary digits of eHT can be used to directly index into the table Listing 148 blockcode52m part 1 definition of 5 2 binary linear block code the generator and paritycheck matrices g1 0 1 0 1 0 1 0 1 1 h1 0 1 0 0 0 1 0 1 0 1 1 0 0 1 the four code words cwxg 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 the syndrome tabl e syn0 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 specifies 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 paritycheck 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 blockcode52m in the for j loop by searching Listing 149 blockcode52m part 2 encoding and decoding data p1 p r o b a b i l i t y of bi t f l i p m10000 length of message dat 05 sign rand1 m 051 m random 0s and 1s for i 12m cmod dat i dat i 1g 2 build codeword for j 1length c i f randp c jc j 1 end f l i p b i t s with prob p end yc r ecei ved s i g n a l ehmodyh 2 multiply by par i ty check h ehindeh14 eh22 eh 31 turn syndrome i nto index esyn ehind er r or from syndrome tabl e ymodye 2 add e to c o r r e c t e r r o r s 9 This is explored in the context of blockcode52m in Exercise 1426 332 Chapter 14 Coding for j 1max size x get message from codewords i f ycw j z i i 1x j end end end er rsumabs zdat how many e r r o r s occurred Running blockcode52m with the default parameters of 10 bit errors and length m10000 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 blockcode52m Exercise 1424 Use blockcode52m to investigate the performance of the binary 5 2 code Let p take on a variety of values p 0001 001 002 005 01 02 and 05 and plot the percentage of errors as a function of the percentage of bits flipped Exercise 1425 This exercise compares the performance of the 5 2 block code in a more realistic setting and provides a good warmup exercise for the receiver to be built in Chapter 15 The program nocode52m all Matlab files 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 4PAM for transmission For efficiency the text is encoded using text2binm recall Example 82 At the receiver the process is reversed the raw 4PAM data are translated into binary then decoded using the 5 2 block decoder and finally translated back into text using bin2textm 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 blockcode52m and nocode52m 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 ie running nocode52m without modification Exercise 1426 Use the matrix ginv1 11 0 0 01 00 1 to replace the for j loop in blockcode52m Observe that this reverses the effect of con structing the code words from the x since cwginvx mod 2 Exercise 1427 Implement the simple majorityrules code described in 1412 a Plot the percentage of errors after coding as a function of the number of symbol errors b Compare the performance of the majorityrules code to the 5 2 block code c Compare the data rate required by the majorityrules code with that required by the 5 2 code and with the naive no coding case Coding 333 1462 Minimum Distance of a Linear Code In general linear codes work much like the example in the previous section although the generator matrix paritycheck matrix and syndrome table are unique to each code The details of the arithmetic may also be different when the code is not binary Two examples will be given later This section discusses the general performance of linear block codes in terms of the minimum distance of a code which specifies how many errors the code can detect and how many errors it can correct A code C is a collection of code words ci which are nvectors with elements drawn from the same alphabet as the source An encoder is a rule that assigns a klength message to each codeword Example 145 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 respec tively 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 d00000 01011 3 The distance between 1001 and 1011 is d1001 1011 1 The minimum distance of a code C is the smallest distance between any two code words In symbols dmin min ij dci cj where ci C Exercise 1428 Show that the minimum distance of the 5 2 binary linear block code is dmin 3 Exercise 1429 Write down all code words for the majorityrules code 1412 What is the minimum distance of this code Exercise 1430 A code C has four elements 0000 0101 1010 1111 What is the minimum distance of this code Let Dit be the decoding sets of all possible received signals that are less than t away from ci For instance the majorityrules code has two code words and hence two decoding sets With t 1 these are D11 000 001 100 010 D21 111 110 011 101 1415 10 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 Chapter 14 Coding When any of the elements in D11 are received the code word c1 0 is used when any of the elements in D21 are received the code word c2 1 is used For t 0 the decoding sets are D10 000 and D20 111 1416 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 Dit are not disjoint and hence cannot be used for decoding Exercise 1431 What are the t 0 decoding sets for the fourelement code in Exercise 1430 Are the t 1 decoding sets disjoint Exercise 1432 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 errorcorrection code that handles up to t errors Now suppose that the decoding sets are disjoint with 2t s dmin but that t dc 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 off Example 146 Consider again the majorityrules 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 1415 code words could suffer 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 1416 the code word could suffer up to two errors and the error would be detected but there would be no way to correct it with certainty Example 147 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 suffer up to three errors and still be correctly decoded But if four errors occurred the message would be incorrect Coding 335 Table 143 Syndrome table for the binary 7 3 code Syndrome Most likely eHT error e 0000 0000000 0001 0000001 0010 0000010 0100 0000100 1000 0001000 1101 0010000 1011 0100000 0111 1000000 0011 0000011 0110 0000110 1100 0001100 0101 0011000 1010 0001010 1001 0010100 1110 0111000 1111 0010010 2 t 2 s 2 In this mode if the codeword suffered up to two errors then it would be correctly decoded If there were three or four errors then the errors would be detected but because they cannot be corrected with certainty no incorrect message is generated Thus the minimum distance of a code is a resource that can be allocated between error detection and error correction How to trade these off is a system design issue In some cases the receiver can ask for a symbol to be retransmitted when an error occurs for instance in a computer modem or when reading a file from disk and it may be sensible to allocate dmin to detecting errors In other cases such as broadcasting it is more common to focus on error correction The discussion in this section so far is completely general that is the definition and results on minimum distance apply to any code of any size whether linear or nonlinear There are two problems with large nonlinear codes r It is hard to specify codes with large dmin r Implementing coding and decoding can be expensive in terms of memory and computational power To emphasize this consider a code that combines binary digits into clusters of 56 and codes these clusters using 64 bits Such a code requires about 10101 code words Considering that the estimated number of elementary particles in the universe is about 1080 this is a problem When the code is linear however it is not necessary to store all the code words they can be generated as needed This 336 Chapter 14 Coding was noted in the discussion of the 5 2 code of the previous section Moreover finding 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 definition by finding the distances between all the code words or by finding 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 1463 Some More Codes This section gives two examples of n k linear codes If the generator matrix G has the form G IkP 1417 where Ik is the k by k identity matrix and P is some k by n k matrix then IkP P Ink 0 1418 where the 0 is the k by n k matrix of all zeros Hence define H PInk Observe that the 5 2 code is of this form since in binary arithmetic 1 1 and so P P Example 148 A 7 3 binary code has generator matrix G 1 0 0 0 1 1 1 0 1 0 1 0 1 1 0 0 1 1 1 0 1 and paritycheck matrix HT 0 1 1 1 1 0 1 1 1 1 0 1 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 The syndrome Table 143 is built by calculating which error pattern is most likely ie has the fewest bits flipped for each given syndrome eHT This code has dmin 4 and hence the code can correct any 1bit errors 7 out of 21 possible 2bit errors and 1 of the many 3bit errors Coding 337 Table 144 Modulo 5 arithmetic 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 1433 Using the code from blockcode52m implement the binary 7 3 linear block code Compare its performance and efficiency with the 5 2 code and the majorityrules code a For each code plot the percentage p of bit flips in the channel versus the percentage of bit flips 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 141 is inappropriate For example consider a source alphabet with five symbols labeled 0 1 2 3 4 Arithmetic operations for these elements are addition and multipli cation modulo 5 which are defined in Table 144 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 define the desired operations via tables like Tables 141 and 144 Example 149 A 6 4 code using a q 5element source alphabet has generator matrix G 1 0 0 0 4 4 0 1 0 0 4 3 0 0 1 0 4 2 0 0 0 1 4 1 and paritycheck matrix HT 4 4 4 3 4 2 4 1 1 0 0 1 1 1 1 2 1 3 1 4 1 0 0 1 338 Chapter 14 Coding Table 145 Syndrome table for the q 5 source alphabet 6 4 code Syndrome Most likely eHT error e 00 000000 01 000001 10 000010 14 000100 13 001000 12 010000 11 100000 02 000002 20 000020 23 000200 21 002000 24 020000 22 200000 03 000003 30 000030 32 000300 34 003000 31 030000 33 300000 04 000004 40 000040 41 000400 42 004000 43 040000 44 400000 since in modulo 5 arithmetic 4 1 3 2 2 3 and 1 4 Observe that these fit in the general form of 1417 and 1418 Table 145 lists the qnk 564 25 syndromes and corresponding errors The code in this example corrects all onesymbol errors and no others Exercise 1434 Find all the code words in the q 5 6 4 linear block code from Example 149 Exercise 1435 What is the minimum distance of the q 5 6 4 linear block code from Example 149 Exercise 1436 Mimicking the code in blockcode52m implement the q 5 6 4 linear block code from Example 149 Compare its performance with the 5 2 and 7 3 binary codes in terms of Coding 339 a performance in correcting errors b data rate Be careful how can a q 5 source alphabet be compared fairly with a binary alphabet Should the comparison be in terms of percentage of bit errors or percentage of symbol errors 147 Encoding a Compact Disc The process of writing to and reading from a compact disc is involved The essential idea in optical media is that a laser beam bounces off the surface of the disc If there is a pit then the light travels a bit further than if there is no pit The distances are controlled so that the extra time required by the round trip corresponds to a phase shift of 180 Thus the light traveling back interferes destructively if there is a pit whereas it reinforces constructively if there is no pit The strength of the beam is monitored to detect a 0 a pit or a 1 no pit While the complete system can be made remarkably accurate the reading and writing procedures are prone to errors This is a perfect application for error correcting codes The encoding procedure is outlined in Figure 146 The original signal is digitized at 44100 samples per second in each of two stereo channels Each sample is 16 bits and the effective data rate is 141 Mbps megabits per second The Cross Interleave ReedSolomon Code CIRC encoder described shortly has an effective rate of about 34 and its output is at 188 Mbps Then control and timing information is added which contains the track and subtrack numbers that allow CD tracks to be accessed rapidly The EFM Eightto Fourteen Module is an encoder that spreads the audio information in time by changing each possible 8bit sequence into a predefined 14bit sequence so that each one is separated by at least two and at most ten zeros This is used to help the tracking mechanism Reading errors on a CD often occur in clusters a small scratch may be many hundreds of bits wide and interleaving distributes the errors so that they can be corrected more effectively Finally a large number of synchronization bits is added These are used by the control mechanism of the laser to tell it where to shine the beam in order to find the next bits The final encoded data rate is 432 Mbps Thus about 13 of the bits on the CD are actual data and about 23 of the bits are present to help the system function and to detect andor correct errors when they occur The CIRC encoder consists of two special linear block codes called Reed Solomon codes which are named after their inventors Both use q 256 8 bit symbols and each 16bit audio sample is split into two code words The first code is a 3228 linear code with dmin 5 and the second code is a linear 2824 code also with dmin 5 These are nonbinary and use special arithmetic operations defined by the Galois field with 256 symbols The encoding is split 340 Chapter 14 Coding Music AD MUX EFM MUX Optical media CIRC Encoder 141 Mbps 188 Mbps 192 Mbps 432 Mbps 441 kHz per channel at 16 bitssample ReedSolomon Linear Block Codes Control and timing tracksubtracks EighttoFourteen Module Synchronization Figure 146 CDs can be used for audio or for data The encoding procedure is the same though decoding may be done differently for different applications 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 andor correct The encoding process on the CD is completely specified 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 five 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 effective if the cause is a defect in the medium For Further Reading The paper that started information theory is still a good read half a century after its initial publication r C E Shannon A Mathematical Theory of Communication The Bell Sys tem Technical Journal vol 27 pp 379423 and 623656 July and October 1948 Step 5 Putting It All Together The projects of Chapters 15 and 16 integrate all the fixes of the fourth step into the receiver structure of the third step to create fully functional digital receivers The wellfabricated 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 Digital Radio your name here 15 Make It So This chapter describes a softwaredefinedradio design project called M6 the Mix n Match Mostly Marvelous Message Machine The M6 transmission standard is specified so that the receiver can be designed using the building blocks of the preceding chapters The DSP portion of the M6 can be simulated in Matlab by combining the functions and subroutines from the examples and exercises of the previous chapters The input to the digital portion of the M6 receiver is a sampled signal at intermediate frequency IF that contains several simultaneous messages each transmitted in its own frequency band The original message is text that has been converted into symbols drawn from a 4PAM constellation and the pulse shape is a squareroot raised cosine The sample frequency can be less than twice the highest frequency in the analog IF signal but it must be sufficiently greater than the inverse of the transmitted symbol period to be twice the bandwidth of the baseband signal The successful M6 Matlab program will demodulate syn chronize equalize and decode the signal so it is a fully operational software defined receiver although it is not intended to work in real time The receiver must overcome multiple impairments There may be phase noise in the trans mitter oscillator There may be an offset between the frequency of the oscillator in the transmitter and the frequency of the oscillator in the receiver The pulse clocks in the transmitter and receiver may differ The transmission channel may be noisy Other users in spectrally adjacent bands may be actively transmitting at the same time There may be intersymbol interference caused by multipath channels The next section describes the transmitter the channel and the analog front end of the receiver Then Section 152 makes several generic observations about receiver design and proposes a methodology for the digital receiver design The final section describes the receiver design challenge that serves as the culminating design experience of this book Actually building the M6 receiver however is left to you You will know that your receiver works when you can recover the mystery message hidden inside the received signal Make It So 343 151 How the Received Signal Is Constructed Receivers cannot be designed in a vacuum they must work in tandem with a par ticular transmitter Sometimes a communication system designer gets to design both ends of the system More often however the designer works on one end or the other with the goal of making the signal in the middle meet some standard specifications The standard for the M6 is established on the transmitted signal and consists in part of specifications on the allowable bandwidth and on the precision of its carrier frequency The standard also specifies the source constel lation the modulation and the coding schemes to be used The front end of the receiver provides some bandpass filtering downconversion to IF and automatic gain control prior to the sampler This section describes the construction of the sampled IF signal that must be processed by the M6 receiver The system that generates the analog received signal is shown in blockdiagram form in Figure 151 The front end of the receiver that turns this into a sampled IF signal is shown in Figure 152 The original message in Figure 151 is a character string of English text Each character is converted into a 7bit binary string according to the ASCII conver sion format eg the letter a is 1100001 and the letter M is 1001101 as in Example 82 The bit string is coded using the 5 2 linear block code specified in blockcode52m which associates a 5bit code with each pair of bits The output of the block code is then partitioned into pairs that are associated with the four Coding Character to binary conversion Pulse shape Text message Baseband signal Transmitted passband signal Analog received signal Adjacent users Broadband noise Modulation includes phase noise Channel Bits Symbols si Scaling 1 Trigger i Tt εt includes periodic marker and training sequence Figure 151 Construction of the received signal Bandpass filter Downconversion to IF Automatic gain control kTs Analog received signal Sampled received signal Figure 152 Front end of the receiver Make It So 345 Table 151 M6 Transmitter specifications Symbol source alphabet 1 3 Assigned intermediate frequency 2 MHz Nominal symbol period 64 µs SRRC pulseshape rolloff factor β 01 03 FDM user slot allotment 204 kHz Width of SRRC pulse shape 8 clock periods Frame markertraining sequence See 152 Frame marker sequence period 1120 symbols Timevarying IF carrier phase Filtered white noise IF offset Fixed 001 Timing offset Fixed Symbol period offset Fixed 001 Intersymbol interference Max delay spread 7 symbols Sampler frequency 850 kHz The channel may be near ideal ie a unit gain multisymbol delay or it may have significant 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 flat 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 001 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 intermediatefrequency signal presented to the receiver sampler may also vary The bandpass filter before the downconverter in the front end of the receiver in Figure 152 partially attenuates adjacent 204kHzwide FDM user bands The automatic gain control is presumed locked and fixed over each transmission The freerunning 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 153 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 filter to frequencies between zero and IF 152 A Design Methodology for the M6 Receiver Before describing the specific design requirements that must be met by a suc cessful M6 receiver this section makes some generic remarks about a systematic approach to receiver design There are four generic stages 346 Chapter 15 Make It So Downconversion Matched filter Carrier recovery Timing recovery Interpolator downsampler Adaptive layer Sampled received signal Equalizer Decision device Equalizer adaptation Training segment locator Frame synchronization Decoder Recovered source Figure 153 DSP portion of softwaredefined receiver 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 preced ing stages be fixed in reality difficulties encountered at one stage in the design process may require a return to and different choices to be made in earlier stages As will soon become clear the M6 problem specification has basically preresolved the design issues of the first two stages 1521 Stage One Ordering the Pieces The first stage is to select the basic components and the order in which they occur The design layout first established in Figure 213 and reappearing in the DSP portion of the receiver in Figure 153 suggests one feasible structure As the signal enters the receiver it is downconverted with carrier recovery matched filtered interpolated with timing recovery equalized adaptively quantized and decoded with frame synchronization This classical ordering while popular is not the only nor necessarily the best way to recover the message from the noisy ISIdistorted FDMPAMIF received signal However it offers a useful foundation for assessing the relative benefits and costs of alternative receiver configurations Also we know for sure that the M6 receiver can be built this way Other configurations may work but we have not tested them1 How was this ordering of components chosen The authors have consulted with worked for talked about and argued with engineers working on a num ber of receiver systems including HDTV highdefinition television DSL and 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 application specific circumstance is a popular pastime of communication engineers Perhaps you too will come up with a unique approach Make It So 347 AlohaNet The ordering of components in Figures 213 and 153 represents an amalgamation of ideas from these and other systems Sometimes it is easy to argue why a particular order is good sometimes it is a matter of preference or personal experience and sometimes the choice is based on factors outside the engineers control2 For example the carrierrecovery algorithms of Chapter 10 are not greatly affected by noise or intersymbol interference as was shown in Exercises 1036 and 1040 Thus carrier recovery can be done before equalization and this is the path we have followed But it need not be done in this order3 Another example is the placement of the timingrecovery element The algorithms of Chapter 12 operate at baseband and hence the timing recovery in Figure 153 is placed after the demodulation But there are passband timingrecovery algorithms that could have been used to reverse the order of these two operations 1522 Stage Two Selecting Components Choices for the second design stage are relatively set as well Since the sampling is done at a subNyquist rate fs relative to the IF frequency fI the spec trum of the analog received signal is replicated every fs The integer n for which f fI nfs is smallest defines the nominal frequency f from which further downconversion is needed Recall that such downconversion by sampling was dis cussed in Section 62 Using different specifications the M6 sampling frequency fs may be above the Nyquist frequency associated with the IF frequency fI4 The most common method of downconversion is to use mixing followed by an FIR lowpass filter This will be followed by an FIR matched filter an interpolatordecimator for downsampling and a symbolspaced FIR equalizer that adapts its coefficients in response to the training data contained in the trans mission The output of the equalizer is quantized to the nearest 4PAM symbol value translated back into binary decoded using the 5 2 block decoder and finally turned back into readable text Given adequate knowledge of the operating environment the SNR in the received signal the carrier frequency and phase the clock period and symbol timing and the marker location the designerselected parameters within these components can be set to recover the message This was in fact the strategy followed in the idealized receiver of Chapter 9 Said another way the choices in stages one and two are presumed to admit an acceptable answer if prop erly tuned Component selections at this point including specification of the 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 3 For instance in the QAM radio of A Digital Quadrature Amplitude Modulation Radio avail able in the website the blocks appear in a different order 4 Indeed changing parameters such as this allows an instructor to create new transmission standards for each class 348 Chapter 15 Make It So fixed lowpass filter in the downconverter and the fixed matched filter preceding the interpolatordownsampler can be confirmed by simulations of the ISIfree idealfullknowledge setting Thus the upper half of Figure 153 is specified by stagetwo activities 1523 Stage Three Anticipating Impairments In the third design stage the choices are less constrained Elements of the third stage are shown in the lower half of the receiver the adaptive layer of Fig ure 153 and include the selection of algorithms for carrier timing frame syn chronization and equalizer adaptation There are several issues to consider One of the primary stagethree activities is algorithm selectionwhich per formance function to use in each block For example should the M6 receiver use a phaselocked loop a Costas loop or a decisiondirected method for carrier recovery Is a dual loop needed to provide adequate carrier tracking or will a single loop suffice What performance function should be used for the equalizer Which algorithm is best for the timing recovery Is simple correlation suitable to locate the training and marker segment Once the specific methods have been chosen it is necessary to select specific variables and parameters within the algorithms This is a traditional aspect of engineering design that is increasingly dominated by computeraided design simulation and visualization tools For example error surfaces and eye diagrams can be used to compare the performance of the various algorithms in particular settings They can be used to help determine which technique is more effective for the application at hand As softwareaided design packages proliferate the need to understand the com putational mechanics underlying a particular design becomes less of a barrier For instance Software Receiver Design has relied exclusively on the filter design algorithms built into Matlab But the specification of the filter its shape cutoff frequencies computational complexity and filter length cannot be left to Matlab The more esoteric the algorithm the less transparent is the process of selecting design parameters Thus Software Receiver Design has devoted considerable space to the design and operation of adaptive elements But even assuming that the tradeoffs associated with each of the individual components are clear how can everything be integrated together to succeed at a multifaceted design objective such as the M6 receiver 1524 Sources of Error and Tradeoffs Even when a receiver is fully operational it might not decode every symbol precisely There is always a chance of error Perhaps part of the error is due to a frequency mismatch part of the error is due to noise in the channel part of the error is due to a nonoptimal timing offset etc This section and the next suggest a general strategy for allocating part of the error to each component Then as 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 specifications 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 accu mulation 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 effectively 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 r Residual interference from adjacent FDM bands caused by imperfect bandpass filtering before downconversion and imperfect lowpass filtering after downcon version r AGC jitter caused by the deviation in the instantaneous signal from its desired average and scaled by the stepsize in the AGC element r Quantization noise in the sampler caused by coarseness in the magnitudes of the quantizer r Roundoff noise in filters caused by wordlength limitations in filter parame ters and filter algebra r Residual interference from the doubly upconverted spectrum caused by imperfect lowpass filtering after downconversion r Carrier phase jitter occurs physically as a system impairment and is caused by the stepsize in the carrierrecovery element r Timing jitter occurs physically as a system impairment and is caused by the stepsize in the timingrecovery element r Residual meansquared error left by the equalizer even an infinitely long lin ear equalizer cannot remove all recovery error in the presence of simultaneous channel noise and ISI r Equalizer parameter jitter caused by the nonvanishing stepsize in the adap tive equalizer r Noise enhancement by the equalizer caused by ISI that requires large equal izer gains such as a deep channel null at frequencies that also include noise Because Matlab implements all calculations in floatingpoint arithmetic the quantization and roundoff noise in the simulations is imperceptible The project setup presumes that the AGC has no jitter A welldesigned and sufficiently long lowpass filter in the downconverter can effectively remove the interference from outside the user band of interest The inband interference from sloppy adjacent FDM signals should be considered part of the inband channel noise This leaves 350 Chapter 15 Make It So carrier phase timing jitter imperfections in the equalizer tap jitter and noise gain All of these are potentially present in the M6 softwaredefined 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 algo rithm 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 ele ment 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 analo gous tradeoff 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 tradeoffs are common in any engineering design task The next section suggests a method of quantifying the tradeoffs to help make concrete decisions 1525 Tuning and Testing The testing and verification stage of receiver design is not a simple matter because there are so many things that can go wrong There is so much stuff that can happen Of course it is always possible to simply build a proto type and then test to see whether the specifications are met Such a haphazard approach may result in a working receiver but then again it might not Surely there is a better way This section suggests a commonsense approach that is not uncommon among practicing engineers It represents a practical compromise between excessive analysis such as one might find in some advanced commu nication texts and excessive trial and error such as try something and cross your fingers The idea is to construct a simulator that can create a variety of test signals that fall within the M6 specification The parameters within the simulator can then be changed one at a time and their effect on various candidate receivers noted By systematically varying the test signals the worst components of the receiver can be identified and then replaced As the tests proceed the receiver gradually improves As long as the complete set of test signals accurately represents the range of situations that will be encountered in operation the testing will lead to a successful design Given the particular stageone and two design choices for the M6 receiver the previous section outlined the factors that may degrade the performance of the receiver The following steps suggest some detailed tests that may facilitate the design process Make It So 351 r Step 1 Tuning the Carrier Recovery As shown in Chapter 10 any of the carrierrecovery algorithms will be capable of locating a fixed phase offset in a receiver in which everything else is operating optimally Even when there is noise or ISI the best settings for the frequency and phase of the demodulation sinusoid are those that match the frequency and phase of the carrier of the IF signal For the M6 receiver there are two issues that must be considered First the M6 specification allows the frequency to be somewhat different from its nominal value Is a dualloop structure needed Or can a single loop adequately track the expected variations Second the transmitter phase may be jittering The userchoosable features of the carrierrecovery algorithms are the LPF and the algorithm stepsize both of which influence the speed at which the estimates can change Since the carrierrecovery scheme needs to track a time varying phase the stepsize cannot be chosen too small Since a large stepsize increases the error due to phase jitter it cannot be chosen too large Thus an acceptable stepsize will represent a compromise To conduct a test to determine the stepsize and LPF requires creating test signals that have a variety of offnominal frequency offsets and phase jitters A simple way to model phase jitter is to add a lowpassfiltered version of zeromean white noise to a nominal value The quality of a particular set of parameters can then be measured by averaging over all the test signals the mean squared recovery error Choosing the LPF and stepsize parameters to make this error as small as possible gives the best values This average error provides a measure of the portion of the total error that is due to the carrierrecovery component in the receiver r Step 2 Tuning the Timing Recovery As shown in Chapter 12 there are several algorithms that can be used to find the best timing instants in the ideal setting When the channel impairment consists purely of additive noise the optimal sampling times remain unchanged though the estimates will likely be more noisy As shown by Example 123 and in Figure 1212 however when the channel contains ISI the answer returned by the algorithms differs from what might be naively expected There are two parts to the experiments at this step The first is to locate the best timingrecovery parameter for each test signal This value will be needed in the next step to assess the performance of the equalizer The second part is to find the mean squared recovery error due to jitter of the timingrecovery algorithm The first part is easy For each test signal run the chosen timingrecovery algorithm until it converges The convergent value gives the timing offset and indirectly specifies the ISI to which the equalizer will need to respond If it jiggles excessively then decrease the stepsize Assessing the mean squared recovery error due to timing jitter can be done much like the measurement of jitter for the carrier recovery measure the average error that occurs over each test signal when the algorithm is initialized 352 Chapter 15 Make It So at its optimum answer then average over all the test signals The answer may be affected by the various parameters of the algorithm the δ that determines the approximation to the derivative the l parameter that specifies the time support of the interpolation and the stepsize these variable names are from the first part of the timingrecovery algorithm clockrecDDm on page 258 In operation there may also be slight inaccuracies in the specification of the clock period When the clock period at the transmitter and that at the receiver differ the stepsize must be large enough that the timing estimates can follow the changing period Recall the discussion surrounding Example 124 Thus again there is a tension between a large stepsize needed to track rapid changes and a small stepsize to minimize the effect 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 r Step 3 Tuning the Equalizer After choosing the equalizer method as specified 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 equal izer the test signals should contain a variety of ISI channels andor additive interferences As suggested in Chapter 13 in a highSNR 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 five 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 differently at the receiver because of the sampling This effect was discussed at length in Section 131 where it was shown how the effective digital model of the channel includes the timing offset Thus as mentioned in the previous step assess ing the actual channel to which the equalizer will adapt requires knowing the timing offset that will be found by the timing recovery Fortunately in the M6 receiver structure of Figure 153 the timingrecovery algorithm oper ates 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 centerspike initial ization is used This was justified in Section 134 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 finding an appropriate delay was discussed in Section 1323 where the leastsquares 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 first 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 designerselected variable is stepsize As with all adaptive methods there is a tradeoff 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 r Step 4 Frame Synchronization Any error in locating the first symbol of each foursymbol 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 markertraining sequence The chosen markertraining sequence A0Oh well whatever Nevermind should be long enough that there are few false spikes when correlating to find 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 specifications described in the previous section as if the downconverter clock timing equalizer and quantizer had recovered the transmitted symbol sequence perfectly Finally after tuning each component separately it is necessary to confirm that when all the pieces of the system are operating simultaneously there are no excessive negative interactions With luck little further tuning will prove necessary to complete a successful design The next section has more specifics about the M6 receiver design Exercise 151 From the parameters in Table 151 do the following a Determine the oversampling or upsampling factor b Determine what frequency the sampled received signal will be centered around Recall that the receiver front end samples at a rate lower than the IF frequency and your answer should be something between 0 and fs2 354 Chapter 15 Make It So Exercise 152 The B3IG transmitter can be used to implement the M6 trans mission specifications as provided in m6paramsm Plot the received signal and its spectrum Use these plots to explain why your answers to Exercise 151 are correct 153 No Soap Radio The M6 Receiver Design Challenge The analog front end of the receiver in Figure 152 takes the signal from an antenna amplifies it and crudely bandpass filters it to partially suppress fre quencies outside the desired users frequency band An analog downconverter modulates the received signal approximately down to the nominal IF fI at 2 MHz The output of the analog downconverter is set by an automatic gain controller to fit the range of the sampler The output of the AGC is sampled at intervals of Ts 850 kHz to give rk which provides a Nyquist bandwidth of 425 kHz that is ample for a 102 kHz baseband user bandwidth The sampled received signal rk from Figure 152 is the input to the DSP portion of the receiver in Figure 153 The following comments on the components of the digital receiver in Fig ure 153 help characterize the design task r The downconversion to baseband uses the sampler frequency fs the known intermediate frequency fI and the current phase estimates to determine the mixer frequency needed to demodulate the signal The M6 receiver may use any of the phasetracking algorithms of Chapter 10 A second loop may also help with frequency offset r The lowpass filtering in the demodulator should have a bandwidth of roughly 102 kHz which will cover the selected source spectrum but reject components outside the frequency band of the desired user r The interpolatordownsampler implements the reduction in sample rate to T spaced values This block must also implement the timing synchronization so that the time between samples after timing recovery is representative of the true spacing of the samples at the transmitter You are free to implement this in any of the ways discussed in Chapter 12 r Since there could be a significant amount of intersymbol interference due to channel dynamics an equalizer is essential Any one will do A trained equalizer requires finding the start of the markertraining segment while a blind equalizer may converge more slowly r The decision device is a quantizer defined to reproduce the known alphabet of the si by a memoryless nearestelement decision r At the final step the decoding from blockcode52m in conjunction with bin2textm can be used to reconstruct the original text This also requires a frame synchronization that finds and removes the start block consisting of Make It So 355 marker plus training which is most likely implemented using a correlation technique The softwaredefined radio should have the following userselectable variables that can readily be set at the start of processing of the received block of data r rolloff factor β for the squareroot raised cosine pulse shape r initial phase offset r initial timing offset and r initial equalizer parameterization The following are some suggestions r Use the B3IG transmitter with m6paramsm to implement the M6 transmis sion specification 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 r Try to break your receiver See how much noise can be present in the received signal before accurate eg 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 r In order to facilitate more effective debugging while building the project implementation of a debug mode in the receiver is recommended The infor mation of interest will be plots of the time histories of pertinent signals as well as timing information eg a graph of matched filter average output power versus receiver symbol timing offset One convenient way to add this feature to your Matlab receiver would be to include a debug flag as an argument that produces these plots when the flag is activated r 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 fixed 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 andor its suitability for the circumstance at hand Several test files that contain a mystery signal with a quote from a wellknown book are available on the website They are labeled easymat mediummat and hardmat5 These have been created with a variety of different 5 One student remarked that these should have been called hardmat hardermat and completelyridiculousmat Nonetheless a wellcrafted M6 receiver can recover the hidden messages 356 Chapter 15 Make It So rolloff factors carrier frequencies phase noises ISI interferers and symbol tim ing offsets We encourage the adventurous reader to try to receive these secret signals Solve the mystery Break it down For Further Reading An overview of a practical application of softwaredefined radio emphasizing the redefinability of the DSP portion of the receiver can be found in r B Bing and N Jayant A Cellphone for All Standards IEEE Spectrum pp 3439 May 2002 The field of software radio erupted with a special issue of the IEEE Commu nications Magazine in May 1995 This was called a landmark special issue in an editorial in the more recent r J Mitola III V Bose B M Leiner T Turletti and D Tennenhouse Eds IEEE Journal on Selected Areas in Communications Special Issue on Soft ware Radios vol 17 April 1999 For more information on the technological context and the relevance of software implementations of communications systems see r E Buracchini The Software Radio Concept IEEE Communications Mag azine 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 H Reed Software Radio A Modern Approach to Radio Engineering PrenticeHall 2002 which overlaps in content if not style with the first half of Software Receiver Design Two recommended monographs that devote more attention than most to the methodology of the same slice of digital receiver design as we consider here are r J A C Bingham The Theory and Practice of Modem Design Wiley Inter science 1988 especially Chapter 5 r H Meyr M Moeneclaey and S A Fechtel Digital Communication Receivers Synchronization Channel Estimation and Signal Processing Wiley Inter science 1998 especially Section 41 16 A Digital Quadrature Amplitude Modulation Radio The preceding chapters of Software Receiver Design focus on a realvalued PAM transmission protocol Though this is one of the simplest digital trans mission systems a working radio for PAM needs to include a variety of tech niques that address the nonideal behaviors encountered in reality Fixes such as the PLL the Costas loop timing recovery and equalization are necessary parts of the system This chapter describes a complexvalued generalization of PAM called quadrature amplitude modulation QAM which forms the basis of a better radio While the change from realvalued PAM to complexvalued QAM signals is straightforward the bulk of this chapter fleshes out the details of operation of the resulting system The various parts of the digital radio need to be rethought carrier recovery timing recovery and equalization The theme of this chapter is that such rethinking can follow the same path as the original designs The basic techniques for the PAM radio of earlier chapters generalize smoothly to more sophisticated designs This chapter begins with the observation already noted in Section 53 that PAM modulations waste bandwidth QAM a more clever modulation strategy is able to halve the bandwidth requirements which represents a significant step towards practicality This is accomplished by sending and then unravelling two real PAM signals simultaneously on orthogonal carriers sine and cosine that occupy the same frequency band A straightforward way to describe QAM is to model the two signals as the real and imaginary portions of a single complex valued signal 161 The Song Remains the Same Sections 162 and 163 show explicitly how QAM can be viewed as PAM that uses complexvalued modulation and demodulation In an ideal world this would be the end of the story But reality intrudes in several ways Just as a PAM radio needs to align the phase at the transmitter with the phase at the receiver so 358 Chapter 16 A Digital Quadrature Amplitude Modulation Radio 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 1641 extends the Costasloop idea to 4QAM while Section 1643 extends the PLL for 4QAM 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 166 extends the timingrecovery methods of PAM in Chapter 12 to QAM Just as a PAM radio needs to build an equalizer to combat intersymbol inter ference 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 complexvalued adaptive equalizer as in Section 168 An interesting feature of QAM is that the carrier recovery can be carried out before the equalizer as in Section 164 or after the equalizer Such post equalization carrier recovery can be accomplished as in Section 167 by derotating the complexvalued 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 different possible QAM constellations are discussed in Section 165 and several possible ways of ordering the receiver elements are drawn from the technical literature in Section 169 As is done throughout Software Receiver Design exercises are structured as minidesign exercises for individual pieces of the system These pieces come together at the end with a description of and Matlab code for the Q3AM prototype receiver which parallels the M6 receiver of Chapter 15 but for QAM A series of experiments with the Q3AM receiver is intended to encourage explo ration of a variety of alternative architectures for the radio Exercises ask for assessments of the practicality of the various extensions and allow for experi mentation discovery and perhaps even a small dose of frustration as the impor tance of realworld 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 162 Quadrature Amplitude Modulation QAM Sections 51 and 52 demonstrate the use of amplitude modulation with and without a large carrier An unfortunate feature of these modulation techniques and of the resulting realvalued AM systems is that the range of frequencies used by the modulated signal is twice as wide as the range of frequencies in the baseband For example Figures 410 and 53 on pages 70 and 82 show baseband 360 Chapter 16 A Digital Quadrature Amplitude Modulation Radio 01 11 10 00 a s1 s2 1 1 1 1 00 01 11 10 b s1 s2 1 1 1 1 Figure 161 Two choices for associating symbol pairs s1 s2 with bit pairs In a 1 1 is associated with 00 1 1 with 01 1 1 with 11 and 1 1 with 10 In b 1 1 is associated with 10 1 1 with 00 1 1 with 01 and 1 1 with 11 1 sequence s2k Taken together these can be thought of as the 4QAM constel lation 1 j There are many ways in which two binary signals can be combined two are shown in Figure 161 which plots s1 s2 pairs in a twodimensional 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 mes sage For example a 1 3 4PAM coding could be recast as 4QAM using an assignment like 3 1 j 1 1 j 1 1 j 3 1 j In either case s1k and s2k are assumed to have zero average and to be uncor related so that their average product is zero The process of generating QAM signals such as 164 is demonstrated in qamcomparem which draws on the PAM pulseshaping routine pulrecsigm from page 194 qamcomparem uses a simple Hamming pulse shape pt and ran dom binary values for the messages s1k and s2k The modulation is carried out in two ways with real sines and cosines corresponding to the first part of 164 and with complex modulation corresponding to the second part of 164 The two outputs can be compared by calculating maxabsvcompvreal which verifies that the two are identical Listing 161 qamcomparem compare real and complex QAM implementations N1000 M20 Ts0001 symbols oversampling f a c t o r timeTsNM1 t 0Ts time sampling i n t e r v a l and time s1pamN 2 1 s2pamN 2 1 length N r e a l 2 l e v e l s i g n a l s pshamming M pulse shape of width M f c 1000 th 10 jsqrt 1 c a r r i e r f r eq and phase s1upzeros 1 NM s2upzeros 1 NM s1up 1 M ends1 oversample by M s2up 1 M ends2 oversample by M sp1f i l t e r ps 1 s1up convolve pulse shape with s1 sp2f i l t e r ps 1 s2up convolve pulse shape with s2 make r e a l and complexvalued ver s i ons and compare vr ealsp1 cos 2 pi f c tthsp2 sin 2 pi f c tth vcomp real sp1j sp2 exp j 2 pi f c tth max absvcompvr eal v e r i f y that they re the same A Digital Quadrature Amplitude Modulation Radio 363 mt e j2πfctθ ej2πf0tφ Transmitter Receiver xt vt st LPF Re Figure 163 Quadraturemodulation transmitter and receiver complexvalued version When f0 fc and φ θ the output st is equal to the message mt This is mathematically the same as the realvalued system shown in Figure 165 163 Demodulating QAM Figure 510 on page 91 shows how a quadraturemodulated signal like 161 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 53 and is also shown in the context of finding the envelope of a complex signal in Appendix C This section focuses on the more practical case where there may be phase and frequency offsets The math is simplified by using the complexvalued form where the received signal vt of 162 is mixed with the complex sinusoid ej2πf0tθ as in Figure 163 Algebraically this can be written xt ej2πf0tθvt ej2πf0tθRemtej2πfctφ ej2πf0tθm1t cos2πfct φ m2t sin2πfct φ ejφθ 2 m1tej2πf0fct m1tej2πf0fct j ejφθ 2 m2tej2πf0fct m2tej2πf0fct Assuming fc f0 and that the cutoff frequency of the LPF is less than 2fc and greater than fc the two highfrequency terms are removed by the LPF so that st LPFxt ejφθ 2 m1tej2πf0fct jm2tej2πf0fct 1 2ej2πf0fctjφθmt 167 where mt m1t jm2t 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 st is an attenuated copy of the message mt The spectra of the various signals in the demodulation process are shown in Figure 164 The transmitted signal vt is realvalued and hence has a symmetric spectrum This is shifted by the mixer so that one of the asymmetric pieces of Xf is near the origin and the other lies near 2fc The lowpass filter removes the highfrequency portion leaving only the copy of 364 Chapter 16 A Digital Quadrature Amplitude Modulation Radio fc fc V f fc 2fc fc X f fc fc S f Figure 164 Spectra of the various signals in the complexvalued demodulator of Figure 163 Observe the asymmetry of the spectra Xf and Sf m1t sin2πf0tθ cos2πf0tθ cos2πfctφ Transmitter Receiver m2t x1t vt x2t s1t s2t LPF LPF sin2πfctφ 1 Figure 165 Quadrature modulation transmitter and receiver realvalued version This is mathematically identical to the system shown in Figure 163 mt near the origin Though the calculations use complexvalued signals the same procedure can be implemented purely with real signals as shown in Figure 165 When f0 fc but θ φ st of 167 simplifies to ejφθmt2 This can be interpreted geometrically by observing that multiplication by a complex expo nential ejα is a rotation in the complex plane through an angle α In terms of the pulsed data sequences s1 and s2 shown in Figures 161 and 162 the constel lations become rotated about the origin through an angle given by φ θ This is the difference 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 st This can be accomplished by estimating the unknown values using techniques that are analogous to the phaselocked loop the Costas loop and decisiondirected methods as will be discussed in Section 164 The details will change in order to account for the differences 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 167 is st 1 2mtej2πf0fct This is a timevarying rotation of the constellation the points s1 and s2 spin as a function of time at a rate proportional to the frequency difference between the carrier frequency fc and the estimate f0 Again it is necessary to estimate this difference using carrierrecovery techniques A Digital Quadrature Amplitude Modulation Radio 365 This complexvalued modulation and demodulation is explored in qamdemodm A message m is chosen randomly from the constellation 1 j and then pulse shaped with a Hamming blip to form mp Modulation is carried out as in 162 to give the realvalued v Demodulation is accomplished by a complexvalued mixer as in Figure 163 to give x which is then lowpass filtered Observe that the spectra of the signals as shown using plotspecm for instance agree with the stylized drawings in Figure 164 After the lowpass filtering the demodulated s is equal to the original mp though it is shifted in time by half the length of the filter and attenuated by a factor of 2 Listing 162 qamdemodm modulate and demodulate a complexvalued QAM signal N10000 M20 Ts 0001 symbols oversample M timeTsNM1 t 0Ts time sampling times mpamN2 1 j pamN 2 1 s i g n a l s of length N pshammingM pulse shape of width M f c 1000 th 10 c a r r i e r f r eq and phase mupzeros 1 NM mup 1 M endm oversample by M mpf i l t e r ps 1 mup convolve pulse shape data vreal mp exp j 2 pi f c tth complex c a r r i e r f0 1000 ph10 f r eq and phase of demod xv exp j 2 pi f0 tph demodulate v l 50 f 0 0 2 0 2 5 1 s p e c i f y f i l t e r parameters a1 1 0 0 bfirpm l f a design f i l t e r sf i l t e r b 1 x sLPFx Exercise 166 qamdemodm shows that when fc f0 and φ θ the reconstruc tion 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 offset tau so that sktau mk for all k b Examine the consequences of a phase offset Let φ 0 th0 and examine the output when θ ph is 10 20 45 90 180 and 270 Explain what you see in terms of 167 c Examine the consequences of a frequency offset Let fc1000 f010001 and thph0 What is the correct timing offset tau for this case Is it possible to reconstruct m from s Explain what you see in terms of 167 Exercise 167 Implement the demodulation shown in Figure 165 using real valued sines and cosines to carry out the same task as in qamdemodm Hint begin with vreal of qamcomparem and ensure that the message can be recovered without use of complexvalued signals Exercise 168 Exercise 162 generates a 16QAM signal What needs to be changed in qamdemodm to successfully demodulate this 16QAM signal Exercise 169 Design a complexvalued demodulation for the imaginary method of Exercise 163 Show that the demodulation can also be carried out using purely real signals A Digital Quadrature Amplitude Modulation Radio 367 164 Carrier Recovery for QAM It should be no surprise that the ability to reconstruct the message symbols from a demodulated QAM signal depends on identifying the phase and frequency of the carrier because these are also required in the simpler PAM case of Chapter 10 Equation 167 illustrates explicitly what is required in order to recover mt from st To see how the recovery might begin observe that the receiver can adjust the phase θ and demodulating frequency f0 to any desired values If necessary the receiver could vary the parameters over time This section discusses two methods of building an adaptive element to iteratively estimate a time varying θ including the Costas loop for 4QAM which parallels the discussion in Section 104 of the Costas loop for PAM and a phaselocked loop for 4QAM which parallels the discussion in Section 103 of a PLL for PAM The variations in phase can then be parlayed into improved frequency estimates following the same kinds of strategies as in Section 106 1641 Costas Loop for 4QAM If it were possible to choose a timevarying θt in 167 so that θt 2πfc f0t φ 169 then st would be directly proportional to mt because ej2πf0fctjφθt 1 The simplest place to begin is to assume that the frequencies are correct ie that fc f0 and that φ is fixed but unknown As in previous chapters the approach is to design an adaptive element by specifying a performance or objective function Equation 169 suggests that the goal in carrier recovery of QAM should involve an adaptive parameter θ that is a function of the unknown parameter φ Once this objective has been chosen an iterative algorithm can be implemented to achieve convergence Sampling perfectly downconverted 4QAM signals s1t and s2t at the proper times should produce one of the four pairs 1 1 1 1 1 1 and 1 1 from the symbol constellation diagram in Figure 161 A rotation through 90ρ for any integer ρ will also produce samples with the same values though they may be a mixture of the symbol values from the two original messages Recall that Exercise 166b asked for an explicit formula relating the various rotations to the sampled s1 s2 pairs For the PAM system of Chapter 10 the phase θ is designed to converge to an offset of an integer multiple of 180 The corresponding objective function JC for the Costas loop from 1015 is proportional to cos2φ θ which has maxima at θ φ ρπ for integers ρ This observation can be exploited by seeking an objective function for QAM that causes the carrierrecovery phase to converge to an integer multiple of 90 It will later be necessary to resolve the ambiguity among the four choices This is postponed until Section 1642 370 Chapter 16 A Digital Quadrature Amplitude Modulation Radio LPF LPF µΣ cos2πf0kTsθkπ2 cos2πf0kTsθkπ4 θk LPF cos2πf0kTsθk vkTs LPF cos2πf0kTsθk3π4 x1k x2k x3k x4k Figure 167 This quadriphase Costasloop adaptive element can be used to identify an unknown phase offset in a 4QAM transmission The figure is a block diagram of Equation 1614 This adaptive element is shown schematically in Figure 167 where the received signal vt is sampled to give vk and then mixed with four outof phase cosines Each path is lowpass filtered with a cutoff frequency above 2fc and then multiplied to give the update term The integrator µΣ is the standard structure of an adaptive element indicating that the new value is updated at each iteration with a step size of µ The QAM Costas loop of 1614 and Figure 167 is implemented in qamcostasloopm The received signal is from the routine qamcomparem on page 360 where the variable vreal is created by modulating a pair of binary message signals The four filters are implemented using the timedomain method of Section 721 and the entire procedure mimics the Costas loop for PAM which is implemented in costasloopm on page 208 Listing 163 qamcostasloopm simulate Costas loop for QAM rvr eal vr eal from qamcompare m f l 100 f 0 2 3 1 a1 1 0 0 f i l t e r s p e c i f i c a t i o n hfirpm f l f a LPF design mu003 algorithm s t e p s i z e f0 1000 qf l 1 f r eq at r e c e i v e r thzeros 1 length t th 1randn i n i t i a l i z e estimate z1zeros 1 q z2zeros 1 q i n i t i a l i z e LPFs z4zeros 1 q z3zeros 1 q z s contain past inputs for k1length t1 s2r k z1z1 2 q s cos 2 pi f0 t kth k z2z2 2 q s cos 2 pi f0 t kpi4th k z3z3 2 q s cos 2 pi f0 t kpi2th k z4z4 2 q s cos 2 pi f0 t k3 pi4th k A Digital Quadrature Amplitude Modulation Radio 371 0 02 04 06 4 2 0 2 Time Phase offset Figure 168 Depending on where it is initialized the estimates made by the QAM Costasloop element converge to θ ρπ2 For this plot the unknown θ was 10 and there were 50 different initializations l p f 1f l i p l r h z1 output of f i l t e r 1 l p f 2f l i p l r h z2 output of f i l t e r 2 l p f 3f l i p l r h z3 output of f i l t e r 3 l p f 4f l i p l r h z4 output of f i l t e r 4 th k1th kmu l p f 1 l p f 2 l p f 3 l p f 4 algorithm update end Typical output of qamcostasloopm appears in Figure 168 which shows the evolution of the phase estimates for 50 different starting values of θ th1 Some of these converge to the correct phase offset θ 10 and others converge to nearby values 1 ρπ2 for integers ρ As expected these stationary points occur at all the 90 offsets of the desired value of θ When the frequency is not exactly known the phase estimates of the Costas algorithm try to follow For example in Figure 169 the frequency of the carrier is f0 1000 while the assumed frequency at the receiver was fc 10001 Fifty different starting points were used and in all cases the estimates converge to lines with the same slope The slope of these lines is directly proportional to the difference in frequency between fc and f0 and this slope can be used as in Section 106 to estimate the frequency difference Exercise 1615 Use the preceding code to play with the Costas loop for QAM a How does the stepsize mu affect the convergence rate b What happens if mu is too large say mu1 c Does the convergence speed depend on the value of the phase offset d When there is a small frequency offset what is the relationship between the slope of the phase estimate and the frequency difference Exercise 1616 How does the filter h influence the performance of the Costas loop 372 Chapter 16 A Digital Quadrature Amplitude Modulation Radio 0 02 04 06 4 6 2 0 2 Time Phase offset Figure 169 When the frequency of the carrier is unknown at the receiver the phase estimates converge to lines The slope of these lines is proportional to the frequency offset and can be used to correct the estimate of the carrier frequency a Try fl 1000 30 10 3 In each case use freqz to verify that the filter has been properly designed b Remove the LPFs completely from costasloopm How does this affect the convergent values The tracking performance Exercise 1617 What changes are needed to qamcostasloopm to enable it to function with 16QAM Recall Exercises 162 and 168 Exercise 1618 Exercise 1021 shows an alternative implementation of the PAM Costas loop that uses cheaper fixedphase oscillators rather than adjustable phase oscillators Refer to Figure 1012 on page 211 Design an analogous QAM implementation and write a simulation or modify qamcostasloopm to demon strate its operation Exercise 1619 Figure 1610 shows a highlevel block diagram of a dualloop system for tracking a frequency offset 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 1018 b Implement the dualloop frequency tracker and verify that small frequency offsets can be tracked For comparison the PAM equivalent is implemented in dualpllsm on page 219 c How large can the frequency offset 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 A Digital Quadrature Amplitude Modulation Radio 373 θ1k vk θ2k θk Carrier Recovery Carrier Recovery Figure 1610 Dualcarrierrecoveryloop Configuration general pulse shapes The key is to find conditions under which the update term 1613 remains proportional to the derivative of the objective function 1612 The generic effect of any smallstepsize adaptive element like 1614 is to average the update term over time Observe that the fourterm product 1613 has two parts one is proportional to cos4φ 4θ and the other is proportional to sin4φ 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 first term is avg4m1tm3 2t 4m2tm3 1t while the average of the second is avgm4 1t 6m2 1tm2 2t m4 2t In QAM the messages mit are built as the product of the data sik and a pulse shape as in 163 Even assuming that the average of the data values is zero which implies that the average of the messages is also zero finding these by hand for various pulse shapes is not easy But they are straightforward to find 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 redefining the variable unpsrrc1003M0 for a squareroot raised cosine pulse or unpones1M 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 1613 with a negative sign the sine term is proportional to the derivative sin4φ 4θ Thus it is possible to approximate all the terms that enter into the algorithm 1614 Listing 164 qamconstantsm calculate constants for avgx1 x2 x3 x4 N2000 M50 of symbols oversample M s1pamN 2 1 s2pamN 2 1 r e a l 2 l e v e l s i g n a l s mup1zeros 1 NM mup2zeros 1 NM mup1 1 M ends1 zero pad Tspaced sequence mup2 1 M ends2 oversample by M unphamming M unnormalized pulse shape psqrt M unpsqrt sum unp ˆ 2 normalized pulse shape m1f i l t e r p 1 mup1 convolve pulse shape data m2f i l t e r p 1 mup2 convolve pulse shape data stermsumm1ˆ4 6m1 ˆ 2 m2ˆ2m2 ˆ 4 NM ctermsum4m1 m2ˆ34m1 ˆ 3 m2NM 374 Chapter 16 A Digital Quadrature Amplitude Modulation Radio Exercise 1620 Find a pulse shape pt and a set of symbol values s1 and s2 that will cause the QAM Costas loop to fail Hint find values so that the average of the sinusoidal term is near zero Redo the simulation qamcostasloopm with these values and verify that the system does not achieve convergence Exercise 1621 Suppose that sik are binary 1 and that avgs1k avgs2k 0 The message sequences mit are generated as in 163 Show that avgm1t avgm2t 0 for any pulse shape pt Exercise 1622 Suppose that avgm1t avgm2t 0 Which of the following are true a avgm1t avgm2t avgm1t m2t b avg4m1t 2 avgm2t avg4m1t 2m2t c avgm1tm2t avgm1t avgm2t d avgm2 1t avgm1t2 e avgm2 1tm2 2t avgm2 1t avgm2 2t f Show that even if c holds e need not Other variations of this quadriphase Costas loop can be found in Sections 631 and 632 of Bingham 1988 and in Section 423 of Anderson 1999 1642 Resolution of the Phase Ambiguity The carrierrecovery element for QAM does not have a unique convergent point because the objective function JCQ of 1610 has maxima whenever θ φ ρπ2 This is shown clearly in the multiple convergence points of Figure 168 The four possibilities are also evident from the rotational symmetry of the constellation diagrams such as Figures 161 and 162 There are several ways in which the phase ambiguity can be resolved including 1 the output of the downsampler can be correlated with a known training signal 2 the message source can be differentially encoded so that the information is carried in the successive changes in the symbol values rather than in the symbol values themselves One way to implement the first method is to correlate the real part of the training signal t with both the real s1 and the imaginary s2 portions of the output of the downsampler Whichever correlation has the larger magnitude is selected and its polarity examined To write this concisely let t si represent A Digital Quadrature Amplitude Modulation Radio 375 the correlation of t with si The four possibilities are as follows if t s1 t s2 t s1 0 no change t s1 0 add 180 if t s1 t s2 t s2 0 add 90 t s2 0 add 90 Using differential encoding of the data bypasses the need for resolving the ambiguous angle To see how this might work consider the 2PAM alphabet 1 and reencode the data so that a 1 is transmitted when the current symbol is the same as the previous symbol and a 1 is transmitted whenever it changes Thus the sequence 1 1 1 1 1 1 1 1 1 is differentially encoded starting from the second element as 1 1 1 1 1 1 1 1 The process can be reversed as long as the value of the first bit in this case a 1 is known This strategy can be extended to complexvalued 4QAM by encoding the differences sk sk 1 This is described in Figure 164 of Barry Lee and Messerschmitt 2004 An advantage of differential encoding is that no training sequence is required A disadvantage is that a single error in the transmission can cause two symbol errors in the recovered sequence Exercise 1623 Implement the correlation method to remove the phase ambi guity a Generate a complex 4QAM signal with a phase rotation φ by use of qamcomparem Specify a fixed training sequence b Use the QAM Costas loop qamcostasloopm to estimate φ c Implement the correlation method in order to disambiguate the received sig nal Verify that the disambiguation works with φ 60 85 and 190 Exercise 1624 Design a differential encoding scheme for 4QAM using suc cessive differences in the data Verify that the scheme is insensitive to a 90 rotation 1643 PhaseLocked Loop for 4QAM Section 101 shows how the carrier signal in a PAM transmission is concealed within the received signal Using a squaring operation followed by a bandpass 376 Chapter 16 A Digital Quadrature Amplitude Modulation Radio filter as in Figure 103 on page 197 passes a strong sinusoid at twice the fre quency and twice the phase of the carrier This doublefrequency surrogate can then be used as an input to a phaselocked loop for carrier recovery as in Section 103 In QAM the carrier is better hidden because it is generated as in 161 by combining two different signals modulated by both sin and cos or equiv alently by the real and imaginary parts of a complex modulating wave as in 162 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 fre quency of the underlying carrier and so the fourth power needs to be followed by a narrowbandpass filter centered at about four times the carrier frequency This quadruplefrequency surrogate can then be used as an input to a standard phaselocked loop for carrier recovery The first step is to verify that using the square really is futile With vt defined in 161 it is straightforward though tedious to show that v2t 1 2m2 1t m2 2t m2 1t m2 2t cos4πfct 2φ 2m1tm2t sin4πfct 2φ A bandpass filter with center frequency at 2fc removes the constant DC term and this cannot be used as in PAM to extract the carrier since avgm2 1t m2 2t avgm1tm2t 0 Nothing is left after passing v2t through a narrowbandpass filter The fourth power of vt 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 BPFv4t 1 84m1tm2tm2 2t m2 1t sin8πfct 4φ m4 1t 6m2 1tm2 2t m4 2t cos8πfct 4φ What is amazing about this equation is that the two terms 4m1m2m2 2 m2 1 and m4 1 6m2 1m2 2 m4 2 are identical to the two terms in 1613 Accordingly the former averages to zero while the latter has a nonzero average Thus BPFv4t cos8πfct 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 filter 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 A Digital Quadrature Amplitude Modulation Radio 377 µΣ θk vkTs sin8πf0kTs4θk LPF BPF X4 centered at 4fc Figure 1611 The sampled QAM input vkTs 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 tradeoff between the uncertainty in fc and the desire for a narrow BPF Exercise 1625 Generate a complex 4QAM signal vt with phase shift φ as in qamcomparem Imitate the code in pllpreprocessm 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 1626 What happens on raising vt 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 BPFv4t of the preprocessor is presumed to be a sinusoid that can be applied to a phasetracking element such as the digital phaselocked loop PLL from Section 103 The preprocessor plus PLL are shown in Figure 1611 which is the same as the PLL derived for PAM in Figure 107 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 sufficient 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 fourthpower method of carrier recovery for 4QAM the methods are also applicable to larger constellations such as 16 QAM The literature offers some encouraging comments For instance Anderson 1999 on page 149 states When the modulation is for instance 16QAM instead of QPSK the PLL refer ence signal is not a steady cos4ω0t 4ψ0 and the phase difference signal has other components besides sin4ψ0 4φ0 Nonetheless the synchronizer still works passably well Bingham 1988 on page 173 says This simple method PLL tracking of quadrupled frequency can be used for constel lations with 16 points but it has been generally assumed that the pattern jitter would be intolerable However it can be shown that at least for 16QAM the outer points dominate and the fourthpower signal has a component at 4fc that is usable if a very narrow band PLL is used to refine it Whether the independence from data 378 Chapter 16 A Digital Quadrature Amplitude Modulation Radio decisions and equalizer convergence that this forwardacting method offers outweighs the problems of such a narrowband PLL remains to be seen Exercise 1627 Implement the 4QAM PLL system shown in Figure 1611 Begin with the preprocessor from Exercise 1625 and combine this with a modi fied version of pllconvergem from page 204 Exercise 1628 What changes need to be made to the 4QAM preprocessor of Exercise 1625 and the corresponding PLL of Exercise 1627 in order to operate with a 16QAM constellation 165 Designing QAM Constellations This chapter has focused on 4QAM and occasionally considered other QAM constellations such as the 16QAM configuration in Figure 162 This section shows a few common variations and suggests some of the tradeoffs that occur with different spacing of the points in the constellation As with PAM the clearest indicator of the resilience of a constellation with respect to noise is the distance between points The transmission is less likely to have bits and hence symbols changed when the points are far apart and more likely to encounter errors when the points are close together This means that when greater power is used in the transmission more noise can be tolerated Accordingly it is common to normalize the power and to consider the symbol error rate SER as a function of the signaltonoise ratio SNR Effectively this means that the points in a constellation such as 16QAM of Figure 162 are closer together than in a simpler constellation such as 4QAM It is straightforward to calculate the SER as a function of the SNR via simula tion The routine qamserm specifies a MQAM constellation and then generates N symbols Noise with variance N0 is added and then a comparison is made If the noise causes the symbol to change then an error has occurred This can be plotted for a number of different noise variances The most complicated lines in the routine are those comparing the real and imaginary portions of the data s and the noisy version r to determine whether the noise has caused a symbol error Listing 165 qamserm symbol error rate for QAM in additive noise N010ˆ0 2 3 noi s e var i ances N10000 symbols to simulate M4 symbols in c o n s t e l l a t i o n spamN sqrt M 1 j pamN sqrt M 1 QAM symbols ss sqrt 2 normalize power constunique real s normalized symbol values a l l s e r s zeros size N0 for i 1length N0 loop over SNR nsqrt N0 i 2 randn 1 N j randn 1 N rsn r ecei ved s i g n a lnoi s e 380 Chapter 16 A Digital Quadrature Amplitude Modulation Radio Figure 1613 The V29 constellation has 16 symbols and four different energy levels 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 elec tronics 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 exam ple Figure 1613 shows an irregular constellation called the V29 constellation Anderson 1999 comments on page 97 that the V29 modem standard has worse error performance in AWGN than does square 16QAM but it is easier to synchronize Another consideration in constellation design is the assignment of bit values to the points of the constellation One common goal is to reduce the number of bit changes between adjacent symbols For 4QAM this might map 45 00 135 01 135 11 and 45 10 Mappings from constellation points to symbols that minimize adjacent symbol errors are called Gray codes Exercise 1629 Adapt qamserm to draw the waterfall plot for the V29 con stellation of Figure 1613 Exercise 1630 If different noises are used the waterfall plot may look signif icantly different than Figure 1612 Redraw the SER vs SNR curves for 4 16 64 and 256QAM when the noise is uniform 166 Timing Recovery for QAM When a QAM signal arrives at the receiver it is a complicated analog waveform that must be demodulated and sampled in order to eventually recover the two messages hidden within The timingrecovery element specifies the exact times at which to sample the demodulated signals One approach would be to use two timing parameters τ1 and τ2 operating independently on the two message signals s1 and s2 using any of the methods described in Chapter 12 But the two A Digital Quadrature Amplitude Modulation Radio 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 specifies when to sample both signals The problem is approached by finding performance or objective functions that have maxima or minima at the optimal point ie at the correct sampling instants The performance functions are then used to define 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 flawlessly the upconversions and downconversions are ideal the pulsematched filters are well designed there is no interference and the channel is benign More over 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 filtered by matched filters that correspond to the pulse shape at the transmitter The output of the matched filters is sent into interpolators that extract the two baudspaced sequences When all goes well these can be decoded into the original messages s1 and s2 For PAM signals as in Chapter 12 the baudtiming rate can be found by optimizing the average of the first second or fourth power of the absolute values of the baudspaced 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 offset or equivalently it is a single complexvalued 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τ avgs1p s2pq 1616 for p 1 2 or 4 and q 1 2 1 or 2 Of course other values for p and q might also be reasonable While the error surfaces for these objective functions are difficult to draw exactly they are easy to calculate numerically as is familiar for PAM from clockrecDDcostm on page 259 also see Figures 128 and 1211 The routine qamtimobjm calculates the value of the objective function over a range of dif ferent τs for a given pulse shape unp In this simulation an offset of τ 1 2 is the desired answer Listing 166 qamtimobjm draw error surfaces for baseband signal objective functions m20 n1000 n data points m1 taus unphamming m pulse shape cpconvunp unp matched f i l t e r pssqrt m cpsqrt sum cp ˆ 2 normalize costzeros m1 1 for i 1m1 f o r each o f f s e t s1pamnm 2 1 s2pamnm 2 1 cr eate 4QAM sequence mup1zeros 1 n mup1 1 m ends1 zero pad and upsample A Digital Quadrature Amplitude Modulation Radio 383 As in Sections 123 and 124 the derivative can be approximated numerically τk 1 τk µm3 1kT τk m3 2kT τk m1kT τ δ m1kT τ δ m2kT τ δ m2kT τ δ where µ µδ and δ is small and positive All of the values for the mit for the offsets τk τk δ and τk δ can be interpolated from the oversampled mi Clearly a similar derivation can be made for any of the objective functions ae Which criterion is best Barry Lee and Messerschmitt 2004 on page 747 say that For some signals particularly when the excess bandwidth is low a fourth power nonlin earity is better than the magnitude squared In fact fourthpower timing recovery can even extract timing tones from signals with zero excess bandwidth Simulations for QPSK suggest that fourthpower circuits outperform absolutevalue circuits for signals with less than about 20 excess bandwidth What about aliasing Barry Lee and Messerschmitt continue If timing recovery is done in discretetime aliasing must be considered Any non linearity will increase the bandwidth of the signal In the presence of sampling however the high frequency components due to the nonlinearity can alias back into the bandwidth of the bandpass filter resulting in additional timing jitter Therefore in a discretetime realization a magnitudesquared nonlinearity usually has a considerable advantage over either absolutevalue or fourthpower nonlinearity What about attempting baudtiming recovery on a passband signal prior to full downconversion to baseband Barry Lee and Messerschmitt 2004 consider this on page 750 The same relative merits of squaring absolutevalue and fourthpower techniques apply to passband timing recovery as to baseband In particular absolutevalue and fourth power are usually better than squaring except when aliasing is a problem in discrete time implementations As with baseband signals it is sometimes advantageous to pre filter the signal before squaring Exercise 1631 Use qamtimobjm as a basis to calculate the five objective functions for 4QAM using the SRRC pulse shape with rolloff factors 01 05 and 07 a For each case state whether the objective must be maximized or minimized b Do any of the objective functions have local stationary points that are not globally optimal Recall Figure 128 which shows local minima for PAM c Derive the corresponding adaptive element ie the update equation for τk for one of the objective functions when using the SRRC Which rolloff factor is best Why 384 Chapter 16 A Digital Quadrature Amplitude Modulation Radio Exercise 1632 Mimic clockrecOPm on page 262 to implement the timing recovery algorithm for τk using objective function e a Derive the adaptiveelement 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 1633 State a dispersionbased objective function for timing recovery of QAM analogous to that in Figure 1211 a Plot the value of the objective function against the timing offset τ b Derive the corresponding adaptive element ie the update equation for τk c Implement the adaptive element mimicking clockrecOPm on page 262 167 Baseband Derotation Carrier recovery identifies the phase and frequency differences between the mod ulating sinusoids at the transmitter and the demodulating sinusoids at the receiver Standard approaches such as the PLL or Costas loop of Section 164 operate at passband that is the iteration that identifies the phases and fre quencies operates at the sampling rate of the receiver which is typically higher than the symbol rate As observed in Section 163 a phase offset can be pictured as a rotation of the constellation and a frequency offset 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 ele ments can derotate a QAM constellation These are essentially singleparameter equalizers that operate on the two real data streams by treating the signal and equalizer as complexvalued quantities Bingham 1988 on page 231 motivates the postequalization carrierrecovery process for QAM A complex equalizer can compensate for any demodulating carrier phase but it is easier to deal with frequency offset by using a separate circuit or algorithm that because it deals with only one variable carrier phase can move faster without causing jitter 386 Chapter 16 A Digital Quadrature Amplitude Modulation Radio The x can be rewritten explicitly as a function of θ since x ejθr which is x1 r1 cosθ r2 sinθ x2 r2 cosθ r1 sinθ when expressed in real and imaginary form observe the similarity to Exercise 1610 Accordingly x1 θ r1 sinθ r2 cosθ x2 x2 θ r2 sinθ r1 cosθ x1 Thus JBDθ θ s1 x1x2 s2 x2x1 s1x2 s2x1 leads to the adaptive update for 4QAM θk 1 θk µs1kx2k s2kx1k 1617 which can be compared directly to Figure 166 in Barry Lee and Messerschmitt Implementation of 1617 requires access to the signals s1k and s2k This can be accomplished using a training sequence or more commonly by using a decisiondirected variation that replaces s1k with ˆs1k and s2k with ˆs2k The adaptive derotator element can be examined in operation in qamderotatem where the 4QAM message is rotated by an angle phi After the derotator the x and the hard decisions shat1 and shat2 restore the con stellation to its proper orientation Listing 167 qamderotatem derotate a complexvalued QAM signal N1000 jsqrt 1 symbols time base spamN2 1 j pamN 2 1 s i g n a l s of length N phi 01 angle to r otate rs exp j phi r otati on mu001 theta 0 thetazeros 1 N i n i t i a l i z e v a r i a b l e s for i 1N1 adapt through a l l data xexp j theta i r i xrotated r x1real x x2imagx r e a l and imaginary parts shat1sign x1 shat2sign x2 hard d e c i s i o n s theta i 1 theta i mu shat1 x2shat2 x1 i t e r a t i o n end An alternative objective function based on dispersion minimization considers the average of JDMθ Rerejθ2 γ2 1618 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 4QAM symbols cluster around 1 choosing γ 1 allows JDMθ to be zero when θ φ For other constellations JDMθθφ will on A Digital Quadrature Amplitude Modulation Radio 387 average be smaller than nearby values The associated dispersionminimizing adaptive element is θk 1 θk µRerejθ2 γRerejθkImrejθk 1619 Exercise 1634 Rewrite the system in Figure 1615 in its real implementable form by letting st s1t js2t and ejz cosz j sinz Express xt directly as a function of the realvalued signals s1t and s2t Show that θ φ implies xt st Exercise 1635 Reimplement the qamderotatem routine without using any complex numbers Exercise 1636 Calculate the derivative of JDMθ of 1618 with respect to θ which is used to implement the algorithm 1619 Exercise 1637 Implement the dispersionminimization derotator by mimick ing qamderotatem Exercise 1638 Formulate a DD derotator for use with 16QAM Implement it in imitation of qamderotatem Is the convergence faster or slower than with 4QAM Exercise 1639 Formulate a dispersionminimization derotator for use with 16QAM Exercise 1640 Formulate a derotator for use with 16QAM that uses only the four corner points of the constellation those with the highest SNR 168 Equalization for QAM Intersymbol interference ISI occurs when symbols interact when the waveform of one symbol overlaps and corrupts the waveform of other symbols nearby in time ISI may be caused by overlapping pulse shapes as discussed in Chapter 11 or it may be caused by a nonunity transmission channel physically a result of multipath reflections or frequencyselective dispersion Chapter 13 showed that for PAM the realvalued received symbols can often be passed through a real valued equalizer in order to undo the effects of the channel It is possible to pass both the real and the imaginary parts of a QAM signal through separate real valued equalizers but it is far more convenient to model the equalization portion of a QAM receiver as complexvalued symbols passing through a complexvalued equalizer This section shows that complexvalued equalizers are no more difficult to design and implement than their realvalued counterparts As in Chapter 13 the A Digital Quadrature Amplitude Modulation Radio 389 where indicates complex conjugation The output of the equalizer yk XTkf can be expanded as XTkf XT Rk jXT I kfR jfI XT RkfR XT I kfI jXT I kfR XT RkfI which has complex conjugate XTkf XT RkfR XT I kfI jXT I kfR XT RkfI Note that ekek e2 Rk e2 Ik which can be expanded using 1621 as eRk Reek Redk ReXTkf dRk XT RkfR XT I kfI eIk Imek Imdk ImXTkf dIk XT I kfR XT RkfI Since the training sequence d is independent of the filter f the derivative df 0 and ekek fR e2 Rk e2 Ik fR e2 Rk eRk eRk fR e2 Ik eIk eIk fR 2eRkXRk 2eIkXIk Similarly ekek fI 2eRkXIk 2eIkXRk Therefore the update is fk 1 fk µeRkXRk eIkXIk jeRkXIk eIkXRk which simplifies to fk 1 fk µekXk 1622 Compare this with the real version of trained LMS for PAM in 1327 Except for the notation the present version is written with vectors the only difference is the complex conjugation The complexvalued 4QAM equalizer LMSequalizerQAMm passes a 4QAM signal through an arbitrary complex channel to simulate the occurrence of ISI The equalizer f adapts and with luck converges to a filter that is roughly the inverse of the channel The equalizer can be tested by generating a new set of data filtered through the same channel and then filtered through the equalizer If it is working the doubly filtered signal should be almost equal to the original though it will likely be shifted in time as it passes through the two 390 Chapter 16 A Digital Quadrature Amplitude Modulation Radio filters Observe that in Matlab when the transpose operator is applied to a complexvalued vector the result is the complexconjugated transpose Hence the final line directly implements 1622 Listing 168 LMSequalizerQAMm 4QAM LMS equalizer b0502 j 1 0602 j def i ne complex channel m1000 how many data points spamm2 1 j pamm 2 1 4QAM source of length m rf i l t e r b 1 s output of channel n4 fzeros n 1 i n i t i a l i z e e q u a l i z e r at 0 mu01 del ta 2 s t e p s i z e and delay del ta yzeros n 1 place to s tor e output for in1m i t e r a t e y i r i 1 i n1 f output of e q u a l i z e r es i del ta y i c a l c u l a t e er r or term ffmue r i 1 i n1 update e q u a l i z e r c o e f f i c i e n t s end 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 final converged equalizer if this is close to a pure possibly multisample delay ie 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 031 0019j 066 015j 034 001j 014 003j and the convolution of b and f is 015 007j 005 004j 101 001j 002 001j 006 004j 008 005j which is reasonably close to 0 0 1 0 0 0 The test routine LMSequalizerQAMTestm uses the final converged value f of the equalizer and the definition of the channel b from LMSequalizerQAMm 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 169 searches over a number of different 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 169 LMSequalizerQAMTestm tests final equalizer filter f i n a l e qf t e s t f i n a l f i l t e r f m1000 new data points spamm2 1 j pamm 2 1 new 4QAM source of length m rf i l t e r b 1 s output of channel ytf i l t e r f 1 r use f i n a l f i l t e r f to t e s t decsign real yt j sign imag yt quantization for sh0n i f e q u a l i z e r working one er r sh105sumabs dec sh 1ends 1 endsh end of these delays zero er r or A Digital Quadrature Amplitude Modulation Radio 391 Exercise 1641 Derive a decisiondirected equalizer for 4QAM analogous to the DD equalizer for PAM in Section 134 Implement the DD equalizer starting with LMSequalizerQAMm Find a channel b for which the LMS equalizer provides a correct equalizer while the DD equalizer does not Exercise 1642 Another way of investigating the quality of an equalizer is to plot the frequency responses Use freqz to plot the frequency response of the default channel and of the resulting equalizer How close is their product to a transfer function that has magnitude unity at all frequencies Because the signals are complex it is necessary to plot both positive and negative frequencies The phase spectrum should be approximately a straight line Can you relate the slope of this line to the total delay in the filter Exercise 1643 Show that a complex dispersionminimization equalizer for 4 QAM analogous to the dispersionminimization equalizer for PAM in Section 135 is given by the update fk 1 fk µXkykγ yk2 where yk is defined in 1620 and where γ 1 Implement the equalizer start ing with LMSequalizerQAMm Discuss the advantages and disadvantages of this equalizer in comparison with LMS Exercise 1644 Modify LMSequalizerQAMm to generate a source sequence from the 16QAM alphabet a jb where a and b can be be 1 or 3 For the default channel 0502j 1 0602j find an equalizer that opens the eye a What equalizer length n is needed b What delays delta give zero error in the output of the quantizer c Is this a fundamentally easier or more difficult task than equalizing a 4QAM signal Exercise 1645 Derive and implement a dispersionminimization equalizer for 16QAM using the update in Exercise 1643 Hint the 4QAM algorithm is still OK but γ 1 might scale the constellation improperly 169 Alternative Receiver Architectures for QAM There are many ways to organize a digital receiver This section takes a glance at the QAM literature and shows how the components of the receiver can be shuffled and rearranged in a surprising number of ways Bingham 1988 calls the receiver in Figure 1616 the analog receiver because the filtering downconversion 392 Chapter 16 A Digital Quadrature Amplitude Modulation Radio 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 1617 is the decisiondirected 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 1642 The third of Binghams receiver structures is the nearlyalldigital receiver of Figure 1618 This uses a freerunning sampler and digital interpolation to esti mate the value of the signals at the desired sampling times as is familiar from Chapter 12 There is a freerunning downconversion before the equalizer and postequalization carrier recovery as described in Section 1642 that operates on the hard decisions The equalization element is also decisiondirected Inter estingly the AGC also incorporates feedback from the same signals entering the carrier recovery The final architecture from Bingham is the alldigital receiver of Figure 1619 The initial sampling is accomplished by a freerunning sampler that oper ates at a subNyquist 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 fixed freerunning oscillator followed by a decisiondirected derotation The decisionfeedback equalizer is a finiteimpulseresponse filter that operates in the feedback loop It is adapted using a decisiondirected objective function LPF Timing Recovery Decoder cos2πf0t sin2πf0t Carrier Recovery LPF BPF Figure 1616 Binghams analog receiver for QAM carries out the bulk of the processing in analog circuitry before sampling This is a redrawing of Figure 51 in Bingham 1988 The figure is c1988 John Wiley Sons Inc and is reprinted with permission Timing Recovery Decoder cos2πf0t sin2πf0t DD Carrier Recovery AGC BPF LPF LPF Figure 1617 The second of Binghams QAM radio designs uses a decisiondirected carrier recovery This is a redrawing of Figure 52 in Bingham 1988 The figure is c1988 John Wiley Sons Inc and is reprinted with permission A Digital Quadrature Amplitude Modulation Radio 393 AGC ADC BPF LPF Timing Recovery Carrier Recovery Phase Splitter Magnitude Error Equalizer interpolation filter Rotator Derotator e jθ ej2πfckTs ejθ Figure 1618 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 Figure 53 of Bingham 1988 The figure is c1988 John Wiley Sons Inc and is reprinted with permission AGC ADC BPF Timing Recovery Carrier Recovery Phase Splitter Magnitude Error Allpass Filter Interpolator e jθ e j2πfckTs ejθ Equalizer Figure 1619 Binghams alldigital receiver structure is a redrawing of Figure 54 of Bingham 1988 The receiver samples at the start of the signal chain and carries out all processes in the digital domain The figure is c1988 John Wiley Sons Inc and is reprinted with permission The receiver structures in Figures 1616 to 1619 follow the development of the generic receivers in Figure 122 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 decisionfeedback equalizer could replace a feedforward equalizer the adaptive elements could operate by optimizing a dis persion objective rather than a decisiondirected objective etc The possibilities are staggering A typical digital QAM receiver is presented in Figure 42 of Meyr Moeneclaey and Fechtel 1998 and is shown here in Figure 1620 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 freerunning 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 filter occurs after the interpolation but before the timing element This helps to 394 Chapter 16 A Digital Quadrature Amplitude Modulation Radio Timing Recovery Phase Estimator an mn Frequency Integrator Frequency Integrator Frequency Error Detection Frequency Synthesizer Coarse Frequency Correction Analog Prefilter Interpolator Filter Matched Prefilter Symbol Detection mnTs unTs znTεT rf kTs rf t rt f1Ts ejω0ωt e jθmnTs Figure 1620 This typical digital QAM receiver is adopted from Figure 42 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 figure is c1998 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 1621 shows a generic equalized data demodulator from Treichler Larimore and Harp 1998 The most prominent feature of this design is the controlloop architecture which emphasizes how tightly coupled the various com ponents 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 downmodulates again after the equalizer which is working faster than the symbol rate Two equalizers are shown a feedforward equalizer and a decisionfeedback equalizer The generic blind demodulator for QAM shown in Figure 1622 is also taken from Treichler Larimore and Harp 1998 The control sequencer amalga mates signals from various places in the receiver and uses them to create a more centralized control structure embedding various elements within the loops of oth ers As before the analog AGC uses feedback correction from the freerunning sampler output The quadrature freerunning downconversion is trimmed by the hard decisions and the resampler uses a timingrecovery 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 1623 The design uses a sampler with an adjustable clock rate a passband equalizer with despun error and a postequalization carrier recovery The final architecture of this section is Lee and Messerschmitts typical pass band QAM receiver that begins with an analog bandpass filter and uses a A Digital Quadrature Amplitude Modulation Radio 395 ControlLoop Bus Carrier Recovery Forward Error Correction Timing Recovery Soft Decisions Hard Decisions w FEC Hard Decisions no FEC Power Estimation BPF AGC Equalizer Equalizer Adjustment DFE θ Figure 1621 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 decisiondirected carrier recovery Many of the loops include significant and complicated portions of the receiver such as the feedforward equalizer and the decisionfeedback equalizer Such nesting of adaptive elements is a tricky business since they must must not interfere with each other The figure is c1998 IEEE and is used with permission Control Sequencer Carrier Recovery Timing Recovery Soft Decisions CMA LMS Hard Decisions Power Estimation BPF AGC QDC AD Equalizer Equalizer Adjustment θ Figure 1622 This receiver can switch between two equalizers LMS for faster convergence when there is a training sequence available and CMA dispersion minimization when there is no training Redrawn from Figure 11 in Treichler Larimore and Harp 1998 The figure is c1998 IEEE and is used with permission sampler adjusted by a decisiondirected method as shown in Figure 1624 The phase splitter is followed by a preliminary freerunning downconversion and then downsampled to T2 sampling again with a decisiondirected adjustment The fractionally spaced equalizer has a despun decisiondirected adjustment and the digital downconversion uses a decisiondirected carrier recovery The decision feedback equalizer at the end is also decisiondirected 396 Chapter 16 A Digital Quadrature Amplitude Modulation Radio Timing Recovery Error Computation Sampling Clock PLL AGC AD Equalizer Decoding ejθk ejθk Figure 1623 This QAM receiver simplified from the original Figure 2 in Jablon 1992 uses a passband equalizer before the demodulation and trimming by the PLL The figure is c1992 IEEE and is used with permission Carrier Recovery Timing Recovery BPF Fractionally Spaced Precursor Equalizer Postcursor Equalizer e j2πfckTs Phase Splitter Twice symbolrate sampling Symbolrate sampling Preliminary demodulation Nyquistrate sampling Hard Decisions Figure 1624 This typical passband QAM receiver is redrawn from Figure 521 of Barry Lee and Messerschmitt 2004 The figure is c2004 Kluwer Academic and is used with the kind permission of Springer Science and Business Media Why are there so many receiver architectures Why not figure 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 difficulty arises when an adaptive equalizer is used in conjunction with a decisiondirected carrier recovery loop Baseband adaptive equalizers assume that the input has been demodulated The solution to this difficulty 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 timevarying 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 A Digital Quadrature Amplitude Modulation Radio 397 From page 429 of Gitlin Hayes and Weinstein 1992 At low SNR the designer can of course use the nonlinearPLL carrier recovery scheme but at moderatetohigh SNR levels when data decisions reliably replicate the transmitted data the datadirected loop has become the preferred carrier recovery system These represent only a handful of the many possible architectures for a QAM radio The next section asks you to explore some alternatives 1610 The Q3AM Prototype Receiver 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 Quasi Quixotic QAM receiver Q3AM for short is somewhat different A complete working prototype was coded by a crack team of students at Cornell University in winter of 20021 The routine qpskRxm 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 16QAM As Section 169 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 Q3AM receiver will be asked to handle including r a carrier frequency that may differ from its nominal value r a clock frequency that may differ from its nominal value r phase noise that may vary over time r a timing offset that may vary over time r multipath interference r timevarying multipath gains r wideband additive channel noise r interference from other narrowband signals nearby in frequency These impairments also bedeviled the M6 design challenge The receiver will include many fixes for these impairments 1 a freerunning four times oversampled relative to baud interval received passband signal 2 a mixer with phase adaptation via dual quadriphase Costas loop 1 Many thanks to J M Walsh C E Orlicki A G Pierce J W Smith and S R Leventhal 398 Chapter 16 A Digital Quadrature Amplitude Modulation Radio 3 lowpass filtering for downconversion matched filter and interpolation all pro vided by a matched filter with adjusted timing offset adapted with maximiza tion of the fourth power of downsampled signals in dualloop configuration 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 decisiondirected LMS adap tation during the data ie nontraining portion 6 framesynchronized descrambler and 5 2 linear blockcode decoder 1611 Q3AM Prototype Receiver Users Manual This section outlines the operation and usage of the Q3AM software radio including the specifications for the transmitter and the receiver The full struc ture is diagrammed in Figure 1625 and the m software routines may be found on the website 16111 Transmitter and Impairments Generated in the Received Signal The transmitter and channel portions of the software use a number of parameters as shown in Tables 161 and 162 in order to generate a sampled received signal with the following impairments Descrambling and Decoding Comparison and BER calculation Carrier Recovery Timing Recovery Trained LMS Equalization DecisionDirected Equalization Correlation Oversampled Carrier Synchronized Signal BaudSpaced ClockSynchronized Signal Equalized and Quantized Message Message Recovered Oversampled Output from Analog Front End Message Original Receiver Inputs Bit Error Rate Receiver Output initial equalizer training data Figure 1625 An overview of the receiver simulator and tester A Digital Quadrature Amplitude Modulation Radio 399 Phase Noise The carrier phase noise is modeled as a random walk such that θk1 θk δk 1623 where δk is a white noise whose variance is dictated when running the software See Section 16113 Timing Offset Noise The timing offset noise is modeled in the same manner as the phase noise only with a white noise δ of a different variance which is specified when running the software Carrier Oscillator Frequency and Phase Offset The frequency offset between the transmitter and receiver carrier oscillators is specified as a ratio γoff such that fact 1 γofffc The phase offset can be specified in any region from 0 to 2π Baud Oscillator Frequency and Phase Offset The frequency offset between the transmitter and receiver baud oscillators aka clocks is also specified as a ratio σoff such that Tsact Tsσoff1 σoff The baud oscillator phase offset which is also known as the fixed timing offset may also be specified Multipath Channels The software has the ability to simulate transmission through a fixed multipath channel specified at run time TimeVarying Multipath It is possible to study the receivers ability to track timingvarying multipath by turning on a flag in the software and specifying the speed of time variation for a particular builtin timevarying multipath channel See Section 16113 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 specified by specifying the channel SNR when running the software 16112 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 first block this data enters is the carrierrecovery unit which uses a quadriphase Costas loop The estimates φestk from the adaptive Costas loop are then used to demodulate the signal by multiplication by expj2πfcTsk φestk The lowpass filtering done in the timingrecovery unit by the matched filter completes the demodulation Timing Recovery The oversampled signal is then sent to the baudtimingrecovery unit which interpolates the signal using a pulse shape with nonzero timing offset with the timing offset estimated adaptively matched to the transmitter pulse shape This is slightly different from sincinterpolation because it uses the timeshifted pulse 400 Chapter 16 A Digital Quadrature Amplitude Modulation Radio Table 161 The parameters which must be set in the first structure b passed into the transmitter portion of the software suite See the example in Section 16113 for more details Name Description debugFlag Flag to indicate whether or not to generate plots ph off Phase offset between the transmitter and receiver carrier f off Frequency offset between the transmitter and receiver carrier t off Timing offset between the transmitter and receiver baud SNR Signaltonoise ratio in the channel channel Fixed channel impulse response ignored if TVChan 1 tNoiseVar Variance of noise in the receiver baud timing bfo Frequency offset between the transmitter and receiver baud pNoiseVar Variance of phase noise in receiver and transmitter carrier TVChan 0 use static channel defined by channel parameter 1 use 1 0 0 0 c g cos2πfcαkTs alpha Controls parameter α variation in timevarying channel c Mean value c of the timevarying channel tap g Variation g about mean value of timevarying channel tap Table 162 The parameters which must be specified in the second structure specs when running the transmitter portion of the the software suite See the example in Section 16113 for more details Name Description v Square QAM constellation has 22v points v 1 for QPSK codingF Whether or not to use coding same as for transmitter scrambleF1 Whether or not to generate diagnostic plots when scrambling beta The rolloff factor used in the SRRC matched filter scrambleF2 Whether or not to scramble same as for transmitter OverSamp Oversampling factor usually set to 4 shape to interpolate instead The timing offset is estimated using an adaptive fourthpower maximization scheme The signal is then downsampled to symbol spaced samples Correlation Correlation must be performed to find the segment used to train the equalizer thus this block correlates the signal with the prearranged 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 first using an adaptive trained LMS algorithm and then when the training runs out using the adaptive decisiondirected LMS A Digital Quadrature Amplitude Modulation Radio 401 algorithm Step sizes for this algorithm along with those mentioned above may be specified as inputs to the software Descrambling and Decoding In order to lower the probability of symbol error the data are mapped to binary and coded at the transmitter using a 5 2 linear block code Because coding cor relates the data scrambling with a length21 random sequence is then performed to restore signal whiteness Scrambling is done by exclusiveoring the data with a length21 sequence Descrambling is then performed at the receiver by exclusiveoring with the same sequence The synchronization for the descram bling is aided by the equalizer training data Just as soon as the equalizer training data end the descrambling begins Performance Evaluation After the receiver has finished processing the received signal its soft decisions data at the equalizer output are compared with the original sent symbols in order to determine the meansquared error at the equalizer output It is then assumed that the dispersion around the decisions is due to additive cir cularly 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 predecoding 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 meansquared error a measured predecoder SER and an empirical coded BER are determined If the coded BER is sufficiently 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 errorsbit by the number of bitssymbol ie 2 for 4QAM When there is only a small amount of data running through the system the first method with its MSEbased approximation will be capable of more accurately estimating smaller probabilities of error because the MSE becomes substantial before the SER does 16113 Using the Software The parameters that must be specified when running the software are all listed and explained in Table 163 These parameters must be within a structure that is passed to the software suite as an argument An example run can be found in sampleTestm In this example m and specs were the structures that were used to pass the arguments into the transmitter software b was the structure used to pass parameters into the receiver software t was the SER derived from a Gaussian approximation of the noise z was the measured predecoding SER and c was the measured BER after decoding 402 Chapter 16 A Digital Quadrature Amplitude Modulation Radio Table 163 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 16113 Name Description Costas Mu1 First step size to use in the typeII Costas loop Costas Mu2 Second step size to use in the typeII Costas loop Time mu1 First step size to use in the dual timing recovery Time mu2 Second step size to use in the dual timing recovery EqMu Step size to use with the trained LMS equalizer ddEqMu Step size to use with the decisiondirected equalizer debugFlag Flag that indicates whether or not to generate plots If debugFlag 1 the plots are drawn scrambleF Flag that turns on and off the scrambling of the signal codingFlag Flag that turns on and off the coding of the signal OverSamp 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 1626 can be found in snrTestm 5 10 15 20 10 3 10 2 10 1 10 0 SER as the SNR increases SNR SER Approximate Measured Figure 1626 The plot generated by the example performance study code snrTest 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 PrenticeHall 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 A Digital Quadrature Amplitude Modulation Radio 403 R D Gitlin J F Hayes and S B Weinstein Data Communication Principles Plenum Press 1992 N K Jablon Joint Blind Equalization Carrier Recovery and Timing Recovery for HighOrder QAM Signal Constellations IEEE Transactions on Signal Processing vol 40 no 6 pp 13831398 June 1992 H Meyr M Moeneclaey and S A Fechtel Digital Communication Receivers Synchronization Channel Estimation and Signal Processing Wiley 1998 J G Proakis and M Salehi Communication Systems Engineering 2nd edition PrenticeHall 2002 J R Treichler M R Larimore and J C Harp Practical Blind Demodulators for HighOrder QAM Signals Proceedings of the IEEE vol 86 no 10 pp 19071926 October 1998 B Simulating Noise Noise generally refers to unwanted or undesirable signals that disturb or interfere with the operation of a system There are many sources of noise In electrical systems there may be coupling with the power lines lightning bursts of solar radiation or thermal noise Noise in a transmission system may arise from atmo spheric disturbances from other broadcasts that are not well shielded and from unreliable clock pulses or inexact frequencies used to modulate signals Whatever the physical source there are two very different kinds of noise nar rowband and broadband Narrowband noise consists of a thin slice of frequencies With luck these frequencies will not overlap the frequencies that are crucial to the communication system When they do not overlap it is possible to build fil ters that reject the noise and pass only the signal analogous to the filter designed in Section 723 to remove certain frequencies from the gong waveform When running simulations or examining the behavior of a system in the presence of narrowband noise it is common to model the narrowband noise as a sum of sinusoids Broadband noise contains significant amounts of energy over a large range of frequencies This is problematic because there is no obvious way to separate the parts of the noise that lie in the same frequency regions as the signals from the signals themselves Often stochastic or probabilistic models are used to charac terize the behavior of systems under uncertainty The simpler approach employed here is to model the noise in terms of its spectral content Typically the noise v will also be assumed to be uncorrelated with the signal w in the sense that Rwv of 83 is zero The remainder of this section explores mathematical models of and computer implementations for simulations of several kinds of noise that are common in communications systems The simplest type of broadband noise contains all frequencies in equal amounts By analogy with white light which contains all frequencies of visi ble light this is called white noise Most randomnumber generators by default give approximately white noise For example the following Matlab code uses 414 Appendix B Simulating Noise given time the program is run some frequencies appear slightly larger than oth ers In Figure B1 there is such a spurious peak near 275 Hz and a couple more near 440 Hz Verify that these spurious peaks occur at different frequencies each time the program is run Exercise B1 Use randspecm to investigate the spectrum when different num bers 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 frequencies1 Exercise B2 Matlabs randn function is designed so that the mean is always approximately zero and the variance is approximately unity Consider a signal defined by w a randn b that is the output of randn is scaled and offset What are the mean and variance of w Hint use B1 and B2 What values must a and b have to create a signal that has mean 10 and variance 50 Exercise B3 Another Matlab function to generate random numbers is rand which creates numbers between 0 and 1 Try the code xrand1N05 in randspecm where the 05 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 05 is removed Explain what you see Exercise B4 Create two different white signals wk and vk that are at least N 216 elements long a For each j between 100 and 100 find the crosscorrelation Rwvj between wk and vk b Find the autocorrelations Rwj and Rvj What values 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 filter with a specified passband The output then has a spectrum that coincides with the passband of the filter For example the following program creates such colored noise by passing white noise through a bandpass filter that attenuates all frequencies but those between 100 and 200 Hz Listing B2 randcolorm generating a colored noise spectrum N2ˆ16 how many random numbers Ts0001 nyq05Ts sampling and nyquist r ates s s f N2N2 1 TsN frequency vector 1 Matlab allows control over whether the random numbers are the same each time using the seed option in the calls to the randomnumber generator Details can be found in the help files for rand and randn Simulating Noise 415 a Spectrum of input random numbers 400 200 0 200 400 b Spectrum of output random numbers Frequency in Hz 0 600 400 200 0 800 600 400 200 Magnitude Magnitude Figure B2 A white input signal top is passed through a bandpass filter creating a noisy signal with bandwidth between 100 and 200 Hz xrandn 1 N N random numbers fbe 0 100 110 190 200 nyq nyq def i ne des i r ed f i l t e r damps0 0 1 1 0 0 des i r ed amplitudes f l 70 f i l t e r s i z e bfirpm f l fbe damps design impulse response yf i l t e r b 1 x f i l t e r x with b Plots from a typical run of randcolorm are shown in Figure B2 which illus trates 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 B5 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 filter using firpm Verify its frequency response by using freqz b Generate a white noise and pass it through the filter Plot the spectrum of the input and the spectrum of the output Exercise B6 Create two noisy signals wk and vk that are N 216 elements long The bandwidths of both wk and vk should lie between 100 and 200 Hz as in randcolorm a For each j between 100 and 100 find the crosscorrelation Rwvj between wk and vk b Find the autocorrelations Rwj and Rvj What values 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 filter C Envelope of a Bandpass Signal The envelope of a signal is a curve that smoothly encloses the signal as shown in Figure C1 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 mes sage from the modulated carrier as discussed in Section 51 One simple design includes a diode capacitor and resistor arranged as in Figure C2 The oscillat ing 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 C1 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 filter the capacitor and resistor For example the Matlab code in AMlargem on page 83 extracted the envelope using an absolute value nonlinearity and an LPF and this method is also used in envsigm Listing C1 envsigm envelope of a bandpass signal time 33 Ts110000 sample i n t e r v a l time t 0Ts time l entlength t def i ne time vector f c 1000 ccos 2 pi f c t s i g n a l i s f a s t wave fm10 f r eq f o r slow wave wcos 2 pifm t exp5 t 05 times slow decay xc w with o f f s e t fbe 0 005 01 1 damps1 1 0 0 lowpass f i l t e r design f l 100 bfirpm f l fbe damps impulse response of LPF envxpi 2 f i l t e r b 1 abs x r e c t i f y f o r envelope 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 Envelope of a Bandpass Signal 417 Signal Lower envelope Upper envelope Approximation of envelope using analog circuit Figure C1 The envelope of a signal outlines the extremes in a smooth manner Signal Envelope Figure C2 A circuit that extracts the envelope from a signal π2 in the definition of envx accounts for this factor so that the output rides on crests of the wave The output of envsigm is shown in Figure C3a where the envelope signal envx follows the outline of the narrowbandwidth passband signal x though with a slight delay This delay is caused by the linear filter and can be removed by shifting the envelope curve by the group delay of the filter This is fl2 half the length of the lowpass filter when designed using the firpm command A more formal definition of envelope uses the notion of inphase and quadra ture components of signals to reexpress the original bandpass signal xt as the product of a complex sinusoid and a slowly varying envelope function xt Regtej2πfct C1 The function gt is called the complex envelope of xt and fc is the carrier frequency in Hz To see that this is always possible consider Figure C4 The input xt 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 xct and xst are contained between B to B Modulation by the final two sinusoids returns the baseband signals to a region around fc and adding them together gives exactly the signal xt Thus Figure C4 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 inphase and quadrature components of the signal 420 Appendix C Envelope of a Bandpass Signal xcf i l t e r b 1 2 x cos 2 pi f c t inphase component xsf i l t e r b 1 2 x sin 2 pi f c t quadrature component envxabs xcsqrt1 xs envelope of s i g n a l Exercise C4 For those who have access to the Matlab signalprocessing tool box an even simpler syntax for the complex envelope is envxabshilbertx Can you figure out why the Hilbert transform is useful for calculating the envelope Exercise C5 Find a signal xt for which all the methods of envelope detection fail to provide a convincing envelope Hint try signals that are not narrowband 424 Appendix D Relating the Fourier Transform to the DFT 1 05 0 05 1 4 2 0 2 4 a Switched sinusoid b Raw DFT magnitude c Magnitude spectrum d Zoom into magnitude spectrum Timeseconds 05 04 03 01 02 0 100 50 0 50 100 FrequencyHz 05 04 03 01 02 0 40 20 0 20 40 FrequencyHz 60 40 20 0 0 500 1000 1500 Bin number Figure D1 Spectrum of the switched sinusoid calculated using the DFT a the time waveform b the raw magnitude data c the magnitude spectrum and d zoomed into the magnitude spectrum samples is T 8 s and that the underlying sinusoid of frequency f0 10 Hz is switched on for only the first Td 1 s Listing D1 switchsinm spectrum of a switched sine Td1 pulse width Td2 Td2 N1024 number of data points f 10 frequency of s i ne T8 t o t a l time window tr ezTN f r e z 1T time and f r eq r e s o l u t i o n wzeros 1 N vector f o r f u l l data record wN2Td tr ez 21N2Td2 tr ez sin tr ez 1 Td tr ez 2 pi f dftmagabs f f t w magnitude of spectrum of w spectr ez dftmag N21N dftmag 1 N 2 s s ff r e z N211N 2 frequency vector plot tr ez length w21 length w 2 w pl ot a plot dftmag pl ot b plot s s f spec pl ot c Plots of the key variables are shown in Figure D1 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 final plot shows a zoom into the lowfrequency region In this case the time resolution is t TN 00078 s and the frequency resolution is f 1T 0125 Hz The largest allowable f0 without aliasing is N2T 64 Hz Exercise D1 Rerun the preceding program with T16 Td2 and f5 Com ment on the location and the width of the two spectral lines Can you find particular values so that the peaks are extremely narrow Can you relate the locations of these narrow peaks to D3 Power Spectral Density 427 where yT t ytΠtT and xT t xtΠtT are truncated versions of yt and xt 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 Hf2 for each frequency f F The ZTransform This appendix presents background material that is useful when designing equal izers 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 Ztransform the discretetime counterpart of the sdomain Laplace transform can be used to represent a linear system such as a channel model or a filter 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 openeye criterion provides a way of determining how good the design is F1 ZTransforms 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 mathemati cally and this section uses the Ztransform which is closely related to a discrete version of the Fourier transform Define the variable z to represent a forward time shift of one sample interval Thus zukT uk 1T The inverse is the backward time shift z1ukT uk 1T These are most commonly written without explicit reference to the sampling rate as zuk uk 1 and z1uk uk 1 For example the FIR filter with input uk and output yk uk 06uk 1 091uk 2 can be rewritten in terms of the timedelay operator z as yk 1 06z1 091z2uk 430 Appendix F The ZTransform can be represented in transferfunction form by taking the Ztransform of both sides of the equation applying F2 and using linearity Thus Y z Zyk Zuk buk 1 Zuk Zbuk 1 Uz bz1Uz 1 bz1Uz which can be solved algebraically for Hz Y z Uz 1 bz1 z b z F4 Hz is called the transfer function of the filter F3 There are two types of singularities that a zdomain transfer function may have Poles are those values of z that make the magnitude of the transfer function infinite The transfer function in F4 has a pole at z 0 Zeros are those values of z that make the magnitude of the frequency response equal to zero The transfer function in F4 has one zero at z b There are always exactly as many poles as there are zeros in a transfer function though some may occur at infinite values of z For example the transfer function z a1 has one finite valued zero at z a and a pole at z A zdomain discretetime system transfer function is called minimum phase maximum phase if it is causal and all of its singularities are located inside outside the unit circle If some singularities are inside and others outside the unit circle the transfer function is mixed phase If it is causal and all of the poles of the transfer function are strictly inside the unit circle ie if all the poles have magnitudes less than unity then the system is stable and a bounded input always leads to a bounded output For example the FIR difference equation yk uk 06uk 1 091uk 2 has the transfer function Hz Y z Uz 1 06z1 091z2 1 07z11 13z1 z 07z 13 z2 This is mixed phase and stable with zeros at z 07 and 13 and two poles at z 0 It can also be useful to represent IIR filters analogously For example Section 722 shows that the general form of an IIR filter is yk a0yk 1 a1yk 2 anyk n 1 b0xk b1xk 1 bmxk m This can be rewritten more concisely as 1 a0z1 a1z2 anznY z 1 b0z1 b1z2 bmzmUz The ZTransform 431 and rearranged to give the transfer function Hz Y z Uz 1 b0z1 b1z2 bmzm 1 a0z1 a1z2 anzn zm b0zm1 b1zm2 bm zn a0zn1 a1zn2 an F5 An interesting and sometimes useful feature of the Ztransform is the relation ship between the asymptotic value of the sequence in time and a limit of the transfer function FinalValue Theorem for Ztransforms If Xz converges for z 1 and all poles of z 1Xz are inside the unit circle then lim k xk lim z1z 1Xz F6 Exercise F1 Use the definition of the Ztransform to show that the transform is linear that is show that Zaxk buk aXz bUz Exercise F2 Find the zdomain transfer function of the system defined by yk b1uk b2uk 1 a What are the poles of the transfer function b What are the zeros c Find limk yk d For what values of b1 and b2 is the system stable e For what values of b1 and b2 is the system minimum phase f For what values of b1 and b2 is the system maximum phase Exercise F3 Find the zdomain transfer function of the system defined by yk ayk 1 buk 1 a What are the poles of the transfer function b What are the zeros c Find limk yk d For what values of a and b is the system stable e For what values of a and b is the system minimum phase f For what values of a and b is the system maximum phase Exercise F4 Find the zdomain transfer function of the filter defined by yk yk 1 2uk 2 µuk 1 a What are the poles of the transfer function b What are the zeros c Find limk yk d Is this system stable 432 Appendix F The ZTransform F2 Sketching the Frequency Response from the ZTransform A complex number α a jb can be drawn in the complex plane as a vector from the origin to the point a b Figure F1 is a graphical illustration of the difference between two complex numbers β α which is equal to the vector drawn from α to β The magnitude is the length of this vector and the angle is measured counterclockwise from the horizontal drawn to the right of α to the direction of β α as shown As with Fourier transforms the discretetime transfer function in the zdomain can be used to describe the gain and phase that a sinusoidal input of frequency ω in radianssecond will experience when passing through the system With transfer function Hz the frequency response can be calculated by evaluating the magnitude of the complex number Hz at all points on the unit circle that is at all z ejωT T has units of secondssample For example consider the transfer function Hz z a At z ej0T 1 zero frequency Hz 1 a As the frequency increases as ω increases the test point z ejωT moves along the unit circle think of this as the β in Figure F1 The value of the frequency response at the test point HejωT is the difference between this β and the zero of Hz at z a which corresponds to α in Figure F1 Suppose that 0 a 1 Then the distance from the test point to the zero is smallest when z 1 and increases continuously as the test point moves around the circle reaching a maximum at ωT π radians Thus the frequency response is highpass The phase goes from 0 to 180 as ωT goes from 0 to π On the other hand if 1 a 0 then the system is lowpass More generally consider any polynomial transfer function aNzN aN1zN1 a2z2 a1z a0 Im ImβImα Re β α α β α β α ReβReα Figure F1 Graphical calculation of the difference between two complex numbers The ZTransform 433 DC or zero frequency Frequency of test points given in radians z2 z1 180o π radians Nyquist sampling rate a3 b3 b1 b2 a2 a1 Zeros Figure F2 Suppose a transfer function has three zeros At any frequency test point specified in radians around the unit circle the magnitude of the transfer function is the product of the distances from the test point to the zeros This can be factored into a product of N possibly complex roots Hz gΠN i1z γi F7 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 F2 where a transfer function has three zeros Two test points are shown at frequencies corresponding to approximately 15 and 80 The magnitude at the first test point is equal to the product of the lengths a1 a2 and a3 while the magnitude at the second is b1b2b3 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 filter Exercise F5 Consider the transfer function z az 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 complexz plane The resulting frequencyresponse magnitude will be relatively flat 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 frequencyresponse magnitude will become more less pronounced This is true irrespective of whether the ring of transfer function zeros is inside or outside the unit circle Of course the phase curves will be different in the two cases Exercise F6 Sketch the frequency response of Hz z a when a 2 Sketch the frequency response of Hz z a when a 2 Exercise F7 Sketch the frequency responses of The ZTransform 435 F3 Measuring Intersymbol Interference The ideas of frequency response and difference equations can be used to inter pret and analyze properties of the transmission system When all aspects of the system operate well quantizing the received signal to the nearest element of the symbol alphabet recovers the transmitted symbol This requires among other things that there is no significant multipath interference This section uses the graphical tool of the eye diagram to give a measure of the severity of the inter symbol interference In Section 113 the eye diagram was introduced as a way to visualize the intersymbol interference caused by various pulse shapes Here the eye diagram is used to help visualize the effects of intersymbol interference caused by multipath channels such as 132 For example consider a binary 1 source sk and a threetap FIR channel model that produces the received signal rk b0sk b1sk 1 b2sk 2 This is shown in Figure F3 where the received signal is quantized using the sign operator in order to produce the binary sequence yk which provides an estimate of the source Depending on the values of the bi this estimate may but might not accurately reflect the source Suppose b1 1 and b0 b2 0 Then rk sk 1 and the output of the decision device is as desired a replica of a delayed version of the source ie yk signsk 1 sk 1 Like the eye diagrams of Chapter 9 which are open whenever the intersymbol interference admits perfect reconstruction of the source message the eye is said to be open If b0 05 b1 1 and b2 0 the system is rk 05sk sk 1 and there are four possibilities sk sk 1 1 1 1 1 1 1 or 1 1 for which rk is 15 05 05 and 15 respectively In each case signrk sk 1 The eye is still open Now consider b0 04 b1 1 and b2 02 The eight possibilities for sk sk 1 sk 2 in rk 04sk sk 1 02sk 2 are 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 and 1 1 1 The resulting choices for rk are 12 16 08 04 04 08 16 and 12 respectively with the corresponding sk 1 of 1 1 1 1 1 1 1 and 1 For all of the possibilities yk signrk sk 1 b0 b1z1 b2z2 sign Decision device Reconstructed source estimate Channel Received signal Source y r s Figure F3 Channel and binary decision device 438 Appendix F The ZTransform 01 10 01 have an open eye Hint use 2srand05 to generate the noise Exercise F14 Modify openclosedm so that the input uses the source alphabet 1 3 Are any of the channels in Problem F12 open eye Is the channel b 01 01 10 01 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 F15 The sampled impulse response from symbol values to the out put of the downsampler in the receiver depends on the baud timing of the downsampler For example let ht be the impulse response from symbol values mkT to downsampler output ykT The sampled impulse response sequence is httkT δ for integers k and symbol period T where δ is the selected baud timing offset Consider the nonzero impulse response values for two different choices for δ httkT δ1 004 100 052 032 018 httkT δ2 001 094 050 026 006 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 openeye Clearly justify your answer b With δ δ2 and a binary source alphabet 1 is the system from the source symbols to the downsampler output openeye Clearly justify your answer c Consider filtering the downsampler output with an equalizer with transfer function Fz z γz to produce soft decisions yk Thus the discrete time impulse response from the symbols mk to the soft decisions yk 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 fourelement source alphabet 1 3 can the system from the source sym bols to the equalizer output be made openeye by selecting γ 06 Explain F4 Analysis of Loop Structures The Ztransform can also be used to understand the behavior of linearized loop structures such as the PLL and the dualloop variations This section begins by studying the stability and tracking properties of the system in Figure 1022 on page 224 which is the linearization of the general structure in Figure 1020 The finalvalue theorem F6 shows that for certain choices of the transfer function 440 Appendix F The ZTransform and so Φz αzz 12 In this case Ez αzAz z 1z 1Az 2µBz and the finalvalue theorem shows that lim k ek lim z1 z 1 z Ez lim z1 αAz z 1Az 2µBz αA1 2µB1 as long as B1 0 and the roots of F9 are strictly inside the unit circle If A1 0 limk ek is nonzero and decreases with larger µ If A1 0 limk ek is zero and θk converges to the ramp φk This means that the loop can also asymptotically track frequency offsets in the carrier Changing µ shifts the closedloop poles in F9 This impacts both the stabil ity of the roots of z and the decay rate of the transient response as θk locks onto and tracks φk Poles closer to the origin of the zplane correspond to faster decay of the transient repsonse Poles closer to the origin of the zplane than to z 1 tend to deemphasize the lowpass nature of the Gz thereby weaken ing the suppression of any highfrequency disturbances from the input Thus the location of the closedloop poles compromises between improved removal of broadband noises and a faster decay of the transient error The choice of Gz which includes a pole at z 1 ie an integrator results in a PLL with typeII 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 typeI polynomial i 1 in input αki with k the time index with zero error asymptotically and a typeII polynomial αk2 with asymptotically constant and finite offset Exercise F16 Suppose that a loop such as Figure 1020 has Gz bz a a What is the corresponding z of F9 b Does this loop track phase offsets Does it track frequency offsets c For what value of µ does z become unstable d Find a value of µ for which the roots of z are complexvalued What does this imply about the convergence of the loop e Describe the behavior of the loop when a 1 Exercise F17 Suppose that a loop such as Figure 1020 has Gz bz cz 1 a What is the corresponding z of F9 b Does this loop track phase offsets Does it track frequency offsets c For what value of µ does z become unstable d Find a value of µ for which the roots of z are complexvalued What does this imply about the convergence of the loop The ZTransform 441 Exercise F18 Suppose that a loop such as Figure 1020 has Gz bz 12z 1 µ a What is the corresponding z of F9 b Does this loop track phase offsets Does it track frequency offsets c For what value of µ does z become unstable Exercise F19 The general loop in Figure 1020 is simulated in pllgeneralm a Implement the filter Gz from Exercise F16 and verify that it behaves as predicted b Implement the filter Gz from Exercise F17 and verify that it behaves as predicted c Implement the filter Gz from Exercise F19 and verify that it behaves as predicted H The B3IG Transmitter In Chapter 9 the Basic Black Box Impairment Generator of Figure 922 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 B3IG The B3IG is implemented in Matlab as the routine BigTransmitterm and it allows straightforward modeling of any or all of the possible impairments discussed throughout Software Receiver Design including carrierfrequency offset baudtiming offsets and frequencyselective and timevarying 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 B3IG is more than a transmitter it includes the communication channel and receiver RF front end as well An overview of the B3IG is shown in Figure H1 The B3IG architecture expands on the simplified 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 Transmitter Channel Between Base Station and User n Sampled IF Receiver for User n Received Digital Signal Message for User 1 Message for User 2 Message for User K Figure H1 The B3IG 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 Appendix H The B3IG Transmitter Figure H2 A base station transmitting to several mobile users within a single cell Users within the cell may use a timedelay protocol whereby each user is assigned a sequential time slot while adjacent cells operate using nearby frequencies Assumption that the receiver employs a sampled intermediatefrequency archi tecture Section 62 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 B3IG transmitter generates a received signal that has been brought down to a lower intermediate frequency IF and then sampled at some specified 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 B3IG 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 Fig ure H2 Thus there are many users in the same geographical region all wishing to transmit and receive simultaneously How is a given receiver able to sepa rate 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 time division multiple access TDMA frequencydivision multiple access FDMA and codedivision multiple access CDMA Within a single cell the transmitter implements multiple users that send mes sages 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 B3IG TDMA is shown in Figure H3 This may be contrasted with the FDMA situation where users each employ their own frequency range as was discussed in Figure 23 on page 22 Typically adjacent cells transmit on different frequencies though frequencies may be reused in cells that are sufficiently 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 The B3IG Transmitter 453 User K User K User 1 User 2 User 1 Preamble Np Characters in Preamble Ns Characters per User Slot 4Ns KNp Symbols per Frame Preamble Figure H3 The timedivision multiple access TDMA frame structure used in the B3IG The indicated sizes are valid for the 8bit ASCII encoding interference from adjacent cells The B3IG makes it easy to study the effects of this kind of interference In codedivision 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 B3IG does not currently implement a CDMA protocol Adding a CDMA component to the receiver would make a great course project H1 Constructing the Received Signal The B3IG transmitter ie the base station simulates K simultaneous users using TDMA Each receiver ie each mobile device in Figure H2 retains and decodes only its intended portion of the signal For singleuser operation K 1 Each of the three blocks in Figure H1 is itself built from several components that are familiar from previous chapters The system that generates the ana log received signal ie the actual transmitter and channel is shown in block diagram form in Figure H4 This is of course the marginally magical M6 trans mitter from Chapter 15 When the signal arrives at the front end of the receiver it is transformed into a sampled IF signal as in Figure H5 The original message in Figure H4 is a character string of English text Each character is mapped into a sequence of 4PAM symbols The mappings may be made using the Matlab function letters2pamm which converts each letter into an 8bit binary string and hence to four 4PAM symbols as in Example 81 Alternatively the mappings may be made with the more terse text2binm TDMA user multiplexing Character tobinary conversion Pulse shape P f Text message Baseband signal st Transmitted passband signal Analog received signal Adjacent users Broadband noise Modulation including phase noise Channel Bits Symbols si Scaling 1 Trigger iTt εt Figure H4 The signalflow diagram of the B3IG transmitter closely follows that of the M6 transmitter of Figure 151 on page 343 The B3IG Transmitter 455 The channel may be near ideal ie a unit gain multisymbol delay or it may have significant intersymbol interference In addition it can be timevarying and the B3IG code allows two ways to introduce time variation The first permits specification 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 randomwalk process can be specified 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 B3IG transmitter and they are assumed to be unknown at the receiver The achieved intermediate frequency is required to be within some user specified 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 intermediatefrequency signal presented to the receiver sampler may also vary The front end of the sampled IF receiver as shown in Figure H5 consists of a lownoise amplifier a preselect filter an AGC a mixer for downconversion to IF and the sampler The preselect filter partially attenuates adjacent FDM user bands The automatic gain control is presumed locked and fixed over each transmission and outputs a signal whose average power is unity The freerunning 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 frontend analog downconverter lowpass filter to frequencies between zero and IF H2 Matlab Code for the Notorious B3IG H21 Function Call To generate the received signal the B3IG transmitter is called by r sBigTransmitterm 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 analogRFrelated parameters and 456 Appendix H The B3IG Transmitter chanParams contains the channel parameters There are two output arguments r is the received sampled signal and s is the 4PAM symbols which were trans mitted Thus the length of s is approximately equal to the length of r times the effective oversampling factor H22 The Input Parameters In order to control all these features of the B3IG various parameters are needed An overview of these parameters is given in Figure H6 and more details are as follows m A characterstring matrix with dimensions equal to the number of users by the message length containing the ASCII messages to be transmitted If there is only a single user this is a single string row vector Description Symbol Matlab variable message m number of characters per user per frame Ns frameParamsuserDataLength character string of preamble text frameParamspreamble channel coefficients at start of transmission c c 1 chanParamsc1 channel coefficients at end of transmission 2 chanParamsc2 variance of timevarying channel enable or disable channel coding frameParamschanCodingFlag 7bit or 8bit ASCII representation frameParamsbitEncodingFlag chanParamsrandomWalkVariance SNR SNR chanParamsSNR power of adjacent interferer 1 chanParamsadjacentUser1Power carrier frequency of adjacent interferer 1 chanParamsadjacentUser1f if channel of adjacent interferer 1 chanParamsadjacentUser1Chan power of adjacent interferer 2 chanParamsadjacentUser2Power carrier frequency of adjacent interferer 2 chanParamsadjacentUser2f if channel of adjacent interferer 2 chanParamsadjacentUser2Chan frequency of narrowband interferer chanParamsNBIfreq power of narrowband interferer chanParamsNBIPower sampler frequency fs rfParamsf s nominal symbol period Tt rfParamsT t error of transmitter symbol period rfParamsT t err assigned intermediate frequency f IF rfParamsf if error transmitter intermediate frequency rfParamsf if err variance of phase noise rfParamsphaseNoiseVariance SRRC filter length rfParamsSRRCLength SRRC pulseshape rolloff factor β rfParamsSRRCrolloff Figure H6 B3IG parameters passed via the stuctures frameParams rfParams and chanParams The B3IG Transmitter 457 frameParamsuserDataLength The number of text characters per user per frame which together with frameParamspreamble effectively determines the length of a frame See Figure H3 frameParamspreamble A character string ie a row vector containing the preamble text which is presumed known at all receivers frameParamschanCodingFlag This parameter can be set to either 0 or 1 If set to 0 the transmitter sends uncoded bits If set to 1 the transmitter encodes the data using the binary block 52 channel code described in Section 1461 frameParamsbitEncodingFlag This parameter can be set to either 0 or 1 and controls how the transmitter translates text into bits If set to 0 the transmitter uses an 8bit representation of the ASCII code and employs letters2pamm If set to 1 the transmitter uses the 7bit representation of the ASCII code and employs text2binm See Examples 81 and 82 for details chanParamsc1 The impulse response of the timevarying channel at the start of the transmission is specified as a row vector chanParamsc2 The impulse response of the timevarying channel at the end of the transmission is also a row vector The actual channel varies linearly over the course of the transmission from the impulse response in chanParamsc1 to that in chanParamsc2 Hence if chanParamsc1 chanParamsc2 and chanParamsrandomWalkVariance 0 the channel will be time invariant chanParamsrandomWalkVariance In addition to being able to control the evo lution of the channel using chanParamsc1 and chanParamsc2 this param eter specifies a random variation in the channel taps using a random walk The parameter controls the variance of the randomwalk process chanParamsSNR The signaltonoise ratio of the signal Note that it controls only the amount of AWGN present in the band of the transmitted signal chanParamsadjacentUser1Power The relative power of the interference caused by the first adjacent user specified in dB Thus when set to 0 dB the interferer will have the same power as the transmitter When set to Inf the interferer is effectively disabled chanParamsadjacentUser1f if The carrier frequency of the first interfering user after conversion to IF chanParamsadjacentUser1Chan The timeinvariant channel impulse response of the first interfering user chanParamsadjacentUser2Power The relative power of the second interfering user specified in dB chanParamsadjacentUser2f if The carrier frequency of the second interfering user after conversion to IF chanParamsadjacentUser2Chan The timeinvariant channel impulse response of the second interfering user chanParamsNBIfreq The frequency of a narrowband interferer after conversion to IF chanParamsNBIPower The relative power of the narrowband interferer speci fied in dB 458 Appendix H The B3IG Transmitter rfParamsf s The sampler frequency rfParamsT t The nominal ie expected symbol period rfParamsT t err The percentage error in the transmitters symbol period which is presumed unknown at the receiver rfParamsf if The assigned intermediate carrier frequency or frequencies rfParamsf if err The percentage error in the transmitters local oscillator which is presumed unknown at the receiver rfParamsphaseNoiseVariance The variance of the additive noise used to model phase noise in the transmitter rfParamsSRRCLength The length of the squareroot raised cosine filter rfParamsSRRCrolloff The rolloff factor of the squareroot raised cosine filter H23 Overview of the BigTransmitterm Code While the B3IG transmitter is a bit more sophisticated than the simple commu nications systems of Chapter 9 it still consists of the same basic operations This section provides a highlevel outline of the code in BigTransmitterm which can be compared with idsysm of Chapter 9 Peeking inside the B3IG transmitter code you will find many familiar operations In addition acquainting yourself with the inner workings of code will help prepare you for the receiver design challenges that await The commented sections in BigTransmitterm point to the code that implements the following operations Parse message convert to bits perform coding if requested insert preamble and generate 4PAM sequence Create adjacent user signals Add in main transmission narrowband interference adjacent users and AWGN Calculate the transmitters slightly inaccurate sample rate and IF Upsample signal perform pulseshaping Generate phase noise process Mix signal to IF while incorporating phase noise Pass signal through channel timeinvariant case Pass signal through channel timevarying case Perform downsampling and normalization ie AGC Exercise H1 Figure H7 shows a typical received signal and its spectrum as generated by B3IG The desired message is centered at 10 MHz and has an absolute bandwidth of 1 MHz As seen in the figure there is an interfering adjacent user centered at baseband with a 1 MHz absolute bandwidth Assume that the desired users signal was transmitted at a frequency of fRF 300 MHz and that the local oscillator shown in Figure H5 operates at fLO 90 MHz Assume that the preselect and IF filters are ideal bandpass filters from 250 to 350 MHz and 200 to 260 MHz respectively Complete the transmitter script in BigEx2m to generate a received signal identical to Figure H7 Note that The B3IG Transmitter 459 0 0004 0008 0012 5 0 5 a Seconds Amplitude 2 1 0 1 2 0 2 4 6 8 b Frequency x107 Magnitude x104 Figure H7 a received signal rl and b its magnitude spectrum Rf three parameters have been left incomplete as indicated by the question marks in BigEx2m 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 H7 Plot the spectrum of the signal you generate Exercise H2 The script in BigEx3m generates an ideal received signal much like idsysm from Chapter 9 This time however the transmitter sends signals for two users using TDMA where frameParamsuserDataLength 5 Mimic the receiver code in BigIdealm to accurately decode the signal for each user Write your receiver code so that it stores the message for the first user in a variable called decoded1 and the message for the second user in a variable called decoded2 H3 Notes on Debugging and Signal Measurement In experimenting with the B3IG transmitter you may find that it will be very useful to look closely at intermediate signals the are inside the transmitter func tion This can be accomplished in a variety of ways Some possibilities are listed here r Add more output arguments to BigTransmitterm so that the variables are available in the Matlab workspace r Use the debugging capabilities of Matlab including breakpoints step exe cution etc r Add plotting commands within the transmitter code Index 5 2 block code 330 333 334 6 4 block code 337 7 3 block code 336 16QAM 361 4PAM 5 30 153 202 205 208 212 223 232 258 293 326 342 4QAM 360 6PAM 307 adaptive components 191 adaptive derotation 386 adaptive element 5556 65 114 Costas phase tracking 208 CV clock recovery 256 DD equalization 288 DD for phase tracking 212 DMA equalization 291 LMS equalization 285 LMS for AGC 123 output power 261 PLL for phase tracking 203 SD for phase tracking 198 simple AGC 123 testing 355 Aeneid 314 AGC 55 120128 166 175 aliasing 28 51 52 99 102 alphabet 4 35 152 211 291 323 AM large carrier 81 419 suppressed carrier 84 419 analog vs digital 11 28 30 121 Anderson J B 39 377 380 402 angle formulas 405 automatic gain control see AGC averaging 122124 199 256 261 285 442450 averaging and LPF 442 bandlimited 18 101 418 bandpass filter see BPF bandwidth 8 18 85 101 102 155 230 414 bandwidth vs data rate 319 bandwidth vs SNR 320 Barry J R 383 396 402 baseband 9 247 251 271 285 Baum Frank 310 Bello P A 79 B3IG transmitter 187190 215 265 354 451459 binary arithmetic 329 binary to text 154 Bing B 356 Bingham J A C 356 377 392393 402 bit error rate 36 bit error vs symbol error 310 bits definition 307 bits to letters 4 153 bits to text 4 153 blind equalization 289 290 block codes 314 BPF 22 24 46 60 63 76 141 151 377 phase shift 196 197 203 Buracchini E 356 Burrus C S 151 capacity see channel capacity carrier frequency 17 20 22 recovery 9 33 192221 367 recovery tuning 351 Carroll Lewis 310 CD encoding 339 CDMA 22 cell phones 17 center spike initialization 292 Cervantes M 314 chain rule 410 channel 5 11 62 164 179 221 237 260 266 270 272 channel capacity 37 318323 CIRC encoder 339 clock recovery 33 251269 decisiondirected 256 output power 261 tuning 351 460 Index 461 cluster variance 174 251 254 256 code division multiplexing see CDMA codeword 333 coding 4 37 303340 block 314 328 channel 328 efficiency 324 instantaneous 324 majority rules 328 prefix 324 source 323327 339 variable length 325 colored noise 414 complex equalization 282 complexvalued modulation see modulation component architecture 15 compression mp3 327 uuencode 327 zip 327 computers and meaning 310 constellation diagram 174 379 convolution 23 70 72 131 142 156 158 275 408 correlation 152 157160 172 178 245 374 426 correlation vs convolution 160 Costas loop PAM 206 QAM 367374 Costas J P 225 Couch L W III 39 data rate 8 102 data rate vs bandwidth 319 DD see decisiondirected decision 35 174 directed equalization 288 directed phase tracking 211 hard 35 soft 36 176 decoder 328 delay spread 270 272 δ function 65 discrete 67 sifting property 66 131 spectrum 67 demodulation see modulation demodulation via sampling 103 dependence of English text 311 derotation 385 design methodology 345 destructive interference 339 dice 307 difference equation 65 430 differential encoding 375 digital radio 1 14 342 discrete frequencies 132 dispersion minimization 290 386 distortionless 238 DMA see dispersion minimization Don Quixote 314 Doppler effect 25 64 downconversion 25 via sampling 103 downsampling 51 109 161 173 185 dual PLLs 218 duality 23 407 dynamic range 121 efficiency 324 electromagnetic transmission 16 encoder 328 333 encoding a CD 339 energy 18 409 425 English dependency 311 frequency of letters 311 random 312 entropy 315318 324 envelope 81 416420 envelope detector 416 equalization 27 34 56 270302 387391 blind 289 290 complex 282 dispersion minimization 290 fractionally spaced 283 initialization 289 292 353 tuning 352 error measures 35 error surface 118 125 200 207 213 259 261 263 errors in transmission 308 Eulers formulas 404 exclusive OR 329 eye diagram 173 181 185 231237 241 250 435 fading 10 64 127 175 FDM 22 25 29 60 FFT 18 42 131 133141 422424 frequency estimation 194 of a sinusoid 136 phase estimation 195 vs DFT 424 filter design 76 77 130 141 146 filters 23 46 62 141 275 final value theorem 117 408 410 431 firpm see Matlab firpm fixes overview 191 flat fading 175 Fourier transform 18 41 131 405408 462 Index meaning of 422 vs DFT 421 fractionally spaced equalization 283 frame 4 Franks L E 225 frequency 16 carrier 20 content 19 20 40 discrete 132 division multiplexing see FDM domain 23 40 72 132 140 421 intermediate 29 93 130 192 measuring 18 of letters in English 311 offset 85 88 179 184 266 radio 9 resolution 140 response 23 65 74 133 432 scale 408 selectivity 27 shift 407 synchronization 85 tracking 216 218 translation 9 17 20 21 24 54 8097 103 192 freqz see Matlab freqz gain of a linear system 426 Galois fields 339 generator matrix 328 Gitlin R D 397 403 gong analysis 139 149 gradient 34 gradient descent 114 Gray code 154 361 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 highside injection 93 highpass filter see HPF Hilbert transform 407 420 hill climbing 115 HPF 24 46 141 Huffman code 37 324 human hearing 102 ideal channel 5 receiver 4 5 13 58 165 transmitter 165 important message 167 impulse response 23 65 70 74 131 141 142 270 impulse sampling 100 independence of English text 311 independent events 306 information 37 303 and complexity 308 and uncertainty 305 axioms 306 definitions 304 in a letter 308 in digits of π 308 vs meaning 310 initialization center spike 292 instantaneous code 324 325 instructor to the viii integration layer 341 interference 10 59 intermediate frequency 29 93 192 342 interpolation 11 110 257 262 intersymbol interference see ISI ISI 34 229230 241 247 266 270 273 387 435 iteration 447 Jablon N K 394 403 Jayant N 356 jitter visualizing 231 Johnson C R Jr 129 302 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 filters 59 65 70 130151 linear vs nonlinear codes 335 LMS see least mean squares local minima 118 logical AND 329 lookfor see Matlab lookfor lowside injection 93 lowpass filter see LPF LPF 23 141 171 LPF and averaging 442 M6 receiver 342356 majority rules 328 332 marker 162 172 178 344 454 matched filter 242249 mathematical prerequisites vi Index 463 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 filter 47 48 70 142 237 firpm viii 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 filter 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 maximumlength pseudonoise 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 modulation 9 17 20 complexvalued 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 inband 10 60 narrowband 61 270 412 outofband 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 openeye 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 v performance function 114 263 293 381 464 Index Costas loop 207 CV timing recovery 256 DD carrier recovery 211 DD equalization 289 DMA equalization 291 for QAM 381383 LMS equalization 284 LMS for AGC 122 LS equalization 276 output power 261 PLL carrier recovery 203 SD carrier recovery 198 simple AGC 123 period offset 185 periodicity 49 101 406 phase ambiguity 374 maximum 430 minimum 430 offset 86 87 179 183 192 shift 404 splitter 366 synchronization 86 phase tracking analysis 206 Costas loop 206 367 376 decisiondirected 210 dual algorithm 218 phaselocked loop 55 202 375 squared difference 197 PLL see phase tracking Porat B 57 power 18 76 84 120 242 409 413 425 and correlation 426 power spectral density 242 245 409 425427 PPM 362 prefix code 324 325 Proakis J G 39 379 403 probability use of vi properties of discretetime signals 132 pulse amplitude modulation see PAM pulse shaping 3032 155 160 161 172 194 226249 251 273 pulse train 68 99 pulsematched filtering 160 172 pulsephase modulation see PPM QAM 357403 Q3AM receiver 397 398 QPSK 361 377 383 quadrature phase shift keying see QPSK quantization 36 161 211 Qureshi S U H 302 radio AM 17 21 80 digital 14 342 FM 17 21 raised cosine pulse 239 240 248 406 rand see Matlab random random numbers 413 seed 414 receive filtering 160 226249 251 receiver M6 342 Q3AM 397 398 design 345 ideal 165 smart 16 testing 350 355 reconstruction 110 rectangular pulse 8 31 72 111 238 248 406 redundancy 37 304 308315 Reed J H 356 ReedSolomon codes 339 replicas 23 24 100 103 resample see Matlab resample reshape see Matlab reshape resolution in time vs frequency 140 423 Robbins T xiv sampling 11 28 33 49 98129 251 for downconversion 103 sampling theorem 28 Schafer R W 57 Schwarzs inequality 243 245 410 scrambling 162 seed for random numbers 414 Sethares W A 302 Shannon C 3 37 305 308 312 340 sifting property of impulse 410 signal 40 41 131 Signal Processing First vi signaltonoise ratio see SNR simple average 442 simulating noise 412415 sinc function 8 31 72 111 138 236 238 248 406 sine wave 21 spectrum 69 singlesideband modulation 81 sketching frequency response 432 SNR 60 76 244 SNR vs bandwidth 320 soft decision 174 softwaredefined radio 2 14 342 356 source coding 37 source recovery error 251 256 261 276 285 source vs channel coding 304 Index 465 sources of error 348 spectrum 41 132 135 δ function 67 magnitude 18 23 of a pulse sequence 227 phase 18 sine wave 69 squarelaw mixing 88 squareroot raised cosine see SRRC squared error 35 squaring 52 195 207 SRRC 113 236 240 248 344 406 steepest descent 114 Steiglitz K 151 step 1 to build a radio 1 2 basic components 15 3 idealized receiver 58 4 adaptive components 191 5 putting it all together 341 step function 407 stepsize 116 123 126 199 204 209 220 257 262 287 290 292 350 353 371 447 Stonick V 57 stopband 141 Stremler F G 39 symbol error vs bit error 310 symbol recovery error 35 271 symmetry 132 405 407 synchronization 7 3334 carrier 9 192 frame 7 34 154 161 177 344 353 454 frequency 85 phase 86 unnecessary 84 syndrome table 330 336 338 system 40 131 tappeddelay line 275 Taylor F J 56 TDM 22 temperature in Wisconsin average 443 testing the receiver 350 text to binary 154 text to bits 4 153 Through the Looking Glass 310 time 250 delay operator 428 division multiplexing see TDM domain 23 40 132 140 421 resolution 140 shift 408 410 428 timing 33 jitter 7 offset 6 179 185 recovery 251269 380384 Toeplitz matrix 276 278 tracking 124 tradeoffs 350 training sequence 273 284 344 454 transfer function 74 133 430 transition band 142 probabilities 313 transmitter B3IG 187 451 design 343 ideal 165 transpose 411 Treichler J R 394 403 trial and error 350 trigonometric identities 404 tuning the receiver 350 TV 17 uniform sampling 50 unit circle 430 unit delay 429 variable length code 323 variance 413 Vergil 314 Verne Jules 314 vestigal sideband modulation 81 wavelength 16 what if 3 167 178 whatever 344 Widrow B 129 wiener 168 Wizard of Oz 310 325 327 zip compression 327 Ztransforms 409 428434