Simple Digital Filters Simple FIR Digital Filters • Later in the course we shall review various methods of designing frequency-selective filters satisfying prescribed specifications • We now describe several low-order FIR and IIR digital filters with reasonable selective frequency responses that often are satisfactory in a number of applications • FIR digital filters considered here have integer-valued impulse response coefficients • These filters are employed in a number of practical applications, primarily because of their simplicity, which makes them amenable to inexpensive hardware implementations 1 2 Copyright © 2001, S. K. Mitra Copyright © 2001, S. K. Mitra Simple FIR Digital Filters 3 Lowpass FIR Digital Filters • The simplest lowpass FIR digital filter is the 2-point moving-average filter given by z +1 H 0 ( z) = 12 (1 + z −1) = 2z • The above transfer function has a zero at z = −1and a pole at z = 0 • Note that here the pole vector has a unity magnitude for all values of ω Simple FIR Digital Filters • On the other hand, as ω increases from0 to π, the magnitude of the zero vector decreases from a value of 2, the diameter of the unit circle, to 0 • Hence, the magnitude response | H 0( e jω )| is a monotonically decreasing function of ω fromω = 0 to ω = π 4 Copyright © 2001, S. K. Mitra Copyright © 2001, S. K. Mitra Simple FIR Digital Filters Simple FIR Digital Filters • The magnitude response | H0 ( e jω )| = cos(ω / 2) can be seen to be a monotonically decreasing function of ω • The maximum value of the magnitude function is 1 at ω = 0, and the minimum value is 0 at ω = π, i.e., | H 0 (e j0 )| = 1, | H 0 (e jπ )| = 0 First-order FIR lowpass filter 1 • The frequency response of the above filter is given by Magnitude 0.8 H 0 (e j ω ) = e − jω / 2 cos(ω / 2) 5 0.4 0.2 6 Copyright © 2001, S. K. Mitra 0.6 0 0 0.2 0.4 0.6 ω/π 0.8 1 Copyright © 2001, S. K. Mitra 1 Simple FIR Digital Filters 7 • The frequency ω = ωc at which 1 H 0 (e j ωc ) = H 0 (e j 0 ) 2 is of practical interest since here the gainG( ωc ) in dB is given by G( ωc ) = 20 log10 H (e jωc ) = 20 log10 H ( e j 0 ) − 20 log10 2 ≅ −3 dB since the dc gain G ( 0) = 20 log H (e j0 ) = 0 10 Simple FIR Digital Filters 8 • Thus, the gain G(ω) at ω = ωc is approximately 3 dB less than the gain at ω =0 • As a result, ω c is called the 3-dB cutoff frequency • To determine the value ofωc we set | H0 ( e j ωc )| 2 = cos2 (ωc / 2 ) = 12 which yields ωc = π / 2 Copyright © 2001, S. K. Mitra Copyright © 2001, S. K. Mitra Simple FIR Digital Filters Simple FIR Digital Filters • A cascade of the simple FIR filter H 0 ( z) = 12 (1 + z −1 ) results in an improved lowpass frequency response as illustrated below for a cascade of 3 sections • The 3-dB cutoff frequency ωc can be considered as the passband edge frequency • As a result, for the filter H 0(z ) the passband width is approximately π/2 • The stopband is fromπ/2 to π • Note: H 0 (z ) has a zero atz = −1 or ω = π, which is in the stopband of the filter First-order FIR lowpass filter cascade 1 Magnitude 0.8 0.6 0.4 0.2 9 10 Copyright © 2001, S. K. Mitra 0 0 0.2 0.4 0.6 ω/ π 0.8 1 Copyright © 2001, S. K. Mitra Simple FIR Digital Filters Simple FIR Digital Filters • The 3-dB cutoff frequency of a cascade of M sections is given by ω c = 2 cos−1(2 −1/ 2M ) • For M = 3, the above yields ωc = 0 .302 π • Thus, the cascade of first-order sections yields a sharper magnitude response but at the expense of a decrease in the width of the passband • A better approximation to the ideal lowpass filter is given by a higher-order movingaverage filter • Signals with rapid fluctuations in sample values are generally associated with highfrequency components • These high-frequency components are essentially removed by an moving-average filter resulting in a smoother output waveform 11 12 Copyright © 2001, S. K. Mitra Copyright © 2001, S. K. Mitra 2 Simple FIR Digital Filters Simple FIR Digital Filters • Corresponding frequency response is given by Highpass FIR Digital Filters • The simplest highpass FIR filter is obtained from the simplest lowpass FIR filter by replacing z with − z • This results in H1 (e j ω ) = j e − j ω / 2 sin( ω / 2) whose magnitude response is plotted below First-order FIR highpass filter 1 0.8 Magnitude H1( z ) = 1 (1 − z −1 ) 2 0.6 0.4 0.2 13 14 0 0 0.2 0.4 0.6 ω/π Copyright © 2001, S. K. Mitra 0.8 1 Copyright © 2001, S. K. Mitra Simple FIR Digital Filters Simple FIR Digital Filters • The monotonically increasing behavior of the magnitude function can again be demonstrated by examining the pole-zero pattern of the transfer function H1(z) • The highpass transfer function H1(z) has a zero at z = 1 or ω = 0 which is in the stopband of the filter • Improved highpass magnitude response can again be obtained by cascading several sections of the first-order highpass filter • Alternately, a higher-order highpass filter of the form −1 H1( z) = 1 ∑M ( −1)n z − n n =0 15 M is obtained by replacing z with − z in the transfer function of a moving average filter 16 Copyright © 2001, S. K. Mitra Copyright © 2001, S. K. Mitra Simple FIR Digital Filters Simple FIR Digital Filters • An application of the FIR highpass filters is in moving-target-indicator (MTI) radars • In these radars, interfering signals, called clutters , are generated from fixed objects in the path of the radar beam • The clutter, generated mainly from ground echoes and weather returns, has frequency components near zero frequency (dc) • The clutter can be removed by filtering the radar return signal through a two-pulse canceler, which is the first-order FIR highpass filterH1( z ) = 1 (1 − z −1 ) 2 • For a more effective removal it may be necessary to use a three-pulse canceler obtained by cascading two two -pulse cancelers 17 18 Copyright © 2001, S. K. Mitra Copyright © 2001, S. K. Mitra 3 Simple IIR Digital Filters Simple IIR Digital Filters • H LP (z) has a real pole at z = α • As ω increases from 0 to π, the magnitude of the zero vector decreases from a value of 2 to 0, whereas, for a positive value of α, the magnitude of the pole vector increases from a value of1 − α to 1 + α • The maximum value of the magnitude function is 1 at ω = 0, and the minimum value is 0 at ω = π Lowpass IIR Digital Filters • A first-order causal lowpass IIR digital filter has a transfer function given by 1 − α 1 + z −1 H L P ( z) = 2 1 − α z−1 where |α| < 1 for stability • The above transfer function has a zero at z = −1 i.e., at ω = π which is in the stopband 19 20 Copyright © 2001, S. K. Mitra Copyright © 2001, S. K. Mitra Simple IIR Digital Filters Simple IIR Digital Filters | H LP ( e j π )| = 0 • i.e., | H LP (e j 0 )| = 1, jω • Therefore, | H LP( e )| is a monotonically decreasing function of ω fromω = 0 to ω = π as indicated below 1 α = 0.8 α = 0.7 α = 0.5 0 -5 Gain, dB Magnitude 0.8 0.6 -10 0.4 21 α = 0.8 α = 0.7 α = 0.5 -15 0.2 0 • The squared magnitude function is given by (1 − α) 2 (1 + cosω) | H LP (e jω )| 2 = 2 (1 + α 2 − 2 α cosω) • The derivative of | H LP (e j ω )| 2 with respect to ω is given by d | H LP ( e j ω )| 2 − (1 − α)2 (1 + 2α + α 2 ) sin ω = dω 2(1 − 2α cosω + α 2 )2 0 0.2 0.4 0.6 ω/ π 0.8 1 -20 -2 10 -1 ω/π 10 0 10 22 Copyright © 2001, S. K. Mitra Copyright © 2001, S. K. Mitra Simple IIR Digital Filters Simple IIR Digital Filters (1 − α) 2 (1 + cosωc ) d | H LP (e j ω )| 2 / dω ≤ 0 in the range 0 ≤ ω ≤ π verifying again the monotonically decreasing behavior of the magnitude function • To determine the 3-dB cutoff frequency we set 1 | H LP (e jω c )| 2 = 2 in the expression for the square magnitude function resulting in 23 = 1 2 2(1 + α − 2α cosωc ) or 2 (1 − α) (1 + cosωc ) = 1 + α 2 − 2 α cosωc which when solved yields 2 cos ω c = 2α 1 + α2 • The above quadratic equation can be solved for α yielding two solutions 24 Copyright © 2001, S. K. Mitra Copyright © 2001, S. K. Mitra 4 Simple IIR Digital Filters Simple IIR Digital Filters • The solution resulting in a stable transfer function H LP (z) is given by α= 1 − sin ωc cosωc • It follows from | H LP (e jω )| 2 = (1 − α) 2 (1 + cosω) 2 (1 + α 2 − 2 α cosω) that H LP (z) is a BR function for |α| < 1 25 26 Highpass IIR Digital Filters • A first-order causal highpass IIR digital filter has a transfer function given by 1 + α 1 − z−1 H HP ( z) = 2 1 − α z −1 where |α| < 1 for stability • The above transfer function has a zero at z = 1 i.e., at ω = 0 which is in the stopband Copyright © 2001, S. K. Mitra Copyright © 2001, S. K. Mitra Simple IIR Digital Filters Simple IIR Digital Filters • Its 3-dB cutoff frequency ωc is given by α = (1 − sin ωc ) / cosωc which is the same as that of H LP (z) • Magnitude and gain responses of H HP (z ) are shown below 0 α = 0.8 α = 0.7 α = 0.5 0.6 -5 Gain, dB Magnitude 1 0.8 • H HP (z) is a BR function for |α| < 1 • Example - Design a first-order highpass digital filter with a 3-dB cutoff frequency of 0.8π • Now,sin(ωc ) = sin(0. 8π) = 0.587785 and cos(0. 8π) = − 0. 80902 α = 0.8 α = 0.7 α = 0.5 -10 0.4 -15 0.2 27 0 0 -20 0.2 0.4 0.6 0.8 1 10 2- 10-1 100 ω/π ω/ π 28 • Therefore α = (1 − sin ωc ) / cosωc = − 0.5095245 Copyright © 2001, S. K. Mitra Copyright © 2001, S. K. Mitra Simple IIR Digital Filters Simple IIR Digital Filters • Therefore, Bandpass IIR Digital Filters • A 2nd-order bandpass digital transfer function is given by 1 + α 1 − z −1 2 1 − α z −1 1 − z −1 = 0.245238 −1 1 + 0. 5095245 z H HP ( z ) = H BP ( z ) = • Its squared magnitude function is H BP (e j ω ) = 29 30 Copyright © 2001, S. K. Mitra 1 − α 1 − z −2 − 1 − 2 2 1 − β(1 + α ) z + α z 2 (1 − α )2 (1 − cos 2ω) 2[1 + β 2 (1 + α) 2 + α 2 − 2β (1 + α )2 cos ω + 2α cos 2ω] Copyright © 2001, S. K. Mitra 5 Simple IIR Digital Filters Simple IIR Digital Filters • | HBP (e jω )| 2 goes to zero at ω = 0 and ω = π • It assumes a maximum value of 1 at ω = ωo , called the center frequencyof the bandpass filter, where ω o = cos−1(β) • The frequencies ωc1 and ωc 2 where | HBP (e j ω )| 2 becomes 1/2 are called the 3-dB cutoff frequencies 31 • The difference between the two cutoff frequencies, assuming ωc 2 > ωc1 is called the 3-dB bandwidth and is given by 2α Bw = ωc 2 − ωc1 = cos−1 1 + α2 • The transfer function H BP (z ) is a BR function if |α| < 1 and |β| < 1 32 Copyright © 2001, S. K. Mitra Copyright © 2001, S. K. Mitra Simple IIR Digital Filters Simple IIR Digital Filters • Example - Design a 2nd order bandpass digital filter with center frequency at 0.4π and a 3-dB bandwidth of 0.1π • Here β = cos(ωo ) = cos(0.4 π) = 0.309017 and 2α = cos(Bw ) = cos(0.1π) = 0.9510565 1 + α2 • The solution of the above equation yields: α = 1.376382 and α = 0.72654253 • Plots of | HBP (e jω )| are shown below α = 0.6 β = 0.34 1 α = 0.8 α = 0.5 α = 0.2 0.6 0.4 0.2 0 β = 0.8 β = 0.5 β = 0.2 1 Magnitude Magnitude 0.8 0.8 0.6 0.4 0.2 0 0.2 0.4 0.6 ω/π 0.8 1 0 0 0.2 0.4 0.6 0.8 1 ω/π 33 34 Copyright © 2001, S. K. Mitra Copyright © 2001, S. K. Mitra Simple IIR Digital Filters Simple IIR Digital Filters • The corresponding transfer functions are 1 − z− 2 H 'BP( z ) = −0.18819 1 − 0.7343424 z −1 + 1.37638 z −2 and • Thus, the poles of H 'BP ( z ) are outside the unit circle making the transfer function unstable • On the other hand, the poles of H "BP ( z ) are at z = 0 .2667655 ± j 0.8095546 and have a magnitude of 0.8523746 • Hence H "BP ( z ) is BIBO stable • Later we outline a simpler stability test 1− z −2 1 − 0.533531z−1 + 0.72654253z −2 • The poles of H 'BP ( z ) are at z = 0.3671712 ± H "BP( z ) = 0.13673 j1.11425636 and have a magnitude > 1 35 36 Copyright © 2001, S. K. Mitra Copyright © 2001, S. K. Mitra 6 Simple IIR Digital Filters Simple IIR Digital Filters • Figures below show the plots of the magnitude function and the group delay of H "BP ( z ) Bandstop IIR Digital Filters • A 2nd-order bandstop digital filter has a transfer function given by 7 1 Group delay, samples Magnitude 0.8 0.6 0.4 0.2 0 37 H BS ( z) = 6 5 4 • The transfer function H BS (z) is a BR function if |α| < 1 and |β| < 1 3 2 1 0 0 0.2 0.4 0.6 0.8 -1 1 0 0.2 ω/π 0.4 0.6 0.8 1 ω/π 38 Copyright © 2001, S. K. Mitra Copyright © 2001, S. K. Mitra Simple IIR Digital Filters Simple IIR Digital Filters 1 1 0.8 0.8 Magnitude Magnitude • Its magnitude response is plotted below 0.6 0.4 α = 0.8 α = 0.5 α = 0.2 0.2 0 0 0.2 0.4 0.6 ω/π 0.8 0.4 β = 0.8 β = 0.5 β = 0.2 0.2 1 • Here, the magnitude function takes the maximum value of 1 at ω = 0 and ω = π • It goes to 0 at ω = ωo, where ωo , called the notch frequency, is given by ω o = cos−1(β) • The digital transfer function H BS (z) is more commonly called a notch filter 0.6 0 0 0.2 0.4 0.6 0.8 1 ω/π 39 40 Copyright © 2001, S. K. Mitra Copyright © 2001, S. K. Mitra Simple IIR Digital Filters Simple IIR Digital Filters • The frequencies ωc1 andωc 2 where | HBS ( e jω )| 2 becomes 1/2 are called the 3-dB cutoff frequencies • The difference between the two cutoff frequencies, assuming ωc 2 > ωc1 is called the 3-dB notch bandwidth and is given by 41 1 + α 1 − 2β z −1 + z −2 2 1 − β(1 + α) z −1 + α z −2 2α Bw = ωc 2 − ωc1 = cos −1 1+ α 2 Copyright © 2001, S. K. Mitra 42 Higher-Order IIR Digital Filters • By cascading the simple digital filters discussed so far, we can implement digital filters with sharper magnitude responses • Consider a cascade ofK first-order lowpass sections characterized by the transfer function 1 − α 1 + z−1 H L P ( z) = 2 1 − α z−1 Copyright © 2001, S. K. Mitra 7 Simple IIR Digital Filters Simple IIR Digital Filters • The overall structure has a transfer function given by K 1 − α 1 + z −1 GLP ( z) = ⋅ −1 2 1 −α z 43 • The corresponding squared-magnitude function is given by K (1 − α )2 (1 + cosω) |GLP (e jω )| 2 = 2 2(1 + α − 2α cosω ) 44 • To determine the relation between its 3-dB cutoff frequency ωc and the parameter α, we set K (1 − α) 2 (1 + cosω c ) 1 = 2 2 2 (1 + α − 2 α cosωc ) which when solved for α, yields for a stable G LP (z): 1 + (1 − C ) cosω c − sin ω c 2C − C 2 α= 1 − C + cosωc Copyright © 2001, S. K. Mitra Copyright © 2001, S. K. Mitra Simple IIR Digital Filters where Simple IIR Digital Filters C = 2( K −1) / K • It should be noted that the expression for α given earlier reduces to α= 1 − sin ω c cosωc for K = 1 45 46 • Example - Design a lowpass filter with a 3dB cutoff frequency at ωc = 0. 4π using a single first-order section and a cascade of 4 first-order sections, and compare their gain responses • For the single first-order lowpass filter we have 1 + sin ω c 1 + sin(0.4 π) α= = = 0. 1584 cosωc cos(0 .4π) Copyright © 2001, S. K. Mitra Copyright © 2001, S. K. Mitra Simple IIR Digital Filters Simple IIR Digital Filters • The gain responses of the two filters are shown below • As can be seen, cascading has resulted in a sharper roll-off in the gain response • For the cascade of 4 first-order sections, we substitute K = 4 and get C = 2( K −1) / K = 2( 4−1) / 4 = 1 .6818 • Next we compute 1 + (1 − C ) cosω c − sin ω c 2C − C 2 α= 1 − C + cosωc = 47 0 K=4 -20 -2 10 0 K=1 -2 10 -1 10 ω/π K=4 -2 -4 -15 48 Copyright © 2001, S. K. Mitra Gain, dB Gain, dB -10 1 + (1 − 1. 6818) cos( 0. 4π ) − sin( 0.4 π) 2(1. 6818) − (1. 6818 )2 1 − 1. 6818 + cos( 0 .4π ) = − 0.251 Passband details K=1 -5 -1 10 ω/π 0 10 0 10 Copyright © 2001, S. K. Mitra 8