Filtering of signals - PowerPoint PPT Presentation

1 / 71
About This Presentation
Title:

Filtering of signals

Description:

... is possible to pass some frequencies and attenuate the others. ... attenuation ... 1 dB, Minimum stop band attenuation 30db cut off frequency 1000Hz ... – PowerPoint PPT presentation

Number of Views:262
Avg rating:3.0/5.0
Slides: 72
Provided by: profmel
Category:

less

Transcript and Presenter's Notes

Title: Filtering of signals


1
Filtering of signals
Adawy
2
What is meant by a filter!
The DTFT is remembered again
Xn is expressed as a summation of sinusoids
with scaled amplitude. Using a system with a
frequency selective to these inputs, then it is
possible to pass some frequencies and attenuate
the others. Such a system is called a Filter.
Adawy
3
The function of a filter is to remove unwanted
parts of the signal, such as random noise, or to
extract useful parts of the signal, such as the
components lying within a certain frequency
range.
Unfiltered signal or raw signal
Filtered signal
Adawy
4
Example
Choose frequency response of a system such that
1, for wwc
0, for wcwp
If xn Acos(w1n) Bcos(w2n), 0ltw1ltwcltw2lt p
y(n)AH(ejw1)cos(w1n?(w1)) AH(ejw2)cos(w2n?
(w2))
Almost 0
y(n)AH(ejw)cos(w1n?(w1))
Which indicating the LPF effect of the LTI system
Adawy
5
Design a HP digital filter that passes the
0.4rad/sec, and stops the 0.1 rad/sec frequency.
hn a b a
?(w)-w
Solving for the two equations gives a-6.76195,
b13.456335
ynhnxn
ynh0xnh1xn-1h2xn-2axnbxn-1
axn-2
Adawy
6
yn-6.76195(xnxn-2)13.456335xn-1
If Xncos(0.1n)cos(0.4n)u(n)
X1X2
Output is almost equal to x2, the high frequency
Output of the filter
Transient
x1
Adawy
7
Classification of filters as analog or digital
Analog filters
Digital filters
An analog filter uses analog electronic circuits
made up from components such as resistors,
capacitors and op amps to produce the required
filtering effect. Such filter circuits are widely
used in such applications as noise reduction,
video signal enhancement, graphic equalizers in
hi-fi systems, and many other areas.
A digital filter uses a digital processor to
perform numerical calculations on sampled values
of the signal. The processor may be a
general-purpose computer such as a PC, or a
specialized DSP (Digital Signal Processor) chip.
Adawy
8
Design of analog filters
  • We need to discuss some of the famous techniques
    for analog filter design due to two main reasons
  • We need them as a prefilter or antialiasing
    filter before the A/D conversion,
  • Some techniques for digital filter design are
    based on the transformation of some analog
    techniques.

Characteristics of a LPF
Ha(j?)
1dp
1-dp
Transition band
Pass band
Stop band
ripples
ds
?
0
?p
?s
Adawy
9
1-dp Ha(j?) 1dp 0 ? ?p
Pass band
Ha(j?) ds ?s ? 8
Stop band
Transition ratio, or selectivity parameter, it is
larger than unity
ap-20log10(1-dp) dB
Peak pass band ripple
as-20log10(ds) dB
Minimum stop band attenuation
Such filter is completely characterized by ?c,
the 3dB point, ?s, ?p, dp, and ds.
Adawy
10
?c is the cut off frequency or the -3db cut ff
frequency
Butterworth Approximation
N2
N4
N10
It has a maximally flat magnitude at zero
frequency. This clear from (2N-1) differentiation
of its function gives zeros.
Adawy
11
MATLAB Butterworth functions
num,den BUTTER(N,Wn) designs an Nth order
lowpass digital Butterworth filter and returns
the filter coefficients in length N1 vectors
(numerator) and (denominator). The coefficients
are listed in descending powers of z. See MATLAB
help for more Butterworth functions
design of butterworth filter num,denbutter(4,1
,'s') w00.15 hfreqs(num,den,w) gain20log1
0(abs(h)) subplot(2,1,1) plot(w,gain) grid xla
bel('Normalized frequency') ylabel('Gain in dB')
Adawy
12
Type 1 Chebyshev Approximation
Type 1 Chebyshev filter. It is equiripple in the
pass band and monotonically decreasing in the
stop band
TN(?) cos(Ncos-1?) ? 1
cosh(Ncosh-1?) ? gt 1
?2 represent the ripples in the pas band
CHEBY1 Chebyshev type I digital and analog filter
design. num,den CHEBY1(N,R,Wn) designs an
Nth order lowpass digital Chebyshev filter with R
decibels of ripple in the pass band. CHEBY1
returns the filter coefficients in length N1
vectors (numerator) and (denominator).
Adawy
13
N3, Rp1 dB, fp1000Hz, wp2pifp
design of type1 chebyshev filter num,dencheby1
(3,1,2000pi,'s') w020012000pi hfreqs(num,d
en,w) gain20log10(abs(h)) subplot(2,1,1) plot
(w/(2pi),gain) grid ylabel('Gain in
dB') w02002400pi hfreqs(num,den,w) gain20
log10(abs(h)) subplot(2,1,2) plot(w/(2pi),gain
) grid xlabel('Frequency in Hz') ylabel('Gain
in dB')
Adawy
14
Type 2 Chebyshev filter. It is equiripple in the
stop band and monotonically decreasing in the
pass band
Type 2 Chebyshev Approximation
CHEBY2 Chebyshev type II digital and analog
filter design. B,A CHEBY2(N,R,Wn) designs
an Nth order lowpass digital Chebyshev filter
with the stop band ripple R decibels down and
stop band edge frequency Wn. CHEBY2 returns the
filter coefficients in length N1 vectors B
(numerator) and A (denominator).
Adawy
15
N11, R30 dB, fs1000Hz, ws2pifs
Type2 Chebyshev filter
design of type2 chebyshev filter num,dencheby2
(11,30,2000pi,'s') w020012000pi hfreqs(num
,den,w) gain20log10(abs(h)) subplot(2,1,1) pl
ot(w/(2pi),gain) grid ylabel('Gain in dB')
Adawy
16
Elliptic filter. It is equiripple in the stop
band and in the pass band
Elliptic Approximation
RN(?) is a rational function satisfies the
property RN(1/?)1/RN(?)
ELLIP Elliptic or Cauer digital and analog filter
design. B,A ELLIP(N,Rp,Rs,Wn) designs an
Nth order lowpass digital elliptic filter
with Rp decibels of ripple in the passband and a
stopband Rs decibels down. ELLIP returns the
filter coefficients in length N1 vectors B
(numerator) and A (denominator).
Adawy
17
N7, pass band ripples 1 dB, Minimum stop band
attenuation 30db cut off frequency 1000Hz
design of elliptic filter num,denellip(7,1,30,
2000pi,'s') w020012000pi hfreqs(num,den,w)
gain20log10(abs(h)) subplot(2,1,1) plot(w/(2
pi),gain) grid ylabel('Gain in
dB') w02002000pi hfreqs(num,den,w) gain20
log10(abs(h)) subplot(2,1,2) plot(w/(2pi),gain
) grid xlabel('Frequency in Hz') ylabel('Gain
in dB')
Adawy
18
Classification of filters According to frequency
response
H(ejw)
LPF
w
wc
p
0
HPF
H(ejw)
w
wc
p
0
BPF
H(ejw)
p
w
wc1
wc2
0
H(ejw)
BSF
p
w
wc1
0
wc2
Adawy
19
Pass band 0 w wc Stop band wc w p
LPF
Stop band 0 w wc Pass band wc w p
HPF
Pass band wc1 w wc2 Stop band 0 w wc1,
wc2 w p
BPF
Stop band wc1 w wc2 Pass band 0 w wc1,
wc2 w p
BSF
Wc, wc1, and wc2 are called the cut off
frequencies.
Adawy
20
Design Of Digital Filters
21
Advantages of using digital filters
1. A digital filter is programmable, i.e. its
operation is determined by a program stored in
the processor's memory. This means the digital
filter can easily be changed without affecting
the circuitry (hardware). An analog filter can
only be changed by redesigning the filter
circuit. 2. Digital filters are easily designed,
tested and implemented on a general-purpose
computer or workstation. 3. The characteristics
of analog filter circuits (particularly those
containing active components) are subject to
drift and are dependent on temperature. Digital
filters do not suffer from these problems, and so
are extremely stable with respect to both time
and temperature.
Adawy
22
4. Unlike their analog counterparts, digital
filters can handle low frequency signals
accurately. As the speed of DSP technology
continues to increase, digital filters are being
applied to high frequency signals in the RF
(radio frequency) domain, which in the past was
the exclusive preserve of analog technology. 5.
Digital filters are very much more versatile in
their ability to process signals in a variety of
ways this includes the ability of some types of
digital filter to adapt to changes in the
characteristics of the signal. 6. Fast DSP
processors can handle complex combinations of
filters in parallel or cascade (series), making
the hardware requirements relatively simple and
compact in comparison with the equivalent analog
circuitry.
Adawy
23
1- Filter Characteristics Specification
Pass band
wwp
1-dpH(ejw)1dp
dp Pass band deviation
wp Pass band edge frequency
Stop band
wsw p
H(ejw)ds
ds Stop band deviation
ws Stop band edge frequency
Adawy
24
Normalized LPF specs
k?p/?s
k, and k1 will be used to estimate the degree of
IIR filter
1/A
Adawy
25
Classification of filters according to impulse
response length
Finite Impulse Response, FIR filters
Infinite Impulse Response, IIR filters
Adawy
26
2- Selection of filter type
FIR or IIR
1. FIR can have an exactly linear phase
response. 2. FIR realized nonrecursively is
always stable. 3. Quantization effects are less
severe in FIR than in IIR. 4. FIR requires more
coefficients for sharp cutoff than IIR. 5. Analog
filters can be transformed into IIR. 6. FIR is
easier to synthesize if CAD support is available.
An FIR system is always stable, But an IIR system
may be stable or not, and it must be designed
properly.
Adawy
27
An originally stable IIR filter with precession
coefficients may become unstable after
implementation due to unavoidable quantization
error in its coefficients. !!!
Stable IIR filter
After quantization unstable IIR filter
Adawy
28
Demonistration for the effect of quantization of
filter coefficients L100 L is the length of
the impulse response hn num1 den1 -1.845
0.850586 den21 -1.85 0.85 h1
timpz(num,den,L) subplot(2,1,1) stem(h1) ylab
el('Amplitude') xlabel('Time index n') h2
timpz(num,den2,L) subplot(2,1,2) stem(h2) yla
bel('Amplitude') xlabel('Time index n')
This program draws the previous impulse response
that shows the effect of quantization on the
system stability.
Adawy
29
Filter degree
Butterworth filter
Chebyshev filter
1- IIR filter
Elliptic filter
2- FIR filter
There are another approximation for very narrow
pass band and very wide pass band
Adawy
30
Example
LPF with 1dB at wp1kHz, and 40dB at ws5kHz
g20.25895
A210000
N3.2814
1- Butterworth filter
N2.60593
2- Chebyshev filter
3- FIR filter
N7
Adawy
31
IIR Filter Design
Design using Analog Filters
1) Impulse Invariant Method (IIM)
2) Bilinear z-Transform (BZT) Method
Adawy
32
1) Impulse Invariant Method (IIM)
In this method we require that the unit sample
response hn of the desired causal digital
transfer function H(z) be equal to the sampled
version ha(t) sampled at uniform intervals of T
seconds. hnha(nT)
We have seen before that the freq. response
H(ejw) of a sampled sequence ha(nT) is given by
Adawy
33
In the last equation put zejw, sj?, and ?w/T
will be s(1/T)lin(z), so we can write this
equation as follows
Z transform of the sequence
Laplace transform of the continuous impulse
response
Take a look at this transformation
S(1/T)lin(z) or zeST
Ssj?
zresT
ZeSTesT ej?T
Points on the j? axis means s0 in the s plane
Points on the unit circle r1 in the z plane
For s negative, left half of the s plane
rlt1 inside the unit circle of the z plane
Adawy
34
j?
Im z
S Plane
Z Plane
3p/T
p/T
s
1
-1
Re z
-p/T
-3p/T
Infinity of strips of width 2p/T in the s plane
maps to the unit circle in the z plane. Left half
of each strip maps inside the unit circle
Adawy
35
The resultant frequency response is given by the
sum of the frequency responses of the original
analog function and its shifted versions at
2pk/T with the over all sum scaled by 1/T. So if
Ha is band limited, there will be no aliasing,
and if it is not band limited there will be
aliasing as it was seen before.
So in Impulse Invariant method IIM
Stable analog filter maps to stable digital filter
Frequency response of the digital filter is a
multiple versions of the analog filter response
centered at 2pk/T, (sampling frequency).
Adawy
36
2) Bilinear Transformation Method
Disadvantage of the previous method is the
aliasing, and the many to one mapping where many
strips in the s plane each of them maps to the
entire z plane.
Bilinear Transformation Method
Adawy
37
Put T2 to make things simple in the expression
of S and Z
Put ssj?
  • For s0 , zr1 unit circle

S Plane
j?
Im z
  • For slt0 LHP, Zlt1 inside unit circle.

Z Plane
s
  • For sgt0 RHP, Zgt1 outside unit circle.

Re z
  • One to one mapping

Adawy
38
w
p
W2tan-1(?T/2)
?
0
-p
ve ? maps into upper half of the unit circle, 0
to p
-ve ? maps into lower half of the unit circle, 0
to -p
The relation is highly nonlinear
Adawy
39
w
W2tan-1(?T/2)
w
p
?
H(ejw)
0
-p
1- Given the digital filter specs, wp and ws,
find there corresponding in the analog filter,
use the relation between w and ?
Ha(j?)
?
2- Design an analog filter that meets these
specs. Find Ha(s)
3- Use bilinear transformation to find H(z) from
Ha(s).
Adawy
40
Example
Design a digital LPF using bilinear
transformation to satisfy the following 1-
Monotonic stop band and pass band, 2- -3.01dB
cutoff frequency at 0.5p, and 15dB at w0.75p
1- Monotonically decreasing magnitude means
Butterworth filter
2- Calculation of corresponding analog
frequencies considering T1 ?p(2/T)tan(wp/2)
2tan(0.5p/2)2 ?s(2/T)tan(ws/2)2tan(0.75p/2)4.8
28
3- Calculation of
N2
Adawy
41
From tables of analog Butterworth filter
Apply bilinear transformation
Adawy
42
IIR digital filter design using MATLAB
1- BUTTER Butterworth digital and analog filter
design. B,A BUTTER(N,Wn) designs an Nth
order low pass digital Butterworth filter and
returns the filter coefficients in length N1
vectors B (numerator) and A (denominator). The
coefficients are listed in descending powers of
z. The cutoff frequency Wn must be 0.0 lt Wn lt
1.0, with 1.0 corresponding to half the sample
rate. If Wn is a two-element vector, Wn W1
W2, BUTTER returns an order 2N band pass filter
with pass band W1 lt W lt W2. B,A
BUTTER(N,Wn,'high') designs a high pass filter.
B,A BUTTER(N,Wn,'stop') is a band stop filter
if Wn W1 W2. When used with three left-hand
arguments, as in Z,P,K BUTTER(...), the zeros
and poles are returned in length N column vectors
Z and P, and the gain in scalar K.
BUTTER(N,Wn,'s'), BUTTER(N,Wn,'high','s') and
BUTTER(N,Wn,'stop','s') design analog Butterworth
filters. In this case, Wn can be bigger than 1.0.
Adawy
43
B,Abutter(N,wn) B,Acheby1(N,Rp,wn) B,Ache
by2(N,Rs,wn) B,Aellip(N,Rp,Rs,wn)
z,p,kbutter(N,wn) z,p,kcheby1(N,Rp,wn) z,p,
kcheby2(N,Rs,wn) z,p,kellip(N,Rp,Rs,wn)
Rp, ripples in the pass band, Rs, ripples in the
stop band
The function freqz(B,A,w) can be used to plot the
frequency response.
Adawy
44
BUTTORD Butterworth filter order selection.
N, Wn BUTTORD(Wp, Ws, Rp, Rs) returns the
order N of the lowest order digital Butterworth
filter that loses no more than Rp dB in the pass
band and has at least Rs dB of attenuation in the
stop band. Wp and Ws are the pass band and stop
band edge frequencies, normalized from 0 to 1
(where 1 corresponds to pi radians/sample). For
example, Low pass Wp .1, Ws
.2 High pass Wp .2, Ws .1
Band pass Wp .2 .7, Ws .1 .8
Band stop Wp .1 .8, Ws .2 .7
BUTTORD also returns Wn, the Butterworth natural
frequency (or, the "3 dB frequency") to use with
BUTTER to achieve the specifications. N, Wn
BUTTORD(Wp, Ws, Rp, Rs, 's') does the
computation for an analog filter, in which case
Wp and Ws are in radians/second. When Rp is
chosen as 3 dB, the Wn in BUTTER is equal to Wp
in BUTTORD.
N, Wn buttord(Wp, Ws, Rp, Rs) N, Wn
cheby1ord(Wp, Ws, Rp, Rs) N, Wn cheby2ord(Wp,
Ws, Rp, Rs) N, Wn ellipord(Wp, Ws, Rp, Rs)
Adawy
45
Example
Determine the transfer function and plot the gain
response of a 5th order elliptic IIR filter with
a pass band edge at wp0.4, pass band ripples
Rp0.5dB, and minimum stop band attenuation
Rs40dB.
elliptic IIR LP digital filter
design N5 Rp0.5 Rs40 wn0.4 b,aellip(5,0
.5,40,0.4) disp('Numerator polynomial') disp(b)
disp('denominator polynomial') disp(a) w00.01
/pipi hfreqz(b,a,w) gain20log10(abs(h)) plo
t(w/pi,gain) grid xlabel('normalized
frequency') ylabel('gain in dB')
Numerator polynomial 0.0528 0.0797
0.1295 0.1295 0.0797 0.0528 denominator
polynomial 1.0000 -1.8107 2.4947
-1.8801 0.9537 -0.2336
Adawy
46
Numerator polynomial 0.0528 0.0797
0.1295 0.1295 0.0797 0.0528 denominator
polynomial 1.0000 -1.8107 2.4947
-1.8801 0.9537 -0.2336
Gain response of the previous filter
Adawy
47
Pole zero representation of the previous filter
elliptic IIR LP digital filter design (poles and
zeros) N5 Rp0.5 Rs40 wn0.4 b,aellip(5,0
.5,40,0.4) z,p,ktf2zp(b,a) disp('Zeros
are') disp(z) disp('Poles are') disp(p) disp
('Gain constant is') disp(k) zplane(b,a)
Stable !!
Poles are 0.2787 0.8973i 0.2787 -
0.8973i 0.3812 0.6274i 0.3812 - 0.6274i
0.4909
Zeros are -1.0000 -0.3020
0.9533i -0.3020 - 0.9533i 0.0474 0.9989i
0.0474 - 0.9989i
Gain constant is 0.0528
Adawy
48
Example
Determine the transfer function and plot the gain
response of an 8th order Butterworth band pass
digital filter with pass band edges 0.4 and 0.7.
butterworth IIR BP digital filter
N8 MN/2 w10.4 w20.7 wnw1
w2 b,abutter(M,wn) disp('numerator
polynomial')disp(b) disp('denominator
polynomial')disp(a) w0.2pi0.01/pi0.85pi h
freqz(b,a,w) gain20log10(abs(h)) plot(w/pi,gai
n) grid xlabel('normalized frequency') ylabel('
gain in dB')
0.0186 0 -0.0743 0 0.1114
0 -0.0743 0 0.0186
Num pol.
Denom pol.
Adawy
1.0000 0.9780 1.9399 1.3386 1.6271
0.7349 0.5826 0.1386 0.0762
49
Pole zero representation of the previous filter
butterworth IIR BP digital filter design (poles
and zeros) N8 w10.4 w20.7 wnw1
w2 b,abutter(N/2,wn) z,p,ktf2zp(b,a) dis
p('Zeros are')disp(z) disp('Poles
are')disp(p) disp('Gain constant
is')disp(k) zplane(b,a)
Poles are -0.4963 0.7058i -0.4963 -
0.7058i 0.2419 0.8060i 0.2419 - 0.8060i
-0.2651 0.5715i -0.2651 - 0.5715i 0.0305
0.6027i 0.0305 - 0.6027i
Zeros are 1.0001 1.0000
0.0001i 1.0000 - 0.0001i 0.9999
-1.0001 -1.0000 0.0001i -1.0000 -
0.0001i -0.9999
Gain constant is 0.0186
Adawy
50
Design of FIR filters
FIR filters are characterized by linear phase
IIR filters cannot produce a linear phase
Linear phase is necessary when it is desired to
maintain the shape of the wave
Adawy
51
Linear phase15 samples
phase
Xsin(pi/30)n
X1sin(pi/30)(n-15)
w
ysin(pi/10)n
y1sin(pi/10)(n-15)
The result is the same wave shifted by 15 samples
Adawy
52
Nonlinear phase
phase
Xsin(pi/30)n
X1sin(pi/30)(n-15)
w
ysin(pi/10)n
y1sin(pi/10)(n-2)
The wave shape is not conserved because delay is
not linear
Adawy
53
Realization of linear phase FIR filter
It is always possible to design an FIR transfer
function with an exact linear phase, but nearly
impossible to design an IIR linear phase one.
1- Design of linear phase FIR filter using odd
length symmetric impulse response
hnhN-n, 0nN
For N8
H(z)h8h7z-1h6z-2h5z-3h4z-4h3z-5
h2z-6 h1z-7h0z-8
Adawy
54
The impulse response is symmetric around the h4
sample, so h0h8, h1h7, h2h6,
h3h5. So we can write
H(z)h0(1z-8)h1(z-1z-7)h2(z-2z-6)h3(
z-3z-5) h4z-4
H(z)h0z-4(z4z-4)h1z-4(z3z-3)
h2Z-4(z2z-2) h3z-4(z1z-1) h4z-4
H(z)z-4h0(z4z-4)h1(z3z-3) h2(z2z-2)
h3(z1z-1) h4
H(ejw)e-jw42h0cos(4w)2h1cos(3w)2h2cos(2w
) 2h3cos(w)h4
?(w)-4w, which is linear, GD4 which is
constant
Where a0hN/2, an2hN/2 n,
1nN/2
Adawy
55
2- Design of linear phase FIR filter using even
length symmetric impulse response
For N7
h0h7, h1h6, h2h5, h3h4.
H(z)h0(1z-7)h1(z-1z-6)h2(z-2z-5)h3(
z-3z-4)
H(z)z-7/2h0(z7/2z-72)h1(z5/2z-5/2)
h2(z3/2z-3/2) h3(z1/2z-1/2)
H(ejw)e-jw7/22h0cos(7w/2)2h1cos(5w/2)
2h2cos(3w/2) 2h3cos(w/2)
?(w)-7w/2, which is linear, GD7/2 which is
constant
Where bn2h(N1)/2 n,
1n(N1)/2
Adawy
56
H(z)(1/6)0.5z-1z-2z-3z-4z-50.5z-6
Example
Phase response, it is linear in the pass band
Frequency response
Impulse response
Adawy
57
3- Design of linear phase FIR filter using odd
length antisymmetric impulse response
For N8
hn-hN-n, 0nN, hN/20
H(z)z-4h0(z4-z-4)h1(z3-z-3) h2(z2-z-2)
h3(z1z-1)
H(ejw)e-j(4w-p/2)2h0sin(4w)2h1sin(3w)2h2
sin(2w) 2h3sin(w)
?(w)-4w-p/2, which is linear, GD4 which is
constant
Where cn2hN/2 n, 1nN/2
Adawy
58
4- Design of linear phase FIR filter using even
length antisymmetric impulse response
For N7
H(z)z-7/2h0(z7/2-z-72)h1(z5/2-z-5/2)
h2(z3/2-z-3/2) h3(z1/2-z-1/2)
H(ejw)e-(jw7/2-p/2)2h0sin(7w/2)2h1sin(5w/2)
2h2sin(3w/2) 2h3sin(w/2)
?(w)-7w/2 p/2, which is linear, GD7/2 which
is constant
Where dn2h(N1)/2 n,
1n(N1)/2
Adawy
59
The four cases of symmetry required for linear
phase realization
Odd antisymmetry
Odd symmetry
even antisymmetry
Even symmetry
Point of symmetry
Adawy
60
Design of FIR filters using Windows
Simply truncate the response of an IIR filter to
a desired length.
Impulse response of the IIR filter
Impulse response of the FIR filter
wn
hnhdn.wn
hdn
Adawy
61
From the properties of the Fourier transform
F.T
hnhdn.wn
H(ejw)Hd(eiw)W(ejw)
H(ejw)


w
4p/N
This convolution produced a smeared version of
the ideal LPF frequency response. The wider the
main lobe of W, the more spread is H. So, there
is a trade off between large N to minimize
smearing, and small N to get a reasonable
implementation of the filter.
Adawy
62
Different window shapes
Much work has been done to adjust wn to satisfy
certain main lobe width and relative side lobes
levels requirements. These windows are
Rectangle, Bartlett, Hanning, Hamming, Blackman,
Kaiser, and more.
Adawy
63
Window Function
Rectangle Window
Hanning Window
-M n M
Hamming Window
-M n M
Blackman Window
-M n M
Adawy
64
Characteristics of different windows
Transition band width (wp-ws)c/M, where c is a
constant depends on type of window as in the
table. This relation can be used to estimate the
order of the filter.
Adawy
65
H(eiw)
Example
1
w
Wcp/2
p
The impulse response of the desired filter is
obtained by calculating the inverse DTFT as
follows
8- n 8
This response will be windowed for -M n M, and
shifting by M samples to make it realizable
(causal).
0 n N-1, N2M1
Freq. response
Adawy
66
N51, wc0.25pi, Rectangle window
Adawy
67
Design of FIR filters based on frequency response
sampling
Start by the desired frequency response Hd(ejw)
Uniformly sample it at N equally spaced points
wk2pk/N, k0, 1, 2, N-1
These samples represent N point DFT Hk
Take IDFT of these N points to get the impulse
response hn
Adawy
68
FIR digital filter using MATLAB
MATLAB includes 5 window functions that can be
used to design FIR filter using the window
method, these windows are
Wblackman(N), Whamming(N), whanning(N),
wchebwin(N,Rs), wkaiser(N,beta). N is the
number of samples, beta, Rs are coefficients
related transition bands.
bfir1(L,wn), generates a length NL1 vector b
that represent the impulse response coefficients
of the LPF FIR filter. Hamming window is
considered if no window is mentioned. Filter type
(low, high, band stop or band stop). Also a type
of the window can be included like this
form bfir1(L,wn, filter type,
window) bfir1(L,wn, stop, kaiser)
Adawy
69
Example
Design a LP FIR filter using kaiser, and hanning
windows with the following specifications
wp0.3pi, ws0.4pi, As50dB.
As is the stop band attenuation50, so, ß4.55126
?f(ws-wp)/2pi 0.05
For Asgt21
N61
For Aslt21
Adawy
70
wp0.3 kwkaiser(61,4.55126) bfir1(60,0.3,kw)
w0pi/256pi hfreqz(b,1,w) mag20log10(abs(h)
) subplot(2,1,1) plot(w/pi,mag) AXIS(0 1 -80
0) hamhamming(61) b2fir1(60,0.3,ham) w0pi
/256pi h2freqz(b2,1,w) mag220log10(abs(h2))
subplot(2,1,2) plot(w/pi,mag2) AXIS(0 1 -80
0)
Adawy
71
design of FIR LPF N61 beta4.55126 wp0.3 kw
kaiser(61,4.55126) bfir1(60,0.3,kw) w0pi/256
pi hfreqz(b,1,w) mag20log10(abs(h)) fiterin
g a sequence of data n01100 bfir1(60,0.3,kw)
x1cos(0.1pin) x2cos(0.4pin) yfilter(b,1,
x1) subplot(3,1,1) plot(n,y,'r',n,x1,'k') yfil
ter(b,1,x2) subplot(3,1,2) plot(n,y,'r',n,x2,'k'
) yfilter(b,1,x1x2) subplot(3,1,3) plot(n,y,'
r',n,x1x2,'k') ylabel('Amplitude') xlabel('Time
index')
Response of previous filter for different inputs
Adawy
Write a Comment
User Comments (0)
About PowerShow.com