You are on page 1of 8

X L TN HIU S II

TRNG I HC BCH KHOA


KHOA IN T - VIN THNG

BO CO
BI TP
MN X L TN HIU S II
Thit k b lc FIR s dng k thut ca s v
k thut ly mu tn s

Ging vin hng dn:

Phm Vn Tun

Sinh vin thc hin:

Phan K Hin - 08DT3


Trn Vn Su - 08DT4

Nhm 14

Trang 1

X L TN HIU S II
Bi 7.11:
S dng k thut ca s Hamming thit k b lc FIR thng di vi cc thng s sau
- Tn s thng di thp : wp1 = 0.4
- Tn s chn di thp : ws1 = 0.3
- Tn s chn di cao : ws2 = 0.6
-Tn s thng di cao : wp2 = 0.5
- gn ca di thng : Rp = 0.5dB
- suy gim trong di chn: As = 50dB
1.1. Thut ton chng trnh:
Bc 1: Tnh ton transition bandwidth v c lng M da trn cc thng s
u vo. i vi ca s Hamming ta c th tnh:
Transition band width: tr_width = min(

M = 6.6/tr_width +1
Tnh c M = 67
Khi to cc gi tr cho cc bin, gi tr As ngng v Rp ngng theo yu cu
ra.
Bc 2: Thit k 1 b lc l tng da trn cc thng s c
Bc 3: To ca s Hamming vi M im dng hm c sn ca matlab
Bc 4: Nhn p ng xung ca b lc l tng vi ca s Hamming ta c
p ng xung b lc FIR
Bc 5: Tnh As (gi tr max ca p ng bin (dB) trn di chn) v Rp
( gn (dB) trn di thng)
Sau so snh As v Rp vi yu cu ca bi ton, nu cha tha th tng M v
quay li bc 3.
1.2. Matlab code:
clc; clear all; close all;
wp1 = 0.4*pi; ws1 = 0.3*pi;
ws2 = 0.6*pi; wp2 = 0.5*pi;
As_th = 50;
Rp_th = 0.5;
tr_width = min((wp1-ws1),(ws2-wp2))
M = ceil(6.6*pi/tr_width) + 1 %;M=67
while(1)
wc1 = (ws1+wp1)/2; wc2 = (wp2+ws2)/2;
Nhm 14

Trang 2

X L TN HIU S II
hd = ideal_lp(wc2,M) - ideal_lp(wc1,M);
w_bla = (hamming(M))';
h = hd .* w_bla;
[db,mag,pha,grd,w] = freqz_m(h,[1]);
delta_w = 2*pi/1000;
Rp = -min(db(wp1/delta_w+1:1:wp2/delta_w));%Actua Passband Ripple
As = -round(max(db(ws2/delta_w+1:1:501)));%Min Stopband Attenuation
if((As>=As_th) && (Rp<=Rp_th))
break;
end
M = M+1; % tang M
end
figure;
% plots
n=[0:1:M-1];
subplot(1,1,1);
subplot(2,2,1); stem(n,hd); title('Ideal Impulse Response')
axis([0 M-1 -0.3 0.3]); xlabel('n'); ylabel('hd(n)')
subplot(2,2,2); stem(n,w_bla);title('Hamming Window')
axis([0 M-1 0 1.1]); xlabel('n'); ylabel('w(n)')
subplot(2,2,3); stem(n,h);title('Actual Impulse Response')
axis([0 M-1 -0.3 0.3]); xlabel('n'); ylabel('h(n)')
subplot(2,2,4);
plot(w/pi,db);
title('Magnitude Response in dB');
grid;
xlabel('frequency in pi units'); ylabel('Decibels')
axis([0 1 -120 10]);
set(gca,'XTickMode','manual','XTick',[0,0.3,0.4,0.5,0.6,1])
set(gca,'YTickMode','manual','YTick',[-190:20:0])

Nhm 14

Trang 3

X L TN HIU S II
1.3 Kt qu:

Rp = 0.0488
As = 51
M = 67
Nhn xt: vi M c lng ban u l 67 tha yu cu bi ton As = 51 > 50,
gn Rp = 0.0488 < 0.5.
Bi 7.25:
S dng k thut ly mu tn s thit k b lc s vi cc thng s k thut nh
bi 7.11. Yu cu chn bc ca b lc thch hp c 2 mu nm trong di chuyn
tip.
2.1. Thut ton chng trnh:
Bc 1: Xc nh loi b lc v kch thc b lc M, la chn 2 mu T1,T2
trong di chuyn tip bng cch tra bng Transition Coefficient.
V bi yu cu thit k mch lc thng di (passband) nn ta c th chn
b lc Type-I thc hin, v do phi chn M l. Cng do bi yu
cu c 2 mu nm trong vng chuyn tip nn ta s c iu kin ca M:
Nhm 14

Trang 4

X L TN HIU S II
M l :

Chn gi tr M trong di: 60 M 80

M = 65

T1 = 0.10726929, T2 = 0.59415763
Bc 2: Tin hnh ly mu p ng tn s
Bc 3: Dng IDFT tnh p ng xung ca b lc v tnh c Rp, As
2.2. Matlab code:
clc; clear all;close all
Rp = 0.5 ; %(dB)
As = 50 ; %(dB)
ws1 = 0.3*pi; wp1 = 0.4*pi; wp2 = 0.5*pi ; ws2 = 0.6*pi ;
M = 65 ;
alpha = (M-1)/2; l = 0:M-1; wl = (2*pi/M)*l;
T1 = 0.10726929 ; T2 = 0.59415763; % lookup table: Transition Coeff
Hrs = [zeros(1,11),T1,T2,ones(1,4),T2,T1,zeros(1,28),...
T1,T2,ones(1,4),T2,T1,zeros(1,10)];
Hdr = [0,0,1,1,0,0]; wdl = [0,0.3,0.4,0.5,0.6,1];
k1 = 0:floor((M-1)/2); k2 = floor((M-1)/2)+1:M-1;
angH = [-alpha*(2*pi)/M*k1, alpha*(2*pi)/M*(M-k2)];
H = Hrs.*exp(j*angH);
h = real(ifft(H,M));
[db,mag,pha,grd,w] = freqz_m(h,1);
[Hr,ww,a,L] = Hr_Type1(h);
delta_w = 2*pi/1000;
Rp = -min(db(wp1/delta_w+1:1:wp2/delta_w)) % Actua Passband Ripple
As = -max(db(ws2/delta_w+1:1:501))
% Min Stopband Attenuation
subplot(2,2,1);plot(wl(1:33)/pi,Hrs(1:33),'o',wdl,Hdr);
axis([0,1,-0.1,1.1]); title('Bandpass: M=43,T1~0.1,T2~0.6')
xlabel('frequency in pi units'); ylabel('Hr(k)')
set(gca,'XTickMode','manual','XTick',[0,0.3,0.4,0.5,0.6,1])
Nhm 14

Trang 5

X L TN HIU S II
set(gca,'YTickMode','manual','YTick',[0,0.1,0.6,1]); grid
subplot(2,2,2); stem(l,h); axis([-1,M,-0.4,0.4])
title('Impulse Response'); xlabel('n'); ylabel('h(n)');
subplot(2,2,3); plot(ww/pi,Hr,wl(1:33)/pi,Hrs(1:33),'o');
axis([0,1,-0.1,1.1]); title('Amplitude Response')
xlabel('frequency in pi units'); ylabel('Hr(w)')
set(gca,'XTickMode','manual','XTick',[0,0.3,0.4,0.5,0.6,1])
set(gca,'YTickMode','manual','YTick',[0,0.1,0.6,1]); grid
subplot(2,2,4);plot(w/pi,db); axis([0,1,-100,10]); grid
title('Magnitude Response'); xlabel('frequency in pi units');
ylabel('Decibels');
set(gca,'XTickMode','Manual','XTick',[0,0.3,0.4,0.5,0.6,1]);
set(gca,'YTickMode','Manual','YTick',[-60,-50.35,0.47]);

Nhm 14

Trang 6

X L TN HIU S II
2.3 Kt qu:

Rp = 0.4696
As = 52.0956
M = 65

Nhn xt: Vi M = 65 th ta thy kt qu tha mn yu cu thit k t ra


As = 52.0956 > 50, Rp = 0.4696 < 0.5.

Nhm 14

Trang 7

X L TN HIU S II
So snh kt qu thit k bng phng php ly mu tn s v hm fir2 :

Ta thy rng khi dng hm fir2 th sai lch ca p ng thc ln hn


phng php ly mu tn s, dc ti giai on chuyn tip ln hn.
3. Kt lun:
- i vi phng php thit k dng ca s Hamming ta ch thay i As, Rp
ti u khi tng M, khng kim sot c cc thng s khc. Do , phng
php ny khng cho kt qu ti u.
- S dng phng php ly mu tn s thit k b lc FIR hiu qu hn
phng php ca s. Cu trc b lc n gin hn nhng vn p ng c
yu cu thit k.

Nhm 14

Trang 8

You might also like