Вы находитесь на странице: 1из 70

Unit-4

IIR & FIR Digital Filters

Filter

Filter is a frequency selective network.


Filters generally do not add frequency components to a signal

It Boost

or attenuate selected frequency regions

General types of filters are:

Practical characteristics

Types of Filters

There are two types of filters.

Analog Filters

Digital Filters.

Analog Filter uses passive elements such as resistors, inductors an


d Capacitors. They described by the Differential equations.

Digital Filter Linear time invariant Discrete time system. Described


by the difference equations.
Ex: IIR,FIR

Concept of Analog LPF

Here input signal is a 5v DC signal. Noise is a high frequency


component. So it is suppressed here. DC Component is a low
frequency component so it is passed here.

Concept of Digital LPF

Implementation of Digital filters

Can be implemented in software like c or assembly language.

Usually such a languages are compiled and an executable code for


processors is prepared.

Digital filters are also implemented by a dedicated hardware contai


ns flip flops, counters, shift registers, ALU.

But digital filters with dedicated hardware can perform one type of
filtering only hence not possible to modify them.

Comparison between Analog & Digital Filters


Analog Filter
Analog filters works on analog signals

Digital Filter
It operates on the digital samples of

It is defined by linear differential equations

the signals
These kinds of filters are defined

While implementing the analog filters in

using linear difference equations


While implementing the digital filters

hardware or software simulation,electrical

in hardware orsoftware(for

components like resistors, capacitors and

simulation), we need adders,

inductors are used.

subtractors, delays, etc which are


classified under digital logic

The frequency response is modified by

components.
The frequency response is modified

changing the components.


by changing the filter coefficients.
Laplace transform is used for the analysis of Z transforms are used for the anaysis
analog filter.
For stability and causality, the poles should

of digital filters
In order to be stable and causal, the

lie on the left half of s-plane.

poles of the transfer function should


lie inside the unit circle in z-plane.

Advantages of Digital Filters.

Digital filter performance is not influenced by component ageing, temperat


ure & power supply variations.

A digital filter is highly immune to noise & possess considerable parameter


stability.

Digital filters afford a wide variety of shapes for amplitude & phase respons
es.

No problems of i/p ,o/p impedance matching.

Operated over a wide range of frequencies.

The coefficients of digital filters can be changed at any time to obtain desir
ed response.

Multiple filtering is possible only in digital filters.

Disadvantages of Digital Filters.


There are few disadvantages also.
Quantization error occurs due to finite word length in the represe
ntation of signals and parameters.
Digital filters also suffer from Bandwidth problems.

Infinite Impulse Response(IIR) Digital Filt


er
In IIR Digital Filter, present o/p samples depends upon present i/p, past i/p also o
n past o/p.
IIR filter is a recursive filter.
Nth order Difference equation is given by

Let a1 =-1 and b0 = a0 =1 with k=1 with remaining coefficients as zeros, the above eq
uation becomes

y(n)=y(n-1)+x(n)

Apply Z-Transform we get

Its inverse Z-Transform is h(n)=u(n)

It indicates that the impulse response of IIR filter is having infi


nite duration.

The T.F of IIR filter is

Design of IIR filter for given specifications is to find the filter co


efficients

Design of Digital filter from Analog Filter

We are using an indirect method for design of IIR filter.

Step1:Map the desired digital filter specifications into equivalent


analog filter specifications.

Step2:Derive analog transfer function for analog prototype.

Step3: Transform the transfer function of analog prototype into an


equivalent digital filter transfer function.

Analog LPF into Digital LPF

Analog Filter Design

The most general form of analog transfer function is

Where H(s) is Laplace Transform of h(t) with

For stable analog filter the poles of H(s) must lies in left half of S-Plane.

There are two types of Analog filter Design techniques.


1. Butterworth filter Approximation
2. Chebyshev filter Approximation

Butterworth filter

TheButterworth filteris a type ofsignal processing filterdesigned


to have as flat afrequency responseas possible in thepassband.
It is also referred to as amaximally flat magnitude filter.

It was first described in 1930 by the British engineer and physicist St


ephen Butterworth in his paper entitled "On the Theory of Filter
Amplifiers"

Analog Low pass(LPF) Butterworth filt


er

Lowpass Butterworth filters are all-pole filters characterized by


the magnitude response given by
1

| H ( j) |

| H ( j ) | 2

(1)

2N

N order of the filter 1,2,3,....


frequency
c 3dB frequency or cutoff frequency
p Passband frequency
parameter specifying allowable passband

2N

1
2

or

2N

...........

Analog Low pass(LPF) Butterworth filter

This magnitude response is monotonically decreasing functio


n where maximum response is unity at =0 as shown in below

Analog Low pass(LPF) Butterworth filter

The response becomes ideal as the order N is increases.


for

c ; H ( j ) 1
c ; H ( j) decreases rapidly
c ; the curve is passed through 0.707 which is a 3dB po int

for normalized butterworth filter c 1 rad / sec

The Magnitude response equation(1) becomes

H j
s

Put
j

......(2)
2N
1

in above equation (2) we get

Analog Low pass(LPF) Butterworth filter

H j

1 s

2 N

......(3)

Equating denominator equal to zero in equation(3) we get


roots

1 s

2 N

0...........(4)

for N is odd then equation(4) becomes


s 2 N 1 e j 2k
now the roots of equation(4) are
sk e j 2k / 2 N ; k 1,2,3,...2 N

Analog Low pass(LPF) Butterworth filter

for N is even then equation( 4) becomes


s 2 N 1 e j ( 2 k 1)
now the roots of this equation are
sk e j ( 2 k 1) / 2 N ; k 1,2,3,...2 N
If N=3 we get the following roots

Analog Low pass(LPF) Butterworth filter

Poles on left half of s-plane gives stability. Poles which are


left in s-plane are

Analog Low pass(LPF) Butterworth filter

This is the denominator polynomial of Transfer function H(s)

Therefore N=3 rd order Butterworth Lowpass filte Transfer functio


n at

c 1 rad / sec

is given by

Analog Low pass(LPF) Butterworth filter

The poles which are present only in left half of s-plane can be calc
ulated using.

sk e jk .........(5)
where k

(2k 1)

; k 1,2,3,...N
2
2N

The poles given by above equation(5) are Normalized poles becau


se they are calculated
1 at
rad / sec
c

So unnormalized poles are given by


|

The transfer function of such a unnormalized Butterworth filter

sk c .sk

can be obtained by substituting s

Order of the Butterworth filter


(N)

let p be the max . passband attenuation at passband frequency p


let s be the max .stopband attenuation at stopband frequency s

Consider | H ( j) |2

1 2

p

2N

Order of the Butterworth filter(N)

.........(1)

take log arithm on both sides of eqn(1) we get

1
2
10 log | H ( j) | 10 log


1 2

2N

2
20 log | H ( j) |10 log(1) 10 log(1

p

20 log | H ( j) | 10 log(1

p
2

2N

2N

)........(2)

here 20 log | H ( j) | is called attenuation.

Order of the Butterworth filter(N)

when p eqn(2) becomes p


p

20 log | H ( j) | 10 log(1
2

10 log(1
2

2N


p
10 log(1 2 ) p

) p

log(1 2 ) 0.1 p
(1 ) 10
2

0.1 p

2 10

0.1 p

(10

0.1 p

1)1/ 2 .............(3)

2N

) p

Order of the Butterworth filter(N)

when s eqn( 2) becomes s

2 s
20 log | H ( j) | 10 log(1

p

2 s
10 log(1

p

10 log(1 2

p

2 s
log(1

p

2 s
(1

p

2

p

2N

2N

) s

2N

) s

2N

) 0.1 s

2N

) 100.1 s

2N

100.1 s 1
100.1 s 1 100.1 s 1

0.1 p
2
10
1

2N

) s

100.1 s 1

................(4)
0.1 p
10
1

Order of the Butterworth filter(N)

take log arithm on both sides to eqn(4)


s

log

p

log

s
log
N log

log
N

100.1 s
0.1
10 p
s

log

p

100.1 s 1
0.1
10 p 1
100.1 s 1
0.1
10 p 1
1
1
.......................(5) this is the order of the filter

This equation does not results int eger therefore eqn(5) can be written as

0.1 s
10
1

log
100.1 p 1

N
s

log

p

Order of the Butterworth filter(N)

100.1 s 1
10 0.1 p 1

log

p

log
so order of the Butterworth filter is

or

log

N
s

log

p

where 10 0.1 s 1, 10

0.1 p

Order can also be written as


p
log A
N
where k
is called transition ratio, A is a parameter and is given by
1
s

log
k

Prove that

10

0.1 p

consider | H ( j) |2

Proof:-

1
2N

1
c

2N

1
c

2N

1

p

2N

1


p

2 10

2N

2N

2N

2N

2N

2N
0.1 p

10 0.1 p 1

1/ 2 N

............(1)
c

10 0.1 p 1 1/ 2 N

10

0.1 s


1

p

2N

1
2N

by comparing we get

2N

Consider

p

100.1 s 1
0.1 p
10
1
1/ 2 N

100.1 s 1

s p

10

0.1 p

100.1 s 1

s p
0.1 p
1
10

s c 10
c

10

s
0.1 s

0.1 p

1/ 2

c 10

0.1 p

1/ 2 N

10

0.1 p

1/ 2 N

10
1

0.1 p
1
10

1/ 2 N

..................(2)

1
from (1) and (2) we can write

10

0.1 p

1
2N

10

0.1 s

1/ 2 N

0.1 s

1/ 2 N

100.1 s 1

1
2N

FIR Filter Design Based on Windowed Se


ries
Least Integral-Squared Error Design of FIR Filters
In practical application:the desired frequency respons
e is piecewise constant with sharp transitions betwe
en bands.
Aim:Find a finite duration impulse response sequenc
htlength
[n]
e
of
the
2M+1 whose DTFT
j
j
(
)
(
H t e approximates the desired DTFT hd e ) In s
ome sense.
one commonly used approximation criterion is to mini
mize the integral-squared error.

FIR Filter Design Based on Windowed Se


ries
Integral-squared error
1

H t (e

j d
) H d (e )

ht[n] hd[n]

M 1

ht[n] hd [n] h [n] h [n]

n M

2
d

n M 1

2
d

ht nwhe

The integral-squared error is minimum


M
n hd n = M n for
.

FIR Filter Design Based on Windowed Se


ries
Impulse Response of Ideal Filters
Four commonly used frequency selective filters are the lowpass,highp
ass,bandpass,bandstop filters.
Example:lowpass filter
zero-phase frequency response

H (e

1, c ,

response
LP
The corresponding
impulse
0, c .
so the impulse response is doubly infinite,not absolutely summable,a
sin c
nd therefore unrealizable.
[ n]

LP

FIR Filter Design Based on Windowed Se


ries
By setting all
Mimpulse
n M response coefficient o
utside the range
equal to zer
o,we
arrival
at
a
finite-length
noncausal
a
N 2M 1
pproximation of length
,which when shifted to the ri
sin( c (n M ))of a causal FIR lo
ght yield the coeffcients
n (n M ) ,0 n N 1
wpasshfilter:
LP
0, otherwise

FIR Filter Design Based on Windowed Se


ries
Gibbs phenomenon
The causal FIR filter obtained by simply truncat
ing the impulse response coefficients of the i
deal filters exhibit an oscillatory behavior in t
heir respective magnitude responses.which i
s more commonly referred to as the Gibbs p
henomenon.

FIR Filter Design Based on Windowed Se


ries
Cause of Gibbs phenomenon:
The FIR filter obtained
by
truncation
can
be
[ n ] h d [ n ] [ n ]
h
t
expressed as:

H t (e

1
)
2

H d (e ) (e

j ( )

) d

FIR Filter Design Based on Windowed Se


ries
Illustration of the effect of the windowing
in frequency domain

FIR Filter Design Based on Windowed Se


ries
The window used to achieve simple truncation
of the ideal filter is rectangular window:

1,0 n M

[ n]

0, otherwise

So two basic reason of the oscillatory behavior:


(1)the impulse response of a ideal filter is infinit
ely long and not absolutely summable.
(2)the rectangular window has an abrupt transit
ion to zero.

FIR Filter Design Based on Windowed Se


ries
How to reduce the Gibbs phenomenon?
(1 )using a window that tapers smoothly to zero at
each end.
(2)providing a smooth transition from the passba
nd to the stopband.

FIR Filter Design Based on Windowed Se


ries
Fixed Window Functions
1
2n
Hann: w[n] 2 1 cos( 2M 1) , M n M
Hamming:
Blackman:

2n
w[n] 0.54 0.46 cos(
), M n M
2M 1

2n
w[n] 0.42 0.5 cos(
)
2M 1
4n
0.08 cos(
), M n M
2M 1

FIR Filter Design Based on Windowed Se


ries
Two important parameters:
(1)main lobe width.
(2)relative sidelobe level.
The effect of window function on FIR filter design
(1) the window have a small main lobe width wil
l ensure a fast transition from the passband to
the stopband.
(2)the area under the sidelobes small will reduc
e the ripple

FIR Filter Design Based on Windowed Se


ries
Designing an FIR filter
(1)select a window above mentioned.
h n hd [n] w[n]
(2)get
(3)determine the cutoff frequency by settin
( p s ) / 2

c
g:
c

(4)M is estimated using


,t
he value of the constant c is obtain from
table given.

FIR Filter Design Based on Windowed Se


ries
Adjustable Window Functions
Windows have been developed that provide
control over ripple by means of an additio
nal parameter.
M
1 1
k
2nk
(1)Dolph-Chebyshev
window
w[n]
) cos
2 T k ( cos

2M 1

(2)Kaiser

k 1

2M 1

2 M 1

(
n
/
M
)

I
0
window
, M n M
w[n]
I 0 ( )
2

FIR Filter Design Based on Wind


owed Series
Impulse Response of FIR Filters with a Smooth T
ransition
--One way to reduce the Gibbs phenomenon.
The simplest modification to the zero-phase lowp
ass filter specification is to provide a transition
band between the passband and stopband resp
onses and to connect these two with a first orde
r spline function .

Computer-Aided Design of Digit


al Filter
Two specific design approaches based in i
terative potimization techniques.
The aim is to determine iteratively the coeff
j
j
D
(
icients of the digital
transfer
function
H (e )
e ) so t

hat the difference


between
0 and

for all value of


over closed su
( ) ,and
bintervals of
is minimized
j
jspecified
j as a wei
usually (the
difference
is
) W (e ) H (e ) D(e )
ghted error function
given by:

Computer-Aided Design of Digit


al Filter
Chebyshev criterion
--to minimize the
peak
absolute
value
of
the
( )
weighted error

max ( )
R

Least-p criterion
--to minimize the integral of pth power of th
( )
e weighted
error function p
K

i 1

W (e ji) D(e ji)

Computer-Aided Design of Digit


al Filter
Design of Equiripple Linear-Phase FIR Filt
er

j
jN / 2
j
The frequency
FI
H (e ) response
e
)
e ofH (alinear-phase
R filter is:
The weighted error function in this case inv

and is given
olves the
amplitude
response
( ) W ( ) H ( ) D( )

by

Computer-Aided Design of Digit


al Filter
Type 1 linear-phase FIR filter
The amplitude
response
is
:
N /2

N
N
H ( ) h[

] 2 h
n 1

n cos(n)
2

N 2M
It can be rewrite using
the
notation
M

in the form
H ( ) a[k ] cos(k )
k 0

Where a[0] h[ M ], a[k ] 2h[ M k ],1 k M

Computer-Aided Design of Digit


al Filter
Type 2 linear-phase FIR filter
( N 1) / 2

The amplitude
response
N 1 is :
H ( ) 2

n 1

1
n cos( (n ))
2

( 2 Min
1) / 2the form:
It can be rewrite
1

H ( )

b[k ] cos( (k 2 ))
k 0

( 2 M 1) / 2
cos( ) b[k ] cos(k )
2 k 0

Where

2M 1
2M 1
b[k ] 2h[
k ],1 k
2
2

Computer-Aided Design of Digit


al Filter
Type 3 linear-phase FIR filter
The amplitude response is :

H ( ) 2 h
n sin(n)

n 1 2

N /2

It can be rewrite in
the
form:
M

H ( ) c[ k ] sin(k )
k 0

M 1

sin c ( k ) cos(k )
k 0

Computer-Aided Design of Digit


al Filter
Type 4 linear-phase FIR filter
The amplitude
( Nresponse
1) / 2

N 1 is :
1
H ( ) 2 h[
n] sin( (n ))
2
2
n 1

It can be rewrite
in the form:
( 2 M 1) / 2

H ( )

k 1

1
d [k ] sin (k )
2

( 2 M 1) / 2
sin( ) d [k ] cos(k )
2 k 0

Computer-Aided Design of Digit


al Filter
The amplitude response for all four types

of linear-phase
can be expresse
H ( ) Q(FIR
) A(filters
)
d in the form
Then the we modify the form of the weigh
t approximation
( ) W ( )function
Q( ) A(as:
) D( )

D( )
W ( )Q( ) A( )

Q( w)

Computer-Aided Design of Digit


al Filter

W ( ) W ( )Q( )

Using
the notions

D( ) D( ) / Q( )

and
we can rewrite it as:

( ) W ( ) A( ) D( )

a[k ]
Then we determine the coefficients
value
to minimize the peak absolute
o
f the weighted approximation
error over t
R
he specified frequency bands

Computer-Aided Design of Digit


al Filter
Alternation Theorem
A( )
The amplitude function
is the best uni
que aproximation of the desired amplitud

e response
obtained by minimizing the pe
( )
L2
ak absolute valu
0 ,1 , L1
of
if and only if there exist at least
0
( ) ( )

extremal angular frequencies,
( )
0 i Lran
1
,in a closed subset Riof the frequency
0

ge

L 1

i 1

Digital Filter Design Using Matla


b
IIR Digital Filter Design Using Matlab
Steps:(1)determine the filter order N and the fre
quency scaling factor Wn .
[N,Wn]=buttord(Wp,Ws,Rp,Rs)
[N,Wn]=cheb1ord(Wp,Ws,Rp,Rs)
[N,Wn]=cheb2ord(Wp,Ws,Rp,Rs)
[N,Wn]=ellipord(Wp,Ws,Rp,Rs)
Where Wp=2Fp/FT and Ws= 2Fs/FT .

Digital Filter Design Using Matla


b
(2)determine the coefficients of the transfer fun
ction.
[b,a]=butter(N,Wn)
[b,a]=cheby1(N,Rp,Wn)
[b,a]=cheby2(N,Rs,Wn)
[b,a]=ellip(N,Rp,Rs,Wn)

Digital Filter Design Using Matla


b
FIR Digital Filter Design Using Matlab
Steps(1).estimate the filter order from the
given specification.
remezord,kaiserord
(2)determine the coefficient of the transfe
r function using the estimated order and t
he filter specification.
remez

Digital Filter Design Using Matla


b
FIR Digital Filter Order Estimation Using
Matlab
[N,fpts,mag,wt]=remezord(fedge,mval,dev)
[N,fpts,mag,wt]=remezord(fedge,mval,dev,F
T)
For FIR filter design using the Kaiser windo
w,the window order should be estimated
using kaiserord
[N,Wn,beta,ftype]=kaiserord(fedge,mval,de

Digital Filter Design Using Matla


b
Equiripple Linear-phase FIR Design Using
Matlab
--emplying the Parks-McClellan algorithm.
b=remez(N,fpts,mag)
b=remez(N,fpts,mag,wt)
b=remez(N,fpts,mag,ftype)
b=remez(N,fpts,mag,wt,ftype)

Digital Filter Design Using Matla


b
FIR equiripple lowpass filter of Example 7.
27 for N=28
50

Gain,dB

-50

-100

-150

-200

0.1

0.2

0.3

0.4

0.5
0.6
\omega/pi\

0.7

0.8

0.9

Digital Filter Design Using Matla


b
Gain response of the FIR equiripple band
pass filter of Example 7.28.

Digital Filter Design Using Matla


b
Window-based FIR Filter Design Using Ma
tlab
Steps:
(1)estimate the order of the FIR filter.
(2)select the type of the window and compu
te its coefficient.
(3)compute the desired impluse response o
f the ideal filter.

Digital Filter Design Using Matla


b
Window Generation
W=blackman(L)
W=hamming(L)
W=hanning(L)
W=chebwin(L,Rs)
W=kaiser(L,beta)

Digital Filter Design Using Matla


b
Filter Design
fir1 is used to design conventional lowpass,h
ighpass,
bandpass,bandstop a
nd multiband FIR filter.
b=fir1(N,Wn)
b=fir1(N,Wn,ftype)
b=fir1(N,Wn,window)
b=fir1(N,Wn,ftypewindow)
b=fir1(,noscale)

Digital Filter Design Using Matla


b
A example of a conventional lowpass FIR f
ilter
50
0

Gain,dB

-50
-100
-150
-200
-250
-300

0.1

0.2

0.3

0.4

0.5
0.6
\omega/pi\

0.7

0.8

0.9

Digital Filter Design Using Matla


b
Filter Design
fir2 is employed to design FIR filters with ar
bitarily shaped magnitude response.
b=fir2(N,f,m)
b=fir2(N,f,m,window)
b=fir2(N,f,m,npt)
b=fir2(N,f,m,npt,window)
b=fir2(N,f,m,npt,lap,window)

Digital Filter Design Using Matla


b
A Examples of multilevel filter
--Magnitude response of the multilevel filte
r designed with fir2
1.2
1.1

magnitude

0.9
0.8
0.7
0.6
0.5
0.4
0.3
0.2

0.1

0.2

0.3

0.4

0.5

/pi

0.6

0.7

0.8

0.9

Digital Filter Design Using Matla


b
Least-squares Error FIR Filter Design Usin
g Matlab
firls to design any type of multiband linea
r-phase FIR filter based on the least-squar
es method
b=firls(N,fpts,mag)
b=firls(N,fpts,mag,wt)
b=firls(N,fpts,mag,ftype)
b=firls(N,fpts,mag,wt,ftype)

Digital Filter Design Using Matla


b
A example of the linear-phase FIR lowpas
s filter
--Gain response of the linear-phase FIR low
pass filter
20

-20
-40

gain,dB

-60
-80
-100
-120
-140
-160
-180

0.1

0.2

0.3

0.4

0.5
0.6
\omega/pi\

0.7

0.8

0.9

Вам также может понравиться