Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Please help: BER for QPSK in OFDM over Rayleigh matlab code doesn't work.

Status
Not open for further replies.

mazdaspring

Advanced Member level 4
Joined
Feb 18, 2008
Messages
108
Helped
4
Reputation
8
Reaction score
3
Trophy points
1,298
Activity points
2,030
I try to implement the matlab code on BER for QPSK in OFDM over rayleigh channel (with n taps). However the result is a straight line. There must be something wrong in my code but I cannot figure it out what is wrong. Could you please help me to check it. I have to hand the work soon. Please please please help. Thank you very much.

clear;
clc;

N=64; % FFT size
Nsd = 48; % Number of data subcarriers 48
Nsp = 4 ; % Number of pilot subcarriers 4
ofdmBW = 20 * 10^6 ; % OFDM bandwidth

%Derived Parameters
deltaF = ofdmBW/N; %=20 MHz/64 = 0.3125 MHz
Tfft = 1/deltaF; % IFFT/FFT period = 3.2us
Tgi = Tfft/4;%Guard interval duration - duration of cyclic prefix
Tsignal = Tgi+Tfft; %duration of QPSK-OFDM symbol
Ncp = N*Tgi/Tfft; %Number of symbols allocated to cyclic prefix
Nst = Nsd + Nsp; %Number of total used subcarriers
nBitsPerSym=2*Nst; %For QPSK the number of Bits per Symbol is double of num of subcarriers

%Simulation parameters
nSym=2; %Number of OFDM Symbols to transmit (I try to work out in small number first)

EbN0dB = 0:2:45; % bit to noise ratio
EsN0dB = EbN0dB + 10*log10(Nst/N) + 10*log10(N/(Ncp+N)); % converting to symbol to noise ratio

simulatedBER = zeros(1,length(EsN0dB));
theoreticalBER = zeros(1,length(EsN0dB));

for i=1:length(EsN0dB),
%-----------------------------------------------
%Transmitter
%-----------------------------------------------
re=rand(1,(nBitsPerSym/2)*nSym)>0.5;
im=rand(1,(nBitsPerSym/2)*nSym)>0.5;


% ----------Modulation---------
%Constellation Mapper
ip = (2*re-1) + j*(2*im-1); %
s1 = (1/sqrt(2))*ip; % normalization of energy to 1

%serial to parallel conversion
s=reshape(s1,nBitsPerSym/2,nSym).';
% Assigning modulated symbols to subcarriers from [-26 to -1, +1 to +26]
X_Freq = [zeros(nSym,6) s:),[1:Nst/2]) zeros(nSym,1) s:),[Nst/2+1:Nst]) zeros(nSym,5)] ;
%IFFT block
x_Time = (N/sqrt(Nst))*ifft(fftshift(X_Freq.')).';

%Adding Cyclic Prefix
ofdm_signal=[x_Time:),N-Ncp+1:N) x_Time];
[rows cols]=size(ofdm_signal);
%-----------------------------------------------
%Channel Modeling
%-----------------------------------------------

nTap = 10;
ht = 1/sqrt(2)*1/sqrt(nTap)*(randn(nSym,nTap) + j*randn(nSym,nTap));

% computing and storing the frequency response of the channel, for use at recevier
hF = fftshift(fft(ht,64,2));

% convolution of each symbol with the random channel
for jj = 1:nSym
xht(jj,:) = conv(ht(jj,:),ofdm_signal(jj,:));
end
xt1 = xht;

% Concatenating multiple symbols to form a long vector
xt = reshape(xt1.',1,nSym*(80+nTap-1));




% Gaussian noise of unit variance, 0 mean
nt = 1/sqrt(2)*[randn(1,nSym*(80+nTap-1)) + j*randn(1,nSym*(80+nTap-1))];

% Adding noise, the term sqrt(80/64) is to account for the wasted energy due to cyclic prefix
%yt = sqrt(80/64)*xt + 10^(-EsN0dB(i)/20)*nt;
yt = sqrt(80/64)*xt + 10^(-EsN0dB(i)/20)*nt;

%-----------------------------------------------
%Receiver
%-----------------------------------------------
%Serial to Parallel conversion

r_Parallel=reshape(yt.',89,nSym).';

%Removing cyclic prefix
r_Parallel=r_Parallel:),Ncp+1:(N+Ncp));

%FFT Block
r_Time = (sqrt(Nst)/N)*fftshift(fft(r_Parallel.')).';

% equalization by the known channel frequency response
yF = r_Time./hF;

%Extracting the data carriers from the FFT output

R_Freq = yF:),[6+[1:Nst/2] 7+[Nst/2+1:Nst] ]);

%----------------------------------------------------------------------

%--------- QPSK demodulation ------------%
y_re = real(R_Freq); % real
y_im = imag(R_Freq); % imaginary
ipHat(find(y_re < 0 & y_im < 0)) = -1 + -1*j; % iphat= input^ hat
ipHat(find(y_re >= 0 & y_im > 0)) = 1 + 1*j;
ipHat(find(y_re < 0 & y_im >= 0)) = -1 + 1*j;
ipHat(find(y_re >= 0 & y_im < 0)) = 1 - 1*j;

%---------------------------------------------%
numErrors = size(find([ip- ipHat]),2); % couting the number of errors
simulatedBER(i)=numErrors/(nSym*nBitsPerSym);
theorySer_QPSK(i) = erfc(sqrt(0.5*(10.^(EsN0dB(i)/10)))) - (1/4)*(erfc(sqrt(0.5*(10.^(EsN0dB(i)/10))))).^2;

end
semilogy(EsN0dB,simulatedBER,'r-o','LineWidth',2);
hold on;

semilogy(EsN0dB,theorySer_QPSK,'k*','LineWidth',2);

Please check it for me and let me know which part is wrong here. Thank you so much in advance.
Here is the result graph.
 

Attachments

  • QPSKOFDM.bmp
    230.7 KB · Views: 71

hiiiiii
i am working in BER using convoltion coading in ofdm . i am using a qpsk modulation scheme .please hel me is it good topic or not
thankssssss
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top