Download presentation
Presentation is loading. Please wait.
1
FILTER DESIGN USING WINDOW TECHNIQUE
(RECTANGULAR WINDOW) - Pralhad Konnur (42) - Ashish Lohar (43) - Karan Kishan (41)
2
Why to study FILTERS in Signal Processing?
Almost all type of signal distortion or corruption can be modelled as an addition of frequency components. Even the rectification/clipping can be thought of as addition of harmonics. So, we have to work in the frequency domain. Time domain analysis will not help. Hence, whenever we are in the frequency domain, to remove any component, filters are the things to use. Digital filters give precise characteristics.
3
Filter??? A filter is a device or process that removes some unwanted components or features from a signal. For example, imagine a device for measuring the electrical activity of a baby's heart (EKG) while still in the womb. The raw signal will likely be corrupted by the breathing and heartbeat of the mother. A filter might be used to separate these signals so that they can be individually analysed.
4
Types of Filters Active or Passive Analog or Digital
High Pass, Low Pass, Band Pass, Band Stop, All Pass Discrete time or Continuous time Linear or Non-Linear Infinite Impulse Response (IIR) or Finite Impulse Response (FIR)
5
Audacity Software Working
7
Comparison of Analog and Digital Filters
Analog Filters Digital Filters Defined by linear differential equations Defined by linear difference equations Electrical components like resistors, capacitors, etc. are used Logic components such as adders, subtractors, delays are used For stability and causality, poles should lie on left half of s-plane For stability and causality, poles must lie inside the unit circle Eg: Chebyshev filter, Butterworth filter Eg: Bandpass, Bandstop
8
Facts about IIR Filters
The impulse response is "infinite" because there is feedback in the filter. IIR filters can achieve a given filtering characteristic using less memory and calculations. Can be unstable Derived from analog filters Has at least one pole around the complex plane (i.e. Numerator as well as Denominator). Output not only depends on input, but also previous inputs
9
Facts about FIR Filter No feedback
Can be easily designed to be in Linear Phase Suited to multi-rate applications (i.e. decimation or reducing the sampling rate) Output depends always on the input Always has poles at (0,0)
10
In simple terms……..
11
Filtering Types The window method The frequency sampling technique
Optimal filter design methods
12
Window Technique The z transform of a N-point FIR filter is given by
H(z) = 𝑛=0 𝑁−1 ℎ 𝑛 𝑧 −𝑛 ……………………………………………………….(1) From the desired response specification 𝐻 𝑑 (ω), corresponding unit sample response ℎ 𝑑 (n) is determined using the following relation: ℎ 𝑑 (𝑛) = 1 2π −∞ ∞ 𝐻 𝑑 𝜔 𝑒 𝑗𝜔𝑛 𝑑𝜔 ………………………………………….(2) where 𝐻 𝑑 𝜔 = −∞ ∞ ℎ(𝑛) 𝑒 −𝑗𝑤𝑛 ………………………………………(3) ℎ 𝑑 𝑛 ) obtained from the above relation is infinite in duration, so it must be truncated (shortened) at some point say n= M-1 to yield an FIR filter of length M (i.e. 0 to M-1). This truncation of ℎ 𝑑 (𝑛) to length M-1 is same as multiplying ℎ 𝑑 (𝑛) by the rectangular window defined as: ω(n) = 1 ; 0≤n≤M-1 = 0 ; otherwise Thus the unit sample response of the FIR filter becomes: h(n) = ℎ 𝑑 (𝑛) . ω(n) = ℎ 𝑑 (𝑛) ; 0≤n≤M-1
13
Now, the multiplication of the window function w(n) with ℎ 𝑑 (𝑛) is equivalent to convolution of 𝐻 𝑑 𝜔 with W(𝜔) , where W(𝜔) is the frequency domain representation of the window function: W(𝜔) = 𝑛=0 𝑀−1 ω(𝑛) 𝑒 −𝑗𝑤𝑛 Thus the convolution of 𝐻 𝑑 𝜔 with W(𝜔) yields the frequency response of the truncated FIR filter: H(𝜔) = 1 2𝜋 −𝜋 𝜋 𝐻 𝑑 𝑣 .𝑊( 𝜔−v) d𝜔 The frequency response can also be obtained using the following relation: H(𝜔) = 𝑛=0 𝑀−1 ℎ 𝑛 . 𝑒 −𝑗𝜔𝑛
14
The basic idea behind the window design it to choose a proper ideal frequency-selective filter(which always has a non causal, infinite-duration impulse response) and then to truncate ( or window) its impulse response to obtain a linear-phase and causal FIR filter. The window method is based on calculating the impulse response of an ideal digital filter, which is IIR, and on using a window to obtain a finite impulse response. The rectangular window is the simplest window, equivalent to replacing all but N values of a data sequence by zeros, making it appear as though the waveform suddenly turns on and off.
15
Magnitude of Rectangular Window F.T
Phase of Rectangular Window F.T.
16
Future Applications 2-D windows i.e. Image Processing ( 7th semester)
To observe noise in a clean way Audio production
17
Code clc; clear all; close all;
rp=input('enter the passband ripple: '); rs=input('enter the stopband ripple: '); fp=input('enter the passband freq: '); fs=input('enter the stopband freq: '); f=input('enter the sampling freq: '); wp=2*fp/f;ws=2*fs/f; num=-20*log10(sqrt(rp*rs))-13; dem=14.6*(fs-fp)/f; n=ceil(num/dem); n1=n+1; if(rem(n,2)~=0) n1=n; n=n-1; end
18
y=boxcar(n1); %low pass filter b=fir1(n,wp,y); [h,o]=freqz(b,1,256); m=20*log10(abs(h)); subplot(2,2,1);plot(o/pi,m);ylabel('gain in db-->'); xlabel(' (a) normalised frequency-->'); %high pass filter b=fir1(n,wp,'high',y); subplot(2,2,2);plot(o/pi,m);ylabel('gain in db-->'); xlabel(' (b) normalised frequency-->'); %band pass filter wn=[wp ws]; b=fir1(n,wn,y);
19
m=20*log10(abs(h)); subplot(2,2,3);plot(o/pi,m);ylabel('gain in db-->'); xlabel(' (c) normalised frequency-->'); %band stop filter b=fir1(n,wn,'stop',y); [h,o]=freqz(b,1,256); subplot(2,2,4);plot(o/pi,m);ylabel('gain in db-->'); xlabel(' (d) normalised frequency-->');
20
Output enter the passband ripple: 0.05 enter the stopband ripple: 0.04
enter the passband freq: enter the stopband freq: enter the sampling freq:
22
Numericals Q.1 Design a linear phase FIR low pass filter of length seven with cut off frequency 1 rad/sec using rectangular window. Step I : The desired frequency response 𝐻 𝑑 𝜔 for the law pass FIR filter is given by, 𝐻 𝑑 𝜔 = 𝑒 −𝑗𝜔 M− 𝑓𝑜𝑟 | 𝜔|<| 𝜔 𝑐 | 𝑜𝑡ℎ𝑒𝑟𝑤𝑖𝑠𝑒 ……….(1) Here M = length of filter = 7 (given) 𝐻 𝑑 𝜔 = 𝑒 −3𝑗𝜔 𝑓𝑜𝑟 | 𝜔|<| 𝜔 𝑐 | 𝑜𝑡ℎ𝑒𝑟𝑤𝑖𝑠𝑒 …….(2)
23
Step II : We will obtain ℎ 𝑑 (𝑛) by taking IFT of Equation (2). Using the definition of IFT we get , ℎ 𝑑 (𝑛) = 1 2𝜋 − 𝜔 𝑐 𝜔 𝑐 𝐻 𝑑 𝜔 𝑒 𝑗𝑤𝑛 𝑑𝜔 …….(3) Here given cut off frequency 𝜔 𝑐 = 1 Now for the symmetric filter Range are 𝜔 𝑐 = -1 to 𝜔 𝑐 = 1. ∴ ℎ 𝑑 𝑛 = 1 2𝜋 −1 1 𝑒 −3𝑗𝜔 . 𝑒 𝑗𝑤𝑛 𝑑𝜔 = 𝜋 −1 1 𝑒 𝑗𝜔 𝑛−3 𝑑𝜔 …….(4) = 1 2𝜋 𝑒 𝑗𝜔 𝑛−3 𝑗 𝑛− −1 = 1 𝜋(𝑛−3) 𝑒 𝑗1(𝑛−3) − 𝑒 −𝑗1(𝑛−3) 2𝑗 ∴ ℎ 𝑑 (𝑛) = sin (𝑛−3) 𝜋(𝑛−3) for 𝑛≠ …….(5)
24
Now if n = 3 then equation (4) becomes
∴ ℎ 𝑑 𝑛 = 1 2𝜋 −1 1 𝑒 −0𝑗𝜔 𝑑𝜔 ∴ ℎ 𝑑 𝑛 = 1 2𝜋 −1 1 𝑑𝜔 = 1 2𝜋 [1−(−1)] = 1 𝜋 …….(6) ℎ 𝑑 𝑛 = sin (𝑛−3) 𝜋(𝑛−3) 𝑓𝑜𝑟 𝑛≠3 1 𝜋 𝑓𝑜𝑟 𝑛= …….(7)
25
Step III : Here we have to make use rectangular window of the order 7. We have rectangular window , 𝑊 𝑅 𝑛 = 𝑓𝑜𝑟 𝑛=0 𝑡𝑜 𝑜𝑡ℎ𝑒𝑟𝑤𝑖𝑠𝑒 (for n=0 to M-1) Now h(n) is, h(n) = ℎ 𝑑 𝑛 . 𝑊 𝑅 𝑛 Thus using equation (7) we get, ℎ 𝑛 = ℎ 𝑑 𝑛 𝑓𝑜𝑟 𝑛=0 𝑡𝑜 𝑜𝑡ℎ𝑒𝑟𝑤𝑖𝑠𝑒 This equation gives Unit impulse response of FIR filter.
26
We will calculate h(n) for n = 0 to 6 as follow
For n = 0 ⇒ h(0) = ℎ 𝑑 (0) = sin (−3) −3𝜋 = For n = 1 ⇒ h(1) = ℎ 𝑑 (1) = sin (−2) −2𝜋 = 0.145 For n = 2 ⇒ h(2) = ℎ 𝑑 (2) = sin (−1) −𝜋 = 0.268 For n = 3 ⇒ h(3) = ℎ 𝑑 (3) = 𝜋 = 0.318 For n = 4 ⇒ h(4) = ℎ 𝑑 (4) = sin (1) 𝜋 = 0.268 For n = 5 ⇒ h(5) = ℎ 𝑑 (5) = sin (2) 2𝜋 = 0.145 For n = 6 ⇒ h(6) = ℎ 𝑑 (6) = sin (3) 3𝜋 =
27
Q 2. Design an FIR digital filter to approximate an ideal LPF with passband gain of unity, cut-off frequency of 850 Hz and working at sampling frequency of 5000 Hz. The length of impulse response should be 5.Use rectangular window. Soln :- Step I :- Calculation of cut-off frequency, 𝜔 𝑐 : Cut-off frequency = Fc = 850 Hz Sampling frequency = Fs = 5000 Hz ∴ fc = = 0.17 cycles/sample ∴ 𝜔 𝑐 = 2 𝜋 fc ∴ 𝜔 𝑐 = 2 𝜋 × 0.17 ∴ 𝜔 𝑐 = rad/sample
28
Now ℎ 𝑑 (𝑛) = 1 2𝜋 − 𝜔 𝑐 𝜔 𝑐 𝐻 𝑑 𝜔 𝑒 𝑗𝑤𝑛 𝑑𝜔
Step II :- Calculation of ℎ 𝑑 (𝑛) ∶ We have, 𝐻 𝑑 (𝜔)= 𝑒 −𝑗𝜔 M−1 2 Here M = 5 ∴ 𝐻 𝑑 𝜔 = 𝑒 −𝑗𝜔 5− = 𝑒 −𝑗2𝜔 Now ℎ 𝑑 (𝑛) = 1 2𝜋 − 𝜔 𝑐 𝜔 𝑐 𝐻 𝑑 𝜔 𝑒 𝑗𝑤𝑛 𝑑𝜔 ∴ ℎ 𝑑 𝑛 = 1 2𝜋 − 𝑒 −𝑗2𝜔 . 𝑒 𝑗𝑤𝑛 𝑑𝜔 ∴ ℎ 𝑑 𝑛 = 𝜋 − 𝑒 𝑗𝜔 𝑛−2 𝑑𝜔 ……….(1) ∴ ℎ 𝑑 𝑛 = 1 2𝜋 𝑒 𝑗𝜔 𝑛−2 𝑗 𝑛− −1.068 ∴ ℎ 𝑑 𝑛 = 1 𝜋(𝑛−2) 𝑒 𝑗1.068(𝑛−2) − 𝑒 −𝑗1.068(𝑛−2) 2𝑗
29
∴ ℎ 𝑑 (𝑛) = 1 𝜋(𝑛−2) sin 1.068(𝑛−2) ….𝑓𝑜𝑟 𝑛≠2 ……(2)
To obtain ℎ 𝑑 (𝑛) at n = 2 ; put n = 2 in Equation (1) ∴ ℎ 𝑑 𝑛 = 𝜋 − 𝑒 0 𝑑𝜔 ∴ ℎ 𝑑 𝑛 = 1 2𝜋 ∴ ℎ 𝑑 𝑛 = for n = ………(3) Step III :- Calculation of h(n) using rectangular window : For rectangular window, 𝑊 𝑅 (n) = 1 for n = 0 to M – 1 𝑊 𝑅 (n) = 1 for n = 0 to 4 Now h(n) = ℎ 𝑑 𝑛 . Wr(n) ℎ 𝑑 𝑛 for n = 0 to 4 We will calculate h(n) for n = 0 to 4 as follow For n = 0 ⇒ h(0) = ℎ 𝑑 (0) = For n = 1 ⇒ h(1) = ℎ 𝑑 (1) = For n = 2 ⇒ h(2) = ℎ 𝑑 (2) = For n = 3 ⇒ h(3) = ℎ 𝑑 (3) = For n = 4 ⇒ h(4) = ℎ 𝑑 (4) =
30
Q3.Determine the filter coefficient ℎ 𝑑 𝑛 for the desired frequency response of a low pass filter
given by, 𝐻 𝑑 𝑒 𝑗𝜔 = 𝑒 −2𝑗𝜔 − 𝜋 4 ≤𝜔≤ 𝜋 𝜋 4 ≤ 𝜔≤𝜋 If we define new filter coefficients by,h(n) = ℎ 𝑑 𝑛 . w(n) Where W(n) = 𝑓𝑜𝑟 𝑛=0 𝑡𝑜 𝑜𝑡ℎ𝑒𝑟𝑤𝑖𝑠𝑒 Then determine h ( n ). Soln:- Given:- 𝐻 𝑑 𝑒 𝑗𝜔 = 𝑒 −2𝑗𝜔 − 𝜋 4 ≤𝜔≤ 𝜋 𝜋 4 ≤ 𝜔≤𝜋 …….(1)
31
ℎ 𝑑 (𝑛) = 1 2𝜋 − 𝜔 𝑐 𝜔 𝑐 𝐻 𝑑 𝑒 𝑗𝜔 𝑒 𝑗𝑤𝑛 𝑑𝜔
Calculation of ℎ 𝑑 𝑛 :- ℎ 𝑑 (𝑛) is given by, ℎ 𝑑 (𝑛) = 1 2𝜋 − 𝜔 𝑐 𝜔 𝑐 𝐻 𝑑 𝑒 𝑗𝜔 𝑒 𝑗𝑤𝑛 𝑑𝜔 ∴ ℎ 𝑑 𝑛 = 1 2𝜋 − 𝜋 4 𝜋 4 𝑒 −2𝑗𝜔 . 𝑒 𝑗𝑤𝑛 𝑑𝜔 = 𝜋 − 𝜋 4 𝜋 4 𝑒 𝑗𝜔 𝑛−2 𝑑𝜔 = 1 2𝜋 𝑒 𝑗𝜔 𝑛−2 𝑗 𝑛−2 𝜋 4 − 𝜋 4 = 1 𝜋(𝑛−2) 𝑒 𝑗(𝑛−2) 𝜋 4 − 𝑒 −𝑗(𝑛−2) 𝜋 4 2𝑗
32
∴ ℎ 𝑑 (𝑛) = sin (𝑛−2) 𝜋 4 𝜋(𝑛−2) for 𝑛≠2 …….(3)
,putting n=2 in equation(2), ∴ ℎ 𝑑 2 = 1 2𝜋 − 𝜋 4 𝜋 4 𝑒 −0𝑗𝜔 𝑑𝜔 ∴ ℎ 𝑑 2 = 1 2𝜋 −1 1 𝑑𝜔 = 𝜋 [ 𝜋 4 −(− 𝜋 4 )] = 1 2𝜋 . 𝜋 2 = 0.25 ℎ 𝑑 𝑛 = sin (𝑛−2) 𝜋 4 𝜋(𝑛−2) 𝑓𝑜𝑟 𝑛≠ 𝑓𝑜𝑟 𝑛= …….(4)
33
Calculation of h(n) We have , h(n) = ℎ 𝑑 𝑛 . W(n) And given as W(n) = 𝑓𝑜𝑟 𝑛=0 𝑡𝑜 𝑜𝑡ℎ𝑒𝑟𝑤𝑖𝑠𝑒 We will calculate h(n) for n = 0 to 4 as follow For n = 0 ⇒ h(0) = ℎ 𝑑 (0) = sin (−2) −2𝜋 = For n = 1 ⇒ h(1) = ℎ 𝑑 (1) = sin (0) 0 = 0.225 For n = 2 ⇒ h(2) = ℎ 𝑑 (2) = sin (−1) −𝜋 = 0.25 For n = 3 ⇒ h(3) = ℎ 𝑑 (3) = sin (1) 𝜋 = 0.225 For n = 4 ⇒ h(4) = ℎ 𝑑 (4) = sin (2) 2𝜋 = 0.168
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.