OFDM BER in awgn channel using bpsk

by

 

This simple script uses communication toolbox to simulate the BER of the bpsk ofdm.

bpsk_ofdm_commtoolbox.m
close all
clear all
clc

nbitpersym  = 52;   % number of bits per OFDM symbol (same as the number of subcarriers for BPSK)
nsym        = 10^4; % number of symbols
len_fft     = 64;   % fft size
sub_car     = 52;   % number of data subcarriers
EbNo        = 0:2:12;

EsNo= EbNo + 10*log10(52/64)+ 10*log10(64/80); % symbol to noise ratio

snr=EsNo - 10*log10(52/64); % snr as to be used by awgn fn.

M = modem.pskmod(2); % modulation object

% Generating data

t_data=randint(nbitpersym*nsym,1);

% modulating data

mod_data = modulate(M,t_data);

% serial to parallel conversion

par_data = reshape(mod_data,nbitpersym,nsym).';

% pilot insertion

pilot_ins_data=[zeros(nsym,6) par_data(:,[1:nbitpersym/2]) zeros(nsym,1) par_data(:,[nbitpersym/2+1:nbitpersym]) zeros(nsym,5)] ;

% fourier transform time doamain data and normalizing the data

IFFT_data = (64/sqrt(52))*ifft(fftshift(pilot_ins_data.')).';

% addition cyclic prefix

cylic_add_data = [IFFT_data(:,[49:64]) IFFT_data].';

% parallel to serial coversion

ser_data = reshape(cylic_add_data,80*nsym,1);

% passing thru channel

no_of_error=[];
ratio=[];
for ii=1:length(snr)
  
chan_awgn = sqrt(80/52)*awgn(ser_data,snr(ii),'measured'); % awgn addition

ser_to_para = reshape(chan_awgn,80,nsym).'; % serial to parallel coversion

cyclic_pre_rem = ser_to_para(:,[17:80]);   %cyclic prefix removal

FFT_recdata =(sqrt(52)/64)*fftshift(fft(cyclic_pre_rem.')).';    % freq domain transform

rem_pilot = FFT_recdata (:,[6+[1:nbitpersym/2] 7+[nbitpersym/2+1:nbitpersym] ]); %pilot removal

ser_data_1 = reshape(rem_pilot.',nbitpersym*nsym,1);  % serial coversion

z=modem.pskdemod(2); %demodulation object

demod_Data = demodulate(z,ser_data_1);  %demodulating the data

[no_of_error(ii),ratio(ii)]=biterr(t_data,demod_Data) ; % error rate calculation

end

% plotting the result

semilogy(EbNo,ratio,'--or','linewidth',2);
hold on;
theoryBer = (1/2)*erfc(sqrt(10.^(EbNo/10)));
semilogy (EbNo,theoryBer,'--*b','linewidth',2);
grid on
axis([0 12 10^-5 .1])
xlabel('EbNo');
ylabel('BER')
title('Bit error probability curve for BPSK using OFDM');

Contact us