0% found this document useful (0 votes)
66 views10 pages

Digital Communication

The document describes a MATLAB simulation that analyzes the bit error rate (BER) performance of OFDM with BPSK modulation over an additive white Gaussian noise (AWGN) channel. The simulation generates OFDM symbols with BPSK modulation, adds AWGN noise, performs OFDM demodulation and decoding at the receiver, and calculates the BER by comparing the transmitted and received bits. The simulation is run for different signal-to-noise ratio (SNR) values and plots the theoretical and simulated BER curves.

Uploaded by

pranjal yadav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
66 views10 pages

Digital Communication

The document describes a MATLAB simulation that analyzes the bit error rate (BER) performance of OFDM with BPSK modulation over an additive white Gaussian noise (AWGN) channel. The simulation generates OFDM symbols with BPSK modulation, adds AWGN noise, performs OFDM demodulation and decoding at the receiver, and calculates the BER by comparing the transmitted and received bits. The simulation is run for different signal-to-noise ratio (SNR) values and plots the theoretical and simulated BER curves.

Uploaded by

pranjal yadav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Exp. No.

11
Analyze BER versus SNR performance for OFDM with BPSK in AWGN
channel.

Roll No.: 19BEC033


Date: 09/11/2021

MATLAB Program:

% Script for computing the Bit Error probability using OFDM with BPSK modulation.
clc; clear all; close all;
format long;
nFFT = 64; % fft size
nDSC = 64; % number of data subcarriers
nBitPerSym = 64; % number of bits per OFDM symbol
% (same as the number of subcarriers for BPSK)
nSym = 10^4; % number of OFDM symbols
EbN0dB =[0:10]; % bit to noise ratio
theoryBer = (1/2)*erfc(sqrt(10.^(EbN0dB/10)));
for k = 1:length(EbN0dB)
% Transmitter
ipBit=randi([0 1],1,nBitPerSym*nSym);
ipMod = 2*ipBit-1; % BPSK modulation 0 --> -1, 1 --> +1
ipMod = reshape(ipMod,nBitPerSym,nSym).'; % grouping into multiple symbols
% Assigning modulated symbols to subcarriers
xF =ipMod;
% Taking FFT, the term (nFFT/sqrt(nDSC)) is for
% normalizing the power of transmit symbol to 1
xt = (nFFT/sqrt(nDSC))*ifft(fftshift(xF.')).';
% Parallel to serial
xt = reshape(xt.',1,nSym*nFFT);
% Gaussian noise of unit variance, 0 mean
nt = 1/sqrt(2)*[randn(1,nSym* nFFT) + j*randn(1,nSym* nFFT)];
% Adding noise
yt = xt + 10^(-EbN0dB(k)/20)*nt;
% Receiver serial to parallel
yt = reshape(yt.', nFFT,nSym).';
% converting to frequency domain
yF = fftshift(fft(yt.')).';
%Parallel to serial
yMod = reshape(yF.',1,nSym* nFFT);
%Hard decision decoding for BPSK demodulation
ipBitHat = (sign(real(yMod))+1)/2;
% counting the errors
nErr = sum(xor(ipBitHat,ipBit));
simBer(k) = nErr/(nSym*nBitPerSym);
[EbN0dB(k) theoryBer(k) simBer(k)];
end
figure(1);
semilogy(EbN0dB,theoryBer,'bd',EbN0dB,simBer);

1
legend('Analytical','Simulation results for OFDM');
xlabel('SNR(Eb/No)dB');
ylabel('Bit Error Rate (BER)');
title('Bit Error probability using OFDM with BPSK modulation');

Interpretation: The above plot shows the BER vs SNR curve using OFDM with BPSK modulation.

Questions:

(1) Draw the block diagram of transmitter and receiver with OFDM.

A. 1

2
(2) What is the advantage of OFDM compared to FDM.

A. 2

(3) Draw the Simulink model for OFDM.

A. 3

3
(4) Use MPSK and MQAM in the system and plot BER versus SNR.

A.4

% OFDM using MPSK:


clc; clear all; close all;
format long;
nFFT = 64; % fft size
nDSC = 64; % number of data subcarriers
nBitPerSym = 64; % number of bits per OFDM symbol
% (same as the number of subcarriers for BPSK)
nSym = 16; % number of OFDM symbols
EbN0dB =[0:10]; % bit to noise ratio
FRM=4096;
M=16;
K=log2(M);
maxNumBits=1000000;
maxNumErrs=1000;
Modulator = comm.PSKModulator(M,'BitInput',true);
AWGN = comm.AWGNChannel;
DeModulator = comm.PSKDemodulator(M,'BitOutput',true);
BitError = comm.ErrorRate;
SNR = EbN0dB + 10*log10(K);
for k = 1:length(EbN0dB)
% Transmitter
ipBit=randi([0 1],1,nBitPerSym*nSym);

nberr=0;
numErrs = 0; numBits = 0; results=zeros(3,1);

4
AWGN.EbNo=SNR(k);
while ((numErrs < maxNumErrs) && (numBits < maxNumBits))
% Transmitter
u = randi([0 1], FRM,1); % Random bits generator
mod_sig = Modulator.step(u); % QPSK Modulator
% Channel
ipMod = reshape(mod_sig',nBitPerSym,nSym).'; % grouping
% into multiple symbols
% Assigning modulated symbols to subcarriers
xF =ipMod;
% Taking FFT, the term (nFFT/sqrt(nDSC)) is for
% normalizing the power of transmit symbol to 1
xt = (nFFT/sqrt(nDSC))*ifft(fftshift(xF.')).';
% Parallel to serial
xt = reshape(xt.',1,nSym*nFFT);
% Gaussian noise of unit variance, 0 mean
nt = 1/sqrt(2)*[randn(1,nSym* nFFT) + j*randn(1,nSym*nFFT)];
% Adding noise
yt = xt + 10^(-EbN0dB(k)/20)*nt;
% Receiver serial to parallel
yt = reshape(yt.', nFFT,nSym).';
% converting to frequency domain
yF = fftshift(fft(yt.')).';
%Parallel to serial
yMod = reshape(yF.',1,nSym* nFFT);
%Hard decision decoding for BPSK demodulation
rx_sig = AWGN.step(mod_sig); % AWGN channel
% Receiver
demod = DeModulator.step(rx_sig); % QPSK Demodulator
ipBitHat = demod(1:FRM); % Compute output bits
results = BitError.step(u, ipBitHat); % Update BER
numErrs = results(2);
numBits = results(3);
end
%% Clean up & collect results
ber(k) = results(1);
reset(BitError);
[EbN0dB(k) ber(k)];
end
figure(1);
semilogy(EbN0dB,ber,'b');
legend('Simulation');
xlabel('SNR(Eb/No)dB');
ylabel('Bit Error Rate (BER)');
title('OFDM using MPSK');

5
% OFDM using MQAM:
clc; clear all; close all;
format long;
nFFT = 64; % fft size
nDSC = 64; % number of data subcarriers

nBitPerSym = 64; % number of bits per OFDM symbol


% (same as the number of subcarriers for BPSK)
nSym = 16; % number of OFDM symbols
EbN0dB =[0:10]; % bit to noise ratio
FRM=4096;
M=16;
K=log2(M);
maxNumBits=1000000;
maxNumErrs=1000;
Modulator = comm.RectangularQAMModulator(M,'BitInput',true);

Warning: COMM.RECTANGULARQAMMODULATOR will be removed in a future release. Use QAMMOD instead. See
this release note for more information.

AWGN = comm.AWGNChannel;
DeModulator = comm.RectangularQAMDemodulator(M,'BitOutput',true);

Warning: COMM.RECTANGULARQAMDEMODULATOR will be removed in a future release. Use QAMDEMOD instead.


See this release note for more information.

BitError = comm.ErrorRate;

6
SNR = EbN0dB + 10*log10(K);
for k = 1:length(EbN0dB)
% Transmitter
ipBit=randi([0 1],1,nBitPerSym*nSym);
nberr=0;
numErrs = 0; numBits = 0; results=zeros(3,1);
AWGN.EbNo=SNR(k);
while ((numErrs < maxNumErrs) && (numBits < maxNumBits))
% Transmitter
u = randi([0 1], FRM,1); % Random bits generator
mod_sig = Modulator.step(u); % QPSK Modulator
% Channel
ipMod = reshape(mod_sig',nBitPerSym,nSym).'; % grouping
% into multiple symbols
% Assigning modulated symbols to subcarriers
xF =ipMod;
% Taking FFT, the term (nFFT/sqrt(nDSC)) is for normalizing
% the power of transmit symbol to 1
xt = (nFFT/sqrt(nDSC))*ifft(fftshift(xF.')).';
% Parallel to serial
xt = reshape(xt.',1,nSym*nFFT);
% Gaussian noise of unit variance, 0 mean
nt = 1/sqrt(2)*[randn(1,nSym* nFFT) + j*randn(1,nSym* nFFT)];

% Adding noise
yt = xt + 10^(-EbN0dB(k)/20)*nt;
% Receiver serial to parallel
yt = reshape(yt.', nFFT,nSym).';
% converting to frequency domain
yF = fftshift(fft(yt.')).';
%Parallel to serial
yMod = reshape(yF.',1,nSym* nFFT);
%Hard decision decoding for BPSK demodulation
rx_sig = AWGN.step(mod_sig); % AWGN channel
% Receiver
demod = DeModulator.step(rx_sig); % QPSK Demodulator
ipBitHat = demod(1:FRM); % Compute output bits
results = BitError.step(u, ipBitHat); % Update BER
numErrs = results(2);
numBits = results(3);
end
%% Clean up & collect results
ber(k) = results(1);
reset(BitError);
[EbN0dB(k) ber(k)];
end
figure(1);
semilogy(EbN0dB,ber,'b');
legend('For M=16');
xlabel('SNR(Eb/No)dB');
ylabel('Bit Error Rate (BER)');
title('OFDM using MQAM');

7
(5) Use (7,4) block code and convolutional code and respective decoder. Plot BER versus SNR in AWGN with
OFDM.

clc; clear all; close all;


Frame = 3e4; % Number of bits to process
maxNumBits=1000000;
maxNumErrs=1000;
%% BPSK and Block code
n=7;
K=4;
m = log2(n+1); % Express n as 2^m-1.
coderate=K/n;
nFFT = 64; % fft size
nDSC = 64; % number of data subcarriers
nBitPerSym = 64; % number of bits per OFDM symbol (same as the
% number of subcarriers for BPSK)

nSym = 10000; % number of OFDM symbols


EbNo =[0:10]; % bit to noise ratio
SNR = EbNo + 10*log10(coderate);
snr=10.^(SNR/10);
bera=0.5*erfc(sqrt(10.^(EbNo/10))/2);
[parmat,genmat] = hammgen(m);
for k = 1:length(EbNo)
numErrs = 0; numBits = 0;
p=sqrt(snr(k));

8
while ((numErrs < maxNumErrs) && (numBits < maxNumBits))
% Transmitter
ipBit=randi([0 1],1,nBitPerSym*nSym);
x_cod = encode(ipBit,n,K,'linear/binary',genmat);
ipMod1 = 2*x_cod-1; % BPSK modulation 0 --> -1, 1 --> +1
ipMod = reshape(ipMod1,nBitPerSym*1.75,nSym).'; % grouping
% into multiple symbols
% Assigning modulated symbols to subcarriers
xF =ipMod;
% Taking FFT, the term (nFFT/sqrt(nDSC)) is for normalizing the
% power of transmit symbol to 1
xt1 = (nFFT/sqrt(nDSC))*ifft(fftshift(xF.')).';
% Parallel to serial
xt = reshape(xt1.',1,nSym*nFFT*1.75);
% Gaussian noise of unit variance, 0 mean
nt = 1/sqrt(2)*[randn(1,nSym* nFFT*1.75) + j*randn(1,nSym*nFFT*1.75)];
% Adding noise
yt = xt + 10^(-EbNo(k)/20)*nt;
% Receiver serial to parallel
yt = reshape(yt.', 1.75*nFFT,nSym).';
% converting to frequency domain
yF = fftshift(fft(yt.')).';
%Parallel to serial
yMod = reshape(yF.',1,nSym* nFFT*1.75);
%Hard decision decoding for BPSK demodulation
ipBitHat = (sign(real(yMod))+1)/2;
x_recov= decode(ipBitHat,n,K,'linear/binary',genmat);
berr=xor(ipBit,x_recov);
sberr=sum(sum(berr));
numErrs=numErrs+sberr;
numBits=numBits+Frame;
end
bep(k)=numErrs/numBits;
[EbNo(k) bep(k)];
end
figure(1);
semilogy(EbNo,bep);
legend('(7,4) Block Code');
xlabel('SNR(Eb/No)dB');
ylabel('Bit Error Rate (BER)');
title(' BER versus SNR in AWGN with OFDM');

9
Conclusions: The critical learnings and findings of this experiment are:

• Orthogonal frequency-division multiplexing is a method of data transmission where a single information


stream is split among several closely spaced narrowband subchannel frequencies instead of a single
wideband channel frequency.
• We have used QPSK mapper(modulator) in the transmitter block.
• The 4-point IFFT is an important block used to calculate IFFT coefficients.
• In OFDM, Guard band is not required and the spectral efficiency of OFDM is high which oppose to the
FDM.
• In OFDM, Single data source attaches all the sub-channels.
• Through OFDM, higher data rate can be achieved.
• Applications of OFDM are in LTE technologies and broadband internet.

10

You might also like