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.

[SOLVED] OFDM BPSK BER Problem

Status
Not open for further replies.

ReComm

Member level 2
Joined
Aug 26, 2010
Messages
46
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Location
Egypt
Activity points
1,640
AA
The following code gives higher BER than the theoretical.

Can anyone help me why? and give me the way to modify the code.

code of BPSK- OFDM
===============
clc;
clear all
nFFT = 4; % fft size
nDSC = 4; % number of data subcarriers
nBitPerSym = 4; % number of bits per OFDM symbol (same as the number of subcarriers for BPSK)
nSym = 10^3; % number of symbols
carriers = (1:nBitPerSym) ;

ep =0;

EbN0dB = [1:15]; % bit to noise ratio

% Transmitter
ipBit = rand(1,nBitPerSym*nSym) > 0.5; % random 1's and 0's
modulated_data = 2*ipBit-1; % BPSK modulation 0 --> -1, 1 --> +1

for ll= 1:length(ep)

for iii=EbN0dB,
k = 1;
for n = 1:nSym
ofdm_symbol = zeros(1,nFFT);
% Map modulated data to FFT bins in OFDM symbol
ofdm_symbol(carriers) = modulated_data(k:k+nBitPerSym-1);

% Time Signal to transmit
tx_signal = (nFFT/sqrt(nDSC))*ifft(ofdm_symbol,nFFT);

% DOPPLER SHIFT
rx_signal1= tx_signal.*exp((2*j*pi*ep(ll)/nFFT ).*(0:length(tx_signal) -1));

rx_signal = awgn(rx_signal1, EbN0dB(iii),0);

% FFT
received_ofdm = (sqrt(nDSC)/nFFT)*fft(rx_signal, nFFT);

% Extract data from carriers in OFDM symbol
received_symbols(k:k+nBitPerSym-1) = received_ofdm(carriers);
k = k + nBitPerSym;
end
% PERFROM DEMODULATION
yF=received_symbols;
yF = reshape(yF,nBitPerSym,nSym).'; % formatting the received vector into symbo
ipModHat = 2*floor(real(yF/2)) + 1;
ipModHat(find(ipModHat>1)) = +1;
ipModHat(find(ipModHat<-1)) = -1;

% converting modulated values into bits
ipBitHat = (ipModHat+1)/2;
ipBitHat = reshape(ipBitHat.',nBitPerSym*nSym,1).';

% counting the errors
nErr(iii) = size(find(ipBitHat - ipBit),2)/(nSym*nBitPerSym);

end
end


Thanks in advance
 

ChakerQ

Member level 1
Joined
Mar 30, 2012
Messages
40
Helped
18
Reputation
36
Reaction score
18
Trophy points
1,288
Location
Tunisia
Activity points
1,503
Hi,

Here the code :

Code:
clc;
clear all
close all
nFFT = 256; % fft size
nDSC = 256; % number of data subcarriers
nBitPerSym = 256; % number of bits per OFDM symbol (same as the number of subcarriers for BPSK)
nSym = 10^3; % number of symbols
carriers = (1:nBitPerSym) ;

ep =0;

EbN0dB = [1:10]; % bit to noise ratio

% Transmitter
ipBit = rand(1,nBitPerSym*nSym) > 0.5; % random 1's and 0's
modulated_data = 2*ipBit-1; % BPSK modulation 0 --> -1, 1 --> +1

%for ll= 1:length(ep)

for iii=EbN0dB,
k = 1;
for n = 1:nSym
ofdm_symbol = zeros(1,nFFT);
% Map modulated data to FFT bins in OFDM symbol
ofdm_symbol(carriers) = modulated_data(k:k+nBitPerSym-1);

% Time Signal to transmit
tx_signal = (nFFT/sqrt(nDSC))*ifft(ofdm_symbol,nFFT);

% DOPPLER SHIFT
%rx_signal1= tx_signal.*exp((2*j*pi*ep(ll)/nFFT ).*(0:length(tx_signal) -1));

rx_signal = awgn(tx_signal, EbN0dB(iii),'measured');

% FFT
received_ofdm = (sqrt(nDSC)/nFFT)*fft(rx_signal, nFFT);

% Extract data from carriers in OFDM symbol
received_symbols(k:k+nBitPerSym-1) = received_ofdm(carriers);
k = k + nBitPerSym;
end
% PERFROM DEMODULATION
yF=received_symbols;
yF = reshape(yF,nBitPerSym,nSym).'; % formatting the received vector into symbo
ipModHat = 2*floor(real(yF/2)) + 1;
ipModHat(find(ipModHat>1)) = +1;
ipModHat(find(ipModHat<-1)) = -1;

% converting modulated values into bits
ipBitHat = (ipModHat+1)/2;
ipBitHat = reshape(ipBitHat.',nBitPerSym*nSym,1).';

% counting the errors
nErr(iii) = size(find(ipBitHat - ipBit),2)/(nSym*nBitPerSym);
end
BPSK =berawgn(EbN0dB,'psk',2,'nondiff');
figure(1)
semilogy(EbN0dB,BPSK,'-bo');
hold on
semilogy(EbN0dB,nErr,'-R*');
grid on
xlabel('EbNo (dB)');
ylabel('BER')

Regards,

Chaker
 
Last edited:

ReComm

Member level 2
Joined
Aug 26, 2010
Messages
46
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Location
Egypt
Activity points
1,640
Thanks for your cooperation
but when i but the next parameter with4, it gives the same error of mismatch

nFFT = 4; % fft size
nDSC = 4; % number of data subcarriers
nBitPerSym = 4; % number of bits per OFDM symbol (same as the number of subcarriers for BPSK)

Thanks
wait your reply,
 

ChakerQ

Member level 1
Joined
Mar 30, 2012
Messages
40
Helped
18
Reputation
36
Reaction score
18
Trophy points
1,288
Location
Tunisia
Activity points
1,503
Hi,

In your code you generate awgn noise only for one OFDM symbol every time. With only one symbole with 4 carries, your noise can't be considred gaussion.
If you don't want to increase nFFT, you must add noise to a sequence with more than one OFDM symbol.

Regards,

Chaker
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top