You are on page 1of 32

Digital Filter Design

Supplement to Lecture Notes on FIR


Filters

Danilo P. Mandic
Department of Electrical and Electronic Engineering
Imperial College London
{d.mandic}@imperial.ac.uk

Danilo P. Mandic 1

Digital Signal Processing


Frequency Response of Digital Filters
Frequency response of digital Filter: H(e ) = |H(e )|e()
continuous function of with period 2 H(e ) = H[e(+m2)]

|H(e )| is the called the Magnitude function.


Magnitude functions are even functions |H(e )| = |H(e )|

() is called the Phase (lag) angle, () , H(e ).


Phase functions are odd functions () = ()
More convenient to use the magnitude squared and group delay
functions than |H(e )| and ().
2

1
Magnitude squared function: |H(e )| = H(z)H(z ) z=e
It is assumed that H(z) has real coefficients only.
Group delay function () = d()
d . Measure of the delay of the filter
response.

Danilo P. Mandic 2

Digital Signal Processing


Digital Filter Frequency Response: Poles & Zeros

{z}
Complex zeros zk and poles pk Occurs in quadruples
zplane
occur in conjugate pairs. Occurs in conjugate pairs
with even multiplicity

Occurs with even multiplicity


2
If zk = a is a real zero/pole Occurs in pairs

of |H(e )|2 zk1 = a1 is


also a real zero/pole.
{z}
2
If zk = rk e is a 2

zero/pole of |H(e )|2


rk e , ( r1 )e and ( r1 )e
k k
are also zeros/poles. 2

Danilo P. Mandic 3

Digital Signal Processing


Digital Filters: Transfer Functions
The problem of finding the transfer function of a filter is the problem of
universal function approximation. This is usually solved by involving
some basis functions (Fourier, Chebyshev, ...). In our case, the basis
functions will be polynomials or rational functions in z (or z 1.

Finite Impulse Response (FIR) filter: Digital filter characterised by


transfer functions in the form of a polynomial
H(z) = a0 + a1z 1 + + zmz M

Infinite Impulse Response (IIR) filter: characterised by transfer


functions in the form of a rational function
M
P
ai z i
i=0 A(z 1)
H(z) = PN
= B(z 1 )
bj z j
j=0

Danilo P. Mandic 4

Digital Signal Processing


Digital Filters: Transfer Functions Properties
FIR filters are stable and causal.

IIR filters are:


Stable if all the poles of H(z) are within the unit circle
Causal if bL is the first non-zero coefficient in the denominator (i.e.
b0 = b1 = = bL1 = 0 and a0 = a1 = = aL1 = 0 .

Causal filters are normally assumed, hence IIR filters are commonly
written as:
M
P
aiz i
i=0 A(z 1 )
H(z) = N
P
= B(z 1)
, b0 = 1
1+ bj z j
j=1

We would ideally like to design filters with linear phase in the


passband - what about the phase in the stopband?

Danilo P. Mandic 5

Digital Signal Processing


Digital Filters: Magnitude and Phase Characteristics
|H(e )| |H(e )|
Lowpass Filter Bandreject Filter

111
000 11
00000
111
000
111
000
111 00
11
00
11000
111
000
111
000
111 rad
00111
11000 rad
-2 - 2 -2 - 2

|H(e )| |H(e )|
Bandpass Filter Allpass Filter

111
000 1111
0000
000
111 0000
1111
000
111 0000
1111
000
111 rad
0000
1111 rad
-2 - 2 -2 - 2

|H(e )| ()
Highpass Filter Phase Characteristics

111
000
000
111
000
111
000
111 rad
rad

-2 - 2 -2 - 2 3

Danilo P. Mandic 6

Digital Signal Processing


Design of All-pass Digital Filters
An all-pass filter is an IIR filter with a constant magnitude function for
all digital frequency values.
For a transfer function H(z) to represent an all-pass filter is that for
every pole pk = rk ej , there is a corresponding zero zk = r1 ej . The
k
poles and zeros will occur in conjugate pairs if k 6= 0 or .

A digital filter H(z) obtained by cascade connection of multiple all-pass


filters H1(z), H2(z) HN (z) sections is itself an all-pass filter, and can
be represented by
H(z) = H1(z)H2(z) HN (z)

So why do we need all-pass filters? They are phase-selective (as


opposed to frequency selective) and are extremely useful in the
design of DSP systems.

Danilo P. Mandic 7

Digital Signal Processing


First order All-pass Digital Filter
A typical first-order section of an all-pass digital filter has a transfer
function
z 1 a
H1(z) = (1)
1 az 1
where a is real and to be stable, we must have |a| < 1.

Im[z]

Unit Circle

Re[z]
a 1/a

Figure 1: Pole-zero pattern of first order all-pass digital filter.

Danilo P. Mandic 8

Digital Signal Processing


First- and Second-Order All-pass Digital Filter

The magnitude function is unity for all frequencies, as given by

j
ej a 2 cos a j sin 2 1 2a cos + a2
2
|H1(e )| = = = =1
1 aej 1 a cos + aj sin 1 2a cos + a2

A typical second-order section of an all-pass digital filter

1 ( r2 ) cos k z 1 + ( r12 )z 2 [1 ( r1 )z 1ej ][1 ( r1 )z 1ej ]


k k k k
H2(z) = =
1 2rk cos z 1 + rk2 z 2 [1 rk z 1ej ][1 rk z 1ej ]

1 jk
The poles are at p1,2 = rk ejk and the zeros at z1,2 = rk e

For filter to be stable, |rk | < 1.

Danilo P. Mandic 9

Digital Signal Processing


First- and Second-Order All-pass Digital Filter

Im[z]

Unit Circle 1

X 1/r
X
Re[z]
r

Figure 2: Pole-zero pattern of a second order all-pass digital filter.

Danilo P. Mandic 10

Digital Signal Processing


First order All-pass Digital Filter

The magnitude function is given by

ej ( r1 )ejk ej ( r1 )ejk
|H2(ej )|2 = | k
|2| k
|2 (2)
ej rk ejk ej rk ejk
ej ( r1 )ejk ej ( r1 )ejk
where | k
ej rk ejk
2
| =| k
ej rk ejk
|2 = rk2

Hence
|H2(ej )|2 = rk4 = c (3)
where c is a constant, implying that it represents an all-pass filter.

Danilo P. Mandic 11

Digital Signal Processing


Design of FIR Digital Filter

The transfer function of FIR digital filter is in the form of

N
X 1
n
H(z) = h(n)z (4)
n=0

where the impulse response is of length N .

The filter will have linear phase response if the FIR digital filter satisfies

h(n) = h(N 1 n) (5)

Danilo P. Mandic 12

Digital Signal Processing


Design of FIR Digital Filter
for n = 0, 1, . . . , (N/2) 1 if N is even, and for n = 0, 1, . . . , (N 1)/2 if N is
odd. Indeed if N is odd, then (4) and (5) give
N
X 1
j jn
H(e ) = h(n)e
n=0

N 3
X2
jn j(N 1n) ` N 1 j n[
(N 1)
]
= [h(n)e + h(N 1 n)e ]+h e 2
n=0
2
N 3
X2
jn j(N 1n) ` N 1 j n[
(N 1)
]
= h(n)[e +e ]+h e 2 (6)
n=0
2
N 3
X2
j[(N 1)/2] N 1
(N 1) (N 1)
j n[ ] j n[ 2 ] ]
= e h( )+ h(n)[e 2 +e
2 n=0

N 3
X2
j[(N 1)/2] N 1 N 1
= e h( )+ 2h(n) cos [(n )] (7)
2 n=0
2

Danilo P. Mandic 13

Digital Signal Processing


Design of FIR Digital Filter
In similar way, (4) and (5), for even values of N , give

(N
2 1)
j j[(N 1)/2]
X N 1
H(e ) = e 2h(n) cos [(n )] (8)
n=0
2

In both cases, the phase () of the FIR digital filter is given by

N 1
() = (9)
2
which is linear for < .

The group delay function is

N 1
() = () = (10)
2
which is constant for < .

Danilo P. Mandic 14

Digital Signal Processing


Constraints on zero-phase FIR filters
The zero locations of FIR filter are restricted to meet certain symmetry requirements due
to constraints imposed by (5). To see this, (4) is written as

N
X 1
(N 1) N n1
H(z) = z h(n)z
n=0

Let m = N n 1 be a new dummy variable, then (12) can be written as

N
X 1
H(z) = z (N 1)
h(N m 1)z m
n=0

N
X 1
(N 1) 1 m
= z h(m)(z ) (11)
n=0
(N 1) 1
= z H(z )

This means that zeros of H(z) are the zeros of H(z 1) except, perhaps, for the zeros at
origin.

Danilo P. Mandic 15

Digital Signal Processing


Symmetry properties of digital FIR filters

If zi = a is a real zero of H(z), then zi1 = a1 is also a zero of H(z).

Im[z]

Unit Circle

Re[z]
a 1/a

Danilo P. Mandic 16

Digital Signal Processing


Symmetry properties of digital FIR filters

If zi = eji is a zero of H(z), where i 6= 0 and i 6= , then zi1 = z i = eji is


also a zero of H(z).

Im[z]

Unit Circle

Re[z]

Danilo P. Mandic 17

Digital Signal Processing


Symmetry properties of digital FIR filters

If zi = rieji is a zero of H(z), where ri 6= 1, i 6= 0 and i 6= , then


z i = ri eji and zi1 = r1 eji and z 1
i = r1 eji are also zeros of H(z).
i i

Im[z]

Unit Circle

i
Re[z]
i

Danilo P. Mandic 18

Digital Signal Processing


Frequency sampling method

An FIR filter has equivalent DFT representation, given by

N
X 1
j2nk
e [ ]
H(k) = h(n)e N (12)
n=0

e
where H(k) is actually the uniformly spaced N-point sample sequence of the
frequency response of the digital filter. As a consequence, the impulse response
sequence h(n) and transfer function H(z) are given by

N 1
1 X e [
j2nk
]
h(n) = H(k)e N (13)
N k=0

and
N 1
1 X e 1 z N
H(z) = H(k) j2k
(14)
N k=0 1z e N ]
1 [

where equation (14) is the key to the design of FIR digital filter.

Danilo P. Mandic 19

Digital Signal Processing


Example
Design a low-pass digital filter whose magnitude characteristics are shown in Figure. Find
an appropriate transfer function via a 16-point frequency sampling method.

Hd(ej ), H(k)
1
Hd(ej )

0 2

0 5 10 15 k

Solution: In this case, the DFT sequence is given by

Danilo P. Mandic 20

Digital Signal Processing


Example

e
H(0) e
= H(1) e
= H(15) =1
e
H(k) = 0 for k = 2, 3, 4, . . . , 14 (15)

By using (14), the desired transfer function can be found

15 e
1 X (1 z 16)H(k)
H(z) =
16 k=0 1 z 1e jk
8

1 z 16 1 1 1
= j0
+ j
+ j15
(16)
16 1
1z e 4 1
1z e 8 1
1z e 8
1 z 16 1 2(1 z 1 cos(/8))
= +
16 1 z 1 1 2z 1 cos(/8) + z 2

It can be be shown that the frequency response of (17) will be equal to the specifications
of (15) at the sampling frequencies = k
8 for k = 0, 1, 2, . . . , 15.

Danilo P. Mandic 21

Digital Signal Processing


The Windowing Method
The Fourier series expansion of the frequency response of a digital filter, H(ej ), is
given by

X
j jn
H(e ) = h(n)e (17)
n=
where Z
1 j jn
h(n) = H(e )e (18)
2 n=
where h(n) is the impulse response of the digital filter.
While the infinite series in (17) can be truncated to obtain the digital filter, the Gibbs
phenomenon states that the truncation will cause overshoots and ripples in the
desired frequency response.
In the method of windowing, a finite weighting sequence w(n), called windows, is
used to obtain the finite impulse response hD (n), where

hD (n) = h(n)w(n)
where w(n) is w(n) = 0 for n > N and n < 0.

Danilo P. Mandic 22

Digital Signal Processing


The Windowing Method

Given the desired frequency response H(ej ), which may be obtained by


the frequency sampling method.

Find the associated impulse response sequence h(n) from 17 or by


inverse z-transform of H(z), where H(z) is obtained from H(ej ) by
replacing ej with z.

Employ an appropriate window function w(n) to modify the sequence


h(n) to obtain the FIR digital filters impulse response sequence
hD (n) = h(n)w(n).

The windowing method has the effect of smoothing out the ripples and
overshoots in the original frequency response as shown in the figure for a
simple window function

Danilo P. Mandic 23

Digital Signal Processing


The Windowing Method
|H(ej )| |H(ej )|
1 1

rad rad

2n
w(n) = 1 + cos for 0 n N 1
N
= 0 otherwise (19)

Danilo P. Mandic 24

Digital Signal Processing


The Windowing Method: Some common window
functions

Rectangular Window

w(n) = 1 for 0 n N 1
= 0 otherwise (20)

Bartlett Window or Triangular Window

2n
w(n) = for 0 n (N 1)/2
N 1
2n
= 2 for (N 2)/2 n N 1 (21)
N 1
= 0 elsewhere

where N is even.

Danilo P. Mandic 25

Digital Signal Processing


The Windowing Method: Some common window
functions

Hann Window

1 2n 
w(n) = 1 cos for 0 n N 1
2 N 1
= 0 elsewhere (22)

Hamming Window

 2n 
w(n) = 0.54 0.46 cos for 0 n N 1
N 1
= 0 elsewhere (23)

Danilo P. Mandic 26

Digital Signal Processing


The Windowing Method: Some common window
functions
Blackman Window
 2n   4n 
w(n) = 0.42 0.5 cos + 0.008 cos for 0 n N 1
N 1 N 1
= 0 elsewhere (24)

Kaiser Window
q
N 1 2 N 1 2
   
I0 wa 2 n 2
w(n) =  N 1
 for 0 n N 1
I0 wa 2
= 0 elsewhere (25)

where I0(.) is a modified zeroth order Bassel function of the first kind
and wa is a window shaper parameter.

Danilo P. Mandic 27

Digital Signal Processing


Two Sinusoids in WGN:- Hamming window

x[n] = 0.1 sin(n 0.2 + 1) + sin(n 0.3 + 2) + w[n] N = 128


 n
Hamming window w[n] = 0.54 0.46 cos 2
N

15 20

10 10

5
0
Magnitude (dB)

Magnitude (dB)
0
10
5
20
10
30
15

40
20

25 50

30 60
0 0.2 0.4 0.6 0.8 1 0 0.2 0.4 0.6 0.8 1
Frequency (units of pi) Frequency (units of pi)

Expexted value of periodogram Periodogram Using Hamming window

Danilo P. Mandic 28

Digital Signal Processing


The Modified Periodogram
The periodogram of a process that is windowed with a general window
w[n] is called a modified periodogram and is given by:-
2
1 X

PM () = x[n]w[n]en

N U n=

1
PN 12
where N is the window length and U = n=0 |w[n]| is a constant,
N
and is defined so that PM () is asymptotically unbiased.
In Matlab:-

xw=x(n1:n2).*w/norm(w);
Pm=N * periodogram(xw);

where, for different windows

w=hanning(N); w=bartlett(N);w=blackman(n);

Danilo P. Mandic 29

Digital Signal Processing


Cosinetype windows
Idea:- suppress sidelobes, perhaps sacrify the width of mainlobe

Hann window

w = 0.5 * (1 - cos(2*pi*(0:m-1)/(n-1)));

Hamming window

w = (54 - 46*cos(2*pi*(0:m-1)/(n-1)))/100;

Blackman window

w = (42 - 50*cos(2*pi*(0:m-1)/(n-1)) +

+ 8*cos(4*pi*(0:m-1)/(n-1)))/100;

Danilo P. Mandic 30

Digital Signal Processing


Standard Window Functions:- Properties
Triangular window Hamming window

Hann window Blackman window

Danilo P. Mandic 31

Digital Signal Processing


Some Comments on FIR digital Filter

Unlike IIR filters, FIR filters can be designed to have linear phase
characteristics.

FIR filters are always stable.

FIR filters are, however, computationally more expensive than IIR filters
and hence are called for to perform tasks not possible/or not practical
by IIR filters such as linear phase, and multirate filters.

Danilo P. Mandic 32

Digital Signal Processing

You might also like