Digital Filter Design

Similar documents
Chapter 7 Filter Design Techniques. Filter Design Techniques

Infinite Impulse Response (IIR) Filter. Ikhwannul Kholis, ST., MT. Universitas 17 Agustus 1945 Jakarta

8: IIR Filter Transformations

NH 67, Karur Trichy Highways, Puliyur C.F, Karur District DEPARTMENT OF INFORMATION TECHNOLOGY DIGITAL SIGNAL PROCESSING UNIT 3

IIR Filter Design Chapter Intended Learning Outcomes: (i) Ability to design analog Butterworth filters

ECE503: Digital Filter Design Lecture 9

LECTURER NOTE SMJE3163 DSP

DIGITAL FILTERS. !! Finite Impulse Response (FIR) !! Infinite Impulse Response (IIR) !! Background. !! Matlab functions AGC DSP AGC DSP

Digital Processing of Continuous-Time Signals

EEO 401 Digital Signal Processing Prof. Mark Fowler

Digital Processing of

ECE 203 LAB 2 PRACTICAL FILTER DESIGN & IMPLEMENTATION

4. Design of Discrete-Time Filters

NOVEMBER 13, 1996 EE 4773/6773: LECTURE NO. 37 PAGE 1 of 5

Analog Lowpass Filter Specifications

3 Analog filters. 3.1 Analog filter characteristics

ELEC-C5230 Digitaalisen signaalinkäsittelyn perusteet

EELE 4310: Digital Signal Processing (DSP)

Digital Signal Processing

Design IIR Band-Reject Filters

EEM478-DSPHARDWARE. WEEK12:FIR & IIR Filter Design

1 PeZ: Introduction. 1.1 Controls for PeZ using pezdemo. Lab 15b: FIR Filter Design and PeZ: The z, n, and O! Domains

Discretization of Continuous Controllers

Continuous-Time Analog Filters

Kerwin, W.J. Passive Signal Processing The Electrical Engineering Handbook Ed. Richard C. Dorf Boca Raton: CRC Press LLC, 2000

Team proposals are due tomorrow at 6PM Homework 4 is due next thur. Proposal presentations are next mon in 1311EECS.

ECE438 - Laboratory 7a: Digital Filter Design (Week 1) By Prof. Charles Bouman and Prof. Mireille Boutin Fall 2015

Rahman Jamal, et. al.. "Filters." Copyright 2000 CRC Press LLC. <

(Refer Slide Time: 02:00-04:20) (Refer Slide Time: 04:27 09:06)

(i) Understanding of the characteristics of linear-phase finite impulse response (FIR) filters

CHAPTER 8 ANALOG FILTERS

Design of infinite impulse response (IIR) bandpass filter structure using particle swarm optimization

(i) Understanding of the characteristics of linear-phase finite impulse response (FIR) filters

4/14/15 8:58 PM C:\Users\Harrn...\tlh2polebutter10rad see.rn 1 of 1

ELEC3104: Digital Signal Processing Session 1, 2013

Filter Approximation Concepts

Design of FIR Filters

GEORGIA INSTITUTE OF TECHNOLOGY. SCHOOL of ELECTRICAL and COMPUTER ENGINEERING. ECE 2026 Summer 2018 Lab #8: Filter Design of FIR Filters

Digital Filters IIR (& Their Corresponding Analog Filters) 4 April 2017 ELEC 3004: Systems 1. Week Date Lecture Title

Poles and Zeros of H(s), Analog Computers and Active Filters

UNIT-II MYcsvtu Notes agk

Classic Filters. Figure 1 Butterworth Filter. Chebyshev

Filters and Tuned Amplifiers

Copyright S. K. Mitra

Brief Introduction to Signals & Systems. Phani Chavali

Design IIR Filters Using Cascaded Biquads

Multirate Digital Signal Processing

Signals and Systems Lecture 6: Fourier Applications

SMS045 - DSP Systems in Practice. Lab 1 - Filter Design and Evaluation in MATLAB Due date: Thursday Nov 13, 2003

SECTION 7: FREQUENCY DOMAIN ANALYSIS. MAE 3401 Modeling and Simulation

Octave Functions for Filters. Young Won Lim 2/19/18

DSP Laboratory (EELE 4110) Lab#10 Finite Impulse Response (FIR) Filters

Filters. Phani Chavali

ECSE-4760 Computer Applications Laboratory DIGITAL FILTER DESIGN

EE 470 Signals and Systems

Massachusetts Institute of Technology Department of Electrical Engineering & Computer Science 6.341: Discrete-Time Signal Processing Fall 2005

Lab S-9: Interference Removal from Electro-Cardiogram (ECG) Signals

Design of IIR Digital Filters with Flat Passband and Equiripple Stopband Responses

UNIT II IIR FILTER DESIGN

Part B. Simple Digital Filters. 1. Simple FIR Digital Filters


George Mason University Signals and Systems I Spring 2016

EE 311 February 13 and 15, 2019 Lecture 10

Transfer function: a mathematical description of network response characteristics.

Review of Filter Types

Active Filter Design Techniques

Dorf, R.C., Wan, Z. Transfer Functions of Filters The Electrical Engineering Handbook Ed. Richard C. Dorf Boca Raton: CRC Press LLC, 2000

Subtractive Synthesis. Describing a Filter. Filters. CMPT 468: Subtractive Synthesis

Digital Filters IIR (& Their Corresponding Analog Filters) Week Date Lecture Title

EELE503. Modern filter design. Filter Design - Introduction

ijdsp Workshop: Exercise 2012 DSP Exercise Objectives

Advanced Digital Signal Processing Part 5: Digital Filters

The University of Texas at Austin Dept. of Electrical and Computer Engineering Final Exam

CS3291: Digital Signal Processing

Final Exam Solutions June 14, 2006

EE 422G - Signals and Systems Laboratory

Outline. Discrete time signals. Impulse sampling z-transform Frequency response Stability INF4420. Jørgen Andreas Michaelsen Spring / 37 2 / 37

Lecture 17 z-transforms 2

APPLIED SIGNAL PROCESSING

Application Note 7. Digital Audio FIR Crossover. Highlights Importing Transducer Response Data FIR Window Functions FIR Approximation Methods

Signal Processing Summary

Electric Circuit Theory

Design IIR Filter using MATLAB

Signals and Systems Lecture 6: Fourier Applications

Infinite Impulse Response Filters

Chapter 2 Infinite Impulse Response (IIR) Filter

Digital Signal Processing

Narrow-Band Low-Pass Digital Differentiator Design. Ivan Selesnick Polytechnic University Brooklyn, New York

Experiment 4- Finite Impulse Response Filters

y(n)= Aa n u(n)+bu(n) b m sin(2πmt)= b 1 sin(2πt)+b 2 sin(4πt)+b 3 sin(6πt)+ m=1 x(t)= x = 2 ( b b b b

Performance Evaluation of Mean Square Error of Butterworth and Chebyshev1 Filter with Matlab

DESIGN OF FIR AND IIR FILTERS

Designing Filters Using the NI LabVIEW Digital Filter Design Toolkit

PROBLEM SET 6. Note: This version is preliminary in that it does not yet have instructions for uploading the MATLAB problems.

F I R Filter (Finite Impulse Response)

Electrical & Computer Engineering Technology

EC6502 PRINCIPLES OF DIGITAL SIGNAL PROCESSING

Frequency-Response Masking FIR Filters

The University of Texas at Austin Dept. of Electrical and Computer Engineering Midterm #2

Using the isppac 80 Programmable Lowpass Filter IC

Transcription:

Chapter9 Digital Filter Design Contents 9.1 Overview of Approximation Techniques........ 9-3 9.1.1 Approximation Approaches........... 9-3 9.1.2 FIR Approximation Approaches......... 9-3 9.2 Continuous-Time Filter Design Overview....... 9-4 9.3 Butterworth Design................... 9-6 9.3.1 General Butterworth Design from Amplitude Specifications..................... 9-1 9.3.2 Amplitude Response and Group Delay Summary 9-16 9.4 Chebyshev Design.................... 9-17 9.4.1 Chebyshev Type I................. 9-17 9.4.2 General Chebyshev Type I Design from Amplitude Specifications................ 9-22 9.4.3 Amplitude Response and Group Delay Summary 9-26 9.4.4 Chebyshev Type II................ 9-26 9.5 Elliptic Design...................... 9-31 9.5.1 Elliptic Design from Amplitude Specifications. 9-39 9.5.2 Amplitude Response and Group Delay Summary 9-42 9-1

CHAPTER 9. DIGITAL FILTER DESIGN 9.6 The Design of Discrete-Time IIR Filters from Analog Prototypes........................ 9-43 9.6.1 Impulse Invariant Design............. 9-44 9.6.2 Bilinear Transformation Design......... 9-52 9.7 Frequency Transformations............... 9-67 9.7.1 Continuous-Time Transformations........ 9-68 9.8 Discrete-Time Transformations............. 9-77 9.9 Design of Discrete-Time FIR Filters.......... 9-79 9.9.1 Design Using Windowing............ 9-8 9.9.2 Lowpass Filter Design.............. 9-84 9.1 Appendix: MATLAB s-domain and z-domain Filter Design Functions..................... 9-9 9.1.1 Introduction.................... 9-9 9.1.2 Some Functions.................. 9-9 9.11 Appendix: Using MATLAB sptool for Filter Design. 9-93 9.11.1 A Chebyshev Type II Bandpass Design..... 9-95 9.11.2 A Windowed FIR Design............. 9-98 9-2 ECE 565/465 Modern DSP

A filter is a frequency selective LTI system, that is a system that passes specified frequency components and rejects others. The discrete-time filter realizations of interest here are those LTI systems which have LCCDE representation and are causal. Note that for certain applications noncausal filters are appropriate. An important foundation for digital filter design are the classical analog filter approximations. An overview of analog approximation techniques will be provided first. The filter design problem can be grouped into three stages: Specification of the desired system properties (application driven) Approximation of the specifications using causal discrete-time systems System realization (technology driven - hardware/software) This chapter will discuss primarily the approximation techniques. Realization techniques have been presented in part earlier. A common senario in which one finds a digital filter is in the filtering of a continuous-time signal using an A/D-H.z/-D/A system (earlier called a C/D-H.e j! /-D/C system). x Discrete- a ( t) x[ n] y[ n] y a ( t) C/D Time D/C System T T A/D-H.z/-D/A system Strictly speaking H.z/ is a discrete-time filter although it is commonly referred to as a digital filter ECE 565/465 Modern DSP 9-3

CHAPTER 9. DIGITAL FILTER DESIGN Recall that for the continuous-time system described above (ideally) H eff.j / D ( H.e j T /; jj < =T ; jj =T Using the change of variables! D T we can easily convert continuous-time specifications to discrete-time specifications i.e. H.e j! / D H eff j! ; j!j < T 9.1 Overview of Approximation Techniques Digital filter design techniques fall into either IIR or FIR approaches 9.1.1 Approximation Approaches Placement of poles and zeros (ad-hoc) Numerical solution of differential equations Impulse invariant (step invariant etc.) Bilinear transformation Minimum mean-square error (frequency domain) 9.1.2 FIR Approximation Approaches Truncated impulse response with windows Frequency sampling 9-4 ECE 565/465 Modern DSP

9.2. CONTINUOUS-TIME FILTER DESIGN OVERVIEW Optimum equiripple approximations Minimum mean-square error (frequency domain) Note: The above designs are also typically constrained to have linear phase. 9.2 Continuous-Time Filter Design Overview The general continuous-time system function of interest is of the form P Mc md H c.s/ D c ms m P N kd d ks k where M c N insures finite gain as! 1. The classical analog filter designs which will be considered here are Butterworth (maximally flat), Chebyshev type I and II, and elliptical. Filter design usually begins with a specification of the desired frequency response The filter requirements may be stated in several ways: Amplitude response jh c.j /j Phase response H c.j / D c.j / or group delay T g.j / D d c.j /=d A combination of amplitude and phase Group delay compensation may be provided by using allpass filters ECE 565/465 Modern DSP 9-5

CHAPTER 9. DIGITAL FILTER DESIGN Example 9.1: Lowpass Specifications H c ( jω) Passband Amplitude Response 1 1 δ 1 alt. form Transition Band 1 + δ 1 1 δ 1 Passband δ 2 T g ( jω) Ω p Ω s Stopband Ω Group Delay Response T Acceptable Region Ω p Ω s Ω Example 9.2: Bandpass Amplitude Specifications 1 1 δ 1 H c ( jω) Passband Amplitude Response δ 2 Stopband Ω s1 Ω p1 Ω p2 Ω s2 Stopband Ω 9-6 ECE 565/465 Modern DSP

9.3. BUTTERWORTH DESIGN In this chapter we will only consider filter requirements in terms of amplitude response Initially only lowpass characteristics will be considered with amplitude specifications: Passband requirement 1 jh c.j /j 1 ı 1 ; jj p Stopband requirement jh c.j /j ı 2 ; jj s Later transformations to highpass, bandpass, and bandstop filters will be introduced 9.3 Butterworth Design Designed to maintain a constant amplitude response in the passband, and stopband ECE 565/465 Modern DSP 9-7

CHAPTER 9. DIGITAL FILTER DESIGN 1.77 H c ( jω) N = 1 N = 2 N = 8 Ω c N = 4 Ω Butterworth Magnitude Response for order N = 1, 2, 4, and 8 The Butterworth filter is optimum 1 in the sense that it provides the best Taylor series approximation to an ideal lowpass filter magnitude at both D and 1 To achieve a Butterworth characteristic we require that the first 2N 1 derivatives of jh c.j /j 2 D at D and 1 2 Typically the cutoff frequency, c, is chosen to correspond to the 3dB point, that is 1 ı 1 D 1 p 2 1 T.W. Parks and C.S. Burrus, Digital Filter Design, John Wiley & Sons, 1987. 2 J.D. Rhodes Theory of Electrical Filters, John Wiley, 1976. 9-8 ECE 565/465 Modern DSP

9.3. BUTTERWORTH DESIGN Under the above assumption the magnitude-squared transfer function is 1 jh c.j /j 2 D 1 C 2N c Butterworth Properties jh c.j /j D D 1, for all N jh c.j /j Dc D 1= p 2, for all N jh c.j /j is monotone decreasing for all For > c jh c.j /j db has slope 2N db/decade or 6N db/octave As N! 1 jh c.j /j approaches an ideal lowpass filter System Function From the form of jh c.j /j 2 and the causality constraint, we can write H c.s/ D 1 B N.s/ D 1 Q N kd1.s s k/ ECE 565/465 Modern DSP 9-9

CHAPTER 9. DIGITAL FILTER DESIGN B N.s/ is an N th order Butterworth polynomial with roots given by s k D c e jœ:5.2k 1/=.2N / ; k D 1; 2; : : : ; N Note that H c.s/ has N zeros at infinity and a pole on the negative real axis at c if N is odd s-plane Ω c Pole here only if N is odd π --- N jω Butterworth pole locations σ Standard and Factored form Butterworth Polynomials for c D 1 rad/sec: Standard Form B N.s/ D a N s N C a N 1 s N 1 C C a 1 s C a a 6 a 5 a 4 a 3 a 2 a 1 a N 1 p 1 1 1 2 1 2 1 2 2 1 3 1 2.613 3.414 2.613 1 4 1 3.236 5.236 5.236 3.236 1 5 1 3.864 7.464 9.141 7.464 3.864 1 6 9-1 ECE 565/465 Modern DSP

9.3. BUTTERWORTH DESIGN Quadratic Factored Form B N.s/ N s C 1 1 s 2 C p 2s C 1 2.s 2 C s C 1/.s C 1/ 3.s 2 C :76536s C 1/.s 2 C 1:84776s C 1/ 4.s C 1/.s 2 C :618s C 1/.s 2 C 1:618s C 1/ 5.s 2 C :5176s C 1/.s 2 C p 2s C 1/.s 2 C 1:9318s C 1/ 6 To frequency scale the above polynomials to a new 3dB cutoff frequency simply let s! s= c Example 9.3: Obtaining the Butterworth Polynomial Design a Butterworth lowpass filter with 3dB frequency c D p D 1 rad/sec, s D 4 rad/sec, and 2 log 1 ı 2 D 24 db. Since s is two octaves above c we need a rolloff of 12 db per octave! N 2 will work. Thus H c.s/ D 1 s 2 C p 2s C 1 from tables 9.3.1 General Butterworth Design from Amplitude Specifications Given: 1. 2 log 1 jh c.j /j db ; p 2. 2 log 1 jh c.j /j A s ; s ECE 565/465 Modern DSP 9-11

CHAPTER 9. DIGITAL FILTER DESIGN ε db H c ( jω) db As Ω p Ω s Ω Amplitude response constraints Find: N and c Solve the following equations: 1 jh c.j p /j db D 1 log D 1 C. p = c / 2N 1 jh c.j s /j db D 1 log D 1 C. s = c / 2N db A s Rewrite the above as 1 db =1 1 A s =1 1 D 1 D 2N p c 2N s c Dividing the first equation into the second gives 2N p 1 db =1 1 D s 1 A s=1 1 or 2 h i3 1 log db =1 1 1 1 N D As=1 1 2 log 6 1. p = s / 7 9-12 ECE 565/465 Modern DSP

9.3. BUTTERWORTH DESIGN where d e is the greatest integer operator Note: Since N is the greatest integer constraints (1) and (2) will not in general both be satisfied with equality at p and s respectively i.e. jh c.j p /j db db or jh c.j s /j db A s For equality at p (most popular) choose c D p 1 db=1 1 1=.2N / For equality at s choose c D s 1 A s=1 1 1=.2N / A third solution is to choose c somewhere in between the above solutions, then both requirements are exceeded Note: db D 2 log 1.1 ı 1 / and A s D 2 log 1 ı 2 Example 9.4: A Butterworth Amplitude Response Design Let p D 2 rad/sec, db D 2 db s D 3 rad/sec, A s D 1 db Solving for N gives N D 2 h i3 1 log 2=1 1 1 1 1=1 1 2 log 6 1.2=3/ 7 D d3:379e D 4 ECE 565/465 Modern DSP 9-13

CHAPTER 9. DIGITAL FILTER DESIGN Matching at p H) c D 2 1 2=1 1 1=8 D 21:3868 rad/sec The normalized H c.s/ from the tables is H c.s/ D 1.s 2 C :76536s C 1/.s 2 C 1:84776s C 1/ Frequency scale c D 1! c D 21:3868 implies that we let s! s=21:3868 Finally, the frequency scaled system function is H c.s/ D MATLAB Analysis.21:3868/ 4.s 2 C 16:37s C 457:4/.s 2 C 39:52s C 457:4/ We can use MATLAB to directly analyze the above Butterworth design MATLAB has the freqs() function for continuous-time systems, analogous to the freqz() function we have been using in the discrete-time domain Frequency scaling is handled in the calculation by letting! =21:3868 >> w = :1:1; >> H = freqs(1,conv([1.76536 1],[1 1.8477 1]),w/21.3868); >> plot(w,2*log1(abs(h))) 9-14 ECE 565/465 Modern DSP

9.3. BUTTERWORTH DESIGN >> grid >> axis([ 1-5 ]) >> patch([ 2 2 ],[-5-5 -2-2],[.75.75.75]) >> patch([3 1 1 3],[-1-1 ],[.75.75.75]) 5 1 2dB 1dB 15 H ( jω ) db 2 25 3 35 4 45 5 1 2 3 4 5 6 7 8 9 1 Ω MATLAB Filter Design Butterworth magnitude response An alternative approach is to design the filter completely using MATLAB filter design tools for the s-domain >> [n,wn] = buttord(2,3,2,1,'s') n = 4 Wn = 2.2795e+1 ECE 565/465 Modern DSP 9-15

CHAPTER 9. DIGITAL FILTER DESIGN >> [b,a] = butter(n,wn,'s') b = 2.7e+5 a = 1.e+ 5.9566e+1 1.7741e+3 3.952e+4 2.7e+5 >> % Calculate the frequency response >> [H,w] = freqs(b,a); >> plot(w,2*log1(abs(h))); -5 2dB -1-15 H ( jω ) db -2-25 -3-35 -4-45 -5 1 2 3 4 5 6 7 8 9 1 Ω Butterworth magnitude response in the all MATLAB design Both the hand calculation and the MATLAB design use N D 4 The normalized cutoff frequencies are slightly different, as MAT- LAB appears to choose c closer to the value we would obtain 9-16 ECE 565/465 Modern DSP

9.3. BUTTERWORTH DESIGN by matching constraints at s, e.g., c D 3 1 1=1 1 1=8 D 22:795 rad/s 9.3.2 Amplitude Response and Group Delay Summary Ω c = 1 rad/s group delay τ g, sec Magnitude Response, db 5 1 15 2 25 3 1 1 1 8 7 6 5 4 3 2 1 N = 7 N = 6 N = 5 N = 4 N = 3 N = 2 N = 1 N = 1 N = 2 N = 3 N = 4 N = 5 N = 6 N = 7 1 1 1 Ω, rad/s ECE 565/465 Modern DSP 9-17

CHAPTER 9. DIGITAL FILTER DESIGN 9.4 Chebyshev Design A Chebyshev design achieves a more rapid rolloff rate near the cutoff frequency than the Butterworth by allowing ripple in the passband (type I) or stopband (type II). Monotonicity of the stopband or passband is still maintained respectively. 1 H c ( jω) H c ( jω) 1 1 δ 1 1 δ 1 Type I (N = 5) Type II (N = 5) δ 2 δ 2 Ω p Ω s Ω Ω p Ω s Ω Differences between type I and II 9.4.1 Chebyshev Type I The magnitude response is given by jh c.j /j 2 D 1 1 C 2 T 2 N.= c/ where T N.x/ D N th order Chebyshev polynomial and specifies the passband ripple 9-18 ECE 565/465 Modern DSP

9.4. CHEBYSHEV DESIGN The Chebyshev polynomials are of the form T.x/ D 1; T 1.x/ D x; T 2.x/ D 2x 2 1 : : : with recurrence formula T N.x/ D 2xT N 1.x/ T N 2.x/; N 2 An alternate form for T N.x/, which will be useful in both analysis and design, is T N.x/ D ( cosœn cos 1 x ; jxj 1 coshœn cosh 1 x ; jxj > 1 Type I Properties p 1 1C 2 jh c.j /j 1; c The equiripple behavior gives a passband ripple in db of db D 1 log 1.1 C 2 / or D p 1 db=1 1 jh c.j /j is monotone decreasing for p The filter gain at D is given by 1 if N is odd and 1= p.1 C 2 / if N is even ECE 565/465 Modern DSP 9-19

CHAPTER 9. DIGITAL FILTER DESIGN H c ( jω) H c ( jω) 1 1 [ 1 + ε 2 ] 1 -- 2 N Even (N = 6) [ 1 + ε 2 ] 1 -- 2 N Odd (N = 5) δ 2 δ 2 Ω p Ω s Ω Ω p Ω s Ω The number of inflections indicates N Type I System Function The system function is of the form where and H c.s/ D V N.s/ D K V N.s/ NY.s s k / kd1 h i 1 s k D c sin 2N.2k 1/ sinh N sinh 1 1 h i 1 Cj cos 2N.2k 1/ cosh N sinh 1 1 for k D 1; 2; : : : ; N 9-2 ECE 565/465 Modern DSP

9.4. CHEBYSHEV DESIGN The poles are located on an ellipse with minor axis length 2a p where a D 1 2. 1=N 1=N / and D 1 C p 1 C 2 s-plane π --- N Pole here only if N is odd Ellipse jω aω p bω p σ The major axis length is 2b p where b D 1 2. 1=N C 1=N / Chebyshev type I pole locations The gain factor K is given by 8 < V N./; N odd K D V : N./ 2; N even p1c which results from requiring that 8 < 1; N odd H c./ D : p 1 1C 2; N even Normalized Chebyshev Polynomials V N.s/ for db D.5, 1, and 2 db: ECE 565/465 Modern DSP 9-21

CHAPTER 9. DIGITAL FILTER DESIGN V N.s/ D s N C a N 1 s N 1 C C a 1 s C a N a a 1 a 2 a 3 a 4 a 5 db D.5, D.34931 1 2.86277 2 1.5162 1.42562 3.7157 1.53489 1.25291 4.3795 1.2545 1.71687 1.19739 5.17892.75252 1.3957 1.93737 1.17249 6.9476.43237 1.17186 1.58976 2.17184 1.15918 V N.s/ D s N C a N 1 s N 1 C C a 1 s C a N a a 1 a 2 a 3 a 4 a 5 db D 1, D.5885 1 1.96523 2 1.1251 1.9773 3.49131 1.23841.98834 4.27563.74262 1.45392.95281 5.12283.5853.9743 1.68881.93682 6.6891.378.93935 1.2214 1.9382.92825 V N.s/ D s N C a N 1 s N 1 C C a 1 s C a N a a 1 a 2 a 3 a 4 a 5 db D 2 D.76478 1 1.3756 2.63677.8382 3.32689 1.2219.73782 4.2576.5168 1.25648.71621 5.8172.45935.69348 1.49954.7646 6.5144.2127.77146.8671 1.74586.7123 9-22 ECE 565/465 Modern DSP

9.4. CHEBYSHEV DESIGN 9.4.2 General Chebyshev Type I Design from Amplitude Specifications Given: db ; A s ; p ; and s ε db H c ( jω) db As Ω p Ω s Ω Amplitude response constraints Find: N To achieve the desired stopband attenuation, A s, at s we set jh c.j s /j 2 D 1 A s=1 D 1 C 2 cosh 2 N cosh 1. s = p / Solve for N s 1 N cosh 1 s = p D cosh 1 @ 1 A s=1 1 A 1 db=1 1 or N D 2 q 3 cosh 1 1 As=1 1 1 db =1 1 cosh 1 s = p 6 7 ECE 565/465 Modern DSP 9-23

CHAPTER 9. DIGITAL FILTER DESIGN Example 9.5: A Chebyshev Type I Design Design a Chebyshev type I lowpass filter to satisfy the following amplitude specifications: db D 2dB, A s D 2dB, p D 4 rad/s, and s D 52 rad/s. Using the design formula for N 2 q cosh 1 N D cosh 1.52=4/ 6 1 2=1 1 1 2=1 1 3 7 D d4:3e D 5 From the 2dB ripple table (9-2), H c.s/ D :817 ˇ s 5 C :76s 4 C 1:5s 3 C :694s 2 C :459s C :817 MATLAB Analysis ˇs!s=4 We can use MATLAB to directly analyze the above Chebyshev type I design Frequency scaling is handled in the calculation by letting! =4 >> w = :1:1; >> w = :1/2:1; >> H = freqs(.8172,... [1.7646 1.4995.6935.4593.8172],w/4); >> plot(w,2*log1(abs(h))) >> axis([ 1-5 ]) >> grid 9-24 ECE 565/465 Modern DSP

9.4. CHEBYSHEV DESIGN -5 2dB H ( jω ) db -1-15 -2-25 -3-35 -4 2dB -45-5 1 2 3 4 5 6 7 8 9 1 Ω 52 MATLAB Filter Design Chebyshev type I magnitude response An alternative approach is to design the filter completely using MATLAB filter design tools for the s-domain >> [n,wn] = cheb1ord(4,52,2,2,'s') n = 5 Wn = 4 >> [b,a] = cheby1(n,2,wn,'s') b = 8.3684e+6 a = 1.e+ 2.8258e+1 2.3993e+3 4.4383e+4 1.1759e+6 8.3684e+6 >> % Calculate the frequency response ECE 565/465 Modern DSP 9-25

CHAPTER 9. DIGITAL FILTER DESIGN >> [H,w] = freqs(b,a); >> plot(w,2*log1(abs(h))); -5 2dB -1 db H j -15-2 -25-3 2dB -35-4 -45-5 1 2 3 4 5 6 7 8 9 1 52 Chebyshev type I magnitude response in the all MATLAB design Both the hand calculation and the MATLAB design result in N D 4 The coefficients are only slightly differnt, e.g., the numerator coefficient in the hand calculation after scaling is :817 4 5 D 8:3668 1 6 compared with 8:3684 1 6 from the MATLAB design The plotted results look virtually identical 9-26 ECE 565/465 Modern DSP

9.4. CHEBYSHEV DESIGN 9.4.3 Amplitude Response and Group Delay Summary c = 1 rad/s g Magnitude sec Response, db group delay 5 1 15 2 25 3 1 1 1 3 25 2 15 1 5 N = 2 N = 3 N = 4 N = 5 N = 6 N = 7 N = 7 N = 6 N = 5 N = 4 N = 3 N = 2 1 1 1 rad/s 9.4.4 Chebyshev Type II The magnitude response is given by jh c.j /j 2 D 1 1 C 2 h T 2 N. s = p / T 2 N. s=/ i ECE 565/465 Modern DSP 9-27

CHAPTER 9. DIGITAL FILTER DESIGN Note that the passband ripple is still db since jh c.j p /j 2 D 1=.1 C 2 / jh c.j /j is monotone decreasing for p Type II System Function The system function is of the form H c.s/ D Q N md1.s z m/ Q N kd1.s p k/ where and z m D j s cos 2N.2m m D 1; 2; : : : ; N 1/; p k D k C jˇk; k D 1; 2; : : : ; N k D p s k k 2 C ; ˇk D p s k 2 k k 2 C 2 k h k D sin 2N.2k h k D cos 2N.2k i 1 1/ sinh N sinh 1 1 i 1 1/ cosh N sinh 1 1 Example 9.6: A Chebyshev Type II Design Design a Chebyshev type II lowpass filter to satisfy the following amplitude specifications: db D 2dB, A s D 4dB, p D 1 rad/s, and s D 2 rad/s. 9-28 ECE 565/465 Modern DSP

9.4. CHEBYSHEV DESIGN To find the filter order N set jh c.j s /j 2 D 1 A s=1 D 1 C 2T 2 N. s= p / T 2 N. s= s / Since T N.1/ D 1 and s = p > 1, or 1 A s=1 D 1 C 2 T 2 N. s= p / N D 2 q 3 cosh 1 1 As=1 1 1 db =1 1 cosh 1 s = p 6 7 which is the same as the type I formula For the problem of interest 2 q 3 cosh 1 1 4=1 1 1 2=1 1 N D cosh 1.2=1/ 6 7 MATLAB Analysis D d4:227e D 5 We can use MATLAB to directly analyze the above Chebyshev type II design Rather than actually computing the polynomial coefficients, numerator and denominator, we will calculate just the frequency response magnitude ECE 565/465 Modern DSP 9-29

CHAPTER 9. DIGITAL FILTER DESIGN To do that we will write a simple m-file to evaluate T N./ function Tn = chebpoly(n,x) % Tn = chebpoly(n,x) % Chebyshev polynomial T_N(x) for use in filter analysis % N = order % x = vector of input values Tn = zeros(size(x)); s = find(abs(x) < 1); s1 = find(abs(x) >= 1); Tn(s) = cos(n*acos(x(s))); Tn(s1) = cosh(n*acosh(x(s1))); >> w = :5/2:5; >> H = -1*log1(1 + (1^(2/1)-1)... *(chebpoly(5,2)./chebpoly(5,2./w)).^2); Warning: Divide by zero. >> plot(w,h) >> grid >> axis([ 5-8 ]) 2dB -1-2 H ( jω ) db -3-4 -5 4dB -6-7 -8 5 1 15 2 25 3 35 4 45 5 Ω 9-3 ECE 565/465 Modern DSP

9.4. CHEBYSHEV DESIGN MATLAB Filter Design Chebyshev type II magnitude response An alternative approach is to design the filter completely using MATLAB filter design tools for the s-domain >> [n,wn] = cheb2ord(1,2,2,4,'s') n = 5 Wn = 1.6864e+2 >> [b,a] = cheby2(n,4,wn,'s') b = 8.4325e+ -8.9874e-13 9.5927e+5-2.521e-8 2.1825e+1 a = 1.e+ 3.6244e+2 6.5647e+4 7.4342e+6 5.3163e+8 2.1825e+1 >> % Calculate the frequency response >> [H,w] = freqs(b,a); >> plot(w,2*log1(abs(h))); 2dB -1-2 H ( jω ) db -3-4 -5 4dB -6-7 -8 5 1 15 2 25 3 35 4 45 5 Ω ECE 565/465 Modern DSP 9-31

CHAPTER 9. DIGITAL FILTER DESIGN Chebyshev type II magnitude response in the all MATLAB design Both the hand calculation and the MATLAB design result in N D 5 The hand calculation and the use of cheb2ord() yield different results in other respects however In the MATLAB design the minimum stopband attenuation is exactly 4dB rather than the 48dB value of the hand calculation; why the difference? In the hand calculation the minimum attenuation increases from 4dB to 48dB when the filter order is rounded up from 4.227 to 5 In the MATLAB calculation is reduced to allow the minimum attenuation to drop to 4dB The filter cutoff frequency is then be reduced (to 168.6 rad/s) so that the db point is still at 2 rad/s 9.5 Elliptic Design Allows both passband and stopband ripple to obtain a narrow transition band. The elliptic (Cauer) filter is optimum in the sense that no other filter of the same order can provide a narrower transition band. 9-32 ECE 565/465 Modern DSP

9.5. ELLIPTIC DESIGN The squared magnitude response is given by jh c.j /j 2 1 D 1 C 2 UN 2.= p/ where U N./ is a Jacobian elliptic function 1 1 -------------- 1 + 2 r = s ------ p N = 4 2 p s Define the transition region ratio as r D s p The normalized lowpass system function can be written in factored form as 8 < H Q.N 1/=2 s 2 CA i scs H c.s/ D id1 ; N odd s 2 CB 1i scb Q i :.N 1/=2 N even id1 s 2 CA i s 2 CB 1i scb i ; Note: H c.s/ contains conjugate pairs of zeros on the j axis which give the stopband nulls The filter coefficients H, and s if N is odd, and A i ; B 1i, and B i are determined from the filter specifications db ; A s, and r ECE 565/465 Modern DSP 9-33

CHAPTER 9. DIGITAL FILTER DESIGN A set of formulas useful for direct calculation of the elliptic lowpass pole and zero locations can be found in Antoniou 3 and MATLAB can be used directly as we will see in the examples The following pages contain several of the design data tables which give the achieved value for r as a function of N for fixed db and A s These tables assume quadratic filter sections described above have been written as a ratio of N -order polynomials, where the numerator contains only even-order coefficients due to the zeros being on the j!-axis, e.g., H.s/ D 8 < : b N s N Cb N 2 s N 2 CCb 2 s 2 Cb s N Ca N 1 s N 1 CCa 1 sca ; N even b N 1 s N 1 Cb N 3 s N 3 CCb 2 s 2 Cb s N Ca N 1 s N 1 CCa 1 sca ; N odd also the filters have a normalized cuttoff frequency of p D 1 rad/s 3 A. Antoniou, Digital Filters: Analysis and Design, McGraw Hill, New York, 1979. 9-34 ECE 565/465 Modern DSP

9.5. ELLIPTIC DESIGN Passband Ripple db D 1, Stopband Attenuation A s D 2 db N H s b N sn + b N 1 s N 1 + + b 1 s + b = ---------------------------------------------------------------------------------- a N s N + a N 1 s N 1 + + a 1 s + a s ------ p b N.11 1.2771 2 2.324 a N 1. 1.2957 1.15311 b N.3257.66468 3 1.378 a N 1..96658 1.2466.66468 b N.9998.54212.52554 4 1.92 a N 1..9376 1.67646.86878.58967 b N 5 6 7 8 9 a N b N a N b N a N b N a N b N a N.2832.7474.47648 1..92728 2.4748 1.4558 1.3362.47648.9996.619.9555.45419 1..89292 2.5783 1.68592 2.8694.79228.5961.27936.99934 1.16875.44882 1..92339 3.646 2.28719 2.9959 1.81256.98946.44882.9996.69714 1.53744 1.3844.44378 1..89183 3.5674 2.56222 4.61773 2.44887 2.55492.77848.49793..27912 1.2755 2.15772 1.6682.4453 1..9231 3.9998 3.2335 5.9826 4.8266 3.9648 2.24735.98254.4453 1.282 1.9 1.29 1.9 1.3 ECE 565/465 Modern DSP 9-35

CHAPTER 9. DIGITAL FILTER DESIGN Passband Ripple db D 1, Stopband Attenuation A s D 3 db N H s b N sn + b N 1 s N 1 + + b 1 s + b = ---------------------------------------------------------------------------------- a N s N + a N 1 s N 1 + + a 1 s + a s ------ p b N.3164.99795 2 4.36 a N 1. 1.7759 1.11971 b N.1492.56866 3 1.7324 a N 1..9715 1.24597.56866 b N.3163.2889.38968 4 1.254 a N 1..92931 1.56646.83918.43723 b N 5 6 7 8 9 a N b N a N b N a N b N a N b N a N.11635.39623.31327 1..924 1.93449 1.22581.89778.31327.3163.2642.5595.27874 1..9155 2.37658 1.58926 1.68344.67748.31275.11191.46635.61684.26297 1..91236 2.82822 2.3866 2.61733 1.3889.78964.26297.3158.28755.73224.73158.25535 1..9756 3.31899 2.44379 3.91523 2.16991 1.88278.63372.28651.11124.56917 1.5647.8577.25223 1..91113 3.79911 2.92176 5.3635 3.36246 3.32451 1.646.76327.25223 1.955 1.38 1.154 1.63 1.1486 9-36 ECE 565/465 Modern DSP

9.5. ELLIPTIC DESIGN Passband Ripple db D 1, Stopband Attenuation A s D 4 db N H s b N sn + b N 1 s N 1 + + b 1 s + b = ---------------------------------------------------------------------------------- a N s N + a N 1 s N 1 + + a 1 s + a s ------ p b N.11.98757 2 7.434 a N 1. 1.915 1.187 b N.692.52652 3 2.4162 a N 1..97825 1.24339.52652 b N.1.152.32196 4 1.5154 a N 1..93913 1.51372.8369.36125 b N 5 6 7 8 9 a N b N a N b N a N b N a N b N a N.4698.227.22985 1..92339 1.84712 1.12923.78813.22985.1.11725.27999.186 1..91544 2.2378 1.47986 1.43164.56516.2869.434.21884.33726.1646 1..91246 2.66449 1.87478 2.27753 1.12567.61545.1646.1.11911.35275.39612.15275 1..9134 3.12221 2.28339 3.3945 1.85875 1.44392.48587.17139.4267.2583.51899.45762.14682 1..912 3.59456 2.7191 4.74646 2.85738 2.71414 1.19524.56223.14682 1.2187 1.989 1.46 1.217 1.13 ECE 565/465 Modern DSP 9-37

CHAPTER 9. DIGITAL FILTER DESIGN Passband Ripple db D 1, Stopband Attenuation A s D 5 db N H s b N sn + b N 1 s N 1 + + b 1 s + b = ---------------------------------------------------------------------------------- a N s N + a N 1 s N 1 + + a 1 s + a s ------ p b N.315.98415 2 12.4939 a N 1. 1.9575 1.1424 b N.3212.5751 3 3.467 a N 1..98333 1.2415.5751 b N.316.8198.2874 4 1.983 a N 1..94472 1.48661.77888.3226 b N 5 6 7 8 9 a N b N a N b N a N b N a N b N a N.1881.1271.18519 1..92736 1.78896 1.7156.7134.18519.316.5259.16247.13585 1..91857 2.14114 1.39498 1.26852.48165.15243.1652.149.19279.1147 1..91412 2.53421 1.75435 2.1674.9522.4884.1147.316.4927.17251.22225.9677 1..91171 2.9674 2.1452 2.9978 1.59958 1.14659.37114.1858.1595.116.2582.25292.8913 1..915 3.41139 2.555 4.22165 2.46916 2.225.91837.4113.8913 1.472 1.1989 1.113 1.527 1.277 9-38 ECE 565/465 Modern DSP

9.5. ELLIPTIC DESIGN Passband Ripple db D 1, Stopband Attenuation A s D 6 db N H s b N sn + b N 1 s N 1 + + b 1 s + b = ---------------------------------------------------------------------------------- a N s N + a N 1 s N 1 + + a 1 s + a s ------ p b N.1.98313 2 22.1625 a N 1. 1.9713 1.139 b N.1491.49879 3 5.218 a N 1..98593 1.2397.49879 b N.1.4533.26844 4 2.468 a N 1..9488 1.4723.76357.3119 b N 5 6 7 8 9 a N b N a N b N a N b N a N b N a N.751.7561.1617 1..9347 1.7519 1.3574.6644.1617.1.238.9829.1751 1..92113 2.7439 1.3346 1.1676.42428.1263.623.532.11537.84 1..91594 2.4369 1.66522 1.82732.8323.4146.84.1.243.862.1333.6565 1..9134 2.83243 2.253 2.6995 1.4225.9432.2945.7366.588.4843.1387.14513.5719 1..91134 3.25687 2.4157 3.79969 2.16887 1.84761.7272.3441.5719 1.6715 1.3435 1.1855 1.131 1.582 ECE 565/465 Modern DSP 9-39

CHAPTER 9. DIGITAL FILTER DESIGN 9.5.1 Elliptic Design from Amplitude Specifications Given: db ; A s ; p ; and s db H c j db A s p s Amplitude response constraints r D s = p Find N from the tables for the specified db and A s by choosing N such that the table value of r is less than or equal to the desired s = p Frequency scale the resulting H.s/ using s! s= p Example 9.7: An Elliptic Design Design an elliptic lowpass filter to satisfy the following amplitude specifications: db D 1dB, A s D 4dB, f p D 1 khz, and f s D 14.4 khz. r D 14:4=1 D 1:44 9-4 ECE 565/465 Modern DSP

9.5. ELLIPTIC DESIGN From the 1 db ripple, 4 db stopband attenuation table we find that N 5 meets or exceeds the r requirement (i.e. in this case the filter will actually have r D 1:2187, so we can scale p to be 2 1 krad and then the desired stopband attenuation will actually be achieved at D 2 1:2187 4 D 76:572 krad/s or 12.187 khz The normalized H.s/ ( p D 1) is H.s/ D :4698s 4 C :227s 2 C :22985 = s 5 C :92339s 4 C 1:84712s 3 C 1:12923s 2 C :78813s C :22985 To complete the design scale H.s/ by letting s! s=.2 1; / MATLAB Analysis We can use MATLAB to directly analyze the above elliptic design Frequency scaling is handled in the calculation by letting! =.2 1; / >> f = :5/2:5; % freq. axis in Hz >> w = 2*pi*f; % freq. axis in rad/s >> H = freqs([.4698.227.22985],... [1.92339 1.84712 1.12923.78813.22985],... w/(2*pi*1)); >> plot(w/(1*2*pi),2*log1(abs(h))) %in khz ECE 565/465 Modern DSP 9-41

CHAPTER 9. DIGITAL FILTER DESIGN 1dB -1 F db H j2-2 -3-4 4dB -5-6 5 1 15 2 25 3 35 4 MATLAB Filter Design F khz Elliptic magnitude response An alternative approach is to design the filter completely using MATLAB filter design tools for the s-domain >> [n,wn] = ellipord(2*pi*1,2*pi*144,1,4,'s') n = 5 Wn = 6.2832e+4 >> Wn/(2*pi) ans = 1 % Fn in Hz >> [b,a] = ellip(n,1,4,wn,'s') b = 9-42 ECE 565/465 Modern DSP

9.5. ELLIPTIC DESIGN a = 2.9517e+3-1.1275e-7 5.4588e+13-7.9768e+2 2.259e+23 1.e+ 5.818e+4 7.2921e+9 2.811e+14 1.2283e+19 2.259e+23 The above results are identical to those obtained from the table except the scaling factor of Wn has been included, e.g., b n! b n. p / n ; a n! a n. p / n The table values were generated using MATLAB s ellip()with Wn = 1 in the first place 9.5.2 Amplitude Response and Group Delay Summary Consider an elliptic design with s D 1 rad/s, db D 1, and A s D 5 db, and vary the filter order from 2 to 7. ECE 565/465 Modern DSP 9-43

CHAPTER 9. DIGITAL FILTER DESIGN group delay τ g, sec Magnitude Response, db 1 2 3 4 5 6 1 1 1 6 5 4 3 2 1 Ω c = 1 rad/s, ε db = 1, A s = 5 db N = 2 N = 3 N = 4 N = 5 N = 6 N = 7 N = 7 N = 6 N = 5 N = 4 N = 3 N = 2 1 1 1 Ω, rad/s 9.6 The Design of Discrete-Time IIR Filters from Analog Prototypes In this section we will discuss the design of discrete-time IIR filters using classical continuous-time design procedures. In particular we will consider design by impulse invariance and the bilinear transformation. 9-44 ECE 565/465 Modern DSP

9.6. THE DESIGN OF DISCRETE-TIME IIR FILTERS FROM ANALOG PROTOTYPES 9.6.1 Impulse Invariant Design In section 3.4.2 of the text (notes page 4-23, Example 4-4), the impulse invariant design was first introduced. Recall that we chose the discrete-time impulse response to be a sampled version of the corresponding continuous-time impulse response. Let h c.t/ L! Hc.s/. Then set hœn D T d h c.nt d / where T d is the design sampling period, which may differ from the A/D and D/A sampling period We thus can write H.e j! / D 1X kd 1 H c j! C j 2 k T d T d Recalling that H.e j! / D H.z/j zde st d we can also write that the system function is given by i H.z/ D Z h L 1 ŒH c.s/ ˇˇtDnTd Note that H.e j! / is just an aliased version of H c.j!=t d / ECE 565/465 Modern DSP 9-45

CHAPTER 9. DIGITAL FILTER DESIGN 1 H c j----- Td Implicit Aliasing 1 H e j 2 T d = 2 design sampling period Aliasing inherent in the impulse invariant technique The stopband characteristic of H c.j / is maintained only if the aliased tails are small To reduce aliasing: 1. Restrict H c.j / to be lowpass with a monotonic stopband 2. Decrease T d (increase f s ) or decrease the filter cutoff frequency Basic Design Technique Expand H c.s/ using partial fractions (for this development we assume there are no repeated poles) H c.s/ D NX kd1 s A k s k 9-46 ECE 565/465 Modern DSP

9.6. THE DESIGN OF DISCRETE-TIME IIR FILTERS FROM ANALOG PROTOTYPES Note: In the following analysis a gain factor G is introduced which also includes T d. The gain factor allows the dc filter gains to be equal. Inverse Laplace transforming H c.s/ we get so and hœn D h c.t/ D G ƒ gain factor H.z/ D G NX A k e skt u.t/ kd1 NX A k.e s kt d / n uœn kd1 NX kd1 A k 1 e s kt d z 1 The s-plane poles are mapped to the z-plane using s D s k ) z D p k D e s kt d To match the dc gains set H.e j / D H.1/ D H c./ which implies that we set G NX kd1 A k 1 e s kt d D NX kd1 A k s k Example 9.8: Design from a Rational H.s/ Let H c.s/ D :5.s C 4/.s C 1/.s C 2/ D 1:5 s C 1 1 s C 2 ECE 565/465 Modern DSP 9-47

CHAPTER 9. DIGITAL FILTER DESIGN Inverse Laplace transforming yields h c.t/ D Œ1:5e t e 2t u.t/ Sampling h c.t/ every T d seconds and gain scaling we obtain hœn D GŒ1:5e nt d which implies that 1:5 H.z/ D G 1 e T d z 1 e 2nT d uœn 1 1 e 2T d z 1 Setting H c./ D H.1/ requires that 1:5 1 G D 1 e T d 1 e 2T d MATLAB Analysis 1 From the above analysis we can have MATLAB directly evaluate H.e j! / for various values of T d or equivalently sampling rate f s D 1=T d ; here we have used T C 1=5, 1/1, and 1/5 sec. >> f = :2/2:2; >> w = 2*pi*f; >> Td = 1/1; G = 1/(1.5/(1-exp(-Td)) - 1/(1-exp(-2*Td))); >> H = G*(1.5./(1 - exp(-td)*exp(-j*w*td))... - 1./(1-exp(-2*Td)*exp(-j*w*Td))); >> Ha = freqs([.5 2],[1 3 2],w); >> plot(f,2*log1(abs(ha))) >> hold Current plot held >> plot(f,2*log1(abs(h)),'-.') 9-48 ECE 565/465 Modern DSP

9.6. THE DESIGN OF DISCRETE-TIME IIR FILTERS FROM ANALOG PROTOTYPES Frequency Response in db 5 1 15 2 25 3 35 4 45 Analog Filter T d = 1 5 H a j db 5 2 4 6 8 1 12 14 16 18 2 F = ----- 2 Digital Filter H T d db T d = 1 1 T d = 1 5 Frequency response of impulse invariant design for various T d values MATLAB Impulse Invariant Synthesis An alternative approach is to use MATLAB to synthesize the z-domain impulse invariant deign directly from s-domain rational transfer function The key function is impinvar() which converts a rational function in s to a rational function in z for a given sampling frequency (see the chapter appendix) >> as = conv([1 1],[1 2]) % multiply out den. poly as = 1 3 2 >> bs =.5*[1 4] bs =.5 2. >> [bz1,az1] = impinvar(bs,as,1); % fs = 1 Hz ECE 565/465 Modern DSP 9-49

CHAPTER 9. DIGITAL FILTER DESIGN bz1 =.5 -.3233 az1 = 1. -1.7236.748 >> [bz5,az5] = impinvar(bs,as,5); % fs = 5 Hz bz5 =.5 -.461 az5 = 1. -1.941.9418 >> [Hc,wc] = freqs(bs,as); >> [H1,F1] = freqz(bz1,az1,256,'whole',1); >> [H5,F5] = freqz(bz5,az5,256,'whole',5); >> plot(wc/(2*pi),2*log1(abs(hc)))» hold Current plot held >> plot(f1,2*log1(abs(h1/h1(1))),'--') >> plot(f5,2*log1(abs(h5/h5(1))),'-.') In the above gain normalization to unity at dc is accomplished by dividing through by H.1/; the plots are not shown as they are identical to the previous results The MATLAB synthesis produces H.z/ in a nice rational form via the polynomial coefficient vectors bz1 and az1, etc. Designing for Discrete-Time Specifications If the design is required to meet specific discrete time specifications, then we begin by transforming the discrete time specifications to continuous time using i D! i =T d for i D p and s Next H c.s/ is found using the approximation methods described earlier in this chapter Given H c.s/ we then proceed to find H.z/ using impulse invariance 9-5 ECE 565/465 Modern DSP

9.6. THE DESIGN OF DISCRETE-TIME IIR FILTERS FROM ANALOG PROTOTYPES Example 9.9: A Chebyshev Design Design a Chebyshev type I lowpass filter to satisfy the following amplitude specifications: db D 1 db, A s D 2 db,! p D :1, and! s D :3. Using the design formula for N N D d2:8e D 3 Note: s = p D! s =! p The normalized system function is H c.s/ D with poles at To frequency scale H c.s/ let so in the z-domain :152 s 3 C :315s 2 C :1222s C :152 :1549e j18ı ; :3132e j14:4ı s! s! p =T d ) s k! s k! p T d p k D e T d s k! p =T d D e s k! p Note that when the design originates from discrete time specifications the poles of H.z/ are independent of T d To complete the design expand H c.s/ in a partial fraction expansion and then use the A k s and p k s to define H.z/ (left as an exercise) ECE 565/465 Modern DSP 9-51

CHAPTER 9. DIGITAL FILTER DESIGN MATLAB Impulse Invariant Synthesis As in the previous example we can again use the MATLAB function impinvar() to synthesize an impulse invariant filter directly from amplitude response specifications The design will assume that T d D 1 >> [n,wn] = cheb1ord(.1*pi,.3*pi,1,2,'s') n = 3 Wn =.3142 >> [bs,as] = cheby1(n,1,wn,'s') bs =...152 as = 1..315.1222.152 >> W = :4/2:4; >> Hc = freqs(bs,as,w); %Compute s-domain freq. resp. >> [bz,az] = impinvar(bs,as,1) >> %impulse invariant design using Fs = 1 bz =..68.61 az = 1. -2.6223 2.3683 -.7331 >> [H,w] = freqz(bz,az); %Compute z-domain aliased resp. >> plot(w/(2*pi),2*log1(abs(hc))) >> hold Current plot held >> plot(w/(2*pi),2*log1(abs(h/h(1)))) %gain normalize at dc 9-52 ECE 565/465 Modern DSP

9.6. THE DESIGN OF DISCRETE-TIME IIR FILTERS FROM ANALOG PROTOTYPES 1dB -1 Frequency Response in db -2-3 -4-5 -6 2dB Analog Digital -7.5.1.15.2.25.3.35.4.45.5 f = 2 Frequency response of Chebyshev impulse invariant design for f s D 1 Hz 9.6.2 Bilinear Transformation Design The impulse invariant technique suffers from aliasing due to the many-to-one mapping z D e st d. To correct this problem employ a one-to-one mapping from say s to s which compresses the entire s-plane into a strip. ECE 565/465 Modern DSP 9-53

CHAPTER 9. DIGITAL FILTER DESIGN jω jω jπ T d σ σ jπ T d s Plane s Plane Desired mapping from s to s to avoid aliasing The one-to-one mapping of interest is s D 2 T d tanh 1 std 2 Consider just the j axis for a moment D 2 T d tan 1 Td 2 π T d Ω π T d Ω Mapping from to Clearly the entire -axis has been compressed (warped) to fit the interval Œ =T d ; =T d 9-54 ECE 565/465 Modern DSP

9.6. THE DESIGN OF DISCRETE-TIME IIR FILTERS FROM ANALOG PROTOTYPES Note that for T d small the mapping is approximately linear, i.e. ; jj 1=T d The complete mapping from s to z is obtained by setting z D e s T d or s D 1 ln z T d s D 1 ln z D 2 tanh 1 std T d T d 2 or s D 2 ln z tanh D 2Td 1 e 2x ˇ T d 2 1 C e 2x ˇxD ln z 2 Finally we have the bilinear transform equations: s D 2 1 z 1 or z D 1 C T d 2 s T d 1 C z 1 T 1 d2 s Mapping properties: jω 2 T d Ω o σ Ω LHP to Interior Ω 2 T d Ω = Ω o = Ω = = Angle ω o s Plane unit circle z Plane Mapping from to The basic filter design equation is H.z/ D H c.s/j sd 2 1 z 1 Td 1Cz 1 ECE 565/465 Modern DSP 9-55

CHAPTER 9. DIGITAL FILTER DESIGN The discrete-time frequency variable must be! D T d with the frequency axis mappings being D 2 T d tan.!=2/ or! D 2 tan 1.T d =2/ π ω ω = 2atan( ΩT d 2) Ω π Mapping from to! Note: Lowpass designs such as the Butterworth and Chebyshev type I, which have N zeros at infinity in the s-plane, will have N zeros at z D 1 in the z-plane as a result of the bilinear mapping Frequency Warping The nonlinear transformation from to! is known as frequency warping The discrete-time frequency response is H.e j! / D H c.j /j D 2 Td tan.!=2/ 9-56 ECE 565/465 Modern DSP

9.6. THE DESIGN OF DISCRETE-TIME IIR FILTERS FROM ANALOG PROTOTYPES Ω Ω Ω = 2 ----- T tan ω --- d 2 H c ( jω ) Ω p Ω s π ω H e jω ( ) ω p ω s π ω Frequency axis warping (compression) of a continuoustime lowpass filter into a discrete-time filter In a practical design in order to preserve the desired discretetime critical frequencies such as! p and! s, the corresponding continuous-time frequencies p and s must be pre-warped using i D 2!i tan T d 2 Note that the frequency axis compression can make the transition ratio! s =! p less than s = p. The net result being that ECE 565/465 Modern DSP 9-57

CHAPTER 9. DIGITAL FILTER DESIGN the actual filter order N may be less than that needed for a pure continuous-time design. Bilinear Transformation Design Steps 1. Given discrete-time amplitude specifications, corresponding critical frequencies, and the sampling spacing T d, we first design a corresponding continuous-time filter, H c.s/, using pre-warped critical frequencies p D 2 T d tan!p 2 ; s D 2 tan T d!s Note: For convenience T d may be set to unity since upon transforming H c.s/ back to H.z/ it will cancel out. The first step in finding H c.s/ is to determine N and any other needed parameters. 2. Map the H c.s/ design to H.z/ using the bilinear transform, that is set 2 1 z 1 H.z/ D H c T d 1 C z 1 Important Simplifications for step 2: The algebraic substitution of 2 T d 1 z 1 1Cz 1 for every s in H c.s/ is tedious Consider developing a general formula for calculating the z-plane poles and zeros directly from the s-plane poles and zeros 9-58 ECE 565/465 Modern DSP 2

9.6. THE DESIGN OF DISCRETE-TIME IIR FILTERS FROM ANALOG PROTOTYPES In general H c.s/ D K ƒ Gain Factor Q Mc md1.s m/ Q N kd1.s s k/ Finite poles and zeros in the s-plane map to finite poles and zeros in the z-plane, while zeros at infinity in the s- plane map to zeros at z D 1 in the z-plane, thus H.z/ D b o.1 C z 1 / N M c Q Mc md1.1 z mz 1 / Q N kd1.1 p kz 1 / where b o is a new gain factor From the bilinear transformation z m D 1 C T d 2 m ; T 1 d2 m p k D 1 C Td 2 s k 1 T d2 s k Note: m ; s k ; z m, and p k are in general complex. The gain factor b o is used to equate the filter gains at some prescribed frequency. For lowpass filters match the dc gains (i.e. set H.1/ D H c./). Example 9.1: A Bilinear Lowpass Design Design a discrete-time lowpass filter to satisfy the following amplitude specifications: db D 3:1 db, A s D 15 db,! p D :5, and! s D :75. Assume a monotonic passband and stopband is desired. Assume 1=T d D f s D 2 khz. The prewarped critical frequencies are: p D 2 2 tan.:5=2/ D 4rad/s ECE 565/465 Modern DSP 9-59

CHAPTER 9. DIGITAL FILTER DESIGN s D 2 2 tan.:75=2/ D 9657rad/s Note:! s =! p D 1:5 < s = p D 2:414 as expected Since both the passband and stopband are required to be monotonic, a Butterworth approximation will be used 2 h i 3 1 log 3:1=1 1 1 1 N D 15=1 1 2 log 6 1.4=9657/ 7 D d1:9412e D 2 From the Butterworth design tables we can immediately write 1 H c.s/ D s 2 C p ˇ 2s C 1 ˇsD s 4 Now find H.z/ by first noting that M c D, N D 2, and s k D 4e j135ı ; k D 1; 2 Using the pole/zero mapping formulas p 1 D 1 C 1 1 4 s 1 1 4 s 1 D 1 C ej135ı 1 e j135ı D :414e j 9ı We can now write p 2 D 1 C e j135ı 1 e j135ı D :414e j 9ı D p 1 H.z/ D b o.1 C z 1 / 2 1.1 p 1 z 1 /.1 p 1 z 1 / 9-6 ECE 565/465 Modern DSP

9.6. THE DESIGN OF DISCRETE-TIME IIR FILTERS FROM ANALOG PROTOTYPES Find b o by setting H.1/ D H c./ 1 D b o.1 C 1/ 2.1 p 1 /.1 p 1 / D 4b o 1 C jp 1 j 2 or b o D 1 C :4142 4 D :293 Finally after multiplying out the numerator and denominator we obtain H.z/ D 1 C 2z 1 C z 2 3:4142 C :5857z 2 MATLAB Bilinear Filter Analysis We can use MATLAB to complete the analysis of the above filter design by computing the pole-zero plot, the frequency response magnitude in db, and the group delay >> zplane([1 2 1],[3.412.5857]) >> [H,F] = freqz([1 2 1],[3.412.5857],512,1); >> plot(f,2*log1(abs(h))) >> grid >> axis([.5-2 ]) >> [Hg,F] = grpdelay([1 2 1],[3.412.5857],512,1); >> plot(f,hg) >> grid >> axis([.5 1.5]) ECE 565/465 Modern DSP 9-61

CHAPTER 9. DIGITAL FILTER DESIGN 1 Imaginary Part.5.5 2 1 1.5.5 1 Real Part Pole-zero map from MATLAB analysis N = 2 Lowpass Bilinear Butterworth Frequency Response in db -2-4 -6-8 -1-12 -14-16 -18-2.5.1.15.2.25.3.35.4.45.5 f = 2 3dB 15dB Magnitude response in db from MATLAB analysis 9-62 ECE 565/465 Modern DSP

9.6. THE DESIGN OF DISCRETE-TIME IIR FILTERS FROM ANALOG PROTOTYPES 1.5 N = 2 Lowpass Bilinear Butterworth Group Delay in Samples 1.5.5.1.15.2.25.3.35.4.45.5 f = 2 Group delay in samples from MATLAB analysis MATLAB Bilinear Filter Design In MATLAB a complete bilinear filter synthesis, for a specific analog prototype, can be done in one step We simply use the filter design functions, in this case since we desire a Butterworth design we use butterord and butter >> % In a digital design the critical frequencies are >> % entered as w/pi, i.e., they lie on the interval >> % (,1). >> [n,wn] = buttord(.5,.75,3.1,15) >> n = 2 >> Wn =.583 >> [b,a] = butter(n,wn) ECE 565/465 Modern DSP 9-63

CHAPTER 9. DIGITAL FILTER DESIGN b =.35.611.35 a = 1..34.1717 >> zplane(b,a) >> [H,F] = freqz(b,a,512,1); >> plot(f,2*log1(abs(h))) >> grid >> axis([.5-2 ]) >> [Hg,F] = grpdelay(b,a,512,1); >> plot(f,hg) >> grid >> axis([.5 1.5]) 1 Imaginary Part.5.5 2 Poles just the left of the imaginary axis 1 1.5.5 1 Real Part Pole-zero map from the MATLAB design 9-64 ECE 565/465 Modern DSP

9.6. THE DESIGN OF DISCRETE-TIME IIR FILTERS FROM ANALOG PROTOTYPES N = 2 Lowpass Bilinear Butterworth Frequency Response in db -2-4 -6-8 -1-12 -14-16 Different than Hand Calc. 3dB 15dB -18-2.5.1.15.2.25.3.35.4.45.5 f = 2 Magnitude response in db from the MATLAB design Note that the hand calculation and the MATLAB design get slightly different results In the MATLAB design the filter cutoff frequency! c is not simply set to! s, but rather to a value slightly higher so as to meet or exceed both the passband and stopband requirements The poles in this case do not lie exactly on the imaginary axis, but slightly to the left ECE 565/465 Modern DSP 9-65

CHAPTER 9. DIGITAL FILTER DESIGN Example 9.11: Rework of Ex 9.8 with Bilinear Transform In the original example we started from am s-domain specification :5.s C 4/ H c.s/ D.s C 1/.s C 2/ A z-domain equivalent of this system function can be designed using the bilinear transform Since the bilinear transform warps the frequency axis we must specify an analog vs digital mathching frequency as well as the sampling frequency For this example we will choose f s D 1 Hz and the transformation invariant matching frequency to be 1 Hz The key function from MATLAB that design the bilinear transform filter for a given s-domain description is bilinear To use bilinear we load in the numerator and denominator s-domain polynomials followed by the sampling frequency in Hz and the matching frequency in Hz >> as = conv([1 1],[1 2]) as = 1 3 2 >> bs =.5*[1 4]; >> [bz,az] = bilinear(bs,as,1,1) bz =.269.92 -.177 az = 9-66 ECE 565/465 Modern DSP

9.6. THE DESIGN OF DISCRETE-TIME IIR FILTERS FROM ANALOG PROTOTYPES 1. -1.7142.7326 >> [Hc,wc] = freqs(bs,as); >> [H1,F1] = freqz(bz,az,512,'whole',1); >> plot(wc/(2*pi),2*log1(abs(hc))) >> grid >> hold Current plot held >> plot(f1,2*log1(abs(h1)),'r') >> axis([ 8-4 ]) j Frequency Response:H c j vs H e with fs = 1Hz -5 Frequency Response in db -1-15 -2-25 -3-35 Match Frequency Bilinear Digital Analog -4 1 2 3 4 5 6 7 8 Frequency in Hz Folding Frequency Bilinear Digital Magnitude response in db of analog and bilinear digital design with f s D 1 Hz ECE 565/465 Modern DSP 9-67

CHAPTER 9. DIGITAL FILTER DESIGN 9.7 Frequency Transformations Of the classical filter design techniques discussed thus far all have produced lowpass designs. Ultimately a highpass, bandpass, or bandstop design may be desired. The appropriate frequency or spectral transformation on either a continuous-time or discrete-time lowpass filter is used to yield the desired filter. Assuming that the desired end result is a discrete-time design, as the following figure indicates, one of two paths may be followed. Discrete-Time Specifications Design of an Equivalent Cont.-Time Lowpass Frequency Transform Lowpass to Desired Form Bilinear of Impulse Inv. Transform to Discrete- Time Equiv. Bilinear Transform to Discrete- Time Frequency Transform Lowpass to Desired Form The two procedures that may be followed to frequency transform a continuous-time lowpass filter to a discretetime filter. If a bilinear transformation is used then either a continuoustime or a discrete-time transformation may be used If the underlying design technique uses impulse invariance, then due to aliasing problems only a discrete-time transformation should be used 9-68 ECE 565/465 Modern DSP

9.7. FREQUENCY TRANSFORMATIONS 9.7.1 Continuous-Time Transformations In the following frequency transformations the lowpass filter is assumed to have a one rad/s cutoff frequency (i.e. p D 1). Lowpass Frequency Scaling: This transformation has been used already, but is repeated here for completeness. s! s p or s H desired.s/ D H c p 1 s s ------ p p 1 (normalized) p Lowpass to Lowpass Mapping Lowpass to Highpass: Assuming the desired cutoff frequency is p, the transformation is s! p s ECE 565/465 Modern DSP 9-69

CHAPTER 9. DIGITAL FILTER DESIGN or p H desired.s/ D H c s p + s ------ s 1 p 1 p (normalized) - Lowpass to Highpass Mapping Lowpass to Bandpass: Assuming the desired lower and upper cutoff frequency are respectively p1 and p2 the transformation is s! s2 C 2 c s b 9-7 ECE 565/465 Modern DSP

9.7. FREQUENCY TRANSFORMATIONS where c D p p1 p2 D center freq. b D p2 p1 D bandwidth 1 1 s 2 2 + c s ------------------ s b (normalized) p2 c p1 p1 c p2 Lowpass to Bandpass Mapping Lowpass to Bandstop: Assuming the desired lower and upper cutoff frequency are respectively p1 and p2 the transformation is s! s b s 2 C 2 c ECE 565/465 Modern DSP 9-71

CHAPTER 9. DIGITAL FILTER DESIGN where c D p p1 p2 D center freq. b D p2 p1 D bandwidth 1 1 s + + b s ------------------ s 2 p2 2 + c c p1 p1 - (normalized) - c p2 Lowpass to Bandstop Mapping Example 9.12: A Bandpass Bilinear Design Bandpass design using a continuous-time (analog) transformation followed by bilinear transformation to obtain H.z/. The desired amplitude specifications of an equivalent C/D-H.e j! /-D/C system with f s D 2 khz are: db D 1 db, A s D 2 db, f s1 D 2 Hz, f p1 D 5 Hz, f p2 D 2 khz, and f s2 D 45 khz. Design the filter using a Chebyshev type I approximation. 1 f s = 2 khz H e j db 2 1 2.5 1 225 2 5 2k 45k 2 f (Hz) 1 3 Bandpass amplitude specifications 9-72 ECE 565/465 Modern DSP

9.7. FREQUENCY TRANSFORMATIONS The design steps may be summarized as follows: 1. Map the digital bandpass specifications back to analog bandpass specifications using prewarping 2. Map the analog bandpass filter back to an analog lowpass prototype H c.s/ of order N 3. Transform H c.s/ using the analog lowpass to bandpass mapping 4. Transform H bp.s/ to H.z/ using the bilinear transform The discrete-time critical frequencies are:! s1 D 1 4 2,! p1 D 2:51 4 2,! p2 D :12, and! s2 D :2252 Find the equivalent prewarped continuous-time critical frequencies using 2f k D k D.2=T / tan.! k =2/ s1 D 125:66 rad/s; s2 D 341:63 krad/s p1 D 314:16 rad/s; p2 D 129:67 krad/s To determine the filter order N, we map the bandpass design back to the lowpass domain using s s 2 C 2 c s b In the lowpass domain we denote the two possible solutions for s as A, and B 2 s1 A D p1 p2 s1. p2 p1 / ; B D 2 s2 p1 p2 s1. p2 p1 / ECE 565/465 Modern DSP 9-73

CHAPTER 9. DIGITAL FILTER DESIGN To insure that both upper and lower stopband attenuation specifications are met let s D minfa; Bg From the specifications of the problem at hand A D 2:552; and B D 2:641; thus s D 2:552 Using the Chebyshev design formula for N N D d2:335e D 3 From the polynomial tables for 1 db ripple, H c.s/ D :4913 s 3 C :988s 2 C 1:238s C :491 To obtain the discrete-time design perform in sequence the following transformations: s! s2 C 2 c s b! 2 T 1 z 1 1 C z 1 MATLAB Bilinear Filter Analysis We can use MATLAB to complete the analysis of the above filter design by computing the frequency response magnitude in db 9-74 ECE 565/465 Modern DSP

9.7. FREQUENCY TRANSFORMATIONS >> F = logspace(1,5,5); >> f = F/2; >> % Inverse map z to s >> s1 = (1-exp(-j*2*pi*f))./(1+exp(-j*2*pi*f)); >> % Inverse map bandpass s to lowpass s >> s = ((2*2*s1).^2 + wc^2)./(2*2*s1*wb); >> H =.4913./(s.^3 +.988*s.^2 + 1.238*s +.491); >> semilogx(f,2*log1(abs(h))) >> axis([1 1-4 2]) >> grid H( e jω ) with f s = 2 khz -5 Frequency Response in db -1-15 -2-25 -3-35 -4 1 1 1 2 1 3 1 4 1 5 Frequency in Hz MATLAB Bilinear Filter Design In MATLAB a complete bilinear filter synthesis, for a specific analog prototype, can be done in one step We simply use the filter design functions, in this case since we desire a Chebyshev type I design we use cheb1ord and cheby1 ECE 565/465 Modern DSP 9-75

CHAPTER 9. DIGITAL FILTER DESIGN >> % In a digital design the critical frequencies are >> % entered as w/pi, i.e., they lie on the interval >> % (,1). >> [N,wn] = cheb1ord([5/1 2/1],... [2/1 45/1],1,2) N = 3 wn =.5.2 >> [b,a] = cheby1(n,1,wn) b =.114 -.342.342 -.114 a = 1. -5.1378 11.1842-13.266 9.712-3.3922.546 >> zplane(b,a) >> [H,F] = freqz(b,a,512,2); >> semilogx(f,2*log1(abs(h))) >> grid >> axis([1 1-4 ]) Imaginary Part 1.8.6.4.2.2.4.6.8 1 Upper Band Edge Poles 3 3 1.5.5 1 Real Part Imaginary Part.1.8.6.4.2.2.4.6.8 These Poles Zoom of Control Lower Lower Band Edge Band Pole-Zeros Edge.1.99.995 1 1.5 1.1 Real Part 3 z-domain pole-zero plot from MATLAB design 9-76 ECE 565/465 Modern DSP

9.7. FREQUENCY TRANSFORMATIONS H( e jω ) with f s = 2 khz Frequency Response in db -5-1 -15-2 -25-3 Results using Matlab Filter Design Functions -35-4 1 1 1 2 1 3 1 4 1 5 Frequency in Hz Magnitude response in db from MATLAB design The two set of results presented above appear to produce similar results The MATLAB design approach is simple to use and provides the complete filter solution, that is the difference equation coefficient vectors a and b ECE 565/465 Modern DSP 9-77

CHAPTER 9. DIGITAL FILTER DESIGN 9.8 Discrete-Time Transformations We desire a rational function Z 1 produce D G.z 1 / that can be used to H.z/ D H lp.z/ˇˇz 1 DG.z 1 / where Z is associated with the lowpass prototype and z is associated with the transformed filter. Since H lp.z/ and G.z 1 / are both rational, we must have: 1. G.z 1 / map the interior of the Z-plane into the interior of the z-plane 2. G.z 1 / map the unit circle of the Z-plane onto the unit circle of the z-plane A fundamental property of G.z 1 / can be observed by letting Z D e j and z D e j!, then e j must D jg.e j! /je j G.e j! / hence jg.e j! /j D 1 ) G.z 1 / is allpass The commonly referenced transformations published by Constantinides 4 are of the general form Z 1 D G.z 1 / D NY kd1 z 1 k 1 kz 1 4 A.G. Constantinides, Spectral Transformations for Digital Filters, Proc. IEE, Vol. 117, No. 8, pp. 1585-159, Aug. 197 9-78 ECE 565/465 Modern DSP

9.8. DISCRETE-TIME TRANSFORMATIONS Transformations From a Digital Lowpass with Cutoff Frequency p Filter Type Transformation Associated Design Formulas p! sin p 2 Filter Type Z 1 D z 1 D 1 z 1 sin Highpass Z 1 D z 1 1 z 1 D Bandpass Z 1 D z 2 2 k k 1 kc1 z 2 Bandstop Z 1 D z 2 2 k 1 k 1Ck z 2 kc1 z 1 C k 1 kc1 2 k kc1 z 1 C1 kc1 z 1 C 1 k 1Ck 2 k kc1 z 1 C1 p C! p 2! p D desired cutoff frequency p C! sin p 2 p sin! p 2! p D desired cutoff frequency!p2 C! sin p1 2 D sin! p2! p1 2!p2! p1 p k D cot tan 2 2! p1 D desired lower cutoff frequency! p2 D desired upper cutoff frequency!p2 C! sin p1 2 D sin! p2! p1 2!p2! p1 p k D cot tan 2 2! p1 D desired lower cutoff frequency! p2 D desired upper cutoff frequency Note that the discrete-time (digital) transformations can be performed directly by substituting G.z 1 / for each Z 1, or by calculating the new pole and zero locations by solving Z 1 k D G.z 1 k /; P 1 k D G.p 1 k / The new poles and zeros are p k and z k respectively. ECE 565/465 Modern DSP 9-79

CHAPTER 9. DIGITAL FILTER DESIGN 9.9 Design of Discrete-Time FIR Filters By definition the impulse response is of finite duration. In contrast to the IIR design techniques, most FIR design techniques originate from the desire to approximate the amplitude response of a discretetime system. Alternate names for FIR systems include: Nonrecursive filter Moving average filter Transversal filter Tapped delay line filter FIR advantages over IIR include: Can be designed to have exactly linear phase Since FIR filters are typically implemented with norecursive structures, they are inherently stable Quantization effects can be minimized more easily FIR disadvantages over IIR: A higher filter order is required to obtain the same amplitude response compared to a similar IIR design The higher filter order also implies higher computational complexity The higher order filter also implies greater memory requirements for storing coefficients 9-8 ECE 565/465 Modern DSP

9.9. DESIGN OF DISCRETE-TIME FIR FILTERS 9.9.1 Design Using Windowing Let the frequency response of the desired LTI system we wish to approximate be given by H d.e j! / D 1X nd 1 h d Œn e j!n where h d Œn is the corresponding impulse response. Consider obtaining a causal FIR filter that approximates h d Œn by letting ( hd Œn ; n M; hœn D ; otherwise The FIR filter then has frequency response H.e j! / D MX hœn e j!n nd Note that since we can write h d Œn D 1 2 Z H d.e j! /e j!n d! we are actually forming a finite Fourier series approximation to H d.e j! / Since the ideal H d.e j! / may contain discontinuities at the band edges, truncation of the Fourier series will result in the Gibbs phenomenon ECE 565/465 Modern DSP 9-81

CHAPTER 9. DIGITAL FILTER DESIGN To allow for a less abrupt Fourier series truncation and hence reduced Gibbs phenomenon oscillations, we may generalize hœn by writing hœn D h d Œn wœn where wœn is a finite duration window function of length M C 1 Special Case: Rectangular Window For this case wœn is simply unity over the window duration and due to the modulation theorem we can write H.e j! / D 1 2 Z H d.e j /W.e j.! / / d Suppose H d.e j! / is an ideal lowpass filter, then H.e j! / is a smeared version of the ideal response as shown on the following page 9-82 ECE 565/465 Modern DSP

9.9. DESIGN OF DISCRETE-TIME FIR FILTERS W e j H d e j (a) Circular convolution (windowing) H e j 2 2 (b) Resulting frequency response of windowed sinc(x) (a) Convolution of H d.e j! / with W.e j! /, (b) Resulting H.e j! / Use of the rectangular window results in peak overshoot of 9% in both the passband and stopband. Equivalently the peak passband ripple is.75 db and the peak stopband ripple is down only 21 db. To reduce the overshoot a tapered window such as those used in spectral analysis may be used. The tradeoff for reduced overshoot will be a wider transition band at the discontinuity due to W.e j! / having a wider main lobe. Imposing a Linear Phase Constraint In practice we would like hœn to be causal and have generalized linear phase. ECE 565/465 Modern DSP 9-83

CHAPTER 9. DIGITAL FILTER DESIGN As a first step in achieving this goal note that all the window functions discussed earlier are symmetrical about M=2, i.e. wœn D ( wœm n ; n M ; otherwise If the desired impulse response is either symmetric or antisymmetric about M=2 then the resulting frequency response will be H.e j! / D A e.e j! /e j!m=2 ; A e.e j! / real and even fctn. of! or H.e j! / D ja o.e j! /e j!m=2 ; A o.e j! / real and odd fctn. of! respectively Note that the symmetric case leads to type I or II generalized linear phase, while the antisymmetric case leads to type III or IV generalized linear phase For hœn symmetric about M=2 we can write magnitude response, A e.e j! /, as A e.e j! / D 1 2 Z H e.e j /W e.e j.! / / d where H e.e j! / and W e.e j! / are real functions corresponding to the magnitude responses of the desired filter frequency response and window function frequency response respectively 9-84 ECE 565/465 Modern DSP

9.9. DESIGN OF DISCRETE-TIME FIR FILTERS 9.9.2 Lowpass Filter Design Design an FIR lowpass filter using H d.e j! / D ( e j!m=2 ; j!j <! c ; otherwise Inverse Fourier transforming we find that h d Œn D sinœ! c.n.n M=2/ M=2/ Assuming wœn is symmetric about M=2, then the linear phase hœn is hœn D sinœ! c.n M=2/ wœn.n M=2/ The relevant lowpass amplitude specifications of interest are shown below 1 + 1 1 H e j p c s Note that the stopband attenuation in db is A s D 2 log 1 ı, and the paek ripple in db is db D 2 log 1.1 C ı/ ECE 565/465 Modern DSP 9-85

CHAPTER 9. DIGITAL FILTER DESIGN For the Rectangular, Bartlett, Hanning, Hamming, and Blackman window functions the relevant design data is given in the following table: Window Characteristics for FIR Filter Design Window Transition Minimum Equivalent Type Bandwidth Stopband Kaiser Window! Atten., A s ˇ Rectangular 1:81=M 21 db Bartlett 1:8=M 25 db 1.33 Hanning 5:1=M 44 db 3.86 Hamming 6:27=M 53 db 4.86 Blackman 9:19=M 74 db 7.4 General Design Steps: 1. Choose the window function, wœn, that just meets the stopband requirements as given in the table above. 2. Choose the filter length, M, (actual length is M C 1) such that!! s! p 3. Choose! c in the truncated impulse response such that! c D! p C! s 2 4. Plot jh.e j! /j to see if the specifications are satisfied. 5. Adjust! c and M if necessary to meet the requirements. If possible reduce M. Note: This is a Trial and Error technique unless one chooses to use a Kaiser window (see below). 9-86 ECE 565/465 Modern DSP

9.9. DESIGN OF DISCRETE-TIME FIR FILTERS Kaiser Window Method: 1. Let wœn be a Kaiser window i.e. wœn D ( I Œˇ.1 Œ.n /= 2 / 1=2 I ;.ˇ/ n M; ; otherwise where D M=2. 2. Choose ˇ for the specified A s as 8 ˆ< :112.A s 8:7/; A s > 5 ˇ D :5842.A s 21/ :4 C :7886.A s 21/; 21 A s 5 ˆ: :; A s < 21 3. The window length M is then chosen to satisfy M D A s 8 2:285! 4. The value for! c is chosen as before. Note: Using the Kaiser empirical formulas M can be determined over a wide range of! and A s values to within 2. Very little if any iteration is needed. Example 9.13: FIR Lowpass Design an FIR lowpass using the windowing method such that! p D :4,! s D :6, and ı D :32 (A s D 5 db). From the window characteristics table we immediately see that for A s = 5 a Hamming window will work ECE 565/465 Modern DSP 9-87

CHAPTER 9. DIGITAL FILTER DESIGN To find M set or! D :1 6:27 M M d31:35e D 32 The cutoff frequency is! c D :2 C :3 2 2 D :25 2 If a Kaiser window is desired, then for ˇ choose ˇ D :5842.5 21/ :4 C :7886.5 21/ D 4:5335 The prescribed value for M should be 5 8 M D D d29:25e D 3 2:285.:2/ Verification of these designs can be accomplished using the MATLAB filter design function fir1() >> % Hamming window design >> % (note fir1 uses hamming by default) >> b = fir1(32,2*.25,hamming(32+1)); >> stem(:length(b)-1,b) >> grid >> zplane(b,1) >> [H,F] = freqz(b,1,512,1); >> plot(f,2*log1(abs(h))) >> axis([.5-7 2]) >> grid >> % Kasier window design >> bk = fir1(3,2*.25,kaiser(3+1,4.5335)); >> [Hk,F] = freqz(bk,1,512,1); 9-88 ECE 565/465 Modern DSP

9.9. DESIGN OF DISCRETE-TIME FIR FILTERS >> plot(f,2*log1(abs(hk))) >> axis([.5-7 2]) >> grid.5.4 M 32 = c =.25 2 h n.3.2.1.1 5 1 15 2 25 3 Sample Index n M D 32, Hamming window, impulse response Imaginary Part 1.5.5 1 32 1.5.5 1 1.5 Real Part Note: There are few misplaced zeros in this plot due to MATLAB s problem finding the roots of a large polynomial. Note: The many zero quadruplets that appear in this linear phase design. M D 32, Hamming window, pole-zero plot ECE 565/465 Modern DSP 9-89

CHAPTER 9. DIGITAL FILTER DESIGN Frequency Response in db -1-2 -3-4 -5-6 M = 32 Hamming Window FIR c =.25 2.6 s = Should be -5 db -7.5.1.15.2.25.3.35.4.45.5 Frequency ----- 2 M D 32, Hamming window, frequency response Frequency Response in db -1-2 -3-4 -5-6 M = 3 Kaiser Window FIR c =.25 2.6 s = = 4.5335 Meets Spec. of -5 db -7.5.1.15.2.25.3.35.4.45.5 Frequency ----- 2 M D 3, Kaiser window (ˇ D 4:5335), frequency response 9-9 ECE 565/465 Modern DSP

9.1. APPENDIX: MATLAB S-DOMAIN AND Z-DOMAIN FILTER DESIGN FUNCTIONS 9.1 Appendix: MATLAB s-domain and z-domain Filter Design Functions 9.1.1 Introduction The intent of this appendix is to introduce some of the MATLAB functions that are useful for filter design. These functions are contained in the MATLAB signal processing toolbox. Many of them are also contained in the signals and systems toolbox of the old Prentice- Hall student edition of MATLAB. 9.1.2 Some Functions The following function list is a subset of the functions contained in the MATLAB signal processing toolbox version 4.3, June 1999. The functions included here are those of most relevance to the current topics in the lecture notes. The function groupings match those of the toolbox manual. y = filter(b,a,x) [H,w] = freqs(b,a) [H,w] = freqz(b,a) [Gpd,w] = grpdelay(b,a) h = impz(b,a) unwrap() zplane(b,a) Filter Analysis/Implementation Direct form II filter vector x s-domain frequency response computation z-domain frequency response computation Group delay computation Impulse response computation Phase unwrapping Plotting of the z-plane pole/zero map ECE 565/465 Modern DSP 9-91

CHAPTER 9. DIGITAL FILTER DESIGN Linear System Transformations residuez() z-domain partial fraction conversion tf2zp() Transfer function to zero-pole conversion zp2sos() Zero-pole to second-order biquadratic sections conversion [b,a] = besself(n,wn) [b,a] = butter (n,wn,`ftype',`s') [b,a] = cheby1 (n,rp,wn,`ftype',`s') [b,a] = cheby2 (n,rs,wn,`ftype',`s') [b,a] = ellip(n,rp,rs,wn, `ftype',`s') IIR Filter Design Bessel analog filter design. Near constant group delay filters, but if transformed to a digital filter this property is lost Butterworth analog and digital filter designs. Use s for s-domain design. ftype is chooses bandpass, highpass or bandstop designs. Chebyshev type I analog and digital filter designs. Use s for s-domain design. ftype chooses bandpass, highpass or bandstop designs. Chebyshev type II analog and digital filter designs. Use s for s-domain design. ftype chooses bandpass, highpass or bandstop designs. Elliptic analog and digital filter designs. Use s for s-domain design. ftype chooses bandpass, highpass or bandstop designs. 9-92 ECE 565/465 Modern DSP

9.1. APPENDIX: MATLAB S-DOMAIN AND Z-DOMAIN FILTER DESIGN FUNCTIONS [n,wn] = buttord (Wp,Ws,Rp,Rs,`s') [n,wn] = cheb1ord (Wp,Ws,Rp,Rs,`s') [n,wn] = cheb2ord (Wp,Ws,Rp,Rs,`s') [n,wn] = ellipord (Wp,Ws,Rp,Rs,`s') IIR Filter Order Selection Butterworth analog and digital filter order selection. Use s for s-domain designs. Chebyshev type I analog and digital filter order selection. Use s for s- domain designs. Chebyshev type II analog and digital filter order selection. Use s for s- domain designs. Elliptic analog and digital filter order selection. Use ŚsŠ for s-domain designs. fir1() fir2() remez() remezord() FIR Filter Design Window-based FIR filter design with standard response. Window based FIR filter design with arbitrary response. Parks-McClellan optimal FIR filter design Parks-McClellan filter order estimation. ECE 565/465 Modern DSP 9-93

CHAPTER 9. DIGITAL FILTER DESIGN [bz,az] = bilinear (bs,as,fs,fp) [bz,az] = impinvar (bs,as,fs) Filter Discretization Maps s-domain transfer function to z-domain using the bilinear transformation. Fs is sampling rate in Hz. The optional parameter Fp, in Hz, is a matching frequency. Maps s-domain transfer function to z-domain using impulse invariance. Fs is sampling rate in Hz. 9.11 Appendix: Using MATLAB sptool for Filter Design The MATLAB signal processing toolbox contains a graphical user interface (GUI) application known as sptool, short for Signal Processing Tool. With the sptool environment there are windows for analyzing and manipulating signals, designing digital filters, and performing spectral analysis. Signals may be imported and exported from sptool and filter designs can be exported in a data structure format which will be described below. In this appendix we are concerned primarily with the filter design capabilities of sptool. To start sptool simply type sptool at the MATLAB prompt. The window that opens is the main window which shows the current signals, filters, and spectra loaded into the sptool environment. 9-94 ECE 565/465 Modern DSP

9.11. APPENDIX: USING MATLAB SPTOOL FOR FILTER DESIGN New Design SPTool startup dialog showing predefined signal, filter, and spectra ECE 565/465 Modern DSP 9-95

CHAPTER 9. DIGITAL FILTER DESIGN 9.11.1 A Chebyshev Type II Bandpass Design Starting with a sampling rate of F s D 1; Hz we set out to design a bandpass filter with the specifications. By choosing the button New Design under the filters heading in the SPTool main dialog, we obtain the Filter Designer dialog as shown below. The filter design dialog configured for a type II Chebyshev bandpass design Once a design has been created we can return to the main dialog and choose View to open the Filter Viewer dialog as shown in the following figure. 9-96 ECE 565/465 Modern DSP

9.11. APPENDIX: USING MATLAB SPTOOL FOR FILTER DESIGN The filter viewer dialog configured to show the magnitude response in db and the pole-zero plot The filter design we have just created is stored locally to sptool in the data structure filt1 The filter data structure can be exported to the MATLAB workspace by using the Export option under the menu File in the sptool main dialog window The expansion of the data structure contents is given in the following listing from the command window of MATLAB Note that not all of the elements are filled, simply because windows displaying that particular plot type were never requested when using the Filter Viewer ECE 565/465 Modern DSP 9-97

CHAPTER 9. DIGITAL FILTER DESIGN >> % Data structure passed out of sptool >> filt1 filt1 = tf: [1x1 struct] ss: [] zpk: [1x1 struct] sos: [] imp: [331x1 double] step: [] t: [331x1 double] H: [1x248 double] G: [1x248 double] f: [1x248 double] specs: [1x1 struct] Fs: 1 type: 'design' lineinfo: [1x1 struct] SPTIdentifier: [1x1 struct] label: 'filt1' >> % Getting access to the transfer function element >> filt1.tf ans = num: [1x17 double] den: [1x17 double] >> % Getting access to the numerator coefficients >> filt1.tf.num ans = Columns 1 through 6 7.3772e-3-4.3836e-2 1.343e-1-2.6554e-1 4.1999e-1-5.4723e-1 Columns 7 through 12 6.1629e-1-6.3818e-1 6.4144e-1-6.3818e-1 6.1629e-1-5.4723e-1 Columns 13 through 17 4.1999e-1-2.6554e-1 1.343e-1-4.3836e-2 7.3772e-3 9-98 ECE 565/465 Modern DSP

9.11. APPENDIX: USING MATLAB SPTOOL FOR FILTER DESIGN >> % Getting access to the denominator coefficients >> filt1.tf.den ans = Columns 1 through 6 1.e+ -7.6586e+ 3.264e+1-8.426e+1 1.5955e+2-2.491e+2 Columns 7 through 12 3.1538e+2-3.2944e+2 2.8649e+2-2.795e+2 1.256e+2-6.2522e+1 Columns 13 through 17 2.524e+1-7.983e+ 1.8856e+ -2.9976e-1 2.4771e-2 9.11.2 A Windowed FIR Design Again starting with a sampling rate of F s D 1; Hz we set out to design an FIR lowpass filter using a Kaiser window. The design tool allows all of the parameters to be varied by filling in quantities in the dialog box as well as dragging the filter gain and critical frequencies around. ECE 565/465 Modern DSP 9-99

CHAPTER 9. DIGITAL FILTER DESIGN Stopband Gain Dragged into Position The filter designer configured for a Kaiser window lowpass design Uisng the Filter Viewer we now plot the magnitude response in db and the impulse response. 9-1 ECE 565/465 Modern DSP

9.11. APPENDIX: USING MATLAB SPTOOL FOR FILTER DESIGN Filter characteristics displayed in the Filter Viewer >> % Data structure passed out of sptool >> filt2.tf.num ans = Columns 1 through 6 3.12e-4 1.6934e-4-2.3616e-4-8.2882e-4-1.3339e-3-1.3738e-3 Columns 7 through 12-6.564e-4 8.81e-4 2.5737e-3 3.8295e-3 3.6959e-3 1.671e-3 Columns 13 through 18-1.9648e-3-6.141e-3-8.6494e-3-8.197e-3-3.5787e-3 4.1252e-3 Columns 19 through 24 1.2432e-2 1.7683e-2 1.6476e-2 7.2632e-3-8.4152e-3-2.5681e-2 ECE 565/465 Modern DSP 9-11