Design of Digital Filters



Similar documents
Cooley-Tukey. Tukey FFT Algorithms. FFT Algorithms. Cooley

CHAPTER 3 DIGITAL CODING OF SIGNALS

Soving Recurrence Relations

Escola Federal de Engenharia de Itajubá

Sequences and Series

Trigonometric Form of a Complex Number. The Complex Plane. axis. ( 2, 1) or 2 i FIGURE The absolute value of the complex number z a bi is

Properties of MLE: consistency, asymptotic normality. Fisher information.

In nite Sequences. Dr. Philippe B. Laval Kennesaw State University. October 9, 2008

SAMPLE QUESTIONS FOR FINAL EXAM. (1) (2) (3) (4) Find the following using the definition of the Riemann integral: (2x + 1)dx

The Binomial Multi- Section Transformer

CS103A Handout 23 Winter 2002 February 22, 2002 Solving Recurrence Relations

THE REGRESSION MODEL IN MATRIX FORM. For simple linear regression, meaning one predictor, the model is. for i = 1, 2, 3,, n

Asymptotic Growth of Functions

Chapter 6: Variance, the law of large numbers and the Monte-Carlo method

Here are a couple of warnings to my students who may be here to get a copy of what happened on a day that you missed.

Incremental calculation of weighted mean and variance

Example 2 Find the square root of 0. The only square root of 0 is 0 (since 0 is not positive or negative, so those choices don t exist here).

I. Chi-squared Distributions

.04. This means $1000 is multiplied by 1.02 five times, once for each of the remaining sixmonth

THE ARITHMETIC OF INTEGERS. - multiplication, exponentiation, division, addition, and subtraction

Lesson 17 Pearson s Correlation Coefficient

5: Introduction to Estimation

Your organization has a Class B IP address of Before you implement subnetting, the Network ID and Host ID are divided as follows:

A Combined Continuous/Binary Genetic Algorithm for Microstrip Antenna Design

INVESTMENT PERFORMANCE COUNCIL (IPC)

CS103X: Discrete Structures Homework 4 Solutions

Chapter 7 Methods of Finding Estimators


Domain 1: Designing a SQL Server Instance and a Database Solution

Confidence Intervals for One Mean

CHAPTER 3 THE TIME VALUE OF MONEY

Output Analysis (2, Chapters 10 &11 Law)

5 Boolean Decision Trees (February 11)

1 Correlation and Regression Analysis

Lecture 13. Lecturer: Jonathan Kelner Scribe: Jonathan Pines (2009)

SECTION 1.5 : SUMMATION NOTATION + WORK WITH SEQUENCES

Approximating Area under a curve with rectangles. To find the area under a curve we approximate the area using rectangles and then use limits to find

1. MATHEMATICAL INDUCTION

Vladimir N. Burkov, Dmitri A. Novikov MODELS AND METHODS OF MULTIPROJECTS MANAGEMENT

Convexity, Inequalities, and Norms

7.1 Finding Rational Solutions of Polynomial Equations

Lecture 4: Cauchy sequences, Bolzano-Weierstrass, and the Squeeze theorem

2-3 The Remainder and Factor Theorems

Infinite Sequences and Series

where: T = number of years of cash flow in investment's life n = the year in which the cash flow X n i = IRR = the internal rate of return

Modified Line Search Method for Global Optimization

Section 11.3: The Integral Test

Theorems About Power Series

Systems Design Project: Indoor Location of Wireless Devices

Building Blocks Problem Related to Harmonic Series

Running Time ( 3.1) Analysis of Algorithms. Experimental Studies ( 3.1.1) Limitations of Experiments. Pseudocode ( 3.1.2) Theoretical Analysis

Overview of some probability distributions.

FOUNDATIONS OF MATHEMATICS AND PRE-CALCULUS GRADE 10

CME 302: NUMERICAL LINEAR ALGEBRA FALL 2005/06 LECTURE 8

Case Study. Normal and t Distributions. Density Plot. Normal Distributions

Class Meeting # 16: The Fourier Transform on R n

INFINITE SERIES KEITH CONRAD

Normal Distribution.

Basic Measurement Issues. Sampling Theory and Analog-to-Digital Conversion

Tradigms of Astundithi and Toyota

Determining the sample size

Domain 1 - Describe Cisco VoIP Implementations

Week 3 Conditional probabilities, Bayes formula, WEEK 3 page 1 Expected value of a random variable

Lecture 5: Span, linear independence, bases, and dimension

Measures of Spread and Boxplots Discrete Math, Section 9.4

Hypothesis testing. Null and alternative hypotheses

3. If x and y are real numbers, what is the simplified radical form

APPLICATION NOTE 30 DFT or FFT? A Comparison of Fourier Transform Techniques

Analyzing Longitudinal Data from Complex Surveys Using SUDAAN

Factoring x n 1: cyclotomic and Aurifeuillian polynomials Paul Garrett <garrett@math.umn.edu>

Chapter 5 Unit 1. IET 350 Engineering Economics. Learning Objectives Chapter 5. Learning Objectives Unit 1. Annual Amount and Gradient Functions

NEW HIGH PERFORMANCE COMPUTATIONAL METHODS FOR MORTGAGES AND ANNUITIES. Yuri Shestopaloff,

1. C. The formula for the confidence interval for a population mean is: x t, which was

Department of Computer Science, University of Otago

S. Tanny MAT 344 Spring be the minimum number of moves required.

Basic Elements of Arithmetic Sequences and Series

Maximum Likelihood Estimators.

Chapter 5: Inner Product Spaces

Design of Cross-talk Cancellation Networks by using Fast Deconvolution

Discrete Mathematics and Probability Theory Spring 2014 Anant Sahai Note 13

1 Computing the Standard Deviation of Sample Means

Notes on exponential generating functions and structures.

WHEN IS THE (CO)SINE OF A RATIONAL ANGLE EQUAL TO A RATIONAL NUMBER?

Finding the circle that best fits a set of points

Present Value Factor To bring one dollar in the future back to present, one uses the Present Value Factor (PVF): Concept 9: Present Value

Convention Paper 6764

GCSE STATISTICS. 4) How to calculate the range: The difference between the biggest number and the smallest number.

3. Greatest Common Divisor - Least Common Multiple

AP Calculus AB 2006 Scoring Guidelines Form B

Chapter 7 - Sampling Distributions. 1 Introduction. What is statistics? It consist of three major areas:

Lesson 15 ANOVA (analysis of variance)

Cantilever Beam Experiment

Partial Di erential Equations

GCE Further Mathematics (6360) Further Pure Unit 2 (MFP2) Textbook. Version: 1.4

5.4 Amortization. Question 1: How do you find the present value of an annuity? Question 2: How is a loan amortized?

Time Value of Money. First some technical stuff. HP10B II users

Hypergeometric Distributions

Fast Fourier Transform and MATLAB Implementation

Repeating Decimals are decimal numbers that have number(s) after the decimal point that repeat in a pattern.

Fast Fourier Transform

Transcription:

Chapter 8 Desig of Digital Filters Cotets Overview........................................................ 8. Geeral Cosideratios................................................. 8. Desig of FIR Filters.................................................. 8.4 Desig of liear-phase FIR filters usig widows.................................... 8.7 Time-delay i desired respose............................................. 8.9 Sidelobes........................................................ 8. Hilbert trasform (9 phase shift)........................................... 8. Desig of FIR filters by frequecy samplig...................................... 8. Optimum equiripple liear-phase FIR filters..................................... 8.4 Compariso of FIR methods............................................... 8.7 Desig of IIR Filters from Aalog Filters........................................ 8.8 IIR filter desig by biliear trasformatio....................................... 8.9 Frequecy Trasformatios............................................... 8.4 Desig of Digital Filters Based o Least-Squares Method............................... 8.4 Summary........................................................ 8.4 8.

8. c J. Fessler, May 7, 4, 3:8 (studet versio) So far our treatmet of DSP has focused primarily o the aalysis of discrete-time systems. Now we fially have the aalytical tools to begi to desig discrete-time systems. All LTI systems ca be thought of as filters, so, at least for LTI systems, to desig a system meas to desig a digital filter. (The desig of oliear or time-varyig systems is geerally more complicated, ad ofte more case specific.) Goal: give desired magitude respose H d () phase respose H d () tolerace specificatios (how far from ideal?), we wat to choose the filter parameters N, M, {a k }, {b k } such that the system fuctio H(z) = where a =, yields a frequecy respose H() H d (). M k= b kz N k= a kz = g i(z z i) j (z p j), Ratioal H(z), so LTI system described by a costat-coefficiet differece equatio, so ca be implemeted with fiite # of adds, multiplies, ad delays. I other words, filter desig meas choosig the umber ad locatios of the zeros ad poles, or equivaletly the umber ad values of the filter coefficiets, ad thus H(z), h[], H(). Overview N =, FIR or all-zero. liear passbad phase. N >, IIR. lower sidelobes for same umber of coefficiets. 8. Geeral Cosideratios Ideally would like N ad M or N + M to be as small as possible for miimal computatio / storage. Causal (for ow) Poles iside uit circle for stability 8.. Causality We will focus o desigig causal digital filters, sice those ca be implemeted i real time. Nocausal filter desig (e.g., for off-lie applicatios) is much easier ad may of the same priciples apply ayway. A LTI system is causal iff iput/output relatioship: y[] depeds oly o curret ad past iput sigal values. impulse respose: h[] = for < system fuctio: umber of fiite zeros umber of fiite poles frequecy respose: What ca we say about H()? Fact: if h[] is causal, the Paley-Wieer Theorem: H() caot be exactly zero over ay bad of frequecies. (Except i the trivial case where h[] =.) Furthermore, H() caot be flat (costat) over ay fiite bad. H R () ad H I () are Hilbert trasform pairs. Therefore they are ot idepedet. Hece magitude ad phase respose are iterdepedet. Thus those ideal filters with fiite bads of zero respose caot be implemeted with a causal filter. Istead, we must desig filters that approximate the desired frequecy respose H d ().

c J. Fessler, May 7, 4, 3:8 (studet versio) 8.3 8.. Characteristics of practical frequecy-selective filters No perfectly flat regios Fact: sice causal filters caot have a bad of frequecies with zero respose, or ca they have ay bad of frequecies over which the frequecy respose is a costat. Proof by cotradictio. Suppose H() = c for, with correspodig impulse respose h[]. Now defie a ew filter g[] = h[] c δ[]. The certaily g[] is also causal. But G() = H() c = for, which is impossible if g[] is causal. Causal filters caot have a bad of frequecies with zero respose. Nor ca they have a ifiitely sharp trasitio betwee the passbad ad the stopbad. Nor ca they have perfectly flat passbad. So a typical realistic magitude respose looks like the followig. H() + δ δ Passbad Ripple PSfrag replacemets Passbad Trasitio Bad δ Stopbad Ripple Stopbad p s π Practical filter desig meas choosig δ, δ, c ad s, ad the desigig N, M, {a k }, {b k } to satisfy those requiremets. Ofte oe must iterate. Ofte we plot H() usig db, i.e., log H(), ad express the ripple i db as well. Note that stopbad ripple is ot defied peak-to-peak, sice the highest magitude respose i the stopbad is more importat tha how wiggly the respose is i the stopbad. Example applicatio: CD digital crossover Separate woofer ad tweeter sigals digitally iside CD player, rather i aalog at speaker. Why is passbad ripple tolerable i this cotext (distortio)? Room acoustics act as aother filter. Speaker respose is ot perfectly flat. Keep filter ripple below these other effects. Now imagie that we have specified δ, δ, c ad s, ad we wish to desig N, M, {a k }, {b k } to satisfy those requiremets. As metioed above, we have two broad choices: FIR ad IIR. We focus first o FIR.

8.4 c J. Fessler, May 7, 4, 3:8 (studet versio) 8. Desig of FIR Filters A FIR filter of legth M is a LTI system with the followig differece equatio : y[] = M k= b k x[ k]. Note that the book chages the role of M here. Earlier, whe discussig ratioal system fuctios, M was the umber of zeros. Now M is the umber of ozero elemets of h[], which correspods to at most M zeros. (More precisely, we assume b M ad b, but some of the coefficiets i betwee could be zero.) The problem: give δ, δ, c, ad s, we wish to choose M ad {b k } M k= to achieve that goal. We focus o liear-phase FIR filters, because if liear phase is ot eeded, the IIR is probably preferable ayway. We focus o lowpass filters, sice trasformatios ca be made to form highpass, badpass from lowpass, as discussed previously. Impulse respose Clearly for a FIR filter h[] = { b, =,..., M, otherwise. So rather tha writig everythig i terms of b k s, we write it directly i terms of the impulse respose h[]. I fact, for FIR filter desig we usually desig h[] directly, rather tha startig from a pole-zero plot. (A exceptio would be otch filters.) 8.. Symmetric ad atisymmetric FIR filters I focus o the symmetric case. System fuctio: H(z) = M = h[] z. How do we make a filter have liear phase? We previously aswered this i the pole-zero domai. Now we examie it i the time domai. A FIR filter has liear phase if h[] = h[m ], =,,..., M. Example. For M = 5: h[] = {b, b, b, b, b }. Such a FIR filter is called symmetric. Cautio: this is ot eve symmetry though i the sese we discussed previously. This is related, but ot exactly the same as circular symmetry. { } Example. For M = 3 ad h[] = /,, /. Does this filter have liear phase? Is it lowpass or highpass? H() = + e j + e j = e j [ ej + + e j ] = e j ( + cos ), so sice + cos, H() =, which is liear phase. So it works for this particular example, but why does the symmetry coditio esure liear phase i geeral? Cautio. At this poit the book switches from M k= to M k= apparetly. This icosistet with MATLAB, so there are M factors that appear frequetly i the MATLAB calls. I thik that MATLAB is cosistet ad the book makes a udesirable switch of covetio here.

c J. Fessler, May 7, 4, 3:8 (studet versio) 8.5 Symmetric real FIR filters, h[] = h[m ], =,..., M, are liear phase. Proof. Suppose M is eve: H(z) = = = = = M = M/ = M/ = M/ = M/ = h[] z h[] z + h[] z + h[] z + M =M/ M/ = M/ = h[] z ] h[] [z + z (M ) M/ = z (M )/ = Thus the frequecy respose is H() = H(z) z=e j M/ = e j(m )/ h[m ] z (M ) h[] z (M ) ] h[] [z (M )/ + z ((M )/ ) = M/ = e j(m )/ = = e j(m )/ H r () M/ [ ( M H r () = h[] cos Phase respose: = (split sum) ( = M ) (symmetry of h[]) (combie) (split phase). ] h[] [e j((m )/ ) + e j((m )/ ) [ ( )] M h[] cos { M H() =, H r () > M + π, H r () <. )]. (Real sice h[] is real.) The case for M odd is similar, ad leads to the same phase respose but with a slightly differet H r ().

8.6 c J. Fessler, May 7, 4, 3:8 (studet versio) I fact, the odd M case is eve easier by otig that h[ + (M )/] is a eve fuctio, so its DTFT is real, so the DTFT of h[] is e j(m )/ times a real fuctio. This proof does ot work for M eve sice the (M )/ is ot a iteger so we caot use the shift property. What about pole-zero plot? (We wat to be able to recogize FIR liear-phase filters from pole-zero plot.) From above, H(z) = z (M )/ M/ = h[] [ z (M )/ + z ((M )/ )] so H ( z ) = z (M )/ M/ = h[] [ z (M )/ + z ((M )/ )] = z M H(z). Thus H(z) = z (M ) H ( z ). So if q is a zero of H(z), the /q is also a zero of H(z). Furthermore, i the usual case where h[] is real, if q is a zero of H(z), the so is q. Example. Here are two pole-zero plots of such liear-phase filters. Im(z) Im(z) r r Re(z) 4 Re(z) What is differece betwee this ad all-pass filter? It was poles ad zeros i reciprocal relatioships for all-pass filter. Now we kow coditios for FIR filters to be liear phase. How do we desig oe? Delays I cotiuous time, the delay property of the Laplace trasform is x a (t τ) L e sτ X a (s). How do we build a circuit that delays a sigal? Sice e sτ is ot a ratioal fuctio, so it caot be implemeted exactly usig RLC circuits. So eve though a time delay system is a LTI system, we caot build it usig RLC compoets! We ca make a approximatio, e.g., which is ratioal i s, so we ca desig such a RLC circuit. e sτ sτ + s τ Or, we ca use more mechaical approaches to delay like a tape loop. Picture. write, read, erase head. delay / tape velocity. Aother approach is to rely o sigal propagatio time dow a log wire, ad tap ito the wire at various places for various delays. What about i discrete time? We just eed a digital latch or buffer (flip flops) to hold the bits represetig a digital sigal value util the ext time poit.

c J. Fessler, May 7, 4, 3:8 (studet versio) 8.7 8.. Desig of liear-phase FIR filters usig widows Perhaps the simplest approach to FIR filter desig is to take the ideal impulse respose h d [] ad trucate it, which meas multiplyig it by a rectagular widow, or more geerally, to multiply h d [] by some other widow fuctio, where h d [] = π H d () e j d. π π Typically h d [] will be ocausal or at least o-fir. {, c, Example. As show previously, if H d () =, otherwise, We ca create a FIR filter by widowig the ideal respose: ( = rect ) c the h d [] = c π sic ( c π ). h[] = w[] h d [] = where the widow fuctio w[] is ozero oly for =,..., M. What is the effect o the frequecy respose? W() = { hd [] w[], =,..., M, otherwise, M = w[] e j ad by time-domai multiplicatio property of DTFT, aka the widowig theorem: where π deotes π-periodic covolutio. H() = W() π H d () = π π π H d (λ) W( λ) dλ, (8-) I words, the ideal frequecy respose H d () is smeared out by the frequecy respose W() of the widow fuctio. What would the frequecy respose of the ideal widow be? W() = π δ() = impulse. Such a widow would cause o smearig of the ideal frequecy respose. However, the correspodig widow fuctio would be w[] =, which is ocausal ad o-fir. So i practice we must make tradeoffs. Example. rectagular widow. w[] = {, =,...,, otherwise, So by the shift property of the DTFT: h d [] = sic ( ( ) ) ad h[] = So the resultig frequecy respose is H() = e j [ + 4 π cos()]. Picture This is oly a 3-tap desig. Let us geeralize ext. k= with H d () = e j rect ( ) π, i.e., c = π/. { sic ( ( ),, sic π δ( πk), a Dirac ) } where sic ( ) = /π.64.

8.8 c J. Fessler, May 7, 4, 3:8 (studet versio) Example. rectagular widow. W() = M = w[] = {, =,..., M, otherwise, e j = = e j(m )/ W r (), where W r () = si(m/) si(/), M, =. I this case the ideal frequecy respose is smeared out by a sic-like fuctio, because W r () M sic ( M π ). The fuctio si(m/) M si(/) is available i MATLAB as the diric fuctio: the Dirichlet or periodic sic fuctio. How much is the ideal frequecy respose smeared out? The width of the mai lobe of W() is 4π/M, because the first zeros of W r () are at = ±π/m. As M icreases, width of mai lobe W() decreases, so arrower trasitio bad. Example. Here is the case c = π/4 for various values of M. Rectagular Widow Widow Respose Magitude Respose.8 w[].8.6.4 W r () / M.6.4. H().8.6.4.. π π. π π Rectagular Widow Widow Respose Magitude Respose.8 w[].8.6.4 W r () / M.6.4. H().8.6.4.. π π. π π How did I make these figures? Usig H = freqz(h,, om) sice b = h for causal FIR filters.

c J. Fessler, May 7, 4, 3:8 (studet versio) 8.9 Time-delay i desired respose The term e j(m )/ i W() above comes from the fact that the rectagular widow is ot cetered aroud =, but rather is time-shifted to be cetered aroud = (M )/. This phase term will cause additioal distortio of H d (), uless H d () is also phase-shifted to compesate. For a lowpass filter with cutoff c, widowed by a legth-m widow fuctio, the appropriate desired respose is: H d () = { e j(m )/, c,, otherwise, = H d () = {, c,, otherwise, so that This is illustrated below. Note that from (8-), H() = π π π H d (λ) W( λ) dλ = π h d [] = ( [ c π sic c M ]). π c e jλ(m )/ j( λ)(m )/ si(( λ) M/) e dλ c si(( λ) /) = e j(m )/ c si(( λ) M/) dλ. π c si(( λ) /) Thus there is a overall delay of (M )/ samples from such a legth-m causal FIR filter. Without the phase term, the covolutio itegral is severely affected Audio applicatio, F s = 44kHz ad say M = 45. The delay i samples is (M )/ =. The time delay is M T = /44kHz =.5msec. The speed of soud i air is about 33meters / secod, so 3.3 meters away takes about msec. Thus a.5msec delay is well withi the tolerable rage for audio. Ideal Frequecy Respose.3.5 Ideal Impulse Respose H d ().8.6.4. h d []..5..5....5... π π. Magitude Respose.3 Causal FIR Filter H().8.6.4. π π h[].5..5..5.5.. Magitude Respose.3 Causal FIR Filter.8.5..5 Shifted by (M )/ H().6 h[]..4..5.5 π π.

8. c J. Fessler, May 7, 4, 3:8 (studet versio) Sidelobes The rectagular widow has high sidelobes i W(), ad the sidelobe amplitude is relatively uaffected by M. Sidelobes cause large passbad ripple, related to Gibbs pheomea. Sidelobes caused by abrupt discotiuity at edge of widow. Solutio: use some other widow fuctio. Examples: Bartlett, Blackma, Haig, Hammig, Kaiser, Laczos, Tukey. MATLAB s widow fuctio has 6 choices! All have lower sidelobes tha rectagular, hece less passbad ripple. Tradeoff? Wider trasitio bad for the same M compared to rectagular widow. Example. Haig widow: w[] = ( ) π cos. M What is the frequecy respose W()? Somewhat messy. How do we plot W()? W = freqz(w,, om) which i tur uses the DFT/FFT with N M via zero paddig. Cautio: this is the ha fuctio i MATLAB, ot the haig fuctio! Rectagular Widow 3 Norm. Widow Respose w[].8.6.4 M=9 W() / W() (db) 3. 5 5 8 π π Haig Widow 3 Norm. Widow Respose w[].8.6.4 M=9 W() / W() (db) 3. 5 5 8 π π Hammig Widow 3 Norm. Widow Respose w[].8.6.4 M=7 W() / W() (db) 3. 5 5 8 π π As M icreases, mai lobe width decreases. As M icreases, some of the sidelobe amplitudes decrease, but peak sidelobe amplitude remais approximately costat. Agai, the price is eed larger M tha for rectagular widow for same trasitio width. The various widows tradeoff mai lobe width with peak sidelobe amplitude. Haig mai lobe width is 8π/M, but peak sidelobe is -3dB compared with -3dB for rectagular.

c J. Fessler, May 7, 4, 3:8 (studet versio) 8. Example. Suppose we wat a FIR filter desig of a lowpass filter with H d () = widow with M = 5. The the desired impulse respose is: h d [] = 4 sic ( 4 ( (M )/) ). {, < π/4, otherwise, desiged usig the Haig I MATLAB, here is how we compute ad display the impulse respose ad the frequecy respose. % fig_wi_example.m M = 5; = [:(M-)]; om = lispace(-pi, pi, ); % for displayig frequecy respose oc = pi/4; % cutoff frequecy % desired impulse respose: hd = ilie( oc/pi * sic(oc/pi*(-(m-)/)),, oc, M ); Hd = ilie( *(abs(om) < oc), om, oc ); h = hd(, oc, M).* ha(m) ; % Haig widow applied to ideal impulse resp. clf, subplot(3) stem(, h, filled ), stem_fix axis([ M- -.,.3]), xlabel, ylabel h[] title(spritf( Haig Lowpass, M=%d, M)) subplot(3) H = freqz(h,, om); plot(om, *log(abs(h)), -, om, *log(max(hd(om,oc),eps)), -- ) xlabel \omega, ylabel H(\omega) (db) title Magitude Respose axisy(-8, ), xaxis_pi -p p/4 p % savefig fig_wi_example.3 Haig Lowpass, M=5 Magitude Respose.5. h[].5..5 H() (db) 4 6.5. 5 8 π π/4 π If we are usatisfied with the width of the trasitio bad, or the sidelobe amplitude, or the passbad ripple, the what could we do? Icrease M, try other widow fuctios, ad/or try other filter desig methods. Filter desig by widowig i MATLAB The fir commad i MATLAB is its tool for widow-based FIR filter desig. I the precedig example, we could have simply typed h = fir(4,.5, ha(5), oscale ) to get exactly the same desig.

8. c J. Fessler, May 7, 4, 3:8 (studet versio) Example. Digital phaser or flage. Time varyig pole locatios i cascade of st ad d-order allpass filters, Sum output of allpass cascade with origial sigal, creatig time-varyig otches. 8..5 FIR differetiator H d () = j skim 8..6 Hilbert trasform (9 phase shift) H d () = j sg() skip 8..3 Desig of FIR filters by frequecy samplig For the frequecy samplig method of FIR filter desig, to desig a M-poit FIR filter we specify the desired frequecy respose at a set of equally-spaced frequecy locatios: H d (), k =,..., M. = π M k I other words, we provide equally spaced samples over [, π). Picture Recall from the DTFT formula that if h d [] is ozero oly for =,..., M, the Thus, at the give frequecy locatios, we have H d () = M = h d [] e j. ( ) M π H d M k = h d [] e j π M k, k =,..., M. = This is the formula for the M-poit DFT discussed i Ch. 5 (ad i EECS 6). So we ca determie h d [] from { ( H π d M k)} M by usig the iverse DFT formula (or h = ifft(h) i MATLAB): k= h d [] = M M k= ( ) π H d M k e j π M k. This will be the impulse respose of the FIR filter as desiged by the frequecy samplig method. If we wat( h d [] to be real, the H d () must be Hermitia symmetric, i.e., Hd () = H d( ) = H d (π ). So if we specify H π d M k) to be some value, we kow that Hd( π M k) ( = H d π π M k) ( = H π d M (M k)) (, so H π d M (M k)) is also specified. Thus, software such as MATLAB s fir commad oly requires ( H d () oly o the iterval [, π]. If h d [] is to be real, the it also follows that H d (π) = H π ) M d M must be real valued whe M is eve. If you choose H d () to be liear phase, the the desiged h[] will be liear phase. But you are ot required to choose H d () to be liear phase! The book discusses may further details, but the above big picture is sufficiet for this class.

c J. Fessler, May 7, 4, 3:8 (studet versio) 8.3 Example. The treble boost revisited. Double the amplitude of all frequecy compoets above c = π/. % fig_freq_sample.m Hd = ilie( exp(-i*om*(m-)/).* ( + (abs(om) > pi/)), om, M ); M = 9; ok = [:(M-)]/M * *pi; Hk = Hd(mod(ok+pi,*pi)-pi, M); % trick: [-pi,pi] specificatio of H(\omega) h = ifft(hk); h = reale(h, war ); % h = fir(m-, [.5.5 ], [ ], boxcar(m) ); om = lispace(-pi,pi,); clf, pl = 3; subplot(pl+), plot(om, abs(hd(om,m))) hold o, stem(ok(ok >= ), abs(hk(ok >= )), filled ), stem_fix, hold off xlabel \omega, ylabel H_d(\omega) axisy([.5]), xaxis_pi -p p/ p subplot(pl+), stem(:(m-), h, filled ), stem_fix, title(spritf( M=%d,M)) xlabel, ylabel h[], axis([ M- -.5.5]) H = freqz(h,, om); subplot(pl+3), plot(om, abs(h), -, om, abs(hd(om,m)), --, ok, abs(hk), o ) xlabel \omega, ylabel H(\omega), axisy([.5]), xaxis_pi -p p/ p % savefig fig_freq_sample.5.5 M=9.5 H d ().5 h[].5 H().5.5.5 π π/ π.5 4 6 8 π π/ π I MATLAB, use h = fir(m-, [.5.5 ], [ ], boxcar(m) ) to desig (almost) the above filter.

8.4 c J. Fessler, May 7, 4, 3:8 (studet versio) 8..4 Optimum equiripple liear-phase FIR filters The widow method has a mior disadvatage, that it is difficult to precisely specify p ad s, sice these two result from the smearig. All we really specify is c, the cutoff. A ideal liear-phase desig procedure would be as follows. Specify p, s, δ, δ, ad ru a algorithm that returs the miimum M that achieves that desig goal, as well as the impulse respose h[], =,..., M, where, for liear phase, h[] = h[m ]. To my kowledge, there is o such procedure that is guarateed to do this perfectly. However, we ca come close usig the followig iterative procedure. Choose M, ad fid the liear-phase h[] whose frequecy respose is as close to H d () as possible. If it is ot close eough, the icrease M ad repeat. How ca we measure closeess of two frequecy respose fuctios? Pictures of H d () ad H(). Possible optios iclude the followig. π π π H d() H() d, average absolute error π π π H d() H() d, average squared error π π π H d() H() W() d, average weighted squared error [ ] π /p, π H d() H() p W() d weighted Lp error, p π max H d () H(), maximum error (p = ) max W(H d () H()), maximum weighted error (p = ) I this sectio, we focus o the last choice, the maximum weighted error betwee the desired respose ad the actual frequecy respose of a FIR filter. We wat to fid the FIR filter that miimizes this error. How to fid this? Not by brute force search or trial ad error, but by aalysis! If W() the Cosider the case of a lowpass filter. Note that H d () = E() = W(H d () H()) = W() H d () H(). { e j(m )/, c,, > c = e j(m )/ H dr () where H dr () = Also recall that for M eve ad h[] liear phase ad symmetric, So H r () is the sum of M/ cosies. The error ca be simplified as follows: H() = e j(m )/ H r (), where H r () = M/ = {, c,, > c. ( ( )) M h[] cos. E() = W() H d () H() = W() e j(m )/ H dr () e j(m )/ H r () = W() H dr () H r (). Thus we oly eed to cosider the real parts of the desired vs actual frequecy respose.

c J. Fessler, May 7, 4, 3:8 (studet versio) 8.5 The logical approach to specifyig the error weightig fuctio W() is as follows: /δ, c pass bad W() =, c < < s trasitio bad /δ, s < < π stop bad. However, the effect of the weightig will be the same if we multiply W() by a costat, such as δ. So the followig weightig fuctio has the same effect: δ /δ, c W() =, c < < s, s < < π. A small δ value meas we wat very low sidelobes, ad are willig to sacrifice uiformity over the passbad, so less weight is give to the errors i the passbad. As a desiger you choose H dr (), the filter legth M, the ratio δ /δ, ad the passbad ad stopbads, i.e., c ad s. The procedure fids the impulse respose that miimizes the maximum weighted error betwee the desired respose ad the actual respose. Mathematically, the mi-max or Chebyshev desig uses the followig criterio: mi {h[]} M/ = max E(). Usig the alteratio theorem, from the theory of Chebyshev approximatio, Parks ad McClella i 97 showed that a ecessary ad sufficiet coditio for a M-tap filter to be optimal (i the maximum weighted error sese) is that the error E() must reach its maximum at least M/ + poit over the itervals where W(). This theorem guaratees that there is a uique optimal filter. It also tells us that the error will alterate back ad forth, i.e., there will be ripples i passbad ad stopbad. The resultig filters are called equiripple because all ripples i passbad have the same peak-to-peak amplitude, ad likewise for the stop bad. The actual procedure for fidig the best filter is iterative, ad it called the Remez exchage algorithm. It is implemeted by the remez fuctio i Matlab. The algorithm first guesses where the extremal frequecies are, ad the computes H r () from that, the fids ew estimates of the extremal frequecies ad iterates. Icreasig M reduces passbad ripple ad icreases stopbad atteuatio MATLAB s remezord commad gives approximatio to required M, based o (8..95): ˆM = D (δ, δ ) f f(δ, δ ) f +, where f = ( s p )/(π) ad D ad f(δ, δ ) are defied i text (8..96-97). Aother formula is also give i text: log 3 (δ ˆM = δ ) +. 4.6 f As trasitio bad f decreases, M icreases As ripples δ j decrease, M icreases This ca be explored graphically usig MATLAB s fdatool or filtdes.

8.6 c J. Fessler, May 7, 4, 3:8 (studet versio) Example. digital crossover for audio F s = 44kHz F pass = 4.4kHz p = πf pass /F s =.π F stop = 6.6kHz s = πf stop /F s =.3π 3 bads: pass, trasitio, stop M = 6 for ow; revisit shortly. % fig_remez_example.m M = 6; f = [..3 ]; Hdr = [ ]; W = [ ]; h = remez(m-, f, Hdr, W); stem(:m-, h, filled ) freqz(h,, ) Equiripple (zoom).5. M=6 h[].5..5 H() (db) 4 6 8 H().8.6.5 4 6. π π.4. π.4 π Haig widow (zoom).5. h[].5..5 H() (db) 4 6 8 H().8.6.5 4 6. π π.4. π.4 π

c J. Fessler, May 7, 4, 3:8 (studet versio) 8.7 Further illustratios of the tradeoffs. The error has to go somewhere: passbad(s), stopbad(s), ad/or trasitio bad(s). 3 W() 3 W() 3 W().5.5.5.5.5.5.5.5.5.4.5 /π.4.5 /π.4.5 /π.374 H(), M=3.6 H(), M=3.78 H(), M=3.37.4.5 /π.53.859.4.5.4.5 /π /π 3 W() 3 W() 3 W().5.5.5.5.5.5.5.5.5.4.5 /π.4.5 /π.4.55 /π H(), M=3 H(), M=7 H(), M=3.374.858.838.37.857.4.5.4.5 /π /π.84.4.55 /π 8..7 Compariso of FIR methods skim

8.8 c J. Fessler, May 7, 4, 3:8 (studet versio) 8.3 Desig of IIR Filters from Aalog Filters Why IIR? With IIR desigs we ca get the same approximatio accuracy (of the magitude respose) as FIR but with a lower order filter. The tradeoff is oliear phase. Aalog filter desig is a mature field. There are well kow methods for selectig RLC combiatios to approximate some desired frequecy respose H d (F ). Geerally, the more (passive) compoets used, the closer oe ca approximate H d (F ), (to withi compoet toleraces). Essetially all aalog filters are IIR, sice the solutios to liear differetial equatios ivolve ifiite-duratio terms of the form t m e λt u(t). Oe way to desig IIR digital filters is to piggyback o this wealth of desig experiece for aalog filters. What do aalog filters look like? Ay RLC etwork is describe by a liear costat coefficiet differetial equatio of the form N k= α k d k dt k y a(t) = M k= β k d k dt k x a(t) with correspodig system fuctio (Laplace trasform of the impulse respose) M k= H a (s) = β ks k N k= α ks. k Each combiatio of N, M, {α k }, {β k } correspods to some arragemet of RLCs. Those implemetatio details are uimportat to us here. The frequecy respose of a geeral aalog filter is H a (F ) = H a (s). s=jπf Overview Desig N, M, {α k }, {β k } usig existig methods. Map from s plae to z-plae somehow to get a k s ad b k s, i.e., a ratioal system fuctio correspodig to a discrete-time liear costat coefficiet differece equatio. Ca we achieve liear phase with a IIR filter? We should be able to use our aalysis tools to aswer this. Recall that liear phase implies that H(z) = z N H ( z ), so if z is a pole of the system fuctio H(z), the z is also a pole. So ay fiite poles (i.e., other tha or ) would lead to istability. There are o causal stable IIR filters with liear phase. Thus we desig for the magitude respose, ad see what phase respose we get. 8.3. IIR by approximatio of derivatives skim s = z T 8.3. IIR by impulse ivariace skim h[] = h a (T ) z = e st

c J. Fessler, May 7, 4, 3:8 (studet versio) 8.9 8.3.3 IIR filter desig by biliear trasformatio Suppose we have used existig aalog filter desig methods to desig a IIR aalog filter with system fuctio M k= H a (s) = β ks k N k= α ks. k For a samplig period T s, we ow make the biliear trasformatio s = T s z + z. This trasformatio ca be motivated by the trapezoidal formula for umerical itegratio. See text for the derivatio. Defie the discrete-time system fuctio H(z) = H a (s) s= z. T s + z This trasformatio yields a ratioal system fuctio, i.e., a ratio of polyomials i z. This H(z) is a system fuctio whose frequecy respose is related to the frequecy respose of the aalog IIR filter. Example. Cosider a st-order aalog filter with a sigle pole at s = α Picture where α >, with system fuctio H a (s) = α + s. How would you build this? Usig the followig RL voltage divider, where V out (s) = i(t) R R+sL V i(s) = H a (s) = R/L R/L+s. vi(t) + R vout(t) L Applyig the biliear trasformatio to the above (Laplace domai) system fuctio yields: + z H(z) = H a (s) s= z = = T s + z α( + z ) + = ( z ) T s = α + z T s + z α + /T s + z /T s α /T s + α z = α + /T s + z (α + /T s ) + (α /T s )z + z [ pz = α + /T s p + + /p ] pz, where p = αt ) s (, ). What is h[]? h[] = + αt α+/t s ( p δ[] +( + /p)p u[]. s Im(z) p Re(z) Where did zero at z = come from?

8. c J. Fessler, May 7, 4, 3:8 (studet versio) Solvig biliear trasformatio for z i terms of s yields: z = + st s st s, so zero at s = maps to z =. Note also that pole at s = α maps to z = p. I geeral, the (fiite) poles ad zeros follow the mappig. Poles (or zeros) at s = map to z =. Real poles ad zeros remai real, complex-cojugate pairs remai pairs. What type of filters are H a (s) ad H(z)? Both are poor lowpass filters. This illustrates the method, but ot the power! The utility is for more sophisticated aalog IIR desigs. Picture : more s-domai poles ad correspodig z-domai poles The biliear trasformatio More geerally, if the system fuctio H a (s) is ratioal, i.e., H a (s) = g s p T s z + z p =... = T s so we will have oe root at z = +pts pt s ad aother oe at z =. See plot o ext page. real(s) > maps to z outside uit circle real(s) < maps to z iside uit circle s = jπf maps to z o uit circle i(s si) j (s pj), the for each term of the form s p we have ( pt s z = + st s st s, s = T s z + z. z = + jπf T s = r ejφ jπf T s r e jφ = ejφ, where r = + jπf T s ad φ = ( + jπf T s ) = arcta ( πf T s ). ( ) πf Thus z = e j, where = φ, so = ta Ts. Coversely, if z = e j the ) z +pt s pt s, z + s = e j T s + e j = e j/ e j/ T s e j/ + e = j si / j/ T s cos / = j ) ta( = F = ) ta(. T s πt s This is a oliear relatioship betwee the aalog frequecy ad the digital frequecy. It is called frequecy warpig. See plot o ext page. Because of this oliearity, a typical desig procedure goes as follows. Determie desired frequecy respose i terms of aalog frequecies, e.g., Hz. Covert the desired frequecies ito digital frequecies usig = πf/f s, yieldig p, s, etc. Map those digital frequecies ito aalog frequecies F = πt s ta(/). We ca use ay coveiet T s for this, e.g., T s =. Desig a aalog filter for those frequecies. Trasform aalog filter ito digital filter usig the biliear trasformatio with that same T s. This is all built ito commads such as MATLAB s cheby routie. Use MATLAB s filtdemo to experimet with various filter types. The Chebyshev Type I filters are all-pole aalog filters with equiripple behavior i the passbad ad mootoic i the stopbad. { ( H a (F ) = + ε TN (F/F where T N (x) = cos N cos x ), x pass) cosh(n cosh x), x > is the Nth order Chebyshev polyomial. There is ripple i the passbad of amplitude /( + ε ) that is user-cotrolled.