You are on page 1of 152

Pr

U ofe
N
SW ss
or
,A E
us . A
tra m
b
lia ik
a ira
ja
Part A: Signal Processing

h
h
ja
a ira
Chapter 5: Digital Filter Design

lia ik
b
5.1 Choosing between FIR and IIR filters

tra m
5.2 Design Techniques
5.3 IIR filter Design

us . A
5.3.1 Impulse Invariant Method
5.3.2 Bilinear Transformation

,A E 5.3.3 Digital to Digital Transformation


5.4 Window functions
or
5.5 Design Methods for FIR filters
5.5.1 Design of FIR Filters Using Windows
SW ss

5.5.2 Design Procedure


5.6 Frequency Sampling Filter
U ofe

5.7 Problem sheet A5


Pr
N
h
ja
ira
5.0 Digital Filter Design

a
lia ik
 The design of a digital filter is the task of determining a

b
transfer function which is a rational function of z-1

tra m
a0 a1 z 1 a2 z 2

us . A
(e.g. 1 2
) in the case of a recursive
1 b1 z b2 z

,A E
filter (IIR) or a polynomial in z-1, (a0+a1z-1+a2z-2
+a3z-3) in the case of a non-recursive filter.
or
SW ss
U ofe
Pr
N
h
ja
ira
 Performance specifications: A typical amplitude
characteristic of a low-pass filter is shown below.

a
lia ik
|A (
)| Transition band

b
1+ 

tra m
1
1
1-1
Note: 1 is the 0dB point

us . A
,A E Pass band
Stop band
or
2
Digital Freq
SW ss

()
L u 
Analogue Freq
U ofe

fL fu fs/2 (f)
Pr
N
h
ja
ira
 The goal of the design is to determine a

a
transfer function H(z) so that its amplitude

lia ik
characteristic |H()| satisfies the conditions.

b
tra m
1 1 H () 1 1 for 0 L

us . A
,A EH () 2 for U 
or
SW ss
U ofe
Pr
N
h
ja
5.1 Choosing between FIR and IIR

ira
filters. [4]

a
FIR Filters IIR Filters

lia ik
System function contain only Contain poles and zeros (normally)

b
zeros

tra m
Non-recursive or recursive Only recursive structure is possible; the
structures are both possible; the most widely used form is the cascade

us . A
best known is the non-recursive connection of first-order and second
(transversal) structure. order sections.
FIR Filters can have an exactly The phase responses of IIR filters are

,A E
linear phase response. The
implication of this is that no
nonlinear, especially at the band edges.
or
phase distortion is introduced into
the signal by the filter.
SW ss

The effects of using a limited Because of quantization of the filter


number of bits to implement coefficients, a pole can in principle
U ofe

filters such as round off noise and move from a position inside the unit
quantization errors are much less circle to a position outside the unit circle
severe in FIR than in IIR. and hence cause instability.
Pr
N
h
ja
ira
FIR requires more coefficients IIR requires fewer coefficients for
for sharp cut-off filters than IIR. sharp cut off filters than FIR.

a
Thus for a given amplitude

lia ik
response specification, more
processing time and storage will

b
be required for FIR

tra m
implementation.
Complexity is proportional to the No direct relation between the

us . A
length of the impulse response. complexity and the length of the
impulse response (which is infinite by
definition)

,A E Filters with high selectivity can be


realized with relatively low
or
complexity.
FIR filters have no analogue Analogue filters can be readily
SW ss

counterpart. FIR design transformed into equivalent IIR


procedures are normally digital filters meeting similar
U ofe

iterative procedures. Design specifications. IIR filters can be


equations do not exist designed using design formulae.
Pr
N
h
ja
ira
Example:

a
 An FIR filter is to be designed to meet the following

lia ik
frequency response specifications.

b
tra m
 Pass-band 0.18-0.33 (normalized)

us . A
 Transition band 0.04 (normalized)
 Stop-band deviation 0.001

,A E Pass-band deviation 0.05


or
(i) Sketch the tolerance scheme for the filter.
SW ss

(ii) Express the filter band edge frequencies in the


standard unit of kHz , assuming a sampling frequency of
U ofe

10kHz and the stop band and pass band deviation in dBs.
Pr
N
h
ja
ira
 The tolerance diagram for the filter, is shown below:

a
|H(f)|

lia ik
1+ 

b
1

tra m
1
1-1
f

us . A
,A E
2
or
0.14 0.18 0.33 0.5 f
SW ss
(normalized)
fs=10kHz , therefore 0.37
Pass band: 1.8-3.3 kHz
U ofe

Stop band: 0-1.4 kHz and 3.7-5kHz


Stop band attenuation: -20log10(0.001) = -60dB
Pass band ripple: 20log10(1+0.05) = 0.42 dB
Pr
N
h
ja
ira
Example:

a
 The following transfer functions represent two

lia ik
different filters meeting identical amplitude–

b
frequency response specifications.

tra m
us . A
a 0 a1 z 1 a2 z 2
H1 ( z )  Filter 1
1 b1 z 1 b2 z 2
,A E
or
Where a0 = 0.4981819; a1 = 0.9274777;
SW ss

a2 = 0.4981819; b1 = -0.6744878; b2 = -0.3633482;


U ofe
Pr
N
h
ja
ira
11
H ( z ) h
k z k Filter 2

a
k 0

lia ik
b
Where
h
0 0.54603280 102 h

tra m
11
h
10 .45068750 10 1 h
10

us . A
h
2 0 .69169420 10 1 h
9

,A E h
3 0.55384370 101 h
h
8
4 0 .63428410 10 1 h
or
7
h
5 0 .57892400 100 h
SW ss
6
U ofe
Pr
N
h
ja
ira
 Determine and comment on the computational and
storage requirements.

a
lia ik
x[n] w[n] y[n]
+ +

b
a0

tra m
us . A
-b1 T

,A E
Filter 1
or T a1

a2
SW ss
-b2

w( n ) x (n ) b1w(n 1) b2 w(n 2)


U ofe

y ( n) ao w( n) a1w( n 1) a2 w(n 2)


Pr
N
h
ja
ira
x[n-1] x[n-11]
x[n]

a
T T T

lia ik
b
h(0) h(1) h(2) h(11)

tra m
us . A
+

,A E
or
y[n]
SW ss

Filter 2
U ofe
Pr
N
h
ja
ira
FIR (Filter 2) IIR (Filter 1)

a
lia ik
Number of Multiplications 12 5

b
Number of additions 11 4

tra m
us . A
Storage locations 24 8
(coefficients and data)

,A E
or
It is evident that the IIR filter is more economical in both
SW ss

computations and storage requirements than the FIR filter.


U ofe
Pr
N
h
ja
ira
5.2 Design Techniques [4]

a
 The method used to calculate the filter coefficients

lia ik
(hk for FIR, ak and bk for IIR) depends on whether

b
the filter is IIR or FIR type. There are several

tra m
methods of calculating filter coefficients of which the
following are the most widely used.

us . A
FIR digital filters IIR digital filters


,A E
window 
Impulse invariant transformation
or

Frequency sampling 
Bilinear transformation
 
SW ss
Optimisation method (e.g Remez Pole-zero placement method
Algorithm)
U ofe

Y(z)  2 1) 
(N  Y ( z ) a0 a1 z 1 ...... an z ( N 1) 
 h0 h1 z h2 z ..... hN 1 z
1
  1 L 
X(z) X ( z ) 1 b1 z .......... bL z 
Pr
N
h
ja
ira
 We choose the methods that best suits

a
our particular applications.

lia ik
b
In most cases, if the FIR properties are

tra m

vital then a good candidate is the

us . A
optimization method, where as, if IIR
,A E
properties are desirable, then the
or
bilinear method will in most cases
SW ss

suffice.
U ofe
Pr
N
h
ja
5.3 IIR Filter Design

ira
 In transforming an analogue filter to digital filter, we

a
must obtain either H(z) or h[n] from the analogue

lia ik
filter design. In such transformations, we generally

b
require that the essential properties of the analogue

tra m
frequency response be preserved in the frequency
response of the resulting digital filter. This implies

us . A
that we want the imaginary axis of the s-plane to
map into the unit circle of z-plane.

,A E
A second condition is that a stable analogue filter
or
should be transformed to a stable digital filter. That
is if the analogue system has two poles only in the
SW ss

left half s-plane, then the digital filter must have


poles inside the unit circle.
U ofe
Pr
N
h
ja
ira
5.3.1 Impulse invariant method [1]

a
 In this method we start from an analogue filter of

lia ik
impulse response ha(t) and the system function

b
Ha(s).

tra m
The objective of our design is to realize an IIR filter

us . A

with an impulse response h[n] which satisfies :

,A E
 h[n] = ha(nT) where T-sampling frequency
or
 The characteristic property preserved by this
SW ss

transformation is that the impulse response of the


resulting digital filter is a sampled version of the
U ofe

impulse response of the analogue filter.


Pr
N
h
ja
ira
ha(t) Ha()

Impulse 1

a
response Frequency

lia ik
Response

b
tra m
t 
h[n] H()

us . A
Aliasing
1/T

,A E
or
T 2/T
n -2/T -/T /T 
SW ss

-2 - 0  2 
U ofe

We see that with this method there are problems to a


greater or lesser extent depending on the choice of T.
Pr
N
h
ja
ira
 The sampling frequency affects the
frequency response of the impulse

a
invariant discrete filter. A sufficient high

lia ik
sampling frequency is necessary for the

b
frequency response to be close to that

tra m
of the equivalent analogue filter.

us . A
Thus due to aliasing, the frequency

,A E
response of the digital filter will not be
or
identical to that of the analogue filter.
SW ss

 So how do we find the filter coefficients of


U ofe

the IIR filter in this design method?


Pr
N
h
ja
ira
 To obtain the mapping let,

a
H a 
1
s  , b 0 Inverse Laplace transform

lia ik
s b

b
tra m
ha (t ) e bt

us . A
Sampled sequence

ha ( nT ) e bnT

,A E h

e bnT n 0
or
Usually written as n 
0 n 0
SW ss

1
U ofe

 H ( z)  z-transform
1 e bT z 1
Pr
N
h
ja
ira
 It is seen that H(z) is obtained from H a(s) by using
the mapping relationship

a
lia ik
1 1
 , b 0 T-sampling period

b
bT 
s b 1 e z 1

tra m
j

us . A
3/T
s-plane z-plane
= 

,A E
=0
/T
 = -
/T
or
|z|=1
SW ss

-3/T
Each strip maps onto
the interior of the unit circle
U ofe

In this kind of mapping, the perimeter is the imaginary axis.


Note: Mapping does not exist for the zeros.
Pr
N
h
ja
ira
Example: 2
H ( s) 

a
( s 1)( s 3)

lia ik
Using partial fractions this can be written as

b

tra m
1 1
H ( s)  

us . A
s 1 s 3

,A E
1

1
or
s b 1 e bT z 1  H (s ) 
1
 3T 1
1
T 
1 e z 1 e z
SW ss
1

T
e e 3T
 z 
1
U ofe

 T 3T 1 4 T 2
1 (e e ) z e z
Pr
N
h
ja
Example:

ira
 Use the impulse invariant method to design digital

a
filter from an analogue prototype that has a system

lia ik
function. s a

b
H ( s) 
( s a ) 2 b 2

tra m
us . A
 To design a filter using the impulse invariant method,
expand H(s) in a partial fraction form:

,A E
 H ( s) 
s a
s a jb s a jb 

A

B
 s (a jb) s ( a jb)
or
1 1
SW ss

 2 2

s (a jb) s ( a jb)


U ofe

1 1  1 1 
   
2 s (a jb)  2 s (a jb) 


Pr
N
h
ja
ira
1 1
Substituting  cT 1
(Impulse invariant transform)
s c 1 e z

a
lia ik
b
tra m
1 1  1 1 
H ( z )   ( a jb)T 1   ( a jb )T 1 
2 1 e z  2 1 e z 

us . A
1

1 e ( a jb )T 
  1
z  1 e ( a jb)T z 1
1

,A E 2 2
(1 e ( a jb)T z 1 )(1 e ( a jb )T z 1 )
or
1 e aT cos(bT ) z 1
SW ss


1 2e aT cos(bT ) z 1 e 2aT z 2
U ofe
Pr
N
h
ja
ira
 Hence,
1
1 a1 z

a
H ( z) 

lia ik
 2
1 b1 z b2 z
1

b
where

tra m
a1 e aT
cos
bT 
, b1 2e aT
cos
bT  and b2 e 2 aT

us . A
s a 1 e aT cos(bT ) z 1
,A E
(s a) b
2 2

1 2e aT cos(bT ) z 1 e 2 aT z 2
or
SW ss
Note that the zero at s=-a is mapped to a zero at
z=e-aTcos(bT). Thus, the location of the zero in the
U ofe

discrete time filter depends on the position of the poles as


well as the zero in the analogue filter.
Pr
N
h
ja
ira
Example:

a
lia ik
 Using impulse invariant method design a digital filter

b
to approximate the following normalized analogue

tra m
transfer function:

us . A
1
H (s )  2 [1]
,A E s  2 s 1
or
 Assume that the 3dB cut-off frequency of the digital
SW ss

filter is 150Hz and the sampling frequency is 1.28 kHz


U ofe
Pr
N
h
ja
ira
Solution:

a
 Before applying the impulse invariant method, we

lia ik
need to de-normalize the transfer function.

b
tra m
1
H 1 ( s) H ( s ) 
 2 1

us . A
s
s s 2 s
c s s

,A E
H ( s)  2
c
2
or
2 where c 2150 942.4778
s  2c s c
SW ss

c2 A B
U ofe

H1 ( s )   
s  2c s c
2
s p1 s p2
Pr
N
h
ja
ira
 2c  2c2 4c2
p1 , p 2 

a
2

lia ik
 2c j 2c

b
2

tra m
 2c 
1 j
 p1 666.4324(1 j )

us . A
2
p 2 666.4324(1 j )

,A E
p1 
 2c
2

1 j  c
A  j
or
2
 2c c
p2  
1 j  B
SW ss
j
2 2
U ofe
Pr
N
h
ja
ira
A B A(1 e p 2T z 1 ) B (1 e p1T z 1 )
H1 ( z )  p1T 
 
1 e z 1
1 e p 2T z 1 (1 e p1T z 1 )(1 e p2T z 1 )

a
lia ik
( A B ) ( Ae p2T Be p1T ) z 1
H (z) 

b
1 (e p1T e p2T ) z 1 e p1T z 2

tra m
393.9264 z 1

us . A
H (z) 
1 1.0308 z 1 0.3530 z 2

,A E
H () 
393.9264e j
1 1.0308e j 0 .3530e j 2
or
SW ss

393.9264
H () 0  1223
1 1.0308 0 .3530
U ofe

This is approximately equal


to the sampling frequency
Pr
N
h
ja
ira
393.9264
H () 0  1223
1 1.0308 0.3530

a
lia ik
 Such a large gain is characteristic of

b
impulse invariant filters .

tra m
us . A
 To keep the gain down (and to avoid
overflows when the filter is implemented).
,A E
It is common practice to divide the gain by
or
fs. Thus the new transfer function becomes
SW ss

1
0.3078 z
H ( z) 
U ofe

 2
1 1.0308 z 0.3530 z
1
Pr
N
h
ja
a ira
x[n] 0.3078
+

lia ik
b
tra m
z-1
1.0308

us . A
y[n]

If x[n]=
,A E
or z-1 [n] then y[n]=h[n].

-0.3530
SW ss
U ofe
Pr
N
h
ja
a ira
Impulse response Impulse response
of the analogue of the digital filter

lia ik
filter h(t) is identical to that h[n]

b
of analogue filter
h(t) = h(n)

tra m
us . A
,A E t 01 2345 n
or
SW ss

Note: The sampling frequency affects the frequency


U ofe

response of the digital filter obtained using impulse invariant


transformation.
Pr
N
h
ja
ira
 A sufficient high samples frequency is necessary for
the frequency response to be closer to that of the

a
equivalent analogue filter (see below)

lia ik
|H(j)|

b
tra m
Low degree of aliasing can
be achieved by making the

us . A
sampling frequency high.

|H()|

,A E
0 f
aliasing
or
SW ss
U ofe

 2 4 

fs/2 fs 2fs
Pr
N
h
ja
ira
5.3.2 Bilinear Transformation [1]

a
The bilinear transformation yields stable

lia ik

digital filters from stable analogue filters (the

b
impulse invariant technique may not).

tra m
Also the bilinear transformation avoids the

us . A
problem of aliasing encountered with the use

,A E
of the impulse invariant transformation,
because it maps the entire imaginary axis in
or
the s-plane on to the unit circle in the z-plane.
SW ss
U ofe
Pr
N
h
ja
ira
j

a
lia ik
s-plane z-plane

b
tra m
us . A

,A E
or
SW ss
Image of the left hand s-plane.
U ofe
Pr
N
h
ja
ira
2
sT sT  1
sT
1    ...

a
e 2
2 2  2
z e sT  sT 

lia ik
2
sT sT  1
e 2 1    ...

b
2 2  2

tra m
sT
1

us . A
z 2
sT (drop out higher order terms)
1
2
,A E
or

1
2 1 z
SW ss

s 
T 1 z 1
U ofe
Pr
N
h
ja
a ira
The price paid for the avoidance of aliasing is

lia ik

an introduction of distortion in the frequency

b
axis.

tra m
us . A
 Consequently, the design of digital filters

,A E
using the bilinear transformation is only
useful when the distortion can be
or
compensated.
SW ss
U ofe
Pr
N
h
ja
ira
Example:

a
 We have a system function Ha(s) such that

lia ik
b

b
H a (s ) 
s b

tra m
us . A
 Applying bilinear transformation,

bT (1 z 1 )
,A E H (z) 
b
2 1 z 1
b

bT 2 (bT 2) z 1
or
1
T 1 z
SW ss

1
Let b 1000 & T 
U ofe

1000
Pr
N
h
ja
ira
 The modulus of the frequency response H() and
H() are shown below:

a
lia ik
|H(j)|
1 b
H ( j) 

b
jb

tra m
us . A
-3000-1500 1500 3000 

,A E fs
1 |H(
)|
fs
or

2 2
SW ss

- -/2 /2  
U ofe

-1000 -500 500 1000 


Pr
N
h
ja
ira
 There is a very important property of

a
the bilinear transformation that can be

lia ik
seen in the above example. The entire

b
frequency range (-∞a ∞) of the

tra m
us . A
continuous system maps into the
fundamental interval (-) of the
,A E
discrete system, where = 0
or
corresponds to = 0, = ∞to = 
SW ss

and = - ∞to = -.


U ofe
Pr
N
h
ja
ira
 To demonstrate that this mapping has the property
that the imaginary axis in the s-plane maps onto the

a
unit circle, let z = ejand s = j.

lia ik
b
, 2 1 z 1
Then since s  2 1 e j

tra m
T 1 z 1 j
T 1 e j

us . A
2 
j j tan 
T 2 
,A E Hence,
2 
 tan 
or
T 2 
SW ss

or
T 
U ofe

 1
2 tan  
2 
Pr
N
h
ja
ira
We see that a nonlinear relation exists between and .
This effect is called ‘Warping’ and is shown below.

a
lia ik

b

tra m
us . A
. T

,A E -
or
T  T
1
At low frequencies tan  
SW ss

2  2
U ofe

 T
2  T
2
Pr
N
h
ja
ira
 The great advantage of warping is that no

a
aliasing of the frequency characteristic can

lia ik
occur in the transformation of an analogue

b
filter to a discrete filter, which we

tra m
encountered in the impulse-invariant method.

us . A
 We must however check carefully just how
the various characteristic frequencies of the
,A E
continuous characteristic frequencies of the
or
discrete filter.
SW ss

 We can illustrate this with the aid of a


U ofe

diagram (next slide) for a band-pass filter.


Pr
N
h
ja
ira

a
 
3

lia ik
2

b
1

tra m

us . A
-

,A E
Digital filter
response Analogue
or
filter
response
SW ss

1 2 3 
U ofe

The effect of “warping” in the conversion of |H()| →|H()|


is seen from the above diagram.
Pr
N
h
ja
ira
 In designing a digital filter by this method we must
first pre-wrap the given filter specifications to find

a
the continuous filter to which we are going to apply

lia ik
the bilinear transformation.

b
tra m
Example:

us . A
 The specification of a desired digital low pass filter is
shown below.

,A E
 Sampling frequency: fs = 8kHz (T =1/fs = 125s)
or
fL
A pass band up to fL = 2.6 kHz (L L T 2 0.65)
SW ss

fs
U ofe

fu
and a stop band, fu, above 3kHz (u LT 2 0.75 ).
fs
Pr
N
h
ja
ira
|H()|

a
1+1

lia ik
1

b
Digital filter Response
1-1

tra m
us . A
,A E
2
0
or
L u  
SW ss
U ofe

2.6kHz 3kHz fs /2
Pr
N
h
ja
ira
We must start from an analogue filter with
L

a
2
L 2f l  tan 2( 4155)  f L 4.155kHz

lia ik
T 2

b
2 u

tra m
u 2f h  tan( ) 2(6148)  fu 6.148kHz
T 2

us . A
H()

,A E Analogue filter
Response
or
4.155kHz
SW ss
U ofe

0
4Hz 6.148 8kHz
Pr
N
h
ja
ira
Example:

a
 Determine, using bilinear transformation

lia ik
method, the transfer function and difference

b
equation for the digital equivalent of the RC

tra m
filter. The normalized transfer function for the

us . A
RC filter is
1
,A E H (s) 
s 1
or
SW ss

 Assume a sampling frequency of 150Hz and a


cut-off frequency of 30Hz.
U ofe
Pr
N
h
ja
ira
Solution:

a
1
c cT 2f c 

lia ik
fs

b
before pre-warping

tra m
1
c 2(30)  0 .4

us . A
150
Pre-warped frequency
,A E
f c' is always > f c (un-warped freq= 30 Hz)
or
SW ss
'
and after warping, f c = 34.68Hz.
U ofe
Pr
N
h
ja
ira
 The de-normalized analogue filter transfer function
s
(this is achieved by replacing s with ) is obtained

a
c

lia ik
from H(s) as

b
tra m
2 
 0.7265
c

us . A
'
H (s )1 H (s )   T
s s s 2 0.7265
s '
s '
c

,A E T
or
0.4208(1 z 1 )
SW ss

0.7265(1 z )
H ( z ) H 1 ( s) 2 z 1 
  
s (1 7265 ) z 0 . 7265 1 1 0. 1584 z 1
U ofe

T z1
Pr
N
h
ja
ira
Example:

a
 It is required to design a digital filter to

lia ik
approximate the following analogue transfer

b
function [1]

tra m
1
H ( s)  2

us . A
s  2 s 1
Using the Bi-linear transformation method
,A E

obtain the transfer function, H(s) of the


or
digital filter assuming a 3dB cut-off frequency
SW ss

of 150Hz and a sampling frequency of


1.28kHz.
U ofe
Pr
N
h
ja
ira
Solution :

a
fc = 150Hz fs = 1280Hz

lia ik
f c  150 15 1
c 2
f  2(1280 ) 64 
T

b
s  fs

tra m
The analogue frequency after pre-warping

us . A
15
  
2   2 2
c'  tan c  1280 tan64 987.5009  0.3859 rad / sec
,A E
T 2  T 2 
 
 
T
or
987.5009
SW ss
f c'  157.1656 Hz
2
U ofe

'
fc is always greater than fc .
Pr
N
h
ja
ira
Prewarped analogue filter is given by,

a
lia ik
2
2 
  0.3857 
2

T 

b
H1 (s )  2
2 

tra m
2
s 2  (0.3857) 2s  (0.3857) 2
T T 

us . A
2
2 
 
0. 3857 
2

,A E
H ( z ) H1 ( s)
s
2 z 1
T z 1

2

2
z 1  2
T

 0.3857  2
2
2 z 1  2 
  0.3857 
2
or
T z 1  T T z 1  T 
SW ss

0.0878 1 2 z z  1 2

U ofe

H ( z) 
1 1.0048z 1 0.3561z 2
Pr
N
h
ja
 

ira
' 2
Bilinear transformation
c 0.0878(1 2 z 1 z 2 )
s 2  2c' s c '  2
1 1.0048 z 1 0.3561z 2

a
lia ik
All pole Poles & zeros

b
tra m
0

us . A
gain Analogue frequency
(dB) response
|H(j)|

,A E |H()|
or
fc 640Hz f (rad/s)
150Hz
SW ss
digital frequency
response fs/2
U ofe

Note:
Same cut-off frequency
increased roll off and attenuation in stop band.
Pr
N
h
ja
ira
Example :
(a) An analogue transfer function can be converted

a
to a digital transformation using the bilinear

lia ik
transformation. Derive this transform relationship

b
using the following equation.

tra m
us . A
y
n y 
n 1
  x
n x
n 1

T Digital Integrator
2
,A E
or
1
H ( s)  Analogue Integrator
s
SW ss

T-sampling period, x[n] - input , y[n] - output


U ofe
Pr
N
h
ja
ira
Solution:

a
Y 
z Y 
T


z z  X ( z) X ( z) z
1 
1

lia ik
2

b

T 1 z 1

tra m
H ( z)  
(1)
2 1 z 1

us . A
1
H ( s)  (2)
,A E s
or
Setting (1) = (2),
SW ss

 1
1 T 1 z 1
2 1 z
 s
U ofe

 
s 2 1 z 1
T 1 z 1
Pr
N
h
ja
ira
(b) Convert the analogue filter H(s)

a
s 0.1

lia ik
H ( s) 
( s 0 .1) 2 16

b
tra m
into a digital IIR filter by means of the bilinear

us . A
transformation. The digital filter is to have a resonant
frequency 0  .

,A E 2
s 0 .1
or
H ( s)  2
s 0 .2 s 16.01
SW ss

02
U ofe
Pr
N
h
ja
ira
 The analogue filter has a resonant frequency 0 4 rad/ sec .

a

The frequency is to be mapped into 0  by selecting

lia ik

2
the value of the parameter T.

b
tra m
2 0
0  tan

us . A
T 2
2 2 2  2
4  tan  tan 4
,A E T 2 T 4 T
or

 1
T  in order to have 0  rad / sec
SW ss
2 2
U ofe

Thus the desired mapping is 


1 z 1 
s 4
 

1 
1 z 

Pr
N
h
ja
ira

1 z 1 
4
 0.1
1 
1 z 

a
H ( z ) H ( s) 
1z 1 

lia ik
2
s 4 
1z 1  
1 z 

1

1 z 1 
  4
 0.2 4
1   16.01
1 

b
 
1 z 
 1 z 

tra m
0.128 0.006 z 1 0.122 z 2 0.128 0.006 z 1 0.122 z 2
 

us . A
1 2
1 0 .0006 z 0 .975 z 1 0 .975 z 2
This filter has poles at
,A E 
or
j
p1 0.987e 2
resonant frequency
SW ss

j
p 2 0.987e 2
U ofe

and zeros at z1 = -1 and z2 = 0.95.


Pr
N
h
ja
ira
Example :
1
Convert the simple low pass filter H ( s ) 

a
 into
s 1

lia ik
an equivalent high pass discrete filter.

b
Assume fs = 50Hz, analogue cut-off fc = 30Hz.

tra m
30 
c 2 0.4

us . A
150 

,A E '
c
2
  tan(
T
0.4 2
2
)  0.7265
T
or
LPF to HPF transformation
SW ss

1 s
H (s ) H ( s)  ' 
U ofe

'

s
c'
c s c'
s 1
s
Pr
N
h
ja
ira
2 z 1 

a
 
T z 1  z 1

lia ik
H ( z ) H ( s) 2 z 1 
'

z    2 z  1  2 z 1 0.7265( z 1)

b
T z 1    0.7265
T z 1  T

tra m
us . A
1 z 1
H ( z ) 0.5792
,A E 1 0.1584 z 1
or
SW ss
U ofe
Pr
N
h
ja
ira
Example 1:

a
lia ik
 Let us now apply this approach to the design of a

b
digital low-pass filter. The amplitude response

tra m
specification is

us . A
 Sampling Frequency : fs = 8 kHz

,A E
 Passband: fc = 0 to 1.3 kHz
 Stopband: fh 2.6 kHz
or
 Maximum ripple in passband: 1 = 0.1 dB
2 = -33.5 dB
SW ss
 Minimum attenuation in stopband:
U ofe
Pr
N
h
ja
ira
Step 1 :

a
From the sampling frequency fs and the cut-off

lia ik

frequency fc we can determine c and h:

b
tra m
us . A
fc fh
c 2 1.0210
and h 2 2.0420
fs fs

,A E
or
SW ss
U ofe
Pr
N
h
ja
ira
Step 2 :

a
 Determine the stop-band edge frequency fh or h

lia ik
using

b
2 c 2 h

tra m
c  tan and h  tan
T 2 T 2

us . A
In filter design tables c is normalised to 1 rad/sec.

,A E 2

c
1.7856
or
T tan c
SW ss

2
U ofe

2 .0420
h 1.7856 tan 2.9139
2
Pr
N
h
ja
ira
Step 3 :

a
 Determine an appropriate transfer function. Thus we

lia ik
need an analogue filter with a maximum ripple of

b
0.1dB in the pass-band (0 ≤≤1) and a minimum

tra m
attenuation of -33.5 in the stop-band (2.914 ≤≤∞).

us . A
 From the tables we choose a 3rd order elliptic filter

,A E
with a transfer function
or
s 2 10.2089
H a 
s 
SW ss

5.8881( s 1.0398)( s 2 0 .8700 s 1.6674)


U ofe

which meets these specifications.


Pr
N
h
ja
ira
Step 4 :

a
 Apply the bilinear transformation to obtain a digital

lia ik
filter transfer function:

b
tra m
2 1 z 1 1 z 1
s 
and s 1.7856
T 1 z 1 1 z 1

us . A
Substituting for s, we get
,A E
or
0.1256(1 1 .0478 z 1 z 2 )(1 z 1 )
H (z) 
SW ss

(1 0.2640 z 1 )(1 0 .4748 z 1 0 .5153 z 2 )


U ofe
Pr
N
h
ja
ira
 % Exercise 1. IIR digital filter design
 % We wish to design an IIR digital filter given some specifications.
 % We use the example given in page 30 of chapter 5.

a
 % The task is to design a low-pass filter, whose magnitude response
specifications

lia ik
 % are as follows:
 sampling_frequency = 8000 % fs = 8 kHz

b
 passband_frequency = 1300 % fc = 1.3 kHz
 stopband_frequency = 2600 % fh = 2.6 kHz

tra m
 passband_ripple = 0.1 % 0.1 dB
 stopband_ripple = 33.5 % 33.5 dB

us . A
 % Step 1. Evaluate digital frequencies
 passband_digital_frequency = 2*pi*passband_frequency/sampling_frequency
 stopband_digital_frequency = 2*pi*stopband_frequency/sampling_frequency
% Step 2. Evaluate analog frequencies

,A E

 passband_analog_frequency =
2*sampling_frequency*tan(passband_digital_frequency/2)
stopband_analog_frequency =
or

2*sampling_frequency*tan(stopband_digital_frequency/2)
 % Step 3. Determine the normalized analog low-pass filter
SW ss
 [filter_order, cutoff_frequency] = ellipord(...
 passband_analog_frequency, stopband_analog_frequency, ...
 passband_ripple, stopband_ripple, 's')
U ofe

 [numerator, denominator] = ellip (filter_order, ...


 passband_ripple, stopband_ripple, cutoff_frequency, 's')
Pr
N
h
ja
ira
 % Plot the magnitude response of the analog low-pass filter
 frequency = 1:sampling_frequency;
 angular_frequency = frequency*2*pi;

a
 [frequency_response] = freqs(numerator, denominator,
angular_frequency);

lia ik
 magnitude_response = 20*log10(abs(frequency_response));
figure(1), clf

b

 plot(frequency, magnitude_response)

tra m
 grid on
 title ('Magnitude response of the analog filter')

us . A
 ylabel('Magnitude (dB)')
 xlabel('Analog frequency')
 hold on

,A E
semilogx([0 passband_analog_frequency/2/pi], [-passband_ripple -
passband_ripple], 'r')
semilogx([passband_analog_frequency
or

passband_analog_frequency]/2/pi, [-passband_ripple -
stopband_ripple*2], 'r')
semilogx([stopband_analog_frequency
SW ss

stopband_analog_frequency]/2/pi, [1 -stopband_ripple], 'r')
 semilogx([stopband_analog_frequency/2/pi sampling_frequency], [-
U ofe

stopband_ripple -stopband_ripple], 'r')


 axis([0 sampling_frequency -stopband_ripple*2 0])
 hold off
Pr
N
h
ja
a ira
Magnitude response of the analog filter

lia ik
0

b
-10

tra m
-20
Magnitude(dB)

us . A
-30

-40

,A E -50
or
-60
SW ss
0 1000 2000 3000 4000 5000 6000 7000 8000
Analog frequency
U ofe
Pr
N
h
ja
ira
 % Step 4. Apply bilinear transformation to obtain the digital filter transfer function
 [digital_numerator, digital_denominator] = bilinear(numerator, denominator,
sampling_frequency)

a
 % Impulse invariant method can be selected instead of bilinear transformation.
% Matlab provides a build-in command called `impinvar'.

lia ik

 % You may experiment with `impinvar' and compare the outcome with those of the bilinear
transformation.

b
 % Plotting the magnitude response
 digital_frequency = (0:0.01:1)*pi;

tra m
 frequency_response = freqz(digital_numerator, digital_denominator, digital_frequency);
 magnitude_response = 20*log10(abs(frequency_response));
 figure(2), clf

us . A
 plot(digital_frequency, magnitude_response)
 grid on
 title ('Magnitude response of the digital filter')
 ylabel('Magnitude (dB)')

,A E
xlabel('Digital frequency')
hold on
semilogx([0 passband_digital_frequency], [-passband_ripple -passband_ripple], 'r')
or
 semilogx([passband_digital_frequency passband_digital_frequency], [-passband_ripple -
stopband_ripple*2], 'r')
 semilogx([stopband_digital_frequency stopband_digital_frequency], [1 -stopband_ripple],
SW ss
'r')
 semilogx([stopband_digital_frequency pi], [-stopband_ripple -stopband_ripple], 'r')
 hold off
axis([0 pi -stopband_ripple*2 0])
U ofe


Pr
N
h
ja
ira
 % There are several methods to produce the impulse response
of the digital IIR filter.
% One method is to feed a unit impulse function into the filter.

a

impulse_response_iir = filter(digital_numerator,

lia ik

digital_denominator, [1 zeros(1,50)]);
figure(3), clf

b

 stem(impulse_response_iir)

tra m
 % Another method is to use Matlab's built-in command, `impz'.
 % `impz' also accepts additional inputs. Use `help' to find out

us . A
more.
 [impulse_response_iir, time] = impz(digital_numerator,
digital_denominator);


,A E
stem(impulse_response_iir)
% You may try different specifications. Other analog filter types,
or
such as, chebyshev type
 % I can also be used, simply by replacing `ellipord' and `ellip'
with `cheb1ord' and `cheby1'.
SW ss
U ofe
Pr
N
h
ja
ira
Magnitude response of the digital filter
0

a
lia ik
-10

b
-20

tra m
M agnitude (dB)

us . A
-30

-40

,A E -50
or
SW ss
-60

0 0.5 1 1.5 2 2.5 3


U ofe

Digital frequency
Pr
N
h
ja
ira
Impulse response of the IIR filter
0.5

a
lia ik
0.4

b
tra m
0.3

us . A
0.2

0.1

,A E0
or
SW ss
-0.1

-0.2
U ofe

0 5 10 15 20 25 30
Pr
N
h
ja
ira
Example 2 :

a
lia ik
 We wish to design a digital filter which meets the

b
following specifications:

tra m
Low-pass filter: 0 to 10 kHz passband

us . A

 Sampling frequency: fs = 100 kHz


 Transition band: 10 kHz to 20 kHz

,A E
 Stopband attenuation : -10 dB(Starting at 20 kHz)
or
 The filter must be monotonic in the pass and stop
SW ss

bands, (i.e. no ripple).


U ofe
Pr
N
h
ja
ira
Step 1 :

a
The monotonic requirement indicates a

lia ik

Butterworth filter.

b
tra m
fc 10,000
c 2 2 0.2

us . A
fs 100,000

,A E and
or
fh
h 2 0.4
SW ss

fs
U ofe
Pr
N
h
ja
ira
Step 2 :

a
 We can calculate the corresponding analogue

lia ik
filter frequencies:

b
tra m
2 0.2
c  tan 2 f s tan(0.1) 0.6498 10

us . A
5

T 2

,A Eh 2 f h tan(0.2) 1.4531105


or
SW ss
U ofe
Pr
N
h
ja
ira
Step 3 :

a
 The required order of the Butterworth filter can be

lia ik
determined by using the following equations,
ensuring at least 10 dB attenuation at

b
tra m
1
H a () 
2

us . A
2N
h 
1 
 
c
,A E  1 .4531  
or
2N

10 log H a () 10 log 


2
1  
 0.6498  

SW ss


U ofe

2N

1.4531 
1   10  N 1.367

0 .6498 
Pr
N
h
ja
ira
 Thus we choose N = 2 (even). The poles occur in
complex conjugate pairs and lie on the left-hand side

a
lia ik
of the s-plane.

b
tra m
3
j
p1 c e 4
0.6498 105 (0.7071 j 0.7071)

us . A
5
j
p 2 c e 4
0.6498 105 ( 0.7071 j 0.7071)
,A E
or
p1 p 2 4.223 10 9
H ( s)   2
s p1 
s p 2  s 0.919 10 5 s 4.223 10 9
SW ss
U ofe
Pr
N
h
ja
ira
Step 4 :

a
 Now apply the bilinear transformations

lia ik
to obtain H(z)

b
tra m
1
1 z

us . A
s 2 10 5

1 z 1

,A E 0.0675 0.1349 z 1 0.0675 z 2


or
H (z) 
(1 1.143 z 1 0.4123 z 2 )
SW ss
U ofe
Pr
N
h
ja
ira
5.3.3 Digital -To-Digital Transformations

a
We have seen in the lecture notes that one method

lia ik

for the design of analogue filters relied on applying a

b
transformation to an analogue low-pass filter with a

tra m
unit bandwidth. It was shown that we could obtain

us . A
low-pass, high-pass, band-pass and band-stop filters
by selecting the appropriate transformation.

,A E
Similarly, a set of transformations can be formed that
or
take a low-pass digital filter and turn it into high-
pass, band-pass, and band-stop or another low-pass
SW ss

digital filter.
U ofe
Pr
N
h
ja
ira
 The transformations are given below:
Digital to Digital Transformations

a
lia ik
20 log |H()| 20 log |H()|

b
Low-pass to Low-pass

tra m
0 0



us . A
1
k1  z k1
z 
1

1 z 1

,A E p  p’ 
or
SW ss

sin[(p p ' ) / 2]



U ofe

sin[(p p ' ) / 2]


Pr
N
h
ja
ira
20 log |H(
)|
20 log |H()|

a
0

lia ik
0 Low-pass to High-pass
k1

b
k1 


tra m
1
 z
z 
1

1z 1

us . A
p  p’ 

,A E
Simplest transformation is to change the signs of poles and zeros of
or
the LP  LP transformation

cos[(p p ' ) / 2]


SW ss


cos[(p p ' ) / 2]
U ofe
Pr
N
h
ja
ira
20 log |H()|
Lowpass to Band-pass 20 log |H()|
0 0

a
k1

lia ik
-3 dB

b
tra m
p  L u 

us . A
2k 1 k 1
2
z  z 
z 1   k 1 k 1
,A E cos[(u L ) / 2]
k 1 2 2k 1
k 1
z 
k 1
z 1
or

cos[(u L ) / 2]
SW ss

p 
U ofe

tan
k cot((u L ) / 2)  2 
 
Pr
N
h
ja
ira
20 log |H()| 20 log |H()|

a
lia ik
0 Lowpass to Band-stop

b
k1

tra m
us . A
p  L u 

2 1 k 1
,A E
2
z  z 
z 1  k 1 k 1
or
k 1 2 2 1
z  z 1
k 1 k 1
SW ss
U ofe
Pr
N
h
ja
5.4 Window Functions

ira
Some of the most commonly used window functions are:

a
Rectangular Bartlett
1 1

lia ik
0.8 0.8

Rectangular 0.6 0.6


Bartlett

b
0.4 0.4

tra m
0.2 0.2

0 0
0 5 10 15 20 0 5 10 15 20

us . A
Blackman Hamming
1 1

0.8 0.8

Blackman Hamming
0.6 0.6

,A E 0.4

0.2
0.4

0.2
or
0 0
0 5 10 15 20 0 5 10 15 20

Hanning Kaiser, beta=4


1 1
SW ss

0.8 0.8

Hanning 0.6 0.6


Kaiser, beta=4
U ofe

0.4 0.4

0.2 0.2

0 0
0 5 10 15 20 0 5 10 15 20
Pr
N
h
ja
ira
 To Analyze a truncation process we model it as a
multiplication of the desired sequence by finite

a
duration window sequence denote by w[n].

lia ik
Truncation of a sequence s[n] is equivalent to

b
tra m
placing a rectangular time window around s[n].

us . A
Frame 1 Frame 2

,A E
w[n]
s[n]
or
speech signal
SW ss
U ofe
Pr
N
h
ja
ira
 Vocal tract shape changes every 15ms. When using
a sampling frequency of 8 kHz (T = 125s) with

a
100 samples in each frame (12.5ms),

lia ik
b
y 
n sw
n  In frequency Y () S 
 W ()

tra m
n
domain,

us . A
(Multiplication becomes convolution in the frequency domain)


,A E
Thus when window is applied, the frequency domain
or
convolution causes distortion in the spectrum Y(). It can be
shown that the rectangular window creates ripples in the
SW ss

spectrum Y(). To reduce the distortion, use Hamming or


U ofe

Kaiser Window.
Pr
N
h
ja
ira
Rectangular Window :

a
w[n]

lia ik
1 0 n N 1

b
1.0
w
n 

tra m

0 otherwise

us . A
N n

,A E N
1
W ( z ) w( n) z n 1 z 1 z 2 ....... z ( N 1) 
1 z N
or
n 0 1 z 1
SW ss

1 e jN
W () W ( z ) z e j 
U ofe

1 e j
Pr
N
h
ja
ira
N N
N 1 sin
N 1 

a
W 
j 
W () e 2
sin 2 
  
  2
 

lia ik
2  sin

b
2 2

tra m
|W()|

us . A
Main Lobe

,A E Side lobes or ripples


or
SW ss

-  
U ofe

-2/N 2/N
Pr
N
h
ja
ira
|W()|

Main Lobe

a
Side lobes or ripples

lia ik
b
tra m
-  

us . A
-2/N 2/N


,A E
If N increases the width of the main lobe
decreases but the peak amplitude of the side
or
lobes grows in a manner such that the area
SW ss

under each lobe is constant while the width


U ofe

of each lobe decreases with N.


Pr
N
h
ja
ira
5.5 Design Methods for FIR filters [11]

a
 The most essential feature of FIR filters is, by

lia ik
definition, the finite length of the impulse response.

b
Another important point is that it can be seem

tra m
directly from the impulse response of an FIR filter
whether we have a linear phase characteristic or not.

us . A
A filter is said to have a linear phase response of its

,A E
response satisfies one of the following relationships.
or
() a (1)
SW ss

where a and b are constants.


U ofe


 b a ( 2)
Pr
N
h
ja
ira
() a (1)

a


lia ik
 b a ( 2)

b
tra m
 It can be shown that for condition (1) above to be
satisfied the impulse response of the filter must have

us . A
positive symmetry.

,A E h
n h
N n 1, a 
N 1
or
2
SW ss

 where N denotes the filter length.


U ofe
Pr
N
h
ja
ira
 When the condition given in (2) is satisfied, the
impulse response of the filter has negative symmetry.

a
lia ik
N 1 
h
n h
N n 1 , a and b 

b
2 2

tra m
centre of symmetry

us . A
(Positive symmetry)

,A E N = 13 (odd)
or
SW ss

n
0 2 4 6 8 10 12
U ofe
Pr
N
h
ja
a ira
centre of symmetry

lia ik
(N even, positive symmetry)

b
tra m
us . A
N = 12 (even)
2 10

,A E
0 4 6 8 n
or
SW ss
U ofe
Pr
N
h
ja
ira
5.5.1 Design of FIR filters using Windows

a
lia ik
 The easiest way to obtain an FIR filter is to simply

b
truncate the impulse response of an IIR filter. If

tra m
hd[n] represents the impulse response of a desired
IIR filter, then an FIR filter with impulse response

us . A
h[n] can be obtained as follows:

,A E
or
hd 
 n N1 n N 2
h
n 
SW ss

0 otherwise
U ofe
Pr
N
h
ja
ira
hd 
 n N1 n N 2
h
n 

a
0 otherwise

lia ik
b
 In general h[n] can be thought of as being formed by the

tra m
product hd[n] and a window function w[n] as follows:

us . A
h
n hd 
nw
n
,A E let it be , for example a
rectangular window
or
H () Hd () 
W ()
SW ss

let it be an ideal low pass filter


U ofe

with cut off frequency 0


Pr
N
0
Pr
- -
U ofe
N

-
SW ss
|Hd(
)|

0
-
0 

or
,A E
*

us . A
|H()|
-

0
tra m

b
lia ik
a
2/N

ira
ja
h

h
ja
ira
 Therefore it is seen that the convolution produces a
smeared version of the ideal low pass frequency

a
response Hd(

lia ik
).

b
tra m
 In general, the wider the main lobe of W(), the
more spreading, where as the narrower the main

us . A
lobe (larger N) the closer |H()| comes to |Hd()|.

,A E
In general we are left with a trade off of making N
or

large enough so that smearing is minimized, yet


SW ss

small enough to allow reasonable implementation.


U ofe
Pr
N
h
ja
ira
 % Exercise 2. FIR filter design
 % We now consider the FIR filter design.
 % The first method we consider is the windowing method.
 % Matlab provides a command called `fir1' to design the FIR filter using the windowing method.

a
 % We design a FIR filter using the same specifications as in exercise 1.
 filter_order = 500;

lia ik
 passband_norm_frequency = passband_frequency/sampling_frequency * 2*pi / pi
 stopband_norm_frequency = stopband_frequency/sampling_frequency * 2*pi / pi
 cutoff_frequency = passband_frequency/sampling_frequency * 2*pi / pi

b
 filter_coeff = fir1(filter_order, cutoff_frequency);
 digital_frequency = (0:0.001:1)*pi;

tra m
 frequency_response = freqz(filter_coeff, 1, digital_frequency);
 magnitude_response = 20*log10(abs(frequency_response));
 figure(4), clf
plot(digital_frequency/pi, magnitude_response)

us . A

 grid on
 title ('Magnitude response of the digital filter')
 ylabel('Magnitude (dB)')
 xlabel('Normalized digital frequency')

,A E
 hold on
 semilogx([0 passband_norm_frequency], [-passband_ripple -passband_ripple], 'r')
 semilogx([passband_norm_frequency passband_norm_frequency], [-passband_ripple -stopband_ripple*2],
'r')
or
 semilogx([stopband_norm_frequency stopband_norm_frequency], [1 -stopband_ripple], 'r')
 semilogx([stopband_norm_frequency 1], [-stopband_ripple -stopband_ripple], 'r')
 hold off
axis([0 1 -stopband_ripple*2 0])
SW ss

 % Observe that we can nearly meet the required specifications when the filter order is over 500.
 % By default the `fir1' uses a hamming window.
 % There is a variety of windows to choose from.
U ofe

 % You may experiment with different windows and observe its impact on the magnitude response.
 % (You may need to reduce the filter order and not to worry about meeting the specifications.
Pr
N
h
ja
ira
Magnitude response of the digital filter

a
0

lia ik
-10

b
tra m
Magnitude (dB) -20

us . A
-30

,A E
or -40

-50
SW ss
-60
U ofe

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1


Normalized digital frequency
Pr
N
h
ja
ira
 % We now consider another method of designing a FIR filter, which is based on
 % the Parks-McClellan optimal algorithm.
 % The command is available in Matlab and is called `remez'.
 % We design a FIR filter using the same specifications as in exercise 1.
 filter_order = 13 % The lowest filter order that meets the required specifications.

a
 passband_norm_frequency = passband_frequency/sampling_frequency * 2*pi / pi
 stopband_norm_frequency = stopband_frequency/sampling_frequency * 2*pi / pi
passband_delta = 10^(0.1/20)-1 % Converting from dB

lia ik

 stopband_delta = 1/10^(33.5/20) % Converting from dB


 frequency_band = [0 passband_norm_frequency stopband_norm_frequency 1];
 % The passband frequency is 0.2pi and the stopband frequency is 0.4pi.

b
 amplitude = [1 1 0 0];
 % This amplitude configuration represents a lowpass filter.
weight = [1/passband_delta 1/stopband_delta]

tra m

 % Setting error weight at the passband and stopband


 filter_coeff = remez(filter_order, frequency_band, amplitude)
 digital_frequency = (0:0.01:1)*pi;

us . A
 frequency_response = freqz(filter_coeff, 1, digital_frequency);
 magnitude_response = 20*log10(abs(frequency_response));
 figure(5), clf
 plot(digital_frequency/pi, magnitude_response)
 grid on
 title ('Magnitude response of the digital filter')

,A E
 ylabel('Magnitude (dB)')
 xlabel('Normalized digital frequency')
 hold on
 semilogx([0 passband_norm_frequency], [-passband_ripple -passband_ripple], 'r')
or
 semilogx([passband_norm_frequency passband_norm_frequency], [-passband_ripple -stopband_ripple*2], 'r')
 semilogx([stopband_norm_frequency stopband_norm_frequency], [1 -stopband_ripple], 'r')
 semilogx([stopband_norm_frequency 1], [-stopband_ripple -stopband_ripple], 'r')
 hold off
SW ss
 axis([0 1 -stopband_ripple*2 0])
 % Note that given some design specifications, we find the filter order by trial-and-error
 % until the transition bandwidth, passband and stopband ripples satisfy the required
 % specifications.
 % Generally, a FIR filter requires higher order than an IIR filter given the same specifications.
U ofe

 % You may try different filter order and observe its impact on the transition bandwidth,
 % passband and stopband ripples.
 % Another method of designing a FIR filter is to use the least-squares error minimization algorithm.
 % The Matlab command to do this is `firls'.
Pr
N
h
ja
ira
Magnitude response of the digital filter

a
0

lia ik
-10

b
tra m
-20

us . A
Magnitude (dB)

-30

,A E
-40
or
-50
SW ss

-60
U ofe

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1


Normalized digital frequency
Pr
N
h
ja
ira
5.5.2 Design Procedure [11]

a
 An ideal low pass filter with linear phase of slope -β

lia ik
and cut-off ωc can be characterized in the frequency

b
domain by

tra m

e j w c
H d () 

us . A
0 wc  

,A E
The corresponding impulse response hd  n can be
or
obtained by taking the inverse Fourier transform of H d 

SW ss

and easily shown to be


sin 
c  
n 
hd 
U ofe

n 
n 
Pr
N
h
ja
ira
 A causal FIR filter with impulse response h[n] can be
obtained by multiplying hd 
n by a window beginning

a
lia ik
at the origin and ending at N-1 as follows :

b
sin 
c ( n )
h 

tra m
n  n
( n )

us . A
 For h[n] to be a linear phase , βmust be selected so

,A E
that the resulting h[n] is symmetric.

sin 
c (n )
or
As is symmetric about n= βand the
n 

SW ss

N 1
window is symmetric about n  .
U ofe

2
 
N 1
2
Symmetric about β
Pr
N
h
ja
ira
Example :
(a) Determine the impulse response hd 
n of the low-

a
pass filter whose frequency response is given by

lia ik

b
 
0 

tra m
1

 3
H () 

us . A
 
0 

,A E 

3

(b) To obtain a finite impulse response from hd 


n a
or
rectangular window of length N = 9 is used.
SW ss

Compute the coefficients of the FIR filter with a


U ofe

linear phase characteristic ands with this finite


impulse response.
Pr
N
h
ja
Solution:

ira
(a)

a
1 
hd 

lia ik
n   H d ()e jn d
2

b

tra m
1 
e jn  1 sin n 
3
3 
     

us . A
2jn   n 
3

,A E  1 n 0
or

hd 
3
n sin(n/ 3)
 n 0
SW ss

 n
U ofe
Pr
N
h
ja
ira
(b) For a linear phase filter, hd 
n is symmetric about n = 0
( N 1) 9 1

a
and the window is symmetric about n   4 .
2 2

lia ik
h
n hd 
n
n

b
h

tra m
0 0 .333

us . A
h
1
3

2

,A E h
2 
3
or
4
h
3 0
SW ss

h
3
4 
U ofe

8
Pr
N
h
ja
ira
The coefficients are

a

lia ik
3 3 3 3 3 3

b
0 0.333 0
8 4 2 2 4 8

tra m
us . A
n 0 1 2 3 4 5 6 7 8

,A E Symmetry about n = 4
or
SW ss
U ofe
Pr
N
h
ja
ira
5.6 Frequency-Sampling Filter [11]

a
Although it is implied that all FIR filters are non-

lia ik

recursive, this is not the case. To illustrate the

b
approach, let us consider the following FIR filter

tra m
having a casual finite-duration unit-sample response

us . A
containing N elements of constant value.

,A E h
g 0 N 0 n N 1
or
n 
0 otherwise
SW ss
U ofe
Pr
N
h
ja
ira
 The corresponding filter system function is equal to

a
lia ik
  z
N

b
1
g0  2 ( N 1) g0 p
H ( z )  1 z z ......... z
1

tra m
N N p0

us . A
g 0 1 z N 1 z N
 
  g0 
 
   1 
N 1 z 1

 N  1 z 
 

,A E  
or
Comb filter Resonator
Hc(z) HR0(z)
SW ss
U ofe
Pr
N
h
ja
ira
 This analytic form of the system function suggests a

a
novel way to implement the above filter, as the two-

lia ik
stage cascade structure shown below.

b
tra m
x[n] g0 y[n]
+ +

us . A
1/N

,A E z -N z-1
or
-1 1
SW ss

Comb filter Resonator


U ofe
Pr
N
h
ja
Example: 1 z 8

ira
1
Let N = 8 and g0 = 1 H (z)   1
8 1 z

a
lia ik
1 1/8
8

b
01 2

tra m
0 1 2 3
-1/8
x[n] y[n]

us . A
+ +
1/8
z-8 z-1

,A E -1 1
or
1/8
SW ss

1/8

0 1
U ofe

0 1 5 8 5 6 7 8 9 n
n
Filter implementation using the comb filter resonator structure.
Pr
N
h
ja
ira
 Hc(z) is given as

a
1 z N 1 e jN 2 j j N2 N

lia ik
H c ( z)  H ()   e sin
c

b
N N N 2

tra m
 H c () is shown in the next slide for N = 8 . H c ()

us . A
has N zeros equally spaced over the frequency
range 0 2, Because the magnitude response
,A E
resembles a comb, this filter has become known as a
or
comb filter.
SW ss

2 j j 82 8 1 j 4
H C ()  e sin  je sin 4
U ofe

8 2 4
Pr
N
h
ja
1

ira
|Hc(
)| | H c () | | sin 4|
4

a
1/4

lia ik
b
tra m
2/8  2 

us . A
0
|Hc()| vs  for a Comb filter

,A EThe pole/zero pattern for the comb filter can be


obtained using the transfer function
or
2k
1 z N 1 z N 1 1 N 1 j
H c (z )    (1 e N
z 1 )
SW ss
N
N N z N k 0
The above equation explicitly indicates that there are N
U ofe

equally spaced zeros over the unit circle with the first
zero at z = 0.
Pr
N
h
ja
ira
j
2
3 e

a
j
4 
e j

lia ik
4
e

b
e j

tra m
us . A
8 poles

,A E e
j

2
or
SW ss

Pole/zero pattern for Comb filter N = 8


U ofe
Pr
N
h
ja
ira
 HR0(z) is the system function of a resonator, or a filter
that has poles on the unit circle at frequency = 0 i.e.

a
at z = 1. Since this pole is not strictly within the unit

lia ik
circle, the filter is not stable. When this resonator is

b
cascaded with the comb filter, however, the zero of the

tra m
comb filter located at z = 1 cancels the resonator pole,

us . A
making the combination stable.

,A E
The transfer function of this two-stage filter is equal to
or
N
  sin
N 1 
SW ss

g 0 1 e jN g0 j
2 
H ()   e 2
N 1 e j N 
U ofe

sin
2
Pr
N
h
ja
ira
N
  sin 
N 1 
g 0 1 e jN g0 
 2 

a
j
H ()   e 2
N 1 e j 

lia ik
N sin
2

b
tra m
The transfer function of this two-stage filter is equal to

us . A
g o 1 z N
H ( z) 
,A E N 1 z 1
or
N
 sin  
SW ss

N 1
 g0
H ()  e
j
2  2 


U ofe

N
sin 
2 
Pr
N
h
ja
Example :

ira
For N=8, |H( )| has a maximum at =0, equal g0

a

and is equal to zero at k 2k .

lia ik
N

b
|H(
)|

tra m
g0
Magnitude response of

us . A
Comb filter plus resonator
(N = 8)

,A E
or
- 2/N  
SW ss

 Let us consider a second-order resonator, whose


U ofe

coefficients are real-valued, and the poles are situated


at the following zero locations of the comb filter.
Pr
N
h
ja
ira
2 2
1  2  1
 (Let N = 8)
N N

a
lia ik

b
j
2
3 e 

tra m
j j
4 4
e e

us . A
8 poles at the
origin

,A E e j
j

or
4
3 e
j 
4 j
e
SW ss
2
e
U ofe
Pr
N
h
ja
ira
 The system function of the second-order resonator
can be written in parallel form as

a
lia ik
g1 g 1
H R1   2
  2

b
j  j 
 N  1  N  1
1 e z 1 e z

tra m
 This procedure can be generalized to include each

us . A
second-order resonator cancelling a pair of zeros of
the comb filter. These resonators are all connected in

,A E
parallel and this parallel combination is then
connected in cascade with the comb filter to produce
or
the total filter H T(z) given by
SW ss

1 z N N 1
gk
HT (z )  
U ofe

2k
N k 0 j
1 e N
z 1
Pr
N
h
ja
ira
g0
1 z 1

a
g1 g 1 Y(z)
X(z) 1-z-N 2
 2 +

lia ik
j j

1/N 1 e N z 1
1 e N z 1

b
g2 g 2

tra m
4
 4
j j
1 e N 1
z 1 e N z 1

us . A
gk g k

,A E
2k 2
j j k

1 e N
z 1
1 e N
z 1
or
SW ss

 j 2Nk  j 2Nk 


H
e

g k
 H
e g k

U ofe

   
Pr
N
h
ja
ira
Example:

a
 Lets us consider implementing the linear

lia ik
interpolator with the comb and resonator

b
structure. The impulse response of the linear

tra m
interpolator is given by

us . A
,A E h
0  ; h
1
2
11; h
1
2  and
2
or
h
n 0 otherwise
SW ss
U ofe
Pr
N
h
ja
ira
Solution:

a
1 1 1 2
H ( z)  1z  z

lia ik
2 2

b
H () e j(1 cos )

tra m
Since the number of elements in the unit sample response

us . A
is equal to 3, we choose N = 3. The comb filter system

,A E
function is then

1 z 3
or
Hc (z) 
3
SW ss

2k
j
H c (z) has three zeros located at z e 3
for k = 0,1 & 2.
U ofe
Pr
N
h
ja
ira
 The zero at z = 1 will be cancelled by a real
2

a
j
resonator, and zeros at z e will be cancelled by
3

lia ik
b
a pair of complex resonators. The gains of the

tra m
resonators are equal to

us . A
2
1 j 3
g0 H () 0 2, g1 H () 2  e

,A E
 2
3
4 2
1 j 1 2
or
j
g 2 H () 4 e  e g , H R 0 ( z) 
3 3 *

1 z 1
1
 2 2
3
SW ss

2 2
1 j 3
e
1 j3
e
1
 1 z 1  
U ofe

H R1 ( z )  2 2  2 2  2 1 2
j
3 
j
3 
1 z z
1 e z 1
1 e z 1
Pr
N
h
ja
ira
2/3

a
1
2
+

lia ik
0 1

b
x[n] z-1 2 y[n]
+ +

tra m
-1/3

us . A
1
z-3 + + 1/2
-1 -1/2

,A E 1/2 0
z-1 3 4
-1
or
-1 1/3
SW ss
z-1
0 1
U ofe

-1
1/6 -1/6
Pr
N
h
ja
ira
 Note: If the comb filter is followed by a

a
recursive network that has a number of poles

lia ik
that coincide exactly with the same number

b
of zeros of the comb filter, we obtain a

tra m
frequency-sampling filter. The frequency-

us . A
sampling filter can be particularly attractive
solution if we want to make a narrow-band
,A E
filter; the N is large, while the number of
or
recursive sections can be very small. This
means that the filter contain only a few
SW ss

multipliers and adders.


U ofe
Pr
N
h
ja
For practical applications we have to keep an eye on a

ira

number of things. In theory we start by assuming that a


number of poles and zeros coincide exactly on the unit circle

a
in the z-plane. This requires that we should be able to realize

lia ik
the filter coefficients to an accuracy of 100%. However, apart

b
from a few obvious exceptions such as -1,0 and +1 this is

tra m
never the case.

us . A
 This means that while we can locate the zeros of the comb-
filter sections in exactly the right position, we cannot do so

,A E
far the corresponding poles. The best we can do is to get
them in the vicinity. This can lead to a very erratic local
or
variation of the frequency response, or even an unstable
system if one of the poles lies just outside the unit circle. In
SW ss

practice both zeros and poles are therefore deliberately


located just inside the unit circle. For comb filter the system
U ofe

function is then chosen as H ( z ) 1 (az 1 ) N


where a is made lightly less than 1.
Pr
N
h
ja
Problem Sheet A5 [1,11]

ira
Q1. Consider the following analogue system with a

a
transfer function 
H ( s)   h(t ) e t

lia ik
s 

b
where a = 104 rad/sec and the sampling period T is 100 s.

tra m
(i) What is the dc gain of H(z)?

us . A
(ii) At what frequency is the H() equal to zero? (-
digital frequency).

,A E (iii) Calculate the impulse response h[n] .


or
(iv) Assuming that the impulse response decays to 1/e
of its initial value at n = N samples, show that:
SW ss

a 
ln  1
U ofe

a 1 
N
ln( a)
Pr
N
h
ja
ira
Q2. A digital low-pass filter is required to meet the
following specifications:

a
lia ik
 Passband ripple ≤1dB (peak–to–peak ripple)
Passband edge : 4kHz

b

 Stopband attenuation : ≥40dB

tra m
 Stopband edge : 6kHz
Sampling rate : 24kHz

us . A

 The filter is to be desired by performing a bilinear

,A E
transformation on an analogue filter. Determine what order
Chebyshev design must be used to meet the specifications
or
in the digital implementation.
SW ss

(Hint: use the design formula given in the lecture notes)


U ofe

{Ans: n = 6}.
Pr
N
h
ja
ira
Q3. The block diagram shows a digital oscillator
which is initialized by an impulse as shown in

a
lia ik
the figure below. The desired unit impulse
response is h n A cos(0 n )u

b
n

tra m
us . A
[n] a0
+ +
,A E -b1
Z -1
a1 a0 a1z1 a2z2
or
H(z) 
1b1z1 b2z2
SW ss

Z -1
-b2 a2
U ofe
Pr
N
h
ja
ira
(a) Assuming 0 is the resonant frequency of

a
the digital oscillator and writing appropriate

lia ik
equations find the values of a0, a1, a2, b1 and b2 .

b
tra m
(Ans: a0=A, a1= -Acos

us . A
0, a2=0,
b1= 2cos= 2cos0, b2 = 1)
,A E
or
SW ss
U ofe
Pr
N
h
ja
(b) The frequency of oscillation is determined by the

ira
coefficient b1. Show that f s b1
f 0 

a
2f0 

lia ik
4sin 
f  
 s 

b
tra m
where fs is the sampling frequency (16kHz) and f0 is

us . A
the desired frequency of oscillation.
Calculate the highest frequency resolution that is

,A E
obtainable and show that this obtainable accuracy
depends on the desired oscillation frequency. You
or
may assume that b1 is represented by a K-bit
SW ss

number (fractional arithmetic) and is given by


b1 1 1
1  K 1 and b1  K 2 where K = 16.
U ofe

2 2 2
(Ans: f 0 0.0777 Hz )
Pr
N
h
ja
ira
(c) Using the equations obtained and the values

a
in parts (a) and (b) above , show that the

lia ik
lowest oscillation frequency obtainable is

b
tra m
fs
given by f 0 min  f 0 f s

us . A
for
256

,A E
You may assume that cos( x) 1 
2
x , given small f .
0
or
2
SW ss
U ofe
Pr
N
h
ja
ira
(d) For the structure shown in figure below,
write down the appropriate difference

a
equations and hence state the function of

lia ik
this structure.

b
tra m
+ y2 [n]

us . A
-1 1
y1 [n]
2 sin 
,A E z-1 z-1
or
SW ss

2cos -1
U ofe

+
Pr
N
h
ja
ira
Q4.
(a) A second-order analogue band pass filter with an

a
s-domain transfer function is given by,

lia ik
b
bp s
H ( s)  2 (1).

tra m
s bp s p
2

us . A
Where ωp and bp are the centre frequency and
bandwidth of the filter; respectively, both expressed
,A E
in rad/s. By applying the bilinear transformation to
or
equation (1) a digital filter with the following transfer
SW ss

function can be obtained:


a 0 a1 z 2
U ofe

H (z)  (2).
1 b1 z 1 b2 z 2
Pr
N
h
ja
ira
Show that the digital filter coefficients are given by

a
2bp T

lia ik
a0 a1 
4 2b pT p T

b
2 2

tra m
us . A
2p T 8
2 2

b1 
,A E 4 2bpT p T
2 2
or
SW ss

4  T 2b pT
2 2

b2  p
U ofe

4 2b pT pT
2 2
Pr
N
h
ja
ira
(b) A digital filter with a centre frequency of 1000 Hz
and a bandwidth of 150 Hz is required. Assuming a

a
lia ik
sampling frequency of 10kHz, compute the digital

b
filter coefficients a0, a1, b1 & b2 and show that

tra m
a0 = a1 = 0.04409115; b1 = -1.551 and b2 = 0.918176

us . A
(c) Comment on the stability of the digital filter H(z) (see

,A E
equation 2 ) which you have obtained .
or
a 0 a1 z 2
H (z)  (2).
SW ss

1 b1 z 1 b2 z 2
U ofe

(Ans : Stable)
Pr
N
h
ja
ira
Q5. A second-order resonant system is given by,

a
lia ik
1 resonant
H ( s)  p
p  2

b
bp  frequency
s  
2
s p

tra m
Q p  Qp Q-factor
  Associated
Bandwidth

us . A
with the
pole

,A E
By applying the impulse invariant transformations to
or
the above equation, a digital filter with the following
transfer function can be obtained.
SW ss

kz 1
U ofe

H (z) 
1 b1 z 1 b2 z 2
Pr
N
h
ja
ira
Show that the filter coefficients b1 and b2
are given by,

a
lia ik
p2T 2 p2T
b1 2e cos( q2T ); b2 e

b
tra m
Also show that K 4q2e p2T sin( q2T )

us . A
p
,A E
, where p2 
2Q p
and q2 p2 4Q 2p 1
or
SW ss
U ofe
Pr
N
h
ja
ira
Q6.
(a) An FIR filter has an impulse response shown in

a
the figure below.

lia ik
b
h[n]

tra m
1

us . A
,A E 0 1 2 3 4 5 n
or
Show that the frequency response of this filter is

2 
SW ss

given by j ( 2) sin 5


H () e
sin 

U ofe

where is the digital frequency.


Pr
N
h
ja
ira
(b) Draw an alternate implementation of this filter

a
using pole and zero configuration.

lia ik
b
(c) Draw an FIR filter structure that has the same

tra m
impulse response as the figure below. State clearly
the values of the FIR filter coefficients.

us . A
X(z)

,A E z-1
b
+ z-1
or
SW ss
c d e
Y(z)
+
U ofe
Pr
N
h
ja
ira
Q7. (a) Determine the impulse response hd[n]
of the bandpass filter whose frequency

a
lia ik
response is given by

b
tra m
 j 3  3

e 
H d () 

us . A
4 4

0 otherwise

,A E
(b) To obtain a finite impulse response from
or
hd[n] a Bartlett window of length N = 7 is
SW ss

used. Compute the coefficients of the FIR


filter with this impulse response.
U ofe
Pr
N
h
ja
ira
Note: The Bartlett Window function is given by

a
lia ik
 2n
0 n 
N 1

b
 N 1 2

tra m

 N 1
wB 
2n
n 
2 n N 1

us . A
 N 1 2
 0 otherwise
,A E 

or
Where N is the length of the window.
SW ss
U ofe
Pr
N
h
ja
ira
( n13) 
sin( n 3) 34 sin(n 3) 4  n 3
Ans : hd 
n 

a

1
n 3

lia ik
2

b
Ans:

tra m
hd[0] after windowing

us . A
,A E
hd[n]
1
0
1
3
0
1
3
0
1
or
2 2
SW ss

n 0 1 2 3 4 5 6
U ofe
Pr
N
h
ja
ira
Q8. (i) (a) Find the transfer function for the following:

a
3 3 Y(z)
X(z)

lia ik
H1 ( z ) 1 z 5 H 2 (z )  5  5
2 2
j

b
j
1/5 1 e 5 z 1 1 e 5 z 1

tra m
(b) Draw a pole-zero diagram

us . A
(c) Sketch the magnitude frequency response.

,A E
(a) If H ( z ) 
1 z 3
, sketch the magnitude response
or
3
|H()|.
SW ss

1 z 3 1
(b) If H 1 ( z )   , sketch the magnitude response of
U ofe

1
1 z 3
|H1()|.
Pr
N
h
ja
ira
Q9. A frequency sampling filter is shown below & N = 3

a
lia ik
a0
1 z 1

b
X(z) Y(z)
+

tra m
1-z-N
1/N

us . A
a1 a2
2
 2
j j

1 e N z 1 e N z 1

,A E
1

(a) Determine a0 , a1 & a2 such that this filter has a real


or
impulse response h[n], where
SW ss
U ofe
Pr
N
h
ja
a ira
lia ik
H (0 ) 3 and H () 6 j 3 3
2

b


tra m
3

us . A
 j 2Nk  j
2k
H
e

ak
 ; H (e N
) ak
 
,A E
or
SW ss
U ofe
Pr
N
h
ja
ira
(b) Draw the frequency-sampling filter structure

a
using delay elements, multipliers and adders.

lia ik
b
tra m
(c) Derive a general expression for H(
).

us . A
(d) Give a filter that has same frequency
,A E
response H(
), but is realized an FIR filter.
or
SW ss
U ofe
Pr
N
h
ja
Summary of Part A Chapter 5

ira
At the end of this chapter, it is expected that you should know:

a

lia ik
 The properties of FIR and IIR filters, so that you can justify

b
your choice of filter type for a given problem. The linear phase

tra m
property of symmetric FIR filters is particularly important.

us . A
 Design techniques, the differences between them, and why each

,A E
are used.
 FIR: windowing and frequency sampling.
or
 IIR: impulse invariant transformation (when and why it is

used), bilinear transformation (when and why it is used) and


SW ss

pole-zero placement.
Prewarping and its role in bilinear transformation–based design.
U ofe


Pr
N
h
ja
ira
 Given a digital filter specification, how to design an IIR digital

a
filter using an analog prototype.

lia ik
b
 Digital to digital transformations, especially lowpass to lowpass,

tra m
and lowpass to highpass.

us . A
 Types of window functions, the differences between them, and

,A E
the fundamental trade-off between time and frequency
resolution. Students should understand the importance of
or
stopband attenuation, and the role of the main lobe width in the
SW ss
definition of frequency resolution.
U ofe
Pr
N
h
ja
ira
 Comb filters as a frequency sampling filter.

a
lia ik
 Comb filters as a particular case of FIR filter design.

b
tra m
 How to draw comb filter structure, and limitations

us . A
associated with the comb filter structure.

,A E
or
SW ss
U ofe
Pr
N

You might also like