Simple FIR Digital Filters • 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

2 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 −1 1 H 0 ( z ) = 2 (1 + z ) = 2z • The above transfer function has a zero at z = −1 and a pole at z = 0 • Note that here the pole vector has a unity magnitude for all values of ω Copyright © 2001, S. K. Mitra

Simple FIR Digital Filters • On the other hand, as ω increases from 0 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

Simple FIR Digital Filters • The maximum value of the magnitude function is 1 at ω = 0, and the minimum value is 0 at ω = π, i.e., j0 jπ | H 0 (e )| = 1, | H 0 (e )| = 0 • The frequency response of the above filter is given by jω

H 0 (e ) = e

− jω / 2

cos(ω / 2)

5 Copyright © 2001, S. K. Mitra

Simple FIR Digital Filters jω

• The magnitude response | H 0 (e )| = cos(ω / 2) can be seen to be a monotonically decreasing function of ω First-order FIR lowpass filter 1

Magnitude

0.8 0.6 0.4 0.2

6

0 0

0.2

0.4

0.6 ω/π

0.8

1

Copyright © 2001, S. K. Mitra

Simple FIR Digital Filters • The frequency ω = ωc at which 1 jωc H 0 (e ) = H 0 (e j 0 ) 2 is of practical interest since here the gain G (ωc ) in dB is given by jωc ( ω ) G c = 20 log10 H (e )

= 20 log10 H (e ) − 20 log10 2 ≅ −3 dB j0 since the dc gain G (0) = 20 log H (e ) = 0 j0

7

10

Copyright © 2001, S. K. Mitra

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 jωc 2 2 | H 0 (e )| = cos (ωc / 2) = 1 2 which yields ωc = π / 2 Copyright © 2001, S. K. Mitra

Simple FIR Digital Filters • 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 at z = −1 or ω = π, which is in the stopband of the filter 9 Copyright © 2001, S. K. Mitra

Simple FIR Digital Filters • A cascade of the simple FIR filter −1 1 H 0 ( z ) = 2 (1 + z ) results in an improved lowpass frequency response as illustrated below for a cascade of 3 sections First-order FIR lowpass filter cascade 1

Magnitude

0.8 0.6 0.4 0.2

10

0

0

0.2

0.4

0.6 ω/π

0.8

1

Copyright © 2001, S. K. Mitra

Simple FIR Digital Filters • The 3-dB cutoff frequency of a cascade of M sections is given by ωc = 2 cos −1 (2−1 / 2 M ) • 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 11 Copyright © 2001, S. K. Mitra

Simple FIR Digital Filters

12

• 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 Copyright © 2001, S. K. Mitra

Simple FIR Digital Filters 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( z ) = 1 (1 − z −1 ) 2

13 Copyright © 2001, S. K. Mitra

Simple FIR Digital Filters • Corresponding frequency response is given by jω − jω / 2 H1 (e ) = j e sin(ω / 2) whose magnitude response is plotted below First-order FIR highpass filter 1

Magnitude

0.8 0.6 0.4 0.2

14

0

0

0.2

0.4

0.6 ω/π

0.8

1

Copyright © 2001, S. K. Mitra

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 15 Copyright © 2001, S. K. Mitra

Simple FIR Digital Filters • 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 M −1 n −n 1 H1( z ) = ∑n =0 (−1) z M

is obtained by replacing z with − z in the transfer function of a moving average filter

16 Copyright © 2001, S. K. Mitra

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) 17 Copyright © 2001, S. K. Mitra

Simple FIR Digital Filters • The clutter can be removed by filtering the radar return signal through a two-pulse canceler, which is the first-order FIR highpass filter H1( 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 18 Copyright © 2001, S. K. Mitra

Simple IIR Digital Filters Lowpass IIR Digital Filters • A first-order causal lowpass IIR digital filter has a transfer function given by −1 1− α 1+ z H LP ( 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 Copyright © 2001, S. K. Mitra

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 of 1 − α to 1 + α • The maximum value of the magnitude function is 1 at ω = 0, and the minimum value is 0 at ω = π 20 Copyright © 2001, S. K. Mitra

Simple IIR Digital Filters j0 jπ | H e = H e ( ) | 1 , | ( )| = 0 • i.e., LP LP jω • Therefore, | H LP (e )| is a monotonically decreasing function of ω from ω = 0 to ω = π as indicated below 1 α = 0.8 α = 0.7 α = 0.5

-5

0.6

Gain, dB

Magnitude

0.8

0

0.4

-15

0.2 0

21

-10

α = 0.8 α = 0.7 α = 0.5

0

0.2

0.4

0.6 ω/π

0.8

1

-20 10

-2

10

-1

ω/π

Copyright © 2001, S. K. Mitra

10

0

Simple IIR Digital Filters • The squared magnitude function is given by 2 (1 − α) (1 + cos ω) jω 2 | H LP (e )| = 2 2(1 + α − 2α cos ω) jω 2 • The derivative of | H LP (e )| with respect to ω is given by 2 2 jω 2 d | H LP (e )| − (1 − α) (1 + 2α + α ) sin ω = 2 2 dω 2(1 − 2α cos ω + α ) 22 Copyright © 2001, S. K. Mitra

Simple IIR Digital Filters 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 jωc 2 1 | H LP (e )| = 2 in the expression for the square magnitude function resulting in 23 Copyright © 2001, S. K. Mitra

Simple IIR Digital Filters (1 − α) 2 (1 + cos ωc ) 1 = 2(1 + α 2 − 2α cos ωc ) 2

or (1 − α) 2 (1 + cos ωc ) = 1 + α 2 − 2α cos ωc which when solved yields 2α cos ωc = 2 1+ α • The above quadratic equation can be solved for α yielding two solutions 24 Copyright © 2001, S. K. Mitra

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 2 ( 1 − α ) (1 + cos ω) jω 2 | H LP (e )| = 2(1 + α 2 − 2α cos ω)

that H LP ( z ) is a BR function for |α| < 1 25 Copyright © 2001, S. K. Mitra

Simple IIR Digital Filters

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

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.8 0.6

-5 Gain, dB

Magnitude

1

-10

0.4 -15

0.2 0

27

α = 0.8 α = 0.7 α = 0.5

0

0.2

0.4

0.6

ω/π

0.8

1

-20

-2

-1

10

10

10

0

ω/π

Copyright © 2001, S. K. Mitra

Simple IIR Digital Filters • 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

28

• Therefore α = (1 − sin ωc ) / cos ωc = − 0.5095245 Copyright © 2001, S. K. Mitra

Simple IIR Digital Filters • Therefore,

1 + α 1 − z −1 H HP ( z ) = 2 1 − α z −1

−1 1 z − = 0.245238 −1 1 + 0.5095245 z

29 Copyright © 2001, S. K. Mitra

Simple IIR Digital Filters Bandpass IIR Digital Filters • A 2nd-order bandpass digital transfer function is given by 1− α 1 − z −2 H BP ( z ) = 2 1 − β(1 + α) z −1 + α z −2 • Its squared magnitude function is jω 2

H BP (e )

30

(1 − α) 2 (1 − cos 2ω) = 2[1 + β2 (1 + α) 2 + α 2 − 2β(1 + α) 2 cos ω + 2α cos 2ω] Copyright © 2001, S. K. Mitra

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 frequency of the bandpass filter, where ωo = cos −1 (β) jω 2 ω ω • The frequencies c1 and c 2 where | HBP (e )| becomes 1/2 are called the 3-dB cutoff frequencies 31 Copyright © 2001, S. K. Mitra

Simple IIR Digital Filters • The difference between the two cutoff frequencies, assuming ωc 2 > ωc1 is called 2αand is given by the 3-dB bandwidth 2 1 + α −1 2α Bw = ωc 2 − ωc1 = cos 2 1 + α • The transfer function H BP ( z ) is a BR function if |α| < 1 and |β| < 1 32 Copyright © 2001, S. K. Mitra

Simple IIR Digital Filters • Plots of | HBP (e jω )| are shown below β = 0.34 1

α = 0.8 α = 0.5 α = 0.2

0.6 0.4 0.2 0 0

β = 0.8 β = 0.5 β = 0.2

1 Magnitude

0.8 Magnitude

α = 0.6

0.8 0.6 0.4 0.2

0.2

0.4

0.6 ω/π

0.8

1

0 0

0.2

0.4

0.6

0.8

ω/π

33 Copyright © 2001, S. K. Mitra

1

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 2 1+ α • The solution of the above equation yields: α = 1.376382 and α = 0.72654253 34 Copyright © 2001, S. K. Mitra

Simple IIR Digital Filters • The corresponding transfer functions are −2 1− z ' H BP ( z ) = −0.18819 −1 −2 1 − 0.7343424 z + 1.37638 z and −2 1 − z " ( z ) = 0.13673 H BP 1 − 0.533531z −1 + 0.72654253z − 2 ' ( z ) are at z = 0.3671712 ± • The poles of H BP j1.11425636 and have a magnitude > 1 35 Copyright © 2001, S. K. Mitra

Simple IIR Digital Filters ' ( z ) are outside the • Thus, the poles of H BP unit circle making the transfer function unstable " ( z ) are • On the other hand, the poles of H BP at z = 0.2667655 ± j 0.8095546 and have a magnitude of 0.8523746 " ( z ) is BIBO stable • Hence H BP • Later we outline a simpler stability test 36 Copyright © 2001, S. K. Mitra

Simple IIR Digital Filters • Figures below show the plots of the magnitude function and the group delay of " ( z) H BP 7 1 Group delay, samples

6

Magnitude

0.8 0.6 0.4 0.2

37

0 0

5 4 3 2 1 0

0.2

0.4

0.6 ω/π

0.8

1

-1 0

0.2

0.4

0.6

0.8

ω/π

Copyright © 2001, S. K. Mitra

1

Simple IIR Digital Filters Bandstop IIR Digital Filters • A 2nd-order bandstop digital filter has a transfer function given by 1 + α 1 − 2β z −1 + z −2 H BS ( z ) = 2 1 − β(1 + α) z −1 + α z −2 • The transfer function H BS (z ) is a BR function if |α| < 1 and |β| < 1 38 Copyright © 2001, S. K. Mitra

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.6 0.4

β = 0.8 β = 0.5 β = 0.2

0.2

1

0 0

0.2

0.4

0.6

0.8

ω/π

39 Copyright © 2001, S. K. Mitra

1

Simple IIR Digital Filters • 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 40 Copyright © 2001, S. K. Mitra

Simple IIR Digital Filters jω 2

• The frequencies ωc1 and ωc 2 where | HBS (e )| 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 2α Bw = ωc 2 − ωc1 = cos 2 1 + α −1

41

Copyright © 2001, S. K. Mitra

Simple IIR Digital Filters

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 of K first-order lowpass sections characterized by the transfer function 1 − α 1 + z −1 H LP ( z ) = 2 1 − α z −1 Copyright © 2001, S. K. Mitra

Simple IIR Digital Filters • The overall structure has a transfer function given by K − 1 1 − α 1 + z GLP ( z ) = ⋅ −1 2 1− α z

43

• The corresponding squared-magnitude function is given by K 2 jω 2 (1 − α ) (1 + cos ω) |GLP (e )| = 2 2(1 + α − 2α cos ω) Copyright © 2001, S. K. Mitra

Simple IIR Digital Filters

44

• To determine the relation between its 3-dB cutoff frequency ωc and the parameter α, we set K 2 (1 − α) (1 + cos ωc ) 1 = 2 2 2(1 + α − 2α cos ωc ) which when solved for α, yields for a stable GLP ( z ): 2 1 + (1 − C ) cos ωc − sin ωc 2C − C α= 1 − C + cos ωc Copyright © 2001, S. K. Mitra

Simple IIR Digital Filters where

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 Copyright © 2001, S. K. Mitra

Simple IIR Digital Filters

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

Simple IIR Digital Filters • 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 2 1 + (1 − C ) cos ωc − sin ωc 2C − C α= 1 − C + cos ωc

1 + (1 − 1.6818) cos(0.4π) − sin(0.4π) 2(1.6818) − (1.6818) 2 = 1 − 1.6818 + cos(0.4π) 47

= − 0.251

Copyright © 2001, S. K. Mitra

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 0

-5

0 Gain, dB

Gain, dB

Passband details

K=1

-10 K=4

K=1 -2 -4

-15 10

48

-20 -2 10

-1

10 ω/π

K=4

10

-2

-1

10 ω/π

10

0

Copyright © 2001, S. K. Mitra

0