Triệt echo sử dụng thuật toán RLS trên kit TMS320C6713

Một phần của tài liệu Lọc thích nghi và ứng dụng thực thi trên KIT TMS320C6713 (Trang 67)

2. Nội dung các phần thuyết minh và tính toán:

5.4Triệt echo sử dụng thuật toán RLS trên kit TMS320C6713

Hình 5.16: Sơ đồ hệ thống triệt echo sử dụng thuật toán RLS.

Tín hiệu ngõ vào s ng sin đƣợc lấy từ máy phát sóng, và Tín hiệu echo đƣợc vào ngõ Desired của bộ lọc RLS.

Kết quả : Tín hiệu ngõ vào giống với tín hiệu ngõ ra ,biên độ có suy giảm so với ban đầu.

Hình 5.18: Dạng sóng tín hiệu thu được sau khi triệt echo dùng thuật toán RLS.

Kết luận:

- Kết quả thu đƣợc sau khi qua bộ lọc RLS tốt, tín hiệu echo bị loại bỏ. - Bộ lọc thích nghi rất tốt trong quá trình khử echo .

CHƢƠNG 6 :

KẾT LUẬN 6.1 Kết quả đạt đƣợc.

Sau quá trình thực hiện nghiên cứu đề tài, nh m thu đƣợc một số kết quả sau : - Tìm hiểu lý thuyết bộ lọc số, lọc thích nghi, echo, kit DSP TMS320C6713.

- Tìm hiểu các thuật toán thích nghi, nguyên tắc hoạt động, cách thức cập nhật trọng số.

 Thuật toán LMS:

Đơn giản, dễ thực hiện, tính toán không phức tạp.

Tốc độ hội tụ chậm.

 Thuật toán RLS:

Tăng số lƣợng các phép toán, tính toán phức tạp.

Tốc độ hội tụ nhanh, độ tin cậy cao.

- Mô phỏng các hệ thống triệt nhiễu tích cực - ANC (active noise canceller) và hệ thống khử echo – AEC (acoustic echo canceller) sử dụng các thuật toán LMS,RLS bằng Matlab đạt kết quả tốt.

- Dựa vào kết quả mô phỏng đánh giá, kiểm chứng lại đƣợc ƣu điểm của thuật toán RLS so với LMS qua thông số MSE và ERLE.

- Thực hiện các thuật toán thích nghi trên Kit DSP TMS320C6713 đạt đƣợc một số kết quả nhất định.

6.2 Tồn tại và hƣớng phát triển của đề tài. 6.2.1 Những mặt còn tồn tại : 6.2.1 Những mặt còn tồn tại :

- Các mô hình mô phỏng trên Matlab, Kit DSP TMS320C6713 chỉ dừng lại ở mức độ tìm hiểu, đánh giá, chƣa phù hợp với các ứng dụng của hệ thống thực tế.

- Thiết kế bộ lọc thích nghi dựa trên ngôn ngữ Matlab khi biên dịch sang ngôn ngữ C, việc này sẽ làm tốn tài nguyên bộ nhớ của Kit DSP TMS320C6713.

- Thực hiện thuật toán RLS trên kit DSP TMS320C6713 chƣa đạt đƣợc kết quả nhƣ mong muốn.

6.2.2 Hƣớng phát triển.

- Tiếp tục tìm hiểu, nghiên cứu chuyên sâu hơn, tối ƣu hoá thuật toán để xây dựng, hoàn thiện mô hình khử nhiễu, triệt echo quả hơn.

- Phát triển lên thành hệ thống xử lý đa kênh nghĩa là c nhiều hơn 1 nguồn âm khử nhiễu. Mục đích nhằm đạt đƣợc hiểu quả khử nhiễu trong không gian rộng hơn. - Định hƣớng phát triển có thể xây dựng triển khai các hệ thống lớn có tính ứng dụng trong thực tế, ví dụ nhƣ lọc nhiễu tín hiệu điện tim, hệ thống triệt nhiễu trong xe hơi, tai nghe triệt nhiễu tích cực, các thiết bị thu tín hiệu trong y tế, triệt echo trong các hội nghi trực tiếp,…

PHẦN C :

PHỤ LỤC VÀ

TÀI LIỆU THAM KHẢO

PHỤ LỤC Phụ lục A.

1. Hƣớng dẫn biên dịch Simulink sang code C. (adsbygoogle = window.adsbygoogle || []).push({});

Simulink là một môi trƣờng ứng dụng dùng để mô phỏng và thiết kế các mô hình cơ sở cho động học cũng nhƣ các hệ thống nhúng ở nhiều lĩnh vực khác nhau nhƣ giao tiếp, điều khiển, xử lý tín hiệu số, xử lý video, hình ảnh…. Với một giao diện giao đồ họa trực quan từ thƣ viện các block chức năng của chƣơng trình, bạn có thể thiết kế, mô phỏng, thực thi chƣơng trình và kiểm tra hệ thống ở các thời điểm khác nhau và cuối cùng sẽ là kết quả của chƣơng trình đƣợc thể hiện bằng đồ thị và biểu bảng. Đầu tiên bạn mở Simulink của Matlab lên và tiến hành ghép nối các khối theo mục tiêu của đề tài. Đối với những phiên bản Matlab khác nhau thì vị trí lấy các khối c thay đổi chút ít, chúng tôi đang trình bày ở đây là Matlab 2010a. Và phần mềm Code Composer Studio V 3.3 (CCS V3.3) để build và load lên KIT TMS320C6713.

Bây giờ chúng tôi đang tiến hành thiết kế một hệ thống Phát – Thu tín hiệu các bƣớc tiến hành nhƣ sau:

1.1Ghép nối các khối.

-Chọn khối I/O và Board C6713DSK: Target Support Package / Texas Intruments C6000 / C6713DSK.

-Chọn các khối Gain, Digital filer , C6713 ADC, C6713 DAC trong mục Libraries và sau đ kết nối lại nhƣ hình bên dƣới.

- Thiết lập thông số bằng cách nhấp đôi vào các khối + Khối ADC

+ Khối Gain.

+ Khối DAC.

1.2Thiết lập cấu hình các thông số trƣớc khi build.

Sau khi chạy mô phỏng thành công trên Simulink thì bạn có thể biên dịch sang CCS nhƣ sau:

- Sau đ gõ ccsboardinfo để kết nối CCS với Matlab

-Mở của sổ Simulink muốn biên dịch lên Vào Simulation chọn Configuration Parameter. Hoặc nhấn tổ hợp phím Ctrl + E.

1.3Build simulink sang ANSI C code .

Nhấn vào biểu tƣợng Increment Build hoặc nhấn tổ hợp phím Ctrl+B.

-Sau khi build xong , sẽ tự động mở cửa sổ làm việc CCS V3.3. với đầy đủ thƣ viện ,code C của chƣơng trình dịch từ simulink sang.

2. Hƣớng dẫn cài đặt CCS V3.3 trên Windows XP.

Tiến hành cài đặt chƣơng trình.

- Chọn Next để tiếp tục quá trình cài đặt

- Chọn Accept để tiếp tục

- Chọn Typical Install hoặc Custom Install - Cuối cùng chọn Finish để kết thúc.

 Composer studio setup.

 -Chọn C6713 Device Cycle Accurate Simulator

 Khi không có KIT C6713 chúng ta c thể thiết lập ở chế độ mô phỏng và làm việc bình thƣờng.

-Ta kích chọn code

Phụ lục B : Code Matlab.

1. Khử nhiễu thích nghi sử dụng thuật toán LMS.

% ANC - LMS algorithm

% R - number of repetitions % I - iterations

% sigmax - standard deviation of the input signal x % Wo - plant/system to be identified

% sigman - standard deviation of the noise n % mi - step-size parameter (adsbygoogle = window.adsbygoogle || []).push({});

% M - misadjustment % ind - sample index

% MSE - Mean-squared error

% MSEmin - Minimum Mean-squared error

% K - Auxiliar vector to store the error btween the % orignal signal and the error signal.

% E - Auxiliar vector to the error %Px - cong suat tin hieu ngo vao %Pe - cong suat tin hieu error %Pn - cong suat nhieu

clear all; close all; R=10; I=50000;

%Length of the adaptive filter

L=5; N=L-1; mi= 0.0002; MSE=zeros(I,1); E=zeros(I,1); K=zeros(I,1); for r=1:R %input signal n = (1:I)'; s = sin(0.075*pi*n);

%noise source signal

v = 0.8*randn(I,1);

%noise signal 1

ar = [1,1/2];

v1 = filter(1,ar,v);

%input signal + noise 1

x = s + v1;

%noise signal 2

ma = [1, -0.8, 0.4 , -0.2]; v2 = filter(ma,1,v);

%create the signals

%tap-weight and input vector

W=zeros(L,1); U=zeros(L,1); for i=1:I U=[v2(i) U(1:N)]; % desired signal d=x(i); % output estimate y=(W'*U); % error signal

E(i)=E(i)+e; K(i)=(s(i)-e); % new/updated filter W=(W+(2*mi*e*U)); % accummulation of MSE MSE(i)=norm(MSE(i)+ (K(i)^2)); % accummulation of MSE end end E=E/R; MSE=MSE/R; ind=0:(I-1); Px=mean((abs(s)).^2) Pe=mean((abs(E)).^2) Pn=mean((abs(v)).^2)

% print the results

figure()

plot(n(9900:10000), [s(9900:10000), x(9900:10000), E(9900:10000)]);

legend('Tin hieu ngo vao s(n)', 'Tin hieu + nhieu d(n)','Tin hieu ngo ra

e(n)');

xlabel('Iterations'); ylabel('Bien do');

title('Khu nhieu tich cuc su dung thuat toan LMS');

2. Khử nhiễu thích nghi sử dụng thuật toán RLS.

%%% ANC - RLS algorithm % R - number of repetitions % I - iterations (adsbygoogle = window.adsbygoogle || []).push({});

% sigmax - standard deviation of the input signal % Wo - plant/system to be identified

% sigman - standard deviation of the noise % ind - sample index

% W - Tap-weight of RLS algorithm % K - gain

% lambda - Fortgetting factor 1 < lambda < 0 % LS - Weighted least-squares of the rls % CC - Cross-correlation matrix

% delta - small positive constant

% K - Auxiliar vector to store the error btween the % orignal signal and the error signal.

% E - Auxiliar vector to the error %Px - cong suat tin hieu ngo vao %Pe - cong suat tin hieu error %Pn - cong suat nhieu

clear all; close all; R=10; I=10000;

%Length of the adaptive filter

L=5; N=L-1; lambda = 1; delta = 20;

E=zeros(I,1); K=zeros(I,1); for r=1:R %input signal n = (1:I)'; s = sin(0.075*pi*n);

%noise source signal

v = 0.8*randn(I,1);

%noise signal 1

ar = [1,1/2];

v1 = filter(1,ar,v);

%input signal + noise 1

x = s + v1;

%noise signal 2

ma = [1, -0.8, 0.4 , -0.2]; v2 = filter(ma,1,v);

%create the signals

%tap-weight and input vector

W=zeros(L,1); U=zeros(L,1); %Cross-correlation matrix fi CC=((1/delta)*eye(L,L)); for i=1:I U=[v2(i) U(1:N)]; % desired signal d=x(i);

%Step 1: Calculation the gain G

k=(((1/lambda)*CC*U)/(1+((1/lambda)*U'*CC*U)));

%Step 2: Filtering

%output estimate for the rls

y=(W'*U);

%Step 3: Error estimation %error of the rls

e=(d-y); E(i)=E(i)+e; K(i)=(s(i)-e); (adsbygoogle = window.adsbygoogle || []).push({});

%Step 4: Tap-weight vector adaptation

W=W+k*conj(e);

%Step 5: Correlation Update

%calculating the CC of the rls algorithm

CC =(((1/(lambda))*CC)-((1/lambda)*k*U'*CC)); % accummulation of LS LS(i)=(LS(i)+(lambda*K(i)^2)); end end E=E/R; LS=LS/R; ind=0:(I-1); Px=mean((abs(s)).^2) Pe=mean((abs(E)).^2) Pn=mean((abs(v)).^2)

% print the results

figure()

plot(n(9900:end), [s(9900:end), x(9900:end), E(9900:end)]);

legend('Tin hieu ngo vao s(n)', 'Tin hieu + nhieu d(n)','Tin hieu ngo ra

e(n)');

ylabel('Bien do');

title('Khu nhieu tich cuc su dung thuat toan RLS' );

3. Triệt tiếng vọng sử dụng thuật toán thích nghi LMS

LMS – AEC

% AEC - LMS algorithm

% R - number of repetitions % I - iterations

% sigmax - standard deviation of the input signal % Wo - plant/system to be identified

% sigman - standard deviation of the noise % mi - step size

% ind - sample index

% MSE - Mean-squared error

% MSEmin - Minimum Mean-squared error

% D - Auxiliar vector to the desired response % E - Auxiliar vector to the error

% Y - Auxiliar vector to the filter output

clear all close all R = 10; I = 5000; % parameters sigmax = 1; sigman = 0.01; mi = 0.01; MSE=zeros(I,1); Y=zeros(I,1); D=zeros(I,1); E=zeros(I,1); MSEmin=zeros(I,1); Wo = randn(7,1);

% length of the plant/system

L=length(Wo);

% order of the plant/system

N=L-1; for r=1:R, X=zeros(L,1); W=zeros(L,1); % input n = (1:I)'; x = sin(0.0295*pi*n);

% delayed version of the input

delay=zeros(20,1); xd=[delay x(1:(I-20))]; % noise n=randn(I,1)*sigman; %awgn(n,); for i=1:I, X=[xd(i) X(1:N)]; % desired signal d=x(i)+xd(i); D(i)=(D(i)+d); % output estimate (adsbygoogle = window.adsbygoogle || []).push({});

Y(i)=(Y(i)+y); % error signal e=(d+n(i)-y); E(i)=E(i)+e; % new/updated filter W=(W+(2*mi*e*X)); % accummulation of MSE MSE(i)=norm(MSE(i)+(e^2)); % accummulation of MSE MSEmin(i)=norm(MSEmin(i)+((n(i))^2)); end end % sample index ind=0:(I-1); MSE = MSE/R; MSEmin = MSEmin/R; % Misadjustment computation M=MSE./MSEmin-1;

% print the results

figure();

plot(ind,D, ind,Y,ind,E); xlabel('Iterations'); ylabel('Signal Value');

title('Acoustic Echo Canceller using the LMS Algorithm' ); legend('Desired','Output','Error');

4. Triệt tiếng vọng sử dụng thuật toán thích nghi RLS

RLS – AEC

%%% AEC - RLS algorithm % R - number of repetitions % I - iterations

% sigmax - standard deviation of the input signal % Wo - plant/system to be identified

% sigman - standard deviation of the noise % W - Tap-weight of RLS algorithm

% K - gain

% lambda - Fortgetting factor 1 < lambda < 0 % LS - Weighted least-squares of the rls % CC - Cross-correlation matrix

% delta - small positive constant

% D - Auxiliar vector to the desired response % E - Auxiliar vector to the error

% Y - Auxiliar vector to the filter output

clear all close all R = 10; I = 5000; % parameters sigmax = 1; sigman = 0.01; mi = 0.02; lambda = 1; delta = 0.01; LS=zeros(I,1); Y=zeros(I,1); D=zeros(I,1);

MSEmin=zeros(I,1); Wo = randn(7,1);

% length of the plant/system

L=length(Wo);

% order of the plant/system

N=L-1; for r=1:R, X=zeros(L,1); W=zeros(L,1); % input n = (1:I)'; x = sin(0.0295*pi*n);

% delayed version of the input

delay=zeros(20,1); xd=[delay x(1:(I-20))]; % noise n=randn(I,1)*sigman; %Cross-correlation matrix fi CC=((1/delta)*eye(L,L)); for i=1:I, X=[xd(i) X(1:N)]; % desired signal d=x(i)+xd(i); D(i)=(D(i)+d);

%Step 1: Calculation the gain G

k=(((1/lambda)*CC*X)/(1+((1/lambda)*X'*CC*X)));

%Step 2: Filtering

%output estimate for the rls

y=(W'*X); Y(i)=(Y(i)+y);

%Step 3: Error estimation

e=((d-n(i))-y); E(i)=E(i)+e; (adsbygoogle = window.adsbygoogle || []).push({});

%Step 4: Tap-weight vector adaptation

W=W+k*conj(e);

%Step 5: Correlation Update

%calculating the CC of the rls algorithm

CC =(((1/(lambda))*CC)-((1/lambda)*k*X'*CC)); % accummulation of LS LS(i)=(LS(i)+(lambda*e^2)); end end % sample index ind=0:(I-1); n = (0:I-1)'; LS = LS/R; MSEmin = MSEmin/R; M=LS./MSEmin-1; figure(); plot(n(1:500),[D(1:500), Y(1:500),E(1:500)]); xlabel('Iterations');

ylabel('Signal Value');

title('Acoustic Echo Canceller using the RLS Algorithm' ); legend('Desired','Output','Error');

5. So sánh thông số ERLE của hai thuật toán RLS và LMS clear all close all R = 10; I = 5000; sigmax = 1; sigman = 0.01; Wo = randn(7,1);

% length of the plant/system

L=length(Wo);

% order of the plant/system

N=L-1; Pn=zeros(I,1); %thong so LMS mi = 0.01; Ylms=zeros(I,1); Dlms=zeros(I,1); Elms=zeros(I,1); ERLElms=zeros(I,1); Pdlms=zeros(I,1); Pelms=zeros(I,1); %thong so RLS lambda = 1; delta = 0.01; ERLErls=zeros(I,1); Pdrls=zeros(I,1); Perls=zeros(I,1); Yrls=zeros(I,1); Drls=zeros(I,1); Erls=zeros(I,1); for r=1:R, %%% LMS Xlms=zeros(L,1); Wlms=zeros(L,1); %%%%RLS Xrls=zeros(L,1); Wrls=zeros(L,1); % input n = (1:I)'; x = sin(0.0295*pi*n);

% delayed version of the input

delay=zeros(20,1); xd=[delay

x(1:(I-20))];

% noise

n=randn(I,1)*sigman;

%ma tran tuong quan cheo

CC=((1/delta)*eye(L,L));

for i=1:I,

%%cong suat nhieu

pn(i)=abs(n(i))^2; Pn(i)=Pn(i)+pn(i);

%%%%%LMS Xlms=[xd(i) Xlms(1:N)]; Dlms(i)=(Dlms(i)+d); pdlms(i) = abs(Dlms(i))^2; Pdlms(i)=Pdlms(i)+pdlms(i); % output estimate ylms=(Wlms'*Xlms); Ylms(i)=(Ylms(i)+ylms); % error signal elms=(d+n(i)-ylms); Elms(i)=Elms(i)+elms; pelms(i)=abs(Elms(i))^2; Pelms(i)=Pelms(i)+pelms(i); % new/updated filter Wlms=(Wlms+(2*mi*elms*Xlms)); %SNR erlelms(i)=mean(Pdlms(i))/mean(Pelms(i)); ERLElms(i)=ERLElms(i)+erlelms(i); %%%%%%RLS Xrls=[xd(i) Xrls(1:N)]; Drls(i)=(Drls(i)+d);

%Step 1: Calculation the gain G

k=(((1/lambda)*CC*Xrls)/(1+((1/lambda)*Xrls'*CC*Xrls)));

%Step 2: Filtering

%output estimate for the rls

yrls=(Wrls'*Xrls); Yrls(i)=(Yrls(i)+yrls);

%Step 3: Error estimation %error of the rls

erls=((d-n(i))-yrls); Erls(i)=Erls(i)+erls; (adsbygoogle = window.adsbygoogle || []).push({});

%Step 4: Tap-weight vector adaptation

Wrls=Wrls+k*conj(erls);

%Step 5: Correlation Update

%calculating the CC of the rls algorithm

CC =(((1/(lambda))*CC)-((1/lambda)*k*Xrls'*CC)); % accummulation of LS pdrls(i) = abs(Drls(i))^2; Pdrls(i)=Pdrls(i)+pdrls(i); perls(i)=abs(Erls(i))^2; Perls(i)=Perls(i)+perls(i); erle(i)=mean(Pdrls(i))/mean(Perls(i)); ERLErls(i)=ERLErls(i)+erle(i); end end % sample index ind=0:(I-1); ERLElms=ERLElms/R; ERLErls=ERLErls/R; maxERLElms=max(10*log10(ERLElms)) meanERLElms=mean(10*log10(ERLElms)) maxERLErls=max(10*log10(ERLErls)) meanERLErls=mean(10*log10(ERLErls))

% print the resultsơ figure(); plot(10*log10(ERLElms)); hold on plot(10*log10(ERLErls),'r'); axis([0 200 -40 100]);

title('echo return loss enhancement'); ylabel('dB');

xlabel('Iterations'); legend ('lms','rls');

TÀI LIỆU THAM KHẢO

[1] “Adaptive filters: theory and applications”, John Wiley and Sons Ltd., Chichester, 1998.

[2] “Adaptive Filtering Algorithms and Practical Implementation” ,Paulo S.R. Diniz. [3] Simon Halkins, “Adaptive Filter Theory”,3 rd Edition, Englewoodclifes,

Newjercy, Princetonhall 1996.

[4] Homana, I.; Topa, M.D.; Kirei, B.S.; “Echo cancelling using adaptive algorithms”, Design and Technology of Electronics Packages, (SIITME) 15th International Symposium., pp. 317-321, Sept.2009.

[5] J.G. Proakis and D.G. Manolakis, Digital Signal Processing Principles,Algorithms and Applications, Prentice Hall,1996.

[6] Homer, J. 1994, Adaptive Echo Cancellation in Telecommunications. PhD thesis, University of Newcastle, Newcastle.

[7] Michel Hutson, “Acoustic Echo Cancellation”, B.E. Thesis, The University of Queensland, Nov.2003.

Một phần của tài liệu Lọc thích nghi và ứng dụng thực thi trên KIT TMS320C6713 (Trang 67)