Académique Documents
Professionnel Documents
Culture Documents
Ashira Jayaweera
Undergraduate, Department of Electronics and Telecommunication Engineering
University of Moratuwa
Katubedda, Sri Lanka
Abstract
Noise and interferences are major issues in digital signal processing (DSP)
applications because they affect the accuracy and reliability of the information carried
by a signal. Therefore filtering noise and interferences is a major operation in DSP. As a
result designing a digital filter having good performance is a demanding one. The design
procedure of a finite extent impulse response (FIR) filter satisfying all the required
conditions using the windowing method in conjunction with the Kaiser window is
discussed in this application report. Matlab is used as the software tool implementing
the filter.
Keywords – FIR Filter; bandpass filter; Matlab; Kaiser Window; passband; stopband
Introduction
Here digital filters are categorized according to the length of their impulse
responses. The output of an IIR filter depends not only on present and past inputs but
also past outputs. FIR filter generates output only from present and past inputs. FIR
filter has more advantages over an IIR filter such as,
FIR digital filters have an exactly linear phase
FIR filter is always stable
Can be realized using a non-recursive structure
Can achieve arbitrary prescribed amplitude and frequency responses
Design and simulation can be achieved easily and efficiently using a software tool
like Matlab
Since it can be designed using closed form method less computations involved
When designing an FIR filter using the closed form method, transfer function of
the filter in z domain should be obtained. Window method and weighted-Chebyshev
method are two methods to find out the transfer function of a nonrecursive FIR filter. In
this report window method is considered. A good window function should have lesser
Gibb’s oscillations and a narrow main lobe width in its spectrum in order to achieve
given specifications of the filter using less resources. Such window functions are listed
below.
Rectangular window
Von-Hann window
Hamming window
Blackman window
Dolph-Chebyshev window
Kaiser window
Among these windows Kaiser Window is more specific because it can be
adjusted in order to meet the given specifications. The design procedure of an FIR
bandpass filter for the following specifications is described in this report.
Specifications
Specifications are defined according to the index number 140270M
Maximum pass band ripple, Ã𝑝 = 0.12 dB
Minimum stop band attenuation, Ã𝑎 = 57 dB
Lower pass band edge, 𝜔𝑝1 = 300 rad/s
Upper pass band edge, 𝜔𝑝2 = 600 rad/s
Lower stop band edge, 𝜔𝑎1 = 200 rad/s
Upper stop band edge, 𝜔𝑎1 = 750 rad/s
Sampling frequency, 𝜔𝑠 = 2000 rad/s
Step 01
Determine the impulse response ℎ(𝑛𝑇) using the Fourier series assuming an idealized
frequency response
1 𝑓𝑜𝑟 − 𝜔𝑐2 ≤ 𝜔 ≤ −𝜔𝑐1
𝑗𝜔𝑡
𝐻(𝑒 ) = {1 𝑓𝑜𝑟 𝜔𝑐2 ≤ 𝜔 ≤ 𝜔𝑐1
0 𝑂𝑡ℎ𝑒𝑟𝑤𝑖𝑠𝑒
This is given by,
2
(𝜔 − 𝜔𝑐2 ) 𝑓𝑜𝑟 𝑛 = 0
𝜔𝑠 𝑐1
ℎ(𝑛𝑇) = 1
(sin 𝜔𝑐2 𝑛𝑇 − sin 𝜔𝑐1 𝑛𝑇) 𝑂𝑡ℎ𝑒𝑟𝑤𝑖𝑠𝑒
𝑛𝜋
{
Step 02
Choose δ such that the actual passband ripple,𝐴𝑝 is equal to or less than specified
passband ripple Ã𝑝 , and the actual minimum stopband attenuation,𝐴𝑎 is equal or
greater than the specified minimum stopband attenuation, Ã𝑎
A suitable value is
𝛿 = min(𝛿𝑝 , 𝛿𝑎 )
10𝑜.𝑜5Ã𝑝 − 1
Where 𝛿𝑝 = and 𝛿𝑎 = 10−𝑜.𝑜5Ã𝑎
10𝑜.𝑜5Ã𝑝 + 1
Step 03
With the required δ defined, the actual stopband attenuation 𝐴𝑎 can be calculated as
𝐴𝑎 = −20 log(𝛿)
Step 04
Choose parameter α as
0 𝑓𝑜𝑟 𝐴𝑎 ≤ 21
0.4
𝛼 = { 0.5842(𝐴𝑎 − 21) + 0.07886(𝐴𝑎 − 21) 𝑓𝑜𝑟 21 < 𝐴𝑎 ≤ 50
0.07886(𝐴𝑎 − 8.7) 𝑓𝑜𝑟 𝐴𝑎 > 50
Step 05
Choose parameter D as
0.9222 𝑓𝑜𝑟 𝐴𝑎 ≤ 21
𝐷 = { 𝐴𝑎 − 7.95 𝑓𝑜𝑟𝐴𝑎 > 21
14.36
Then select the lowest odd value of N that would satisfy the inequality
ωs D
N≥ + 1 where 𝐵𝑡 = 𝜔𝑎 − 𝜔𝑝
Bt
Step 06
Form 𝑤𝑘 (𝑛𝑇) using the following equations:
𝐼0 (𝛽)
𝑓𝑜𝑟 |𝑛| ≤ (𝑁 − 1)/2
𝑤𝑘 (𝑛𝑇) = { 𝐼0 (𝛼)
0 𝑂𝑡ℎ𝑒𝑟𝑤𝑖𝑠𝑒
Where
2 2
2𝑛 1 𝑥 𝑘
𝛽 = 𝛼 √1 − (𝑁−1) , 𝐼0 (𝑥) = 1 + ∑∞
𝑘=1 [𝑘! (2) ]
Step 07
Form the transfer function of the FIR filter by,
Step 08
Finally the operation of the filter can be checked by finding the output of the below
signal in the frequency domain when sent through the filter by multiplying frequency
response of input signal and the filter.
3
Where ω1 is the middle frequency of the lower stopband, ω2is middle frequency of the
passband and ω3 is middle frequency of the upper stopband.
Results
The generated Kaiser Window function after completing step 06, which is displayed in
Figure 02.
Magnitude response of the FIR filter within the whole analog frequency band and
passband is shown in Figure 04 and Figure 05 respectively.
Results from the step 08 are shown below. Figure 06 shows the time domain
representations of input signal to the filter, output from the filter and expected output
for the input signal from the ideal filter. The corresponding frequency responses are
shown in Figure 07.
Discussion
According to the specifications the lower transition band is from 200 to 300
rad/s and the upper transition band is from 600 to 750 rad/s. The critical transition is
at lower edge. Filter has been designed to satisfy both the conditions and hence
specifications are over satisfied at the upper edge. Therefore the cutoff frequencies have
been obtained accordingly.
Figure 01 shows the impulse response of the filter with a length (N) of 73
samples. However the initially calculated value for N is 71 in which case the designed
filter does not satisfy the prescribed specifications for attenuation in the lower
stopband. Therefore N is incremented by 2 in order to meet the specifications. Thus the
stopband characteristics have become more critical and eventually filter has over
satisfied the limitations for passband ripple.
Figure 05 is the time domain comparison of the input excitation and the
output signal which is given by the filter. There is also the output, if an ideal band pass
filter was used. The output of the filter is generated by taking the Discrete Fourier
Transform (DFT) of input signals using the fft() tool in Matlab. In this case lengths of
input signals and number of points in DFT are chosen according to following condition
in order to ensure that there is no time aliasing happens.
𝑁+𝑃−1≤𝐿
Where,
N = Length of the impulse response
P = Length of input signal
L = No. of points in DFT
A careful observation of the outputs of designed FIR filter and ideal filter
concludes that the two outputs are identical except the following two factors.
1. Output of the designed filter has initially appeared after few samples
This is because transient response of the filter. It will take little number of
samples to generate steady state response.
Conclusions
From the analysis of results it can be concluded that the obtained bandpass
FIR filter has achieved the prescribed specifications and key desired feature of linear
phase response. In addition Kaiser Window can be used to design an FIR filter with
arbitrary prescribed specifications.
References
[1] Andreas Antoniou. (2010, October 28). Chapter 9 Design of Nonrecursive (FIR)
Filters [Online]. Available: http://www.d-filter.ece.uvic.ca/SupMaterials/Slides/DSP-
Ch09-S3,4.pdf
Appendix
close all;
clear;
clc;
% Calculating delta
deltaP = ( 10^(0.05*Ap_) - 1 ) / ( 10^(0.05*Ap_) + 1 );
deltaA = 10 ^ (-0.05*Aa_);
delta = min (deltaP , deltaA);
% calculating N
N = ceil(ws*D/Bt + 1);
if (mod(N,2) == 0)
N = N+1;
end
% Sampling period
T = 2*pi/ws;
% Gerating the impulse response and frequency response of the filter
% Iteratively check whether the frequency response meets the specifications
while 1
% Impulse response of idealized filter
hnT = zeros(1,N);
for i = -(N-1)/2 : (N-1)/2
if i==0
hnT(1,i+(N+1)/2) = 2*(wc2-wc1)/ws ;
else
hnT(1,i+(N+1)/2) = ( sin(wc2*T*i) - sin(wc1*T*i) )/( i*pi);
end
end
% Window function
n=0:(N-1)/2;
beta = alpha * sqrt(1-(2*n/(N-1)).^2);
bessel_0Alpha = bessel_0(alpha);
bessel_0Beta = bessel_0(beta);
wnT = bessel_0Beta / bessel_0Alpha;
leftHalf = fliplr(wnT);
wnT = [leftHalf(1:(N-1)/2) wnT];
end
% Filter plots
% magnitude response of the filter
figure;
plot(frequency,gain);
grid on;
title('Magnitude response');
xlabel('Frequency (rad/s)');
ylabel('Gain (dB)');
axis([0 ws/2 -100 10])
% magnitude response of the filter in passband
figure;
plot(frequency,gain);
grid on;
title('Magnitude response in passband');
xlabel('Frequency (rad/s)');
ylabel('Gain (dB)');
axis([wp1 wp2 -0.03 0.03])
i = 0 : N-1 ;
% Window function
figure;
stem(i,wnT)
title('Window function')
grid on
xlabel('n');
ylabel('w(nT)');
axis([0 N-1 0 1])
% Input signal
Xk = fftshift(Xk);
subplot(3,1,1)
plot(k_,abs(Xk));
title('Input signal - X[k]')
xlabel('Frequency (rad/s)');
ylabel('Magnitude');
axis([-ws/2 ws/2 0 500])
% Output signal
Yk = fftshift(Yk);
subplot(3,1,2)
plot(k_,abs(Yk));
title('Output signal - Y[k]')
xlabel('Frequency (rad/s)');
ylabel('Magnitude');
axis([-ws/2 ws/2 0 500])
% Output signal
subplot(3,1,2)
stem(k,ynT);
axis([1 200 -1.5 1.5]);
title('Output signal - y(nT)');
xlabel('n');
ylabel('Amplitude');
fvtool(hnT);
2. Code for the 0th order Bessel function used in Kaiser Window calculations