Sie sind auf Seite 1von 17

ECE 569

Project 1 Report
Xiao Yang
Feb. 26 2015
1. Design objectives
A band pass filter with specification shown as Fig.1 Desired Filter Performance Plot
need to be designed by different method. Its has the following request to meet and
these requirements apply to all different designing method in this project.
1. Requirement on pass band: ripple 05 . 0
1
= o , presented in dB is
dB 4455 . 0
1
1
log 20
1
~
o
, at the mean time, 3287 . 0 , ) 1 ( ) 1 (
2
1
1 2
~ = +

c o c
2. Requirement on stop band: ripple 01 . 0 2 = o , presented in dB is
dB 40 ) log( 20
1
=

2
o , because
2
1
) 1 (

2
+ = o o , so 99.995 = o
3. Pass band is ] 5 . 0 , 25 . 0 [ t t e = p , lower bound t e 25 . 0 =
L
, upper bound is
t e 5 . 0 =
U
, for prewarping 828 . 0 )
2
tan(
2
~ = O
L
L
T
e
4. Stop band is | | = t t t e , 55 . 0 [ ] 2 . 0 , 0 s , the first part of stop band ends at
t e t e 55 . 0 2 . 0 2 1 = , = s s , for prewarping, 65 . 0 )
2
tan(
2
1
1 ~ = O
s
s
T
e
5. Transition band is | | = t t t t e 55 . 0 , 5 . 0 [ ] 25 . 0 , 2 . 0 tr
6. Filter length should be as small as possible and linear phase property should be
met when designing FIR filter
2. FIR filter design
Window method using Hamming window
Design objective
The objective of this designing method has been indicated in the first part.
Design Procedure
While we design filters based upon ideal frequency response h() we desired, we
have to perform Inverse Discrete Time Fourier Transformation (IDTFT) to transfer
h() from frequency domain to time domain h(n). For a finite length in frequency
domain, it will be transformed to h(n) of infinite length. So for a practical applied
filter, a finite number of corresponding response are selected to build the filter and the
tool used to select the response is called window. Hamming window is one of them.
The filter length, or the order of filter is represented by N. N is even or not does not
affect the designing the filter in the case of FIR filter designing, either does not the
symmetry of N. To minimize the order of filter N, the bandwidth used for calculation
is not the lower and upper bound of pass band but one expands it to be the middle of
transitional band. Also in the calculation, a relaxation factor was applied. Then the
frequency response will be
] 2 / ) ( 2 / ) [( , 1
, 0 d
2 1
{ ) ( H
e e e e e
e
+ , + + e
=
U s L s
otherwise
When designing the filter, I designed M to be odd and the delaying
2
1 M
units for
linear phase property. Under such condition, by performing IDTFT which is
}

=
t
t
e
e e
t
d e Hd n h
n j
d
) (
2
1
) ( , we have ) (n h
d
as
2
1
]}, 2 / ) 1 2 ( ) 225 . 0 sin[( ] 2 / ) 1 2 ( ) 525 . 0 {sin[(
2
1
) (

= + + + =
M
n M n M n n h
d
t t t t
t
or 2 / ) 1 ( , / ) 2 3 . 0 ( ) ( = = M n h
d
t t e With knowing Hamming window as
)
1
2
cos( 46 . 0 54 . 0 ) (

=
M
n
n h
m
t
, the real unit sample response at each point of n when
we design using Hamming window will be ) ( * ) ( ) ( n h n h n h
m d
= . In the following
process of designing, Matlab and Matlab function freqz was applied, from the
introduction, freqz is:
[h,w] = freqz(b,a,n) returns the frequency response vector h and the
corresponding angular frequency vector w for the digital filter whose transfer
function is determined by the (real or complex) numerator and denominator
polynomials represented in the vectors b and a, respectively. The vectors h and
w are both of length n. n must be a positive integer greater than or equal to two.
The angular frequency vector w has values ranging from 0 to radians per
sample.
1
In this case, the denominator is considering as 1 and 8192 points are applied, so the
range form 0 to is divided to be 8192 equal spaced and the relaxation factor is
designed to be 0.0029 which gives band edges 0.2279 and 0.5221 to achieve the
required performance. The minimum order I achieve in designing is 109. Its
frequency response is plotted and attached in Fig.2 Hamming window design plot.
The Frequency-sampling method
Design objective
The objective of this designing method has been indicated in the first part remains the
same.
Design Procedure
The first step in the designing is to choose the length of the filter. From previous designing
experience, choose M=120 is a good option and divide 2 by 120, we can get 0.016 between two
continued sampling points. Although the passing band could be simply decided as 1 but some
ripple added will help it to reduce order of filter. So the Hd() could be presented in the following
way after parameter of magnitude response of particular frequency in the transitional band has
been decided by trials
Hd()=
] 44 , 25 [ , 0
] 24 [ ], 2 . 0 [
] 23 , 22 [ , ] 8 . 0 , 1 [
] 21 , 12 [ ], 1.01,1 1.01,0.97, 1.01,0.97, 1.02,0.97, 1.02,0.97, [
] 11 , 10 [ , ] 8 . 0 , 15 . 0 [
] 9 , 0 [ , 0
1
1
e
e
e
e
e
e

k
k
k e
k
k e
k
k
M
M
j
k
M
M
j
t
t
The whole serial is 90 numbers and using IDTFT and freqz, the corresponding filter will be
achieved and the plot is in Fig.3 Frequency Response of Frequency Sampling Method
The Remez method
Design objective
The objective of this designing method has been indicated in the first part remains the
same.
Design Procedure
Another designing is performed by using Remez method. The algorithm was improved by Parks
MmClellan. The designing procedure was done by Matlab with function firpm which works as
described below:
B=FIRPM(N,F,A) returns a length N+1 linear phase (real, symmetric coefficients) FIR filter
which has the best approximation to the desired frequency response described by F and A in the
minimax sense. F is a vector of frequency band edges in pairs, in ascending order between 0 and 1.
1 corresponds to the Nyquist frequency or half the sampling frequency. At least one frequency
band must have a non-zero width. A is a real vector the same size as F which specifies the
desired amplitude of the frequency response of the resultant filter B.
2
The function actually used is B=firpm(N,F,A,W) where the extra parameter W is weighting
function which affecting the magnitude relationship between pass band ripples and stop band
ripples.
So in this designing, following parameters was applied:
F=[0 0.2 0.25 0.5 0.55 1]
A=[0 0 1 1 0 0]
W=[1 5 1]
The smallest M that success in the designing is M=65, the function talked above firpm is used to
get h(n). After getting h(n), use function freqz in Matlab to calculate filters frequency response,
the frequency response is plotted in Fig.4 Frequency Response of Remez designed filter.
3. IIR filter design
The primary task in designing IIR filter is to decide the order of filters of different
designing method. By evaluating the order for a low pass filter, we can double the
order of low pass filter and take it to design the band pass filter to fit requirement of
design objectives, under assumption of 65 . 0 and , 8248 . 0
1
~ O = O ~ O = O
s p L s
,
99.995 and 0.3287. Hereby are the evaluation of pass band filters order of
different designing methods:
Butterworth filter: 48
) log(
) log(
2 ~
O
O
=
p
s
M
c
o
Chebyshev filter: 18
) ( cosh
) ( cosh
2
1
1
~
O
O
=

p
s
M
c
o
Elliptic filter: 10
) ( 1 ) (
) ( 1 ) (
2
2
2
~
O
O

O
O
=
s
p
s
p
K K
K K
M
c
o
c
o
Considering a filter H(z), it could be actually write as the following format

+
=
1
1
1
0
1
) (
M
m
m
m
M
n
n
n
z a
z b
z H
For FIR filter, the denominator is 1 with all coefficient of z at denominator equals to 0,
so we only need calculate the coefficient of numerator. For IIR filter, we need to
calculate the coefficient of z at both numerator and denominator. After the calculation,
use Matlab function freqz to achieve frequency response.
Butterworth filter
Design Objectives
The objective of this designing is to design a Butterworth filter which achieves the
performance indicated in the first part.
Design Procedure
Using Matlab and the function butter, which calculate the coefficient of numerator
and denominator of a digital filter by giving the performance we desired for the filter,
we can design the filter in Butterworth method. The function of butter works in the
following way:
BUTTER Butterworth digital and analog filter design.
[B,A] = BUTTER(N,Wn) designs an Nth order lowpass digital Butterworth filter
and returns the filter coefficients in length N+1 vectors B (numerator) and A
(denominator). The coefficients are listed in descending powers of z. If Wn is a
two-element vector, Wn = [W1 W2], BUTTER returns an order 2N bandpass filter
with passband W1 < W < W2.
3
Beginning from the order of 48/2=24, the performance requirement could be successfully met at
this order. Then adjust band edge and decrease the order of the filter. By taking trials step by step,
the design could be succeed at minimum order of M=18. At this time, the band edge applied to
designing is 0.241 and 0.508. Frequency plot is available in Fig.5 Frequency Response of
Butterworth Filter Design.
Chebyshev filter
Design Objectives
The objective of this designing is to design a Chebyshev filter which achieves the
performance indicated in the first part.
Design Procedure
By using Matlab and the function of cheby1, nomerator and denominator coefficient
of Chebyshev filter could be calculated. The function cheby1 works as described
below:
CHEBY1 Chebyshev Type I digital and analog filter design. [B,A] =
CHEBY1(N,R,Wp) designs an Nth order lowpass digital Chebyshev filter with R
decibels of peak-to-peak ripple in the passband. CHEBY1 returns the filter
coefficients in length N+1 vectors B (numerator) and A (denominator). The
passband-edge frequency Wp must be 0.0 < Wp < 1.0, with 1.0 corresponding to half
the sample rate. Use R=0.5 as a starting point, if you are unsure about choosing R.
If Wp is a two-element vector, Wp = [W1 W2], CHEBY1 returns an order 2N
bandpass filter with passband W1 < W < W2.
4
As calculated previously, R=0.4455dB. The filter design start at M=18/2=9. From the
succeed designing of 9, the smallest order achieved is 8 which means the the pass
band filter length is 16. Band edge applied to the design of order of 8 is 0.25 and
0.5. The frequency response is attached as Fig.6 Frequency Response of Chebyshev
Filter Design
Elliptic filter
Design Objectives
The objective of this designing is to design a Elliptic filter which achieves the
performance indicated in the first part.
Design Procedure
By using Matlab and the function of ellip, numerator and denominator coefficient of
Chebyshev filter could be calculated. The function ellip works as described below:
ELLIP Elliptic or Cauer digital and analog filter design.
[B,A] = ELLIP(N,Rp,Rs,Wp) designs an Nth order lowpass digital elliptic filter with
Rp decibels of peak-to-peak ripple and a minimum stopband attenuation of Rs
decibels. ELLIP returns the filter coefficients in length N+1 vectors B (numerator)
and A (denominator). The passband-edge frequency Wp must be 0.0 < Wp < 1.0, with
1.0 corresponding to half the sample rate. Use Rp = 0.5 and Rs = 20 as starting
points, if you are unsure about choosing them. If Wp is a two-element vector, Wp =
[W1 W2], ELLIP returns an order 2N bandpass filter with passband W1 < W < W2.
5
Based on Matlab function introduced previously, Rp=0.4455 and Rs is 40 dB. The
designing was using M=10/2=5 and the band edge applied to the designing is 0.25
and 0.5. The result of minimum M is still 5 after several trials to reduce the number.
The plot is available on Fig.7 Frequency Response of Elliptic Filter Design
4. Conclusion
The designing process of this project walked through FIR to IIR design, from mathematical aspect,
as mentioned previously, the filter could be represented as a numerator polynomial over another
denominator polynomial. The difference between FIR and IIR is that FIR has a denominator
polynomial equals to 1 and IIR is not. In FIR, both the Hamming window and frequency sampling
method could be summarized as knowing h(n), reversing it to h(), but frequency sampling allow
designer to pic certain frequency to as desired magnitude and reflect it on the final designing. On
the aspect of minimize the order, because Remez fully used the ripple allowed in the pass
band/stop band, so it has the minimum filter order. On the aspect of saving resource including cost
and expense, Remez has the advantage. But Hamming still has the smoothest pass band. The
advantage and disadvantage is decided relatively on the demand of using. Same idea was applied
to IIR design. Chebyshev has better reaction speed which means transitional band is stiffer but the
lager ripple of pass band than Butterworth. Elliptical has even stiffer transitional band than
Chebyshev but the ripple exist on both pass band and stop band. The Chebyshev we designed here
is Chebyshev type 1 which has ripple in pass band only and there is another type 2 which has
ripple in stop band only. As same mentioned, these three type has advantage and disadvantage
relatively on pass band ripple, stop band ripple and transitional band width. In practical
application, we need to focus on real requirement and choose the most appropriate one.
1
http://www.mathworks.com/help/signal/ref/freqz.html
2
Matlab help function text on function firpm
3
Matlab help function text on function butter
4
Matlab help function text on function cheby1
5
Matlab help function text on function ellip
Fig.1 Desired Filter Performance Plot
Fig.2 Hamming window design
plot
Fig.3 Frequency Response of Frequency Sampling
Method
Fig.4 Frequency Response of Remez designed
filter
Fig.5 Frequency Response of Butterworth Filter Design.
Fig.6 Frequency Response of Chebyshev Filter Design
Fig.7 Frequency Response of Elliptic Filter Design
APPDIX
1.
wc1 =(1/4)*pi;
wc2 =(1/2)*pi;
wc3 =(0.2)*pi;
wc4 =(0.55)*pi;
delta1=0.05;
delta2=0.01;
nps = 8192;
M=109;
n = 0:(M-1);
h =
( sin((wc4+wc2-0.0029*pi)/2*(n-(M-1)/2))-sin((wc3+wc1+0.0029*pi)/2
*(n-(M-1)/2)) )./ (pi*(n-(M-1)/2));
if (M/2)~=ceil(M/2),h((M+1)/2)=0.288 ; end
hamming = 0.54 - 0.46*cos(2*pi*n/(M-1));
[Hhm,w]=freqz(hamming.*h,1,nps);
Hhmphase=angle(Hhm);
figure(1),subplot(211),plot(w/pi,abs(Hhm),'-');
axis([xlim 0 1.1]);
xlabel('normalized frequency')
ylabel('magnitude')
title(['filter response, H(\omega), M=',num2str(M)]);
grid;
set(gca,'Xtick',[0 wc3/pi wc1/pi wc2/pi wc4/pi 1]);
set(gca,'Ytick',[0 delta2 1-delta1 1+delta1]);
subplot(212),plot(w/pi,Hhmphase,'-')
axis([xlim -pi pi])
xlabel('normalized frequency')
ylabel('phase')
title(['filter response, H(\omega), M=',num2str(M)])
2
M=90;BW=10;TBW=2;alpha = [0.15; 0.8];alpha1 = [1 ; 0.8];
w_k1 = ((2*pi)/M)*[0:M/2-1]';
Hd_1 = [0.*ones(10,1);
alpha.*ones(TBW,1) ;1.02;0.97;1.02;0.97;1.01;0.97;1.01;0.97;1.01;1;
alpha1.*ones(TBW,1);0.2;0.*ones(20,1)] .* exp(-j*((M-1)/2)*w_k1);
Hd_2 = conj(flipud(Hd_1));
Hd_2 = conj(flipud(Hd_1));
Hd = [Hd_1 ; zeros(M-2*length(Hd_1)-1,1) ; Hd_2 ] ;
h = ifft(Hd);
nps = 4096;
[H,w]=freqz(h,1,nps);
Hphase=angle(H);
figure(1);subplot(211);
plot(w/pi,abs(H),2*[0:floor((M+1)/2)-1]'/M,abs(Hd(1:floor((M+1)/2)
)),'o');
set(gca,'XTick',[0.2 0.25 0.5 0.55 1]);
set(gca,'YTick',[0.01 0.95 1 1.05]);
xlabel('normalized frequency (\pi rad/sample)'),
ylabel('|H(\omega)|')
title(['Freq. samp. filt. resp.: M = ',num2str(M),', BW =
',num2str(BW)])
grid
3.
subplot(212);plot(w/pi,Hphase);
axis([xlim -pi pi]);
grid
xlabel('normalized frequency (\times\pi rad./sample)')
ylabel('phase')
title(['filter response, H(\omega), M=',num2str(M)])
3.M=65;
delta_1=0.05;%PB tolerance
delta_2=0.01;%SB tolerance
F=[0 0.2 0.25 0.5 0.55 1];%freq in Hz
A=[0 0 1 1 0 0];
W=[1 delta_2/delta_1 1];
h=firpm(M-1,F,A,W);
omega=[0:12000]*pi/12000;
H=freqz(h,1,omega);
subplot(211),plot(omega/pi,abs(H));
grid;
set(gca,'Xtick',[0 0.2 0.25 0.5 0.55 1]);
set(gca,'Ytick',[0 delta_2 1-delta_1 1+delta_1]);
xlabel('Nomarlized Frequency');
ylabel('Magnitude Response');
title(['Filter Length N=',num2str(M)]);
Hrphase=angle(H);
subplot(212),plot(omega/pi,Hrphase,'-','linewidth',2);
grid;
set(gca,'Xtick',[0 0.45 0.6 1]);
set(gca,'Ytick',[-3 -2 -1 0 1 2 3]);
xlabel('Nomarlized Frequency');
ylabel('Phase Response');
4.[a,b]=butter(18,[0.241 0.508]);
[z,p,k]=butter(18,[0.241 0.508]);
Hz=tf(a,b,1);
num=Hz.num;
den=Hz.den;
num=num{:};
den=den{:};
figure(1);
nps = 10000;
[H,w]=freqz(a,b,nps);
Hphase=angle(H);
figure(1);subplot(211);
plot(w/pi,abs(H));
set(gca,'XTick',[0.2 0.25 0.5 0.55 1]);
set(gca,'YTick',[0.01 0.95 1 1.05]);
xlabel('normalized frequency (\pi rad/sample)'),
ylabel('|H(\omega)|')
grid
subplot(212);plot(w/pi,Hphase);
axis([xlim -pi pi]);
grid
xlabel('normalized frequency (\times\pi rad./sample)')
ylabel('phase')
5.[a,b]=cheby1(8,0.4455,[0.25 0.5]);
[z,p,k]=cheby1(8,0.4455,[0.25 0.5]);
Hz=tf(a,b,1);
num=Hz.num;
den=Hz.den;
num=num{:};
den=den{:};
figure(1);
nps = 10000;
[H,w]=freqz(a,b,nps);
Hphase=angle(H);
figure(1);subplot(211);
plot(w/pi,abs(H));
set(gca,'XTick',[0.2 0.25 0.5 0.55 1]);
set(gca,'YTick',[0.01 0.95 1 1.05]);
xlabel('normalized frequency (\pi rad/sample)'),
ylabel('|H(\omega)|')
grid
subplot(212);plot(w/pi,Hphase);
axis([xlim -pi pi]);
grid
xlabel('normalized frequency (\times\pi rad./sample)')
ylabel('phase')
6.[a,b]=ellip(5,0.4455,40,[0.25 0.5]);
[z,p,k]=ellip(5,0.4455,40,[0.25 0.5]);
Hz=tf(a,b,1);
num=Hz.num;
den=Hz.den;
num=num{:};
den=den{:};
figure(1);
nps = 10000;
[H,w]=freqz(a,b,nps);
Hphase=angle(H);
figure(1);subplot(211);
plot(w/pi,abs(H));
set(gca,'XTick',[0.2 0.25 0.5 0.55 1]);
set(gca,'YTick',[0.01 0.95 1 1.05]);
xlabel('normalized frequency (\pi rad/sample)'),
ylabel('|H(\omega)|')
grid
subplot(212);plot(w/pi,Hphase);
axis([xlim -pi pi]);
grid
xlabel('normalized frequency (\times\pi rad./sample)')
ylabel('phase')

Das könnte Ihnen auch gefallen