INTRODUCTION TO DIGITAL SIGNAL PROCESSING INTRODUCTION TO DIGITAL SIGNAL PROCESSING RomanKuc Department of Electrical Engineering Yate University SSP BS Publications 4-4-309, Giriraj Lane, Sultan Bazar, Hyderabad -500 095 -AP. Phone: 040-23445677,23445688 e-mail: ci.: .• [email protected] www.bspublications.net Reprint 2008 All rights reserved. No part of this book or parts thereof may be reproduced, stored in a retrieval system or I transmitted in any language or by any means, , electronic, mechanical, photocopying, recording , or otherwise without the prior written permission of the publishers. Copyright © 1982, by Author "This Reprint of Introduction to Digital Signal Processing, originally published by McGraw Hill, Inc. 1982, is published by agreement with the author". Published by : =S_S _P BS Publications 4-4-309, Giriraj Lane, Sultan Bazar, Hyderabad -500 095 -A. P. Phone: 040-23445677,23445688 Fax No: 040-23445611 e-mail: [email protected] www.bspublications.net Printed at Adithya Art Printers Ilyderabad ISBN 81-7800-168-3 PREFACE This book is intended to be used in the first course covering digital signal processing and filter design, typically offered at the senior or first-year graduate level in electrical engineering. The course is also appropriate for a graduate course in departments other than electrical engineering, such as geophysics and mechanical engineering, in which the analysis of discrete"time data is performed. It is assumed that the student has had a course covering Fourier series and LaPlace transforms on the level of the first linear circuits or control systems course. This text also includes projects that require students to write computer programs to accomplish signal processing projects. The student should bO'familiar with some programming language 'such as FORTRAN, BASIC, PASCAL, or C. This book approaches digital signal processing and filter design in a novel way, by presenting the relevant theory and then having the student apply it by implementing signal processing routines on a computer. This mixture of theory and application has worked successfully for the past six years' in teaching this course at Yale University. With this approach, the students receive a deeper and intuitive understanding of the theory, its applications and its limitations. The text can accommodate a wide variety of courses. Currently, the course on digital filters at the undergraduate level are taught primarily as a theory course, with homework problems and exams to determine the course grade. This book can be used directly in this type of course. However, the course becomes much more interesting and enjoyable when students apply the theory to write programs to perform signal processing tasks. Each chapter describes programming techniques that implement the theory and includes projects that illustrate different applicatio'!l:>. Digital filter routines are written from the very beginning of the course, immediately after the time-domain description of discrete-time systems is presented in Chapter 2. The programs can be written on any computer from personal to mainframe, requiring only a standard terminal for displaying the results in graphical form and a printer for v vi PREFACE generating the hard copy. The programs to be written by the student are not difficult. Each routine performs only one primitive task in the signal processing procedure. For example, the discrete Fourier transform subprogram can be accomplished in only nine lines of code. But once the student has given sufficient thought to the problem to write these nine lines, the magic associated with this procedure disappears, being replaced by understanding. To minimize the programming effort of the student, the routines are used as building blocks in later projects. Constructing more sophisticated programs from these simpler building blocks aids the student in conceptualizing projects later in the course. By the end of the course, the student has a package of signal processing programs that can be used for a variety of applications. The graphic outputs for the projects are displayed on the terminal and on a printer, being generated by programs provided in the Appendix. These plots, although having crude resolution, are adequate for illustrating the ideas and also have the advantage of not requiring special plotting hardware. Students having higher-resolution terminal graphic capabilities have readily written their own graphic routines using the programs in the Appendix as guides. This text differs from others in the area of digital filters and signal processing in the important respect that processing signals and designing filters on a digital computer, using simple programs composed by the students, are an integral part of the course. For this reason, more realistic problems can be assigned and discussed than would be in a course without computers, for which these problems would be mathematically untenable or at least tedious. The organization of the material presented in the text allows the student to start writing meaningful filtering programs from the beginning of the course. Projects included in the text illustrate both digital signal processing and digital filter design concepts. The book is organized in the following manner. Chapter 1 defines the basic components of a digital filter and provides motivation by describing several common applications of digital filters and signal processing. The material in Chapters 2 through 5 covers the fundamentals of time, frequency, and z-plane analysis. If some of this material has been introduced in previous courses, the respective chapters can be treated as a review. Several common structures that are employed to implement digital filters are described in Chapter 6. The synthesis of digital filters to meet a desired specification is presented in Chapters 7 through 9. To compare the different filter design procedures, the projects are structured to allow each student to be assigned a personal specification to be satisfied. In Chapter 7, the digital filter design is accom plished by interactively and intuitively placing poles and zeros in the z plane. This procedure serves three purposes. First, it develops an understanding of the interaction of the singularities in generating a filter magnitude response or system spectrum. Second, it provides an appreciation for the conventional filter design procedures presented in Chapters 8 and 9. Finally, this intuitive procedure indicates how to correct the locations of the poles and zeros PREFACE vii generated by conventional design procedures. The computed positions of these singularities are slightlY, but significantly, displaced from the desired positions by the round-off errors that are always present in any computation. These round-off effects become obvious in the filter design projects. The conventional procedures for designing infinite-impulse response (IIR) digital filters are described in Chapter 8, and those for finite-impulse response (FIR) digital filters in Chapter 9. Two advanced topics are covered in Chapters 10 and 11. Chapter 10 describes the effects of finite precision encountered in practical hardware implementation of digital filters. Some elementary results from probability theory are presented to describe noise effects. Chapter 11 provides an overview of inverse filters. This topic was chosen because it includes and integrates many of the concepts introduced in the previous chapters to illustrate an important practical application. In addition to the Problems, a set of Computer Projects is included, the programs for which should be written by the student. Instructions for program development are included as an integral part of the text and Project description. The ability to manipulate sequences by a computer program is essential for appreciating the concepts involved for signal processing, which is important when the studen~ IS faced with novel problems in his or her own application. Projects in the analysis part of the book illustrate the practical applica tions of digital interpolation procedures and the simulation of a frequency-shift keying (FSK) digital communication channel. In the filter synthesis part of the book, the Projects include designing digital filters to satisfy a practical specification. In the chapters describing finite-precision effects and the inverse filter, the Projects illustrate programming techniques for simulating physical hardware and systems. One main benefit of the Projects is to relate the analytic results to those produced by the computer. At times, the analysis is simple and should then be used to predict and verify the computer results. At other times, the analytic procedure is very complicated mathematically, in which case the computer results should be obtained first to indicate what type of results should be expected. In this latter case, the computer results indicate the direction in which the analysis should proceed. For example, the computer results may indicate that a complex-valued operation in a particular analytic step results in a real-valued sequence. This knowledge may serve to drive the analytic steps. In practice, it is often found that computer simulations demonstrate an effect that can be proven analytically. An insider's knowledge of the signal processing algorithms is attained by having the students write their own programs. This knowledge then allow~ the student comfortably to make the intellectual move to more sophisticated signal processing and filter design programs and packages, such as those distributed by the IEEE or SIG or offered by many vendors. This text has the flexibility of being used in a wide variety of digital signal viii PREFACE processing courses at the undergraduate and graduate levels. For a conven tional undergraduate theory course in digital filters, the first nine chapters of this book supply the necessary topics in discrete-time signals and systems. In some universities, such a theory course is followed by a digital filter design laboratory. The Projects in this book can be used as the exercises in such a course. At the graduate level, a faster pace allows topics from all chapters to be covered. Courses stressing the signal processing aspects should emphasize the analytic methods and the discrete Fourier transform and de-emphasize IIR filter design and quantization effects, while courses stressing filter implementa tion should stress the latter and reduce the emphasis on the former. To allow adequate space for this treatment of this material, the analytic techniques have been restricted to those that are absolutely necessary for understanding the filter synthesis and signal processing procedures. Topics that are normally covered in a senior/first-year graduate course on digital signal processing, but that are not considered in this text, include the solution of the difference equations with the one-sided z-transform, the numerical methods for optimizing digital filter designs, and the area of multidimensional signal processing. These topics are better treated in a second course in which the students have the familiarity of the material contained in this book. The author is indebted to the students at Yale University who have taken this course and provided many useful comments regarding the topics and the exercises in this book. Among these are Ata Arjomand, Billur Barshan, Leo Costello. An;lOld Englander, Kannan Parthasarathy, Rob Roy, and David Starer. The author would like to thank the following reviewers for their comments and-suggestions, J. I. Aunon, Purdue University; Edward Delp, Purdue University; Simon Haykin; McMaster University; M. Kaveh, Univers ity of Minnesota; and Paul Prucnal, Columbia University. The author hopes that the instructors teaching digital signal processing as a combination of theory and computer exercises, as described in this text, have an enjoyable learning experience. This learning comes about from the questions posed by the students, who inevitably find some novel approach or interpretation to filter design on the computer. This has certainly been the case every time the author has taught this course. Roman Kuc CONTENTS Preface v 1 Introduction 1 1-1 What is a Digital Filter? 1 1-2 Anatomy of a Digital Filter 3 1-3 Frequency Domain Description of Signals and Systems 5 1-4 Some Typical Applications of Digital Filters 7 1-5 Replacing Analog Filters with Digital Filters 12 1-6 Overview of the Course 13 1-7 Description of the Computer Projects 17 1-8 Summary 18 2 Discrete-time Description of Signals and Systems 20 2-1 Introduction 20 2-2 Discrete-Time Sequences 20 2-3 Superposition Principle for Linear Systems 26 2-4 Unit-sample Response Sequence 27 2-5 Time-Invariant Systems 30 2-6 Stability Criterion for Discrete-time Systems 38 2-7 Causality Criterion for Discrete-time systems 40 2-8 Linear Constant-Coefficient Difference Equations 41 2-9 Suggested Programming Style 44 2-10 Writing a Digital Filter Program 45 2-11 Summary 55 3 Fourier Transform of Discrete-time Signals 65 3-1 Introduction 65 3-2 Definition of the Fourier Transform 65 3-3 Important Properties of the Fourier Transform 69 ix