adi_sharma84
Newbie level 1
LMS Equalizer for SC_FDE
Hi All,
I am trying to simulate a SC-Frequency domain LMS equalizer.
Now since it is SC the detection has to be in time domain although the
channel estimation is in frequency domain so i follow these steps
1) Multiply data -> data_f (in frequency domain) with weights in frequency
domain
2} Convert data in time domain data_t by ifft and pass it through
detector.
3) compute the error (detector - data_t)
4) convert the error back in frequency domain (by fft or error)->err_f
5) update weighs by weights=weights+Mu*(data_f*conj(err_f)) where Mu is
step size
6) now multiply new weight with next set of data and repeat the process
Am i doing something wrong as error never decreases no matter what i do
and it increases rapidly with each run.
Any kind of help is highly appreciated as this is making me crazy.
Regards
Aditya
Please see the sample matlab code below
________________________________________
close all
clear all
clc
z=zeros(1,256);
zd=0;
x1=[];
z3=[];
pak_loc=[];
pak_loc_1=[];
pak_dis=[];
map_bins=[];
%%%%%%%%%%%%%%%usr1%%%%%%%%%%%%%%%%%%%%%%%%%%%
for k=1:50
%%%%%%%%%%%%%%%%%paking 32 bins left 32 bins right% center dc
zero%%%%%%%%%
x=(floor(2*rand(1,64))-.5)/(.5)+j*(floor(2*rand(1,64))-.5)/(.5);
x1=[x x1];
for n=97:128
z=x(n-96);
end
for n=130:161
z=x(n-97);
end
t=fftshift(z);
map_bins=[map_bins z];
dtd=fft(t,256);
%%%%%%%%%%%%%%subcarrier mapping%%%%%%%%%%%%%
subm_d=[];
subm_l=[];
subm_l=[dtd];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%256 point ifft of localized and
disterbuted%%%%%%%%%%%%%%%%%%%%%
iff_out_l=ifft(subm_l,256);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%cyclic prefix%%%%%%%%%
out_l_s=[];
out_l_s=[iff_out_l(193:256) iff_out_l]; %%%%%%%%%one ofdm symbol with
cyclic prefix
%%%%%%%%%%%%%%%%%50 symbol packet%%%%%%%%%%%%% 1 symbol is 320 samples
long
pak_loc_1=[pak_loc_1 out_l_s];
end
%%%%%%%%%%%%%%%%%%%%preamble for usr1%%%%%%%%%%%%%%%%%%%%%%%%%%%
a= 1+j;
b=-1+j;
c=-1-j;
d= 1-j;
p_all=[d d c a d d b d d d a c a a c a c c d b...
d d c a d d b d d d a c a a c a c c d b...
d d c a d d b d d d a c a a c a c c d b...
a a d b a a c a a a b d b b d b d d a c...
c c b d c c a c c c d b d b b d b b c a...
0 ...
c a b b c a a a c a d b d b b b b d c c...
b d a a b d d d b d c c c a a a a c b b...
a c d d a c c c a c b b b d d d d b a a...
c a b b c a a a c a d d d b b b b d c c...
d b c c d b b b d b a a a c c c c a d d];
ff_1=zeros(1,256);
ff_2=zeros(1,256);
d2=p_all(1:2:201);
d1=p_all(1:4:201);
ff_2(129+(-100:2:100))=sqrt(2)*d2;%%%%%long preamble
usr1_pre=fft(ff_2,256);%%%%%%%%%%%%%fft of usr1
ot1=[usr1_pre];
i_ot1=ifft(ot1,256);
c_iot1=[i_ot1(193:256) i_ot1];
preamble_cp_usr1=c_iot1; %%%%%%%long preamble
pak_usr1_preamble=[preamble_cp_usr1 pak_loc_1];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ci1=[1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .5*j]; %%%%%%%%%%channel
fil_ch_out=filter(ci1,1,pak_usr1_preamble);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%channel estimation
cp_long_pre=fil_ch_out(1:320);
long_pre=cp_long_pre(65:end);
ff_long_pre=fft(long_pre,256);
long_usr1=ff_long_pre;
ratio_usr1=long_usr1./usr1_pre; %%%%ratio of recived preamble to the
known preamble
ratio_usr1=ratio_usr1(1:2:end);
%%%%interpolating
inter_r_us1=[];
for n=1:length(ratio_usr1)-1
inter_r_us1=[inter_r_us1 ratio_usr1
(ratio_usr1+ratio_usr1(n+1))/2];
end
inter_r_us1=[inter_r_us1 ratio_usr1(128) ratio_usr1(128)];
ch1_fr=fft(ci1,256);
figure(1)
hold on
plot(abs(log(inter_r_us1)),'linewidth',4)
plot(abs(log(ch1_fr)),'xg')
hold off
title('channel in green to estimated channel in blue')
axis([1 256 -2 2])
%%%%%%%%%%%%%%lms_equil%%%%%%%%%%%%%%%%
l8=320;
data=fil_ch_out(321:end);
w=ones(1,256)./inter_r_us1; %%%%w=estimated channel
errtt=[];
for n=1:50
dat=data((n-1)*l8+1:n*l8);
dat1=dat(65:end);
dat_f=fft(dat1,256);
eq_dat_f=dat_f.*w;
dat_t=ifft(eq_dat_f,256);
figure(2)
plot(dat_t,'x')
%%%%%%%%%%%%%%%detector
detc=[];
for n=1:256
dc_tmp=dat_t;%%%%%%%%%%%%%input to detector
sinng=sign(real(dc_tmp));
if sinng==1
if real(dc_tmp)<0.5
rl_tmp=0;
else
rl_tmp=1;
end
else
if real(dc_tmp)>-0.5
rl_tmp=0 ;
else
rl_tmp=-1;
end
end
sinng=sign(imag(dc_tmp));
if sinng==1
if imag(dc_tmp)<0.5
ig_tmp=0;
else
ig_tmp=1;
end
else
if imag(dc_tmp)>-0.5
ig_tmp=0 ;
else
ig_tmp=-1;
end
end
tmp_d=rl_tmp+i*ig_tmp;
detc=[detc tmp_d]; %%%%%%%%%%%%%%%%output of detector
end
figure(3)
plot(detc,'x')
title('detector plot')
axis([-2 2 -2 2])
err_t=detc-dat_t; %%%%error of detector to data in time domain
err_f=fft(err_t,256);%%%%%error back in freq domain
errtt=[errtt err_f];
figure(4)
subplot(2,1,1)
plot(abs(err_t));
subplot(2,1,2)
plot(abs(err_f));
w_up=(dat_f.*conj(err_f)); %%%new weights in freq domain
w=w+0.01*(w_up);%%%%weights update lms algrothim
end
figure(5)
plot(abs(errtt))
___________________________________
Hi All,
I am trying to simulate a SC-Frequency domain LMS equalizer.
Now since it is SC the detection has to be in time domain although the
channel estimation is in frequency domain so i follow these steps
1) Multiply data -> data_f (in frequency domain) with weights in frequency
domain
2} Convert data in time domain data_t by ifft and pass it through
detector.
3) compute the error (detector - data_t)
4) convert the error back in frequency domain (by fft or error)->err_f
5) update weighs by weights=weights+Mu*(data_f*conj(err_f)) where Mu is
step size
6) now multiply new weight with next set of data and repeat the process
Am i doing something wrong as error never decreases no matter what i do
and it increases rapidly with each run.
Any kind of help is highly appreciated as this is making me crazy.
Regards
Aditya
Please see the sample matlab code below
________________________________________
close all
clear all
clc
z=zeros(1,256);
zd=0;
x1=[];
z3=[];
pak_loc=[];
pak_loc_1=[];
pak_dis=[];
map_bins=[];
%%%%%%%%%%%%%%%usr1%%%%%%%%%%%%%%%%%%%%%%%%%%%
for k=1:50
%%%%%%%%%%%%%%%%%paking 32 bins left 32 bins right% center dc
zero%%%%%%%%%
x=(floor(2*rand(1,64))-.5)/(.5)+j*(floor(2*rand(1,64))-.5)/(.5);
x1=[x x1];
for n=97:128
z=x(n-96);
end
for n=130:161
z=x(n-97);
end
t=fftshift(z);
map_bins=[map_bins z];
dtd=fft(t,256);
%%%%%%%%%%%%%%subcarrier mapping%%%%%%%%%%%%%
subm_d=[];
subm_l=[];
subm_l=[dtd];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%256 point ifft of localized and
disterbuted%%%%%%%%%%%%%%%%%%%%%
iff_out_l=ifft(subm_l,256);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%cyclic prefix%%%%%%%%%
out_l_s=[];
out_l_s=[iff_out_l(193:256) iff_out_l]; %%%%%%%%%one ofdm symbol with
cyclic prefix
%%%%%%%%%%%%%%%%%50 symbol packet%%%%%%%%%%%%% 1 symbol is 320 samples
long
pak_loc_1=[pak_loc_1 out_l_s];
end
%%%%%%%%%%%%%%%%%%%%preamble for usr1%%%%%%%%%%%%%%%%%%%%%%%%%%%
a= 1+j;
b=-1+j;
c=-1-j;
d= 1-j;
p_all=[d d c a d d b d d d a c a a c a c c d b...
d d c a d d b d d d a c a a c a c c d b...
d d c a d d b d d d a c a a c a c c d b...
a a d b a a c a a a b d b b d b d d a c...
c c b d c c a c c c d b d b b d b b c a...
0 ...
c a b b c a a a c a d b d b b b b d c c...
b d a a b d d d b d c c c a a a a c b b...
a c d d a c c c a c b b b d d d d b a a...
c a b b c a a a c a d d d b b b b d c c...
d b c c d b b b d b a a a c c c c a d d];
ff_1=zeros(1,256);
ff_2=zeros(1,256);
d2=p_all(1:2:201);
d1=p_all(1:4:201);
ff_2(129+(-100:2:100))=sqrt(2)*d2;%%%%%long preamble
usr1_pre=fft(ff_2,256);%%%%%%%%%%%%%fft of usr1
ot1=[usr1_pre];
i_ot1=ifft(ot1,256);
c_iot1=[i_ot1(193:256) i_ot1];
preamble_cp_usr1=c_iot1; %%%%%%%long preamble
pak_usr1_preamble=[preamble_cp_usr1 pak_loc_1];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ci1=[1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .5*j]; %%%%%%%%%%channel
fil_ch_out=filter(ci1,1,pak_usr1_preamble);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%channel estimation
cp_long_pre=fil_ch_out(1:320);
long_pre=cp_long_pre(65:end);
ff_long_pre=fft(long_pre,256);
long_usr1=ff_long_pre;
ratio_usr1=long_usr1./usr1_pre; %%%%ratio of recived preamble to the
known preamble
ratio_usr1=ratio_usr1(1:2:end);
%%%%interpolating
inter_r_us1=[];
for n=1:length(ratio_usr1)-1
inter_r_us1=[inter_r_us1 ratio_usr1
(ratio_usr1+ratio_usr1(n+1))/2];
end
inter_r_us1=[inter_r_us1 ratio_usr1(128) ratio_usr1(128)];
ch1_fr=fft(ci1,256);
figure(1)
hold on
plot(abs(log(inter_r_us1)),'linewidth',4)
plot(abs(log(ch1_fr)),'xg')
hold off
title('channel in green to estimated channel in blue')
axis([1 256 -2 2])
%%%%%%%%%%%%%%lms_equil%%%%%%%%%%%%%%%%
l8=320;
data=fil_ch_out(321:end);
w=ones(1,256)./inter_r_us1; %%%%w=estimated channel
errtt=[];
for n=1:50
dat=data((n-1)*l8+1:n*l8);
dat1=dat(65:end);
dat_f=fft(dat1,256);
eq_dat_f=dat_f.*w;
dat_t=ifft(eq_dat_f,256);
figure(2)
plot(dat_t,'x')
%%%%%%%%%%%%%%%detector
detc=[];
for n=1:256
dc_tmp=dat_t;%%%%%%%%%%%%%input to detector
sinng=sign(real(dc_tmp));
if sinng==1
if real(dc_tmp)<0.5
rl_tmp=0;
else
rl_tmp=1;
end
else
if real(dc_tmp)>-0.5
rl_tmp=0 ;
else
rl_tmp=-1;
end
end
sinng=sign(imag(dc_tmp));
if sinng==1
if imag(dc_tmp)<0.5
ig_tmp=0;
else
ig_tmp=1;
end
else
if imag(dc_tmp)>-0.5
ig_tmp=0 ;
else
ig_tmp=-1;
end
end
tmp_d=rl_tmp+i*ig_tmp;
detc=[detc tmp_d]; %%%%%%%%%%%%%%%%output of detector
end
figure(3)
plot(detc,'x')
title('detector plot')
axis([-2 2 -2 2])
err_t=detc-dat_t; %%%%error of detector to data in time domain
err_f=fft(err_t,256);%%%%%error back in freq domain
errtt=[errtt err_f];
figure(4)
subplot(2,1,1)
plot(abs(err_t));
subplot(2,1,2)
plot(abs(err_f));
w_up=(dat_f.*conj(err_f)); %%%new weights in freq domain
w=w+0.01*(w_up);%%%%weights update lms algrothim
end
figure(5)
plot(abs(errtt))
___________________________________