Code covered by the BSD License  

Highlights from
DESIGN OF NOVEL DIGITAL EQUALIZERS FOR NOISY NONLINEAR CHANNEL USING LMS ALGORITHM

image thumbnail

DESIGN OF NOVEL DIGITAL EQUALIZERS FOR NOISY NONLINEAR CHANNEL USING LMS ALGORITHM

by

 

DESIGN OF NOVEL DIGITAL EQUALIZERS FOR NOISY NONLINEAR CHANNEL USING LMS ALGORITHM.

Non_linear_Channel_equalizer.m
clear all;
clc;
tic;
% DESIGN OF NOVEL DIGITAL EQUALIZERS FOR NOISY NONLINEAR CHANNEL USING LMS
% By Y.Yella Reddy, 08EE01015, SES, IIT Bhubaneswar.

%---------------Channel or Filter "Intialization"-----------------------%
Select=input('Enter the channel u want select.. select 1 for CH1 otherwise 2 :');
if(Select==1)
Channel_Weights=[0.26 0.93 0.26] ; % Transfer function coefficients
else
Channel_Weights=[0.3040 0.9030 0.3040];
end

%---------------Transmission data "Intialization"------------------------%
N=input('Enter the no of the iterations/input samples: '); %input number of samples.
Transmit_Data= rand(1,N);  % input to the plant.

%Changing Transmitted data into digital bits of amplitude 1 and -1.
for i=1:1:N
if (Transmit_Data(i)>0.5)
    Transmit_Data(i)=1;
else
    Transmit_Data(i)=-1;
end
end

%zeros are padded for later use in the algorithm.
Transmit_Data=[0 0 Transmit_Data];

%------------------------Equalizer "Intialization"------------------------%
Equalizer_Weights=zeros(1,8);%[0 0 0 0 0 0 0 0];
Learning_Rate=input('Enter the Learning Parameter value:'); % Learning rate of the model

%Signal Power to noise power
SNR=input('Enter the snr value : ');

%Signal Power and Noise Power
sp=var(Transmit_Data);
np =(sp)*power(10,-(SNR/10)); 

%Noise to be added
Noise=sqrt(np)*(rand(1,N)-0.5);

%Received output after delay
 for i=1:1:4
 Delayed_Input(i)=0;
end

%---------------------Desired output------------------------------------%
Delayed_Input=[Delayed_Input(1:4) Transmit_Data];
Desired_Output=Delayed_Input;

 % adding non-linearity ..select any values of the given
Select_nonlinear=input('Enter the value(1,2,3) of function which u want to be function of non linearity:');

 for j=1:1:N     
  % Finding the channel filter output
 Filter_Output(j)=(Channel_Weights(1)*Transmit_Data(j+2))+(Channel_Weights(2)*Transmit_Data(j+1))+(Channel_Weights(3)*Transmit_Data(j));

%selecting type of non linearity and as well finding the Equalizer input.
if (Select_nonlinear==1)
        Equalizer_Input(j)=tanh(Filter_Output(j));
else if (Select_nonlinear==2)
        Equalizer_Input(j)= Filter_Output(j)+ 0.1*Filter_Output(j)^2 - 0.2*Filter_Output(j)^3;
     else
        Equalizer_Input(j) = Filter_Output(j)+ 0.1*Filter_Output(j)^2 - 0.2*Filter_Output(j)^3+0.5*cos(pi*Filter_Output(j));
     end
end
end
%adding noise to the equalizer input
%Equalizer_Input_with_noise=awgn(Equalizer_Input,SNR);
Equalizer_Input_with_noise=Equalizer_Input+ Noise;
Equalizer_Input_with_noise=[0 0 0 Equalizer_Input_with_noise];

Equalizer_Output=zeros(1,N);

for k=1:1:N-4

%finding equalizer output.
for j=1:8
       Equalizer_Output(k)=Equalizer_Output(k)+ Equalizer_Input_with_noise(k+j-1)*Equalizer_Weights(j);
end

%finding error
Error(k)=Desired_Output(k+6)-Equalizer_Output(k);

%updating weight values of equalizer.
for m=1:8
        Equalizer_Weights(m)= Equalizer_Weights(m)+(2*Learning_Rate*Equalizer_Input_with_noise(k+m-1)*Error(k));
end
end




%-------------------Testing of the Equalizer------------------------------%
n=input('Enter the no of test samples :');% no of test samples
ber=zeros(1,10);
Test_Equalizer_Input=zeros(1,n);

for snr=2:2:20
    
Test_Input= rand(1,n);  % input to the plant.
for m=1:1:n
    if (Test_Input(m)>0.5)
    Test_Input(m)=1;
else
    Test_Input(m)=-1;
    end
end
Test_Input1=[0 0 Test_Input];
Delayed_Test_Output=[0 0 0 0 Test_Input1];


%Signal Power and Noise Power
SP=var(Test_Input1);
NP =(sp)*power(10,-(snr/10)); 

%Noise to be added
noise=sqrt(NP)*(rand(1,n)-0.5);

 for j=1:1:n     
 Test_Filter_Output(j)=Channel_Weights(1)*Test_Input1(j+2)+Channel_Weights(2)*Test_Input1(j+1)+Channel_Weights(3)*Test_Input1(j);    
     %selecting type of non linearity and as well finding the Equalizer input.
if (Select_nonlinear==1)
        Test_Equalizer_Input(j)=tanh(Test_Filter_Output(j));
else if (Select_nonlinear==2)
        Test_Equalizer_Input(j)= Test_Filter_Output(j)+ 0.1*Test_Filter_Output(j)^2 - 0.2*Test_Filter_Output(j)^3;
     else
        Test_Equalizer_Input(j) =Test_Filter_Output(j)+ 0.1*Test_Filter_Output(j)^2 - 0.2*Test_Filter_Output(j)^3+0.5*cos(pi*Test_Filter_Output(j));
    end
end 
 end
 %adding noise
    %Test_Equalizer_Input_with_noise=awgn(Test_Equalizer_Input,snr);
    Test_Equalizer_Input_with_noise=Test_Equalizer_Input+noise;
    Test_Equalizer_Input_with_noise=[0 0 0 Test_Equalizer_Input_with_noise];
    Test_Equalizer_Output=zeros(1,n);
% Calculating the final equalizer output
for k=1:1:n-4 
for j=1:8
       Test_Equalizer_Output(k)=Test_Equalizer_Output(k)+ Test_Equalizer_Input_with_noise(k+j-1)*Equalizer_Weights(j);
end

%Converting the Output into digital bits of 1 and -1
if (Test_Equalizer_Output(k)>0.5)
    Test_Equalizer_Output(k)=1;
else
    Test_Equalizer_Output(k)=-1;
end

%Calculation of BER
if (Test_Input1(k+2)~= Test_Equalizer_Output(k))
    ber(snr/2)=ber(snr/2)+1;%it will give cunt of errors
end

end
 
 end
 

plot(log10(ber/n));
figure,
plot(power(Error,2));
figure,
plot(log10(ber));
figure,
plot(ber);
toc;

Contact us