BER of LDPC Encoded QPSK Modulated in AWGN environment

4 views (last 30 days)
Hi all...
i am stuck in plotting the BER of LDPC Encoded QPSK Modulated in AWGN environment.. kindly help me in this regard
i can mail my code to you for checking it .
any help from your side would be appreciated.
  3 Comments
ABDUL
ABDUL on 10 Jul 2019
% All Parameters Initialization to be done here - begin
M=4;
k=log2(M); % number of bits/symbol
number_of_data_points=64; % FFT Size or total number of subcarriers=N=64= IFFT size
block_size=16;
BW=8*10^6;
Nsp=52;
%Derived Parameters
deltaf=BW/number_of_data_points;%bandwidth of each subcarriers including used and unused subacarriers
TFFT=1/deltaf; % ofdm_symbol_duration
TGI=TFFT/4; % duration of the cyclic prefix= guard interval duration 25% of the subcarriers to be used as a GI
% possible guard band values 1/4, 1/8, 1/16 and 1/32
Tsignal= TGI+TFFT ; % total ofdm symbol duration
Ncp=number_of_data_points*(TGI/TFFT); % length of the cyclic prefix
cp_len=ceil(0.25*block_size);
fft_points=number_of_data_points;
ifft_points=number_of_data_points;
Nt=2;
Nr=2;
cp_start=block_size-cp_len;
cp_end=block_size;
actual_cp=zeros(cp_len, block_size);
data_subcarriers=cp_start+Nsp;
nsf=8/7;
Fs=ceil(nsf*BW);
EbNo=0:10;
% initialization of SNR
SNRstart=1;
SNRincrement=1;
SNRend=9;
index=0;
EbN0=0:10; % Eb/N0
E=1;
% 2. Generate Parity Check Matirx %
c=64;%size(x1,2);
n=64;%size(x1,2);% number of information bits/ message bits/ length of message vector...
wc=4; % enter the number of ones in each columns
wr=(n.*wc)./c; %number of ones in each row
H=zeros(c,n); %generate the empty matrix and start assigining the 1's c=n; n=k
j=1;
jj=wr;
for i=1:c./wc
H(i,j:jj) =1;
j=j+wr;
jj=(i.*wr)+wr;
end
for i=1:wc-1
for ii=1:n
colind=(round(rand(1)*(n-1)))+1;
rCol=H(1:c./wc,colind);
H((i.*(c./wc))+1:((i.*(c./wc))+1+(c./wc)-1),ii)=rCol;
end
end
%1. 1st Block -Implementation of binary data %
%1st Block -Implementation of bianry data- generation %
for keb=1:length(EbN0)
SNR=10^(EbN0(k)/10); % Eb/N0(dB) to linear value
standar_dev =sqrt((E/(2*SNR))); % Standard Deviation of Noise
bit_error=0;
% for snr=SNRsta2rt:SNRincrement:SNRend
x1=randi([0 1],1,64);
br=BW; %Let us transmission bit rate 1000000
fc=br; % minimum carrier frequency
Tc=1/br; % bit duration
tmod=Tc/99:Tc/99:Tc; % Time vector for one bit information
%------- encoded data by using LDPC Encoder and Parity Check Matrix-------%
data_encoded=x1*H;
mod_data=mod(data_encoded,2);
%---------3. modulation of the data by using psk------------------------- %
data_NRZ=2*mod_data-1; % Data Represented at NZR form for QPSK modulation
s_p_data=reshape(data_NRZ,2,length(x1)/2); % S/P convertion of data
ymod=[];
ycomplex=[];
y_in=[];
y_qd=[];
% for jmodsp=1:size(s_p_data,1)
for imod = 1:length(x1)/2
y1 = s_p_data(1,imod)*cos(2*pi*fc*tmod); % inphase component
y2 = s_p_data(2,imod)*sin(2*pi*fc*tmod);% Quadrature component
y_in = [y_in y1]; % inphase signal vector
% y_in1=reshape(y_in,16,[]);
y_qd = [y_qd y2]; %quadrature signal vector
ymod = [ymod y1+y2]; % modulated signal vector
ycomplex = [ycomplex (sign(y1))+(1i*sign(y2))];
end
% end
psk_mod=ycomplex;
% psk_mod=ymod;
Tx_sig1=ymod; % transmitting signal after modulation
Tx_sig=ycomplex; % transmitting signal after modulation
Tx_sig_complex=ycomplex;
ttmod=Tc/99:Tc/99:(Tc*length(x1))/2;
% to find out the number of columns after reshaping
num_colums=ceil((size(Tx_sig_complex,1)*size(Tx_sig_complex,2))/block_size);
% 5.to perform serial to parallel conversion %
reshaped_mod_data = reshape(Tx_sig1,[block_size, num_colums]);
% data divided into 4 subcarriers
reshaped_mod_data_1=reshaped_mod_data(:,1);
reshaped_mod_data_2=reshaped_mod_data(:,2);
reshaped_mod_data_3=reshaped_mod_data(:,3);
reshaped_mod_data_4=reshaped_mod_data(:,4);
% 6. To Perform IFFT and Cyclic Prefix %
% to create empty matrix to put ifft data %
% 7.operate column wise and do cyclic prefix, column wise cyclic prefix is done
% ifft_data_matrix=zeros(size(reshaped_mod_data,1),size(reshaped_mod_data,2));
for ireshape=1:num_colums
ifft_data_matrix(:,ireshape)=ifft(reshaped_mod_data(:,ireshape));
for jcplen= 1:cp_len % compute cyclic prefix data
actual_cp(jcplen,ireshape) = ifft_data_matrix(jcplen+cp_start,ireshape).';
end
ifft_data_after_cp(:,ireshape) = vertcat(actual_cp(:,ireshape),ifft_data_matrix(:,ireshape));% perform cyclic prefix
end
% 8. to perform parallel to serial conversion %
parallel_serial_tx = reshape(ifft_data_after_cp(:,:),size(ifft_data_after_cp(:,:),2),size(ifft_data_after_cp(:,:),1));
% to calculate PAPR of MIMO OFDM signal %
magk=abs(parallel_serial_tx).^2;
meank=mean(magk,2);
% meank=mean(abs(parallel_serial_tx).^2);
% peak=max(abs(parallel_serial_tx).^2);
peak=max(magk,[],2);
papr=10*log10(peak./meank);
[cy,cx]=ccdf(papr,0.1);
% 12. To find the number of rows and colums after ifft %
[ifft_rows,ifft_colums]=size(parallel_serial_tx);
ofdm_length=ifft_rows*ifft_colums;
% to convert to serial stream for to obtain OFDM Signal %
% to generate ofdm signal - begin %
% to generate OFDM signal
ofdm_signal= reshape(parallel_serial_tx,1,ofdm_length) ;% serial_parallel_form = reshape( b,block_size,num_colums) ;1x130
received_bits=zeros(size(SNRstart:SNRincrement:SNRend));
index=0;
index=index+1;
%creation of multipath channel
% channel = randn(size(parallel_serial_tx))+sqrt(-1)*randn(size(parallel_serial_tx));
%
% % Pass the signal thru the channel
%
% after_channel = filter(reshape(channel,1,[]),1,ofdm_signal);
%generate AWGN noise
% awgn_noise=awgn(after_channel,snr,'measured');
% awgn_noise=awgn(parallel_serial_tx,snr,'measured');
awgn_noise=standar_dev*(randn(size(parallel_serial_tx,1),size(parallel_serial_tx,2))+sqrt(-1)*randn(size(parallel_serial_tx,1),size(parallel_serial_tx,2)));
% received signal
% received_signal = after_channel+awgn_noise;
% To perform Serial to Parallel Conversion
% serial_parallel_form_rx = reshape(received_signal,[ifft_rows,ifft_colums]).';%64x2
serial_parallel_form_rx = reshape(awgn_noise,[ifft_rows,ifft_colums]).';%64x2
%To Remove Cyclic Prefix
serial_parallel_form_rx(1:cp_len,:,:)=[];
% To Perform FFT operation
receivd_signal_fft_rx=fft(serial_parallel_form_rx);
% To Perform Parallel to Serial Conversion
parallel_serial_form_rx= reshape(receivd_signal_fft_rx,1,[]);
% To pass through Demodulator
Rx_data=[];
Rx_sig=parallel_serial_form_rx; % Received signal
Rx_sig_real=(real(Rx_sig));
Rx_sig_imag=(imag(Rx_sig));
for (idemod=1:1:length(x1)/2)
%%XXXXXX inphase coherent dector XXXXXXX
Z_in=Rx_sig_real((idemod-1)*length(tmod)+1:idemod*length(tmod)).*cos(2*pi*fc*tmod);
% above line indicat multiplication of received & inphase carred signal
Z_in_intg=(trapz(tmod,Z_in))*(2/Tc);% integration using trapizoidal rule
if(Z_in_intg>0) % Decession Maker
Rx_in_data=1;
else
Rx_in_data=0;
end
%XXXXXX Quadrature coherent dector XXXXXX
Z_qd=Rx_sig_imag(((idemod-1)*length(tmod))+1:idemod*length(tmod)).*sin(2*pi*fc*tmod);
%above line indicat multiplication ofreceived & Quadphase carred signal
Z_qd_intg=(trapz(tmod,Z_qd))*(2/Tc);%integration using trapizoidal rule
if (Z_qd_intg>0)% Decession Maker
Rx_qd_data=1;
else
Rx_qd_data=0;
end
Rx_data=[Rx_data Rx_in_data Rx_qd_data]; % Received Data vector
end
psk_demod_mod=Rx_data;
Hinv=H.';
rece_decoder=psk_demod_mod*Hinv;
rece_decoder_mod=mod(rece_decoder,2);
% [n, received_bits(index)]=biterr(x1,psk_demod_mod);
[n, received_bits(index)]=biterr(x1,rece_decoder_mod);
bit_error=sum(xor(rece_decoder_mod,x1));
estimated_bits(keb)=bit_error/64
end
figure (7)
semilogy(EbN0,(estimated_bits),'-ok');
% semilogy(snr,1-sort(received_bits),'-ok');
grid;
title('OFDM Bit Error Rate .VS. Signal To Noise Ratio');
axis([0 max(SNRend) 10^-5 1])
ylabel('BER');
xlabel('SNR [dB]');

Sign in to comment.

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!