Foundations of Digital Signal Processing: theory, algorithms and hardware design Patrick Gaydecki The Institution of Electrical Engineers
Foundations of Digital Signal Processing: theory, algorithms
and hardware design Patrick Gaydecki
The Institution of Electrical Engineers
Contents
Preface xvii
About the programs xxi
1 Definitions and applications of digital signal processing 1
1.1 What is digital signal processing? 1 1.2 For whom this book is written and its content 5 1.3 What is DSP used for? 6 1.4 Application areas 9 1.5 A little history 10
2 A linear Systems toolbox 15 2.1 Introduction 15 2.2 Linear Systems 15
2.2.1 First ideas 15 2.2.2 Continuous and discrete signals: some definitions 18 2.2.3 The impulse function and step function 21 2.2.4 Shifting and weighting 22 2.2.5 Properties and characteristics of linear Systems 24 2.2.6 Examples of non-linear Systems 27 2.2.7 The complexities of linear Systems 29
2.3 Complex numbers 29 2.4 Calculus 33
2.4.1 Differentiation 34 2.4.2 Integration 36 2.4.3 Calculus and linear Systems 39
2.5 Introduction to differential equations 40 2.5.1 Solving linear first order differential equations using
an integrating factor 41
viii Contents
2.5.2 Solving linear second order homogeneous differential equations with constant coefficients 44
2.5.3 Solving linear second order mhomogeneous differential equations with constant coefficients 46
2.6 Calculus and digital signal processing 48 2.6.1 The difference and the running sum of a discrete
signal 48 2.6.2 Difference equations in digital signal processing 49
2.7 Operational amplifiers 50 2.8 Final remarks: using linear Systems theory 52
An introduction to high-level Computer programming using Delphi 53 3.1 Introduction 53 3.2 Why Delphi? 54 3.3 General program structure 55
3.3.1 Comment fields 56 3.4 A blank Delphi program 56 3.5 Adding some functionality 60
3.5.1 Experimenting with an object's properties 62 3.5.2 The Delphi help System 63
3.6 A program to demonstrate some key Delphi capabilities 63 3.6.1 Proj ect planning 64 3.6.2 Designing the user interface 65 3.6.3 Major code modules ofa Delphi application 67 3.6.4 Global and local variables, arrays and constants 68 3.6.5 Types 70 3.6.6 Simple input and Output 71 3.6.7 Radio groups, control and loops structures 72 3.6.8 Conditional Statements 74 3.6.9 Functions, procedures and Information exchange 75 3.6.10 Additional units and forms 77 3.6.11 Creating, saving and opening text files; file dialog
boxes 78 3.6.12 Creating and saving user-defined file types 81 3.6.13 Creating and saving records 82 3.6.14 Block writing and reading data 83 3.6.15 Efficient creation and storage oftext information 84 3.6.16 Bit Operations 84 3.6.17 Pointers 85 3.6.18 Dynamic arrays 86 3.6.19 Timer functions and program multitasking 87 3.6.20 Dynamic object creation (instantiation) 88 3.6.21 Error checking 89
Contents ix
3.6.22 Graphics and plotting 90 3.6.23 Other graphic features: animation and responding
to the mouse 94 3.7 Advanced features of Delphi: writing components,
the media player, DLLS and Windows API 95 3.7.1 Custom components: a short introduction 95 3.7.2 The Delphi media player 96 3.7.3 Dynamically linked libraries 96 3.7.4 The Windows API 97
3.8 Final remarks: programming and DSP 99
Analysis of simple electrical Systems using complex impedance, differential and difference equations 117 4.1 Introduction 117 4.2 Complex impedance analysis 118
4.2.1 Analysis of a first order low-pass RC filter 120 4.2.2 A two-stage buffered first order low-pass filter 122 4.2.3 A non-buffered, two-stage first order filter 123 4.2.4 A runed LCR band pass filter 125 4.2.5 Software for complex impedance analysis 127
4.3 Differential equations in the analysis of circuits 129 4.3.1 Differential equation of a first order RC filter 130 4.3.2 Fourier transform of the .KC impulse response 133 4.3.3 Differential equation of a second order LCR filter 134 4.3.4 A cautionary note conceming a system's differential
equation 141 4.4 Difference equations in the Simulation of circuits 144
4.4.1 The usefulness of difference equations 148 4.4.2 Cautionary notes when using difference equations 149
4.5 Final remarks: complex impedance, differential and difference equations in DSP 150
Introduction to convolution and correlation 153 5.1 Introduction 153 5.2 Using impulse function to represent discrete Signals 155 5.3 Description of convolution 15 6
5.3.1 Using linear superposition 156 5.3.2 Using timereversal of the impulse response 158 5.3.3 Fourier interpretation of convolution 160 5.3.4 Simple filtering using convolution 161 5.3.5 Efficient convolution algorithms 164
5.4 Auto-correlation and cross-correlation 166 5.4.1 Defmitions 166
x Contents
5.4.2 Cross-correlation, matched filters and signal-to-noise ratio enhancement 168
5.4.3 Temporal smearing and pseudo-random bit sequences 170
5.5 Final remarks: convolution and the Fourier domain 172
Fourier analysis 6.1 6.2
6.3 6.4
6.5
173 Introduction 173 The continuous trigonometric Fourier series for periodic signals 175 6.2.1 Magnitude and phase of the Fourier coefficients 178 Data representation and graphing 180 The continuous trigonometric Fourier series for aperiodic signals 181 Observations on the continuous Fourier series 183 6.5.1 Magnitude, phase and position in space 183 6.5.2 Discontinuities and infinite series 184 6.5.3 How to understand the continuous Fourier series 184 6.5.4 Synthesising digital waveforms using Fourier series 186 6.5.5 The continuous Fourier series and the continuous
Fourier transform 187 6.6 Exponential representation of the Fourier series 188 6.7 The continuous Fourier transform 191 6.8 Discrete Fourier analysis 198
6.8.1 Confüsing terminology 198 6.8.2 The Shannon sampling theorem and spectral
resolution 199 6.8.3 The discrete Fourier transform in
trigonometric form 200 6.8.4 Exponential representation: the complex DFT and
IDFT 207 6.8.5 Practical considerations of the complex transform 211
6.9 Introduction to the fast Fourier transform 211 6.9.1 A fast Fourier transform algorithm in place 213
6.10 Final remarks: from theory to implementation 214
Discrete Fourier properties and processing 217 7.1 Introduction 217 7.2 Discrete frequencies and spectral leakage 219 7.3 Side lobes and the use of window functions 219
7.3.1 Pitfalls associated with window functions 225 7.4 Representation of spectral data 225
7.4.1 Real, imaginary, positive and negative frequencies 225
Contents xi
7.4.2 Linear, logarithmic (dB) and power representations of spectral magnitude 226
7.4.3 Logarithmic representation of the frequency axis 228 7.5 Considerations of phase 229
7.5.1 Phase trends and phase wrap-around 230 7.5.2 Phase advancement and the representation of signal
values in the past 234 7.5.3 Phase errors due to polar flip and small signals 236
7.6 Key properties of the discrete Fourier transform 238 7.7 Common signal Operations processing using the discrete
Fourier transform 241 7.7.1 Filtering 241 7.7.2 Spectral and time domain interpolation 242 7.7.3 Fourier domain-based convolution 244 7.7.4 Long duration signal processing using Fourier 250
7.8 Final remarks: other properties and processing techniques associated with the DFT 252
Introduction to Laplace space and the Laplace transform 253 8.1 Introduction 253 8.2 Conceptual frameworkof the Laplace transform 253
8.2.1 Laplace transforms ofelementary functions 255 8.2.2 Laplace transforms and the Solution of differential
equations 258 8.3 A more detailed look at Laplace space 259
8.3.1 The poles and zeros of the Laplace transform 261 8.3.2 The Software of Laplace.exe 263 8.3.3 Transfer functions, electrical circuits and networks 267
8.4 Stability, passive and active Systems and cascade design 271 8.4.1 Low-pass Butterworth filter design 271 8.4.2 High-pass Butterworth filter design 274 8.4.3 Cascade design strategies 275
8.5 Final remarks: Laplace in relation to DSP 276
An introduction to z-space, the z-transform and digital filter design 277 9.1 Introduction 277 9.2 The z-transform: definitions and properties 277
9.2.1 The z-transform and its relationship to the Laplace transform 277
9.2.2 The z-transform as a power series and its role as a delay Operator 281
9.3 Digital filters, diagrams and the z-transfer function 282 9.3.1 Digital filter processing blocks 282
Contents
9.3.2 Details of difference equations and the z-transfer function 283
9.3.3 The poles and zeros of digital filters 286 9.3.4 Factored forms of the transfer function 288
9.4 HR filter design using pole-zero placement: the program ztransfer.exe 290 9.4.1 Simple design strategies 290 9.4.2 Standard filters using biquad cascading 294
9.5 FIR and HR filters: merits and disadvantages 296 9.6 Final remarks: the z-transform in relation to FIR
and HR filters 298
Signal sampling, analog to digital and digital to analog conversion 299 10.1 Introduction 299 10.2 The process of sampling 299
10.2.1 Importance of the aliased spectra 303 10.2.2 Anti-aliasing design 304
10.3 Signal digitisation 305 10.3.1 Basic principles of analog to digital conversion 306 10.3.2 Intrinsic ADC sources of error 307 10.3.3 Extrinsic ADC sources of error: conversion times and
input voltage stability 308 10.4 Principles of analog to digital conversion 310
10.4.1 Successive approximation ADC 310 10.4.2 Flash ADC 311 10.4.3 Sigma-delta ADC 312
10.5 Principles of digital to analog conversion 318 10.5.1 R-2R ladder DAC 318 10.5.2 Reconstruction filters 319
10.6 ADCs and DACs in system 320 10.6.1 Memory mapped data transfer 320 10.6.2 The synchronous serial interface 321
10.7 Final remarks: dynamic ränge of ADCs and DACs 323
The design and implementation of flnite impulse response filters 325 11.1 Introduction 325 11.2 The window method 326 11.3 Phase linearity 331 11.4 The frequency sampling method 334 11.5 Software for arbitrary FIR design: Signal Wizard 336
11.5.1 Using the off-line processing facility of Signal Wizard 338
11.5.2 Cascade FIR filters and audio noise attenuation 341
Contents xiii
11.5.3 Arbitrary frequency response design 342 11.5.4 Linear-phase analog equivalents using FIR methods 344 11.5.5 Phase change filters 346
11.6 Inverse filtering and signal reconstruction 348 11.7 Final remarks: FIR design and implementation algonthms 351
The design and implementation of infinite impuise response filters 355 12.1 Introduction 355 12.2 The bilinear z-transform: defmitions 356 12.3 The BZT and second order passive Systems 363 12.4 Digital Butterworth and Chebyshev HR filters 370
12.4.1 The Butterworth low-pass filter in detail 371 12.4.2 The Chebyshev low-pass filter in detail 374 12.4.3 Frequency transformations 375
12.5 Biquad algorithm design strategies 377 12.6 Pole-zero placement revisited 378 12.7 FIR expression of HR responses 380 12.8 Observations on HR and FIR filters 3 81
12.8.1 Comparisons of efficiency 381 12.8.2 Word length sensitivity 382 12.8.3 Phase 382
12.9 Final remarks: the classes of digital filter 383
Rudiments of adaptive filters 385 13.1 Introduction 385 13.2 Brief theory of adaptive FIR filters 386 13.3 The least mean square adaptive FIR algorithm 389 13.4 Use of the adaptive filter in system modelling 390 13.5 Delayed (single) input adaptive LMS filters for noise
removal 394 13.6 The true (dual input) adaptive LMS filter 397 13.7 Observations on real-time applications of adaptive filters 400 13.8 Final remarks on adaptive filters 401
The design and programming of real-time DSP Systems 403 Part 1: The Motorola DSP56309 processor - architecture and language 14.1 Introduction 403 14.2 The Motorola DSP56309 404
14.2.1 Memory 405 14.2.2 Communications 407 14.2.3 The data arithmetic and logic unit 407 14.2.4 Processor ports 407
Contents
14.2.5 Register control of peripheral Systems 407 14.2.6 Pipelining and parallelism 408 14.2.7 DSP56309 modes of Operation 408
14.3 DSP563xx assembly language programming 408 14.3.1 The anthmetic and logic unit and data representation 409 14.3.2 Single Statement language syntax 410 14.3.3 Addressing modes 411 14.3.4 The DSP563xx language Instruction set and parallel
Operations 412 14.3.5 Program development 414 14.3.6 Simple program example: a Square wave oscillator 414 14.3.7 DSP56309 interrupts 416
14.4 Final remarks: the DSP56309 417
The design and programming of real-time DSP Systems 419 Part 2: Hardware and alogrithms 15.1 Introduction 419 15.2 Reset and clock system 419
15.2.1 Configuring the PLL 421 15.3 Communication system 422 15.4 External memory System 423
15.4.1 Setting wait states and setting the address attribute register 424
15.4.2 Writing to the flash memory 425 15.5 The audio codec System 427 15.6 Hints on circuit layout 430 15.7 Real-time DSP algorithms 431
15.7.1 Implementing FIR Filters in DSP563xx assembly language 432
15.7.2 Implementing HR Alters in DSP563xx assembly language 435
15.7.3 Implementing true adaptive FIR filters in DSP563xx assembly language 437
15.8 Final remarks: real-time system design 439
Concluding remarks 441
Appendix: Summary of the theory and algorithmic development of the fast Fourier transform 445 A. 1 Introduction 445 A.2 Important algebraic notations 445 A.3 The re-composition equations 447 A.4 The FFT butterfly 447 A.5 Re-ordering the input data 448