You are on page 1of 28

II Semester M.Tech.

(CE)

EC736 COMMUNICATION AND


NETWORKING LABORATORY

Laboratory Manual

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


NATIONAL INSTITUTE OF TECHNOLOGY KARNATAKA, SURATHKAL
SRINIVASNAGAR-575025, KARNATAKA, INDIA
January 2023
EC736 – Communication & Networking Lab Manual, II Semester M.Tech.(CE), Feb-June 2021

Expt.1: BER performance of M-ary PSK system


Aim: To analyze BER performance of M-ary PSK system under AWGN & Rayleigh fading channels

Simulator: MATLAB

Schematic diagram’s:

Binary M-ary PSK x y


AWGN M-ary PSK Binary
Source Modulator Channel De-Modulator Sink

n
Noise
Source

Fig-1: Wireline Communication System Model

Binary M-ary PSK x y


Rayleigh Matched M-ary PSK
Source Modulator Fading Binary
Filter De-Modulator
Channel Sink
Receiver
(h)

Noise
Source

Fig-2: Wireless Communication System Model


Theory:
1. Wireline Communication Channel Model:
This channel model is also called Additive White Gaussian Noise (AWGN) channel Model
because we assume Noise is White and follows Gaussian Probability Density Function.
Mathematically we can write as y = x + n
Where, x = Input vector to the channel
n = Additive White gaussian Noise Vector
y = Output vector received from the channel
The Theoretical BER for this Channel Model with BPSK/QPSK Modulation is Given as

BER = Q(√𝑆𝑁𝑅) = 0.5erfc(√𝑆𝑁𝑅)


where, SNR = Signal to Noise Ratio
Q = Complementary Cumulative Distribution Function
2
EC736 – Communication & Networking Lab Manual, II Semester M.Tech.(CE), Feb-June 2021

erfc = Complementary error Function.


For M-ary PSK the theoretical BER is given as
1 𝜋
BER = 𝑒𝑟𝑓𝑐(√𝑛 𝑆𝑁𝑅 Sin ( ))
𝑛 𝑀

Where, n = No. of Bits; M = No. of Symbols


2. Rayleigh Fading Communication Channel Model:
The signal fading occurs when the signal propagates through a channel which has large number
of scatters such as trees, vehicles, buildings etc., Because of scattering at the receiver we have
multiple copies (Multi path components) of transmitted signal interfering either constructively or
destructively which give rise to fading. The Amplitude of this multi path channel follows Rayleigh
Probability Density Function, hence the name Rayleigh Fading channel.
Mathematically we can write as y = hx + n
Where, x = Input vector to the channel
n = Additive White gaussian Noise vector
h = Fading channel coefficient vector
y = Output vector received from the channel
The Theoretical BER for this Channel Model with BPSK Modulation is Given as

1 𝑆𝑁𝑅
BER = { 1 − √ }
2 2+𝑆𝑁𝑅

where, SNR = Signal to Noise Ratio.


MATLAB Code:

% BER performance of AWGN and Rayleigh Fading System's for M-ary PSK
Modulation

%% Initialization

close all;
clear all;
clc;
rng('shuffle');
blockLength = 100; % # Symbols in a block of serial data
numBlocks = 10000; % # Iterations to get smooth BER curve
SNRdB = [1:0.5:12];
BER = zeros(size(SNRdB)); BER_fad = zeros(size(SNRdB)); %Initialization
of BER
SNR = zeros(size(SNRdB));

for n = 1:2 % # Bits Per Symbol (n = 1 For BPSK, n = 2 For QPSK)

M = 2^n; % M-ary PSK


3
EC736 – Communication & Networking Lab Manual, II Semester M.Tech.(CE), Feb-June 2021

%% Transmission, Fading, White Gaussian Noise addition, Reception &


Decoding

for L = 1: numBlocks

bits = randi([0, M-1], [blockLength,1]); % Generate serial random


integers between 0 & M-1 of size 1 X blockLength
h = 1/sqrt(2)*(randn+1j*randn); % Multi Path Fading Channel
Coefficient
ChNoise = (randn(blockLength,1) + 1j*randn(blockLength,1)); % Noise
Generation os size blockLength X 1(#bits = #Noise samples)

for k = 1: length(SNRdB) % Since we have to compute BER for different


SNR's

SNR(k) = 10^(SNRdB(k)/10); % Absolute SNR computed from SNRdB


Txbits = sqrt(SNR(k))*pskmod(bits,M); % Transmitted Bits(Symbols )
Rxbits = Txbits + ChNoise; % Received Bits(Symbols)from AWGN Channel
Rxbits_fad = h*Txbits + ChNoise; % Received Bits(Symbols)from Rayleigh
Fading Channel
Bitsprocessed_MF_fad = conj(h)*Rxbits_fad; % Bits Processed using
matched filter receiver for Rayleigh Fading Channel
DecodedBits = pskdemod(Rxbits, M); % Bits decoded for AWGN Channel
DecodedBits_fad = pskdemod(Bitsprocessed_MF_fad,M); % Bits decoded for
Rayleigh Fading Channel
BER(k) = BER(k) + symerr(DecodedBits,bits); % Net BER for all
iterations(1:NumBlocks)
BER_fad(k) = BER_fad(k) + symerr(DecodedBits_fad,bits); % Net BER for
all iterations(1:NumBlocks)

end
end

%% Simulated (Practical) BER Calculations & Plots

BER = BER/(blockLength*numBlocks); % Avg BER = Total # Bits received in


error / total # Bits transmitted i.e.(=blockLength*iter)
BER_fad = BER_fad/(blockLength*numBlocks);
semilogy(SNRdB,BER,'linewidth',2.0);
hold on;
semilogy(SNRdB,BER_fad,'linewidth',2.0); % Gives Simulated BER
hold on;

end

%% Theoretical BER Calculations & Plots

BER_Theoretical = qfunc(sqrt(SNR)); % Theoretical BER for AWGN Channel


semilogy(SNRdB,BER_Theoretical,'bo','linewidth',2.0); % Gives
Theoretical BER
hold on;
4
EC736 – Communication & Networking Lab Manual, II Semester M.Tech.(CE), Feb-June 2021

BER_Theoretical_fad = 0.5*(1-sqrt(SNR./(2+SNR))); % Theoretical BER for


Rayleigh Fading Channel
semilogy(SNRdB,BER_Theoretical_fad,'ro','linewidth',2.0); % Gives
Theoretical BER
hold on;
axis tight; grid on;
legend('simulated @ BPSK(AWGN)','simulated @ BPSK(FADING)','simulated @
QPSK(AWGN)','simulated @ QPSK(FADING)','Theoretical @
BPSK(AWGN)','Theoretical @ BPSK(FADING)');
xlabel('SNR(dB)');
ylabel('BER');
title('BER vs SNR(dB)');

Procedure:
1. Type the MATLAB code in editor window.
2. Run the code and get the BER curves.
3. Calculate the BER for Various Modulation orders at a given SNR and tabulate the
results.
4. Compare theoretical and Simulated BER Curves for BPSK Modulation scheme.
Results:

5
EC736 – Communication & Networking Lab Manual, II Semester M.Tech.(CE), Feb-June 2021

S. SNR Modulation BER AWGN BER AWGN BER Fading BER Fading
no
(In dB) Type (Theoretical) (Simulated) (Theoretical) (Simulated)
1 9 BPSK
2 9 QPSK
3 10 BPSK
4 10 QPSK
5 12 BPSK
6 12 QPSK

Selected References:
1. NPTEL online course on Advanced 3G & 4G Wireless Communications by Prof. Aditya K.
Jagannatham (IIT Kanpur, EEE Dept.)
2. Aditya K. Jagannatham - Principles of Modern Wireless Communications Systems-MC GRAW
HILL INDIA (2015)
3. Wireless Communications Principles and practice by T S. Rappaport, Second edition.

6
EC736 – Communication & Networking Lab Manual, II Semester M.Tech.(CE), Feb-June 2021

Expt.2: BER performance of M-ary QAM system


Aim: To analyze BER performance of M-ary QAM system under AWGN & Rayleigh fading
channels.

Simulator: MATLAB

Schematic diagram’s:

Binary M-ary x y
AWGN M-ary QAM Binary
Source QAM Channel De-Modulator Sink
Modulator
n
Noise
Source

Fig-1: Wireline Communication System Model

Binary M-ary x y
Rayleigh Matched M-ary QAM
Source QAM Fading Binary
Filter De-Modulator
Modulator Channel Sink
Receiver
(h)

Noise
Source

Fig-2: Wireless Communication System Model


Theory:
1. Wireline Communication Channel Model:
This channel model is also called Additive White Gaussian Noise (AWGN) channel Model
because we assume Noise is White and follows Gaussian Probability Density Function.
Mathematically we can write as y = x + n
Where, x = Input vector to the channel
n = Additive White gaussian Noise Vector
y = Output vector received from the channel
The Theoretical BER for this Channel Model with BQAM/4-QAM Modulation is Given as

BER = Q(√𝑆𝑁𝑅) = 0.5erfc(√𝑆𝑁𝑅)


where, SNR = Signal to Noise Ratio.

7
EC736 – Communication & Networking Lab Manual, II Semester M.Tech.(CE), Feb-June 2021

Q = Complementary Cumulative Distribution Function.


erfc = Complementary error Function.
For M-ary QAM the theoretical BER is given as

2 1 3𝑛
BER = (1 − ) 𝑒𝑟𝑓𝑐(√ 𝑆𝑁𝑅 )
𝑛 √𝑀 𝑛2(𝑀−1)

Where, n = No. of Bits; M = No. of Symbols


2. Rayleigh Fading Communication Channel Model:
The signal fading occurs when the signal propagates through a channel which has large number
of scatters such as trees, vehicles, buildings etc., Because of scattering at the receiver we have
multiple copies (Multi path components) of transmitted signal interfering either constructively or
destructively which give rise to fading. The Amplitude of this multi path channel follows Rayleigh
Probability Density Function. Hence the name Rayleigh Fading channel.
Mathematically we can write as y = hx + n
Where, x = Input vector to the channel
n = Additive White gaussian Noise vector
h = Fading channel coefficient vector
y = Output vector received from the channel
The Theoretical BER for this Channel Model with BQAM Modulation is Given as

1 𝑆𝑁𝑅
BER = { 1 − √ }
2 2+𝑆𝑁𝑅

where, SNR = Signal to Noise Ratio.


MATLAB Code:
% BER performance of AWGN and Rayleigh Fading System's For M-ary QAM
Modulation

%% Initialization

close all;
clear all;
clc;
rng('shuffle');
blockLength = 100; % # Symbols in a block of serial data
numBlocks = 10000; % # Iterations to get smooth BER curve
SNRdB = [1:0.5:12];
BER = zeros(size(SNRdB)); BER_fad = zeros(size(SNRdB)); %
Initialization of BER
SNR = zeros(size(SNRdB));

8
EC736 – Communication & Networking Lab Manual, II Semester M.Tech.(CE), Feb-June 2021

for n = 1:2 % # Bits Per Symbol (n = 1 For B-QAM, n = 2 For 4-QAM)

M = 2^n; % M-ary QAM

%% Transmission, Fading, White Gaussian Noise addition, Reception &


Decoding

for L = 1:numBlocks

bits = randi([0,M-1],[blockLength,1]); % Generate serial random


integers between 0 & M-1 of size 1 X blockLength
h = 1/sqrt(2)*(randn+1j*randn); % Multi Path Fading channel
Coefficient
ChNoise = (randn(blockLength,1) + 1j*randn(blockLength,1)); % Noise
Generation os size blockLength X 1(#bits = #Noise samples)

for k = 1:length(SNRdB) % Since we have to compute BER for different


SNR's

SNR(k) = 10^(SNRdB(k)/10); % Absolute SNR computed from SNRdB


Txbits = sqrt(SNR(k))*qammod(bits,M); % Transmitted Bits( Symbols )
Rxbits = Txbits + ChNoise; % Received Bits(Symbols)from AWGN Channel
Rxbits_fad = h*Txbits + ChNoise; % Received Bits(Symbols)from Rayleigh
Fading Channel
Bitsprocessed_MF_fad = conj(h)*Rxbits_fad; % Bits Processed using
matched filter receiver for Rayleigh Fading Channel
DecodedBits = qamdemod(Rxbits,M); % Bits decoded for AWGN Channel
DecodedBits_fad = qamdemod(Bitsprocessed_MF_fad,M); % Bits decoded for
Rayleigh Fading Channel
BER(k) = BER(k) + symerr(DecodedBits,bits); % Net BER for all
iterations(1:NumBlocks)
BER_fad(k) = BER_fad(k) + symerr(DecodedBits_fad,bits); % Net BER for
all iterations(1:NumBlocks)

end
end

%% Simulated (Practical) BER Calculations & Plots

BER = BER/(blockLength*numBlocks);% Avg BER = Total # Bits received in


error / total # Bits transmitted i.e.(=blockLength*iter)
BER_fad = BER_fad/(blockLength*numBlocks);
semilogy(SNRdB,BER,'linewidth',2.0);
hold on;
semilogy(SNRdB,BER_fad,'linewidth',2.0); % Gives Simulated BER
hold on;

end

9
EC736 – Communication & Networking Lab Manual, II Semester M.Tech.(CE), Feb-June 2021

%% Theoretical BER Calculations & Plots

BER_Theoretical = qfunc(sqrt(SNR)); % Theoretical BER for AWGN Channel


semilogy(SNRdB,BER_Theoretical,'bo','linewidth',2.0); % Gives
Theoretical BER
hold on;
BER_Theoretical_fad = 0.5*(1-sqrt(SNR./(2+SNR))); % Theoretical BER For
Rayleigh Fading Channel
semilogy(SNRdB,BER_Theoretical_fad,'ro','linewidth',2.0); % Gives
Theoretical BER
hold on;
axis tight;grid on;
legend('simulated @ B-QAM(AWGN)','simulated @ B-QAM(FADING)','simulated
@ 4-QAM(AWGN)','simulated @ 4-QAM(FADING)','Theoretical @ B-
QAM(AWGN)','Theoretical @ B-QAM(FADING)');
xlabel('SNR(dB)');
ylabel('BER');
title('BER vs SNR(dB) for M-ary QAM');

Procedure:
1. Type the MATLAB code in editor window.
2. Run the code and get the BER curves.
3. Calculate the BER for Various Modulation orders at a given SNR and tabulate the
results.
4. Compare theoretical and Simulated BER Curves for BPSK Modulation scheme.
Results:

10
EC736 – Communication & Networking Lab Manual, II Semester M.Tech.(CE), Feb-June 2021

S. SNR Modulation BER AWGN BER AWGN BER Fading BER Fading
no
(In dB) Type (Theoretical) (Simulated) (Theoretical) (Simulated)
1 9 BQAM
2 9 4-QAM
3 10 BQAM
4 10 4-QAM
5 12 BQAM
6 12 4-QAM

Selected References:
1. NPTEL online course on Advanced 3G & 4G Wireless Communications by Prof. Aditya K.
Jagannatham (IIT Kanpur, EEE Dept.)
2. Aditya K. Jagannatham - Principles of Modern Wireless Communications Systems-MC GRAW
HILL INDIA (2015)
3. Wireless Communications Principles and practice by T S. Rappaport, Second edition.

11
EC736 – Communication & Networking Lab Manual, II Semester M.Tech.(CE), Feb-June 2021

Expt.3: BER performance of OFDM system


Aim: To analyze BER performance of OFDM system under Rayleigh Fading Channel with M- ary
PSK Constellation Mapper.

Simulator: MATLAB

Schematic diagram’s:

Noise

b s x x_cp Rayleigh Fading


Binary OFDM CP
Mapper Modulator Addition Wireless
Source
Y
Channel (h)
z
y_cp
b^ s^ x^ y
Binary De- OFDM Frequency
Sink Mapper De-Modulator Domain CP Removal
Equalizer

Fig-1: OFDM System Model.

Serial to Parallel to
Information N-Point Cyclic
Parallel IFFT Serial
source prefix
Converter Converter
(Mapper) Addition
(De-MUX) (MUX)

Fig-2: OFDM transmitter Schematic

Serial to N-Point Parallel to Information


Cyclic Detection
Parallel FFT Serial sink
prefix
Converter Scheme Converter (De-
Removal
(De-MUX) (MUX) Mapper)

Fig-3: OFDM receiver Schematic

12
EC736 – Communication & Networking Lab Manual, II Semester M.Tech.(CE), Feb-June 2021

Theory:
OFDM is one of the types of multi carrier modulation technique, which converts a frequency
selective wide band channel into an orthogonal set of narrow band flat fading channel across each
subcarrier. OFDM is a key technology for 4G/5G wireless communications and Wi-Fi. OFDM replaces
the bank of modulators in traditional MCM system with Simple IFFT and FFT operations at transmitter
and Receiver respectively there by reducing implementational complexity. The Cyclic prefix acts as
guard interval between the two adjacent OFDM symbols, and usually its length must be greater than
delay spread of the channel to avoid inter OFDM symbol interference. Because of additional of cyclic
prefix, the effective throughput of the system decreases (because we are transmitting the tail samples
in OFDM symbol again) but the advantage is it converts the linear convolution action of channel into
circular convolution. Hence gives rise to circulant channel matrix ‘H’ which makes the system simpler
to analyze.
Mathematically we can express the OFDM system model as
y = cconv (h, x) + n
(or)
y = Hx + n
Where, x = Input vector to the channel
n = Additive White gaussian Noise vector
h = Fading channel coefficient vector
H = circulant channel matrix
y = Output vector received from the channel
cconv = Circular convolution
The Theoretical BER for the OFDM system with BPSK Constellation Mapper is Given as

1 𝑆𝑁𝑅_𝑒𝑓𝑓
BER = { 1 − √ }
2 2+𝑆𝑁𝑅_𝑒𝑓𝑓

L∗SNR
where, SNR_eff = Effective Signal to Noise Ratio =
Nsub
L = No. of channel Taps.

MATLAB Code:

% BER Performance of OFDM System for M-ary PSK Modulation with frequency
domain equalization at receiver
close all;
clear all;
clc;
rng('shuffle');
Nsub = 1024;
13
EC736 – Communication & Networking Lab Manual, II Semester M.Tech.(CE), Feb-June 2021

Ncp = round(Nsub/10);
iter = 10000; % #Iterations
numTaps = 4; % # Channel Taps(# Coefficients)
SNRdB = [1:5:80];

n = 1; % # Bits Per Symbol


M = 2^n;% M-ary PSK
BER = zeros(size(SNRdB)); % Initialization of BER Since we have to
accumulate all BER's...
...corresponding to all MP's for each Ant
SNR = zeros(size(SNRdB)); % Initialization of SNR
for L = 1:iter
bits = randi([0,1],[Nsub,1]); % Source Generates serial random
integers(0's&1's)of size...
...1 X Nsub (TwoBlock of 0's & 1's)
h = 1/sqrt(2)*(randn(numTaps,1)+1j*randn(numTaps,1)); % Multi Path
channel Coefficient Matrix
H_freq = fft(h,Nsub);
ChNoise = (randn(numTaps+Nsub+Ncp-1,1)+1j*randn(numTaps+Nsub+Ncp-
1,1));% Noise Generation os size numAnt X blockLength(#bits per Ant =
#Noise samples per Ant)
for k = 1 : length(SNRdB) % Since we have to compute BER for different
SNR's
SNR(k) = 10^(SNRdB(k)/10);% For a given SNR(k)
Loadedbits = sqrt(SNR(k))*pskmod(bits,M); % Default Grey ordering
Txsamples = ifft(Loadedbits);
Txsamples_WCP = [Txsamples(Nsub-Ncp+1 : Nsub); Txsamples];% Transmitted
samples with CP
Rxsamples_Withnoise = conv(h,Txsamples_WCP) + ChNoise; % Linear
Convolution
Rxsamples_WoCP = Rxsamples_Withnoise(Ncp+1:Ncp+Nsub); % Received samples
after CP Removal
Rxbits = fft(Rxsamples_WoCP,Nsub);
Bitsprocessed = Rxbits./H_freq;% Bitsprocessed X = Rxd samples Y ./
Channel Coeff H_freq
DecodedBits = pskdemod(Bitsprocessed,M);
BER(k) = BER(k) + sum(DecodedBits~=bits); % Net BER computed including
all multipaths components and all TX & Rx Ant's
end
end
BER = BER/(iter*Nsub);% Avg BER = Total # Bits received in error / total
# Bits transmitted by multipleTxAnt's ...
...i.e.(=blockLength*iter*numTxAnt)
semilogy(SNRdB,BER,'linewidth',2.0); % Gives Simulated BER
hold on;

SNR_effective = numTaps*SNR/Nsub;
BER_Theoretical = 0.5*(1-sqrt(SNR_effective./(2+SNR_effective))); %
Theoretical formula for OFDM...
... with BPSK mod at High SNR
semilogy(SNRdB,BER_Theoretical,'ro','linewidth',2.0); % Gives
Theoretical BER
14
EC736 – Communication & Networking Lab Manual, II Semester M.Tech.(CE), Feb-June 2021

axis tight;grid on;


legend('Simulated (BPSK)','Theoretical(BPSK)');
xlabel('SNR(dB)');
ylabel('BER');
title('BER vs SNR(dB)');

Procedure:
1. Type the MATLAB code in editor window.
2. Run the code and get the BER curves.
3. Calculate the BER for Various Modulation orders at a given SNR and tabulate the
results.
4. Compare theoretical and Simulated BER Curves for M- ary PSK Modulation
scheme.

Results:

15
EC736 – Communication & Networking Lab Manual, II Semester M.Tech.(CE), Feb-June 2021

S. no SNR Modulation BER BER


(In dB) Type (Theoretical) (Simulated)
1 30 BPSK
2 30 QPSK
3 40 BPSK
4 40 QPSK
5 60 BPSK
6 60 QPSK
7 50 BQAM

Selected References:
1. NPTEL online course on Advanced 3G & 4G Wireless Communications by Prof. Aditya K.
Jagannatham (IIT Kanpur, EEE Dept.)
2. Aditya K. Jagannatham - Principles of Modern Wireless Communications Systems-MC GRAW
HILL INDIA (2015)
3. Wireless Communications Principles and practice by T S. Rappaport, Second edition.

16
EC736 – Communication & Networking Lab Manual, II Semester M.Tech.(CE), Feb-June 2021

Expt.4: BER performance of Multiple Input Multiple Output System


Aim: To analyze BER performance of MIMO system under Rayleigh fading channel for various
MIMO detectors with M-ary PSK modulation

Simulator: MATLAB

Schematic diagram’s:

Tx Ant-1 (x1) Rx Ant-1 (y1)

Tx Ant-2 (x2) MIMO Rx Ant-2 (y2)


Tx Ant-3 (x3) Rx Ant-3 (y3)
.
Channel .
. .
.
Tx Ant-t (xt)
“H” .
Rx Ant-r (yr)

Fig: MIMO System Model

Theory:
MIMO system have multiple transmit and receive antennas at transmitter and receiver,
respectively. Because of having multiple transmit and receive antennas MIMO systems can be
employed for achieving “Diversity gain” to increase SNR at receiver and also we can do “Spatial
multiplexing” to increase the data rate with same transmit power.
Mathematically we can express the MIMO system model as
Y=HX

Where, X tx1 = Input vector

H r x t = MIMO channel matrix


Y r x 1 = Output vector
t = No. of Transmit antennas
r = No. of Receive antennas
And the MIMO channel matrix is decomposed as

17
EC736 – Communication & Networking Lab Manual, II Semester M.Tech.(CE), Feb-June 2021

ℎ11 ℎ12 ℎ13 . . . ℎ1𝑡


ℎ21 ℎ22 ℎ23 . . . ℎ2𝑡
ℎ ℎ32 ℎ33 . . . ℎ3𝑡
𝐻 = 31
. . . . . . .
. . . . . . .
[ℎ𝑟1 ℎ𝑟2 ℎ𝑟3 . . . ℎ𝑟𝑡 ]

Where, hij = MIMO channel coefficient between ith Receive and jth transmit antenna’s.

MIMO Receivers:
a. MIMO Zero-Forcing receiver:
BZF = H† = (HHH)-1HH
The estimated output vector X^ = BZF Y
This receiver Forces (Suppress) Interference to zero but gives Noise enhancement.

b. MIMO Matched Filter receiver:


BMF = HH
The estimated output vector X^ = BMF Y
This receiver Suppress Noise and enhance the interference.

c. MIMO Minimum Linear Mean Square Error receiver:


𝑰
BMMSE = (HHH + )-1HH
𝑺𝑵𝑹
The estimated output vector X^ = BMMSE Y
This is the complex but most efficient receiver which suppress both noise and interference.
At low SNR this behaves like Matched Filter receiver and at low SNR it behaves like Zero
Forcing receiver

MATLAB Code:

% Comparison of BER Performance of MIMO System For ZF, Matched Filter


and LMMSE Receiver's with M-ary PSK Modulation
close all;
clear all;
clc;
rng('shuffle');
blockLength = 1000; % # Symbols in a block of serial data
iter = 10000; % # Iterations
numTxAnt = 2;
numRxAnt = 2;

18
EC736 – Communication & Networking Lab Manual, II Semester M.Tech.(CE), Feb-June 2021

SNRdB = [1:2:20];

for n = 1 % # Bits Per Symbol


M = 2^n; % M-ary PSK
BER_ZF = zeros(size(SNRdB)); BER_MF = zeros(size(SNRdB)); BER_MMSE =
zeros(size(SNRdB)); % Initialization of BER

SNR = zeros(size(SNRdB)); % Initialization of SNR


for L = 1:iter
bits = randi([0,1],[numTxAnt,blockLength]);% Source Generates serial
random integers(0's&1's)of size...
...numTxAnt X blockLength
(TwoBlock of 0's & 1's)
H =
1/sqrt(2)*(randn(numRxAnt,numTxAnt)+1j*randn(numRxAnt,numTxAnt)); %
Multi Path channel Coefficient Matrix
ChNoise =
(randn(numRxAnt,blockLength)+1j*randn(numRxAnt,blockLength));% Noise
Generation os size numAnt X blockLength...

...(#bits per Ant = #Noise samples per Ant)


for k = 1 : length(SNRdB) % Since we have to compute BER for different
SNR's
SNR(k) = 10^(SNRdB(k)/10);% For a given SNR(k)
Txbits = sqrt(SNR(k))*pskmod(bits,M);
Rxbits = H*Txbits + ChNoise; % Rxd bits
ZF = pinv(H); %Zero Forcing Detector
MF = H';% Maximal Ratio Combiner / Spatial Matched Filter
MMSE = (H'*H + (eye(numTxAnt))*(1/SNR(k)))\H'; % LMMSE Detector
Bitsprocessed_ZF = ZF * Rxbits;
Bitsprocessed_MF = MF * Rxbits;
Bitsprocessed_MMSE = MMSE * Rxbits;
DecodedBits_ZF = pskdemod(Bitsprocessed_ZF,M);
DecodedBits_MF = pskdemod(Bitsprocessed_MF,M);
DecodedBits_MMSE = pskdemod(Bitsprocessed_MMSE,M);
BER_ZF(k) = BER_ZF(k) + symerr(DecodedBits_ZF,bits);%
sum(sum())because inside sum computes sum across various Row's for all
columns..
BER_MF(k) = BER_MF(k) + symerr(DecodedBits_MF,bits);
BER_MMSE(k) = BER_MMSE(k) + symerr(DecodedBits_MMSE,bits);
end
end
BER_ZF = BER_ZF/(blockLength*iter*numTxAnt);% Avg BER = Total # Bits
received in error / total # Bits transmitted by multipleTxAnt's ...

...i.e.(=blockLength*iter*numTxAnt)
BER_MF = BER_MF/(blockLength*iter*numTxAnt);
BER_MMSE = BER_MMSE/(blockLength*iter*numTxAnt);
semilogy(SNRdB,BER_ZF,SNRdB,BER_MF,SNRdB,BER_MMSE,'linewidth',2.0); %
Gives Simulated BER
hold on;
end
19
EC736 – Communication & Networking Lab Manual, II Semester M.Tech.(CE), Feb-June 2021

dord = numRxAnt - numTxAnt+1; % Diversity order for MIMO ZF Receiver is


'L = r-t+1' System, Where L = # independent links
BER_Theoretical = nchoosek(2*dord-1,dord)*(1./(2*SNR)).^dord; %
Theoretical formula for multi Ant s/m...

... with BPSK mod at High SNR


semilogy(SNRdB,BER_Theoretical,'ro','linewidth',2.0); % Gives
Theoretical BER
axis tight;grid on;
legend('BER@ZF','BER@MF','BER@MMSE','Theoretical MIMO/ZF(BPSK)@HIGH
SNR');
xlabel('SNR(dB)');
ylabel('BER');
title('BER vs SNR(dB)For 2X2 MIMO with BPSK Modulation');

Procedure:
1. Type the MATLAB code in editor window.
2. Run the code and get the BER curves.
3. Calculate the BER for Various MIMO Receivers, Modulation orders at a given
SNR and tabulate the results.
4. Compare theoretical and Simulated BER Curves for M- ary PSK Modulation
scheme.
Results:

20
EC736 – Communication & Networking Lab Manual, II Semester M.Tech.(CE), Feb-June 2021

S. SNR Modulation BER for BER for BER for BER for BER for BER for
no ZF ZF MF MF MMSE MMSE
dB Type
Theoretical Simulated Theoretical Simulated Theoretical Simulated
1 5 BPSK
2 10 BPSK
3 15 BPSK
4 5 QPSK
5 10 QPSK
6 15 QPSK
7 10 BQAM

Selected References:
1. NPTEL online course on Advanced 3G & 4G Wireless Communications by Prof. Aditya K.
Jagannatham (IIT Kanpur, EEE Dept.)
2. Aditya K. Jagannatham - Principles of Modern Wireless Communications Systems-MC GRAW
HILL INDIA (2015)
3. Wireless Communications Principles and practice by T S. Rappaport, Second edition.

21
EC736 – Communication & Networking Lab Manual, II Semester M.Tech.(CE), Feb-June 2021

Expt.4: BER performance of MIMO-OFDM system


Aim: To analyze BER performance of MIMO-OFDM system for various MIMO-OFDM receivers
under Rayleigh Fading Channel for M-ary PSK Modulation

Simulator: MATLAB
Schematic diagram’s:

Serial to Parallel to Tx-1


N-Point Cyclic
Parallel IFFT Serial prefix
Converter Converter
Addition
(De-MUX) (MUX)
S/P
symbols DE
M
U
X Tx2
Serial to Parallel to
N-Point Cyclic
Parallel Serial
IFFT prefix
Converter Converter
Addition
(De-MUX) (MUX)

Fig-1: 2X2 MIMO-OFDM Transmitter

Rx-1 Detection
Cyclic Serial to N-Point Parallel
FFT for 1st
prefix Parallel to Serial
Subcarrier
Removal Converter Converter

P/S
M
U
X
Rx-2 Detection
Serial to N-Point Parallel
Cyclic
FFT For Nth to Serial
prefix Parallel
Subcarrier Converter
Removal Converter

Fig-2: 2X2 MIMO-OFDM Receiver


Tx-1 Rx-1

Tx-2 Rx-2

Fig-3: 2X2 MIMO Channel Model

22
EC736 – Communication & Networking Lab Manual, II Semester M.Tech.(CE), Feb-June 2021

Theory:
MIMO-OFDM is a combination of MIMO with OFDM. It converts a frequency selective MIMO
channel into multiple parallel flat fading MIMO channels. MIMO-OFDM significantly simplifies base
band receiver processing by eliminating the need for a complex MIMO equalizer.
Now the received Symbols on ith Received antenna at any time instant ‘n’ from MIMO ISI channel
after the addition of cyclic prefix in Summation form is given by
𝑇
𝐿
Yi(n) = ∑ (∑𝑙=1 hij(𝑙) Xj(n − 𝑙)) + Wij(n)
𝑗=1

Where,
j = Transmit Antenna index
i = Receive Antenna index
n = Time index
L = No, of taps of ISI channel
hjj = Multipath channel coefficient vector between ith Receive and jth Transmit Antenna’s
Ex: L = 2 implies hjj = [hij(1) hij(2)]T
Wij = Complex AWGN Noise vector between ith Receive and jth Transmit Antenna’s
And the MIMO channel matrix is decomposed as
ℎ11 ℎ12 ℎ13 . . . ℎ1𝑡
ℎ21 ℎ22 ℎ23 . . . ℎ2𝑡
ℎ ℎ32 ℎ33 . . . ℎ3𝑡
𝐻 = 31
. . . . . . .
. . . . . . .
[ℎ𝑟1 ℎ𝑟2 ℎ𝑟3 . . . ℎ𝑟𝑡 ]

Where, hij = MIMO channel coefficient between ith Receive and jth transmit antenna’s.

MIMO-OFDM Receivers:
a. MIMO Zero-Forcing receiver:
BZF = H†sub= (HHsub Hsub)-1HHsub
The estimated output vector X^ = BZF Y;
where, Y = fft of received symbols after removing Cyclic prefix
Hsub = Sub carrier Matrix to detect Nth subcarrier at the receiver
This receiver Forces (Suppress) Interference to zero but gives Noise enhancement.

23
EC736 – Communication & Networking Lab Manual, II Semester M.Tech.(CE), Feb-June 2021

b. MIMO Matched Filter receiver:


BMF = HHsub
The estimated output vector X^ = BMF Y
This receiver Suppress Noise and enhance the interference.

c. MIMO Linear Minimum Mean Square Error receiver:


𝑰
BMMSE = (HHsub Hsub + )-1HHsub
𝑺𝑵𝑹
The estimated output vector X^ = BMMSE Y
This is the complex but most efficient receiver which suppress both noise and interference.
At low SNR this behaves like Matched Filter receiver and at high SNR it behaves like Zero
Forcing receiver

MATLAB Code:

% BER Performance of MIMO OFDM System using ZF, MF & LMMSE Receiver's
for M-ary PSK
%% INITIALIZATION

close all;
clear all;
clc;
rng('shuffle');
Nsub = 16;
Ncp = round(Nsub/10);
iter = 10000; % # Iterations
L = 2; % # Channel Taps
T = 2; % # Tx Ants at Transmitter
R = 2; % # Rx Ants at Receiver
SNRdB = [1:2:25];
BER_ZF = zeros(size(SNRdB)); BER_MF = zeros(size(SNRdB)); BER_MMSE =
zeros(size(SNRdB));% Initialization of BER
SNR = zeros(size(SNRdB)); % Initialization of SNR

%% # CONSTELLATION MAPPER

n = 1;% # Bits Per Symbol (1st For)


M = 2^n;% M-ary psk

%% BITS, CHANNEL TAPS AND CHANNEL COEFFICIENTS GENERATION(After Zero


Padding)

for it = 1:iter % # Iterations (2nd For)

24
EC736 – Communication & Networking Lab Manual, II Semester M.Tech.(CE), Feb-June 2021

Bits = randi([0,M-1],[T,Nsub]);% We are Taking As many bits As many


of Subcarriers
h = 1/sqrt(2)*(randn(R,L,T)+1j*randn(R,L,T));% MIMO Multi Path
channel Coefficient matrix of size = (R x L x T)
H_freq = zeros(R,Nsub,T); % Initializing Channel Coefficient matrix

for Tx = 1:T %(3rd For)

H_freq(:,:,Tx) = fft([h(:,:,Tx),zeros(R,Nsub-L)],[],2);

end % End to (3rd For)

%% SIMULATED BER CALCULATIONS

for k = 1:length(SNRdB) %(4th For) Since we have to compute BER for


different SNR's

SNR(k) = 10^(SNRdB(k)/10); % For a given SNR(k)


Rxsamples_WoCP = zeros(R,Nsub);% Initialization of Rxd Samples With Out
Cyclic Prefix Vector

for Tx = 1:T %(5th For) Loading Samples on each Tx Antenna

LoadedBits = sqrt(SNR(k))*pskmod(Bits(Tx,:),M);
Txsamples = ifft(LoadedBits,Nsub);
Txsamples_WCP = [Txsamples(Nsub-Ncp+1 : Nsub), Txsamples];% Transmitted
samples with CP
Rxsamples_WCP =[];%Initialization of Rxd Samples With Cyclic Prefix
Vector

for Rxi = 1:R %(6th For)Receiving Samples on each Rx Antenna

Rxsamples_WCP = [Rxsamples_WCP;conv(h(Rxi,:,Tx),Txsamples_WCP)];%
Linear Convolution Whose...
...size = numTaps+Nsub(i.e.
size os bits loaded)+Ncp-1
end % End to(6th For)

Rxsamples_WoCP = Rxsamples_WoCP + Rxsamples_WCP(:,Ncp+1:Ncp+Nsub); %


Received samples after CP Removal

end % End to (5th For)

%% Channel Noise Generation and Addition to Received samples without


Cyclic Prefix

ChNoise = (randn(R,Nsub)+1j*randn(R,Nsub));% Channel Noise


Rxsamples_WoCP = Rxsamples_WoCP +ChNoise;

%% Bits Received on Each Rx Antenna without Cyclic prefix and with


Noise

25
EC736 – Communication & Networking Lab Manual, II Semester M.Tech.(CE), Feb-June 2021

Processed_Samples = fft(Rxsamples_WoCP,[],2);

%% Detecting Symbols form Processed Samples with MIMO ZF,MF & MMSE
Receiver's

for nx = 1:Nsub %(7th For)

Hsub = squeeze(H_freq(:,nx,:));
Bitsprocessed_ZF = pinv(Hsub)*Processed_Samples(:,nx);% ZF Receiver
Bitsprocessed_MF = Hsub'*Processed_Samples(:,nx);% MF Receiver
Bitsprocessed_MMSE = ((Hsub'*Hsub +
(eye(T))*(1/SNR(k)))\Hsub')*Processed_Samples(:,nx);% MMSE Receiver
DecodedBits_ZF = pskdemod(Bitsprocessed_ZF,M);
DecodedBits_MF = pskdemod(Bitsprocessed_MF,M);
DecodedBits_MMSE = pskdemod(Bitsprocessed_MMSE,M);
BER_ZF(k) = BER_ZF(k) + sum(symerr(Bits(:,nx),DecodedBits_ZF)); % Net
BER
BER_MF(k) = BER_MF(k) + sum(symerr(Bits(:,nx),DecodedBits_MF)); % Net
BER
BER_MMSE(k) = BER_MMSE(k) + sum(symerr(Bits(:,nx),DecodedBits_MMSE)); %
Net BER

end % End to(7th For)


end % End to(2nd For)
end % End to(4th For)

BER_ZF = BER_ZF/(iter*Nsub*T);% Avg BER = Total # Bits received in


error/ Total # Txd Bits
BER_MF = BER_MF/(iter*Nsub*T);
BER_MMSE = BER_MMSE/(iter*Nsub*T);
semilogy(SNRdB,BER_ZF,SNRdB,BER_MF,SNRdB,BER_MMSE,'linewidth',2.0); %
Gives Simulated BER
hold on;

%% Theoretical BER CALCULATIONS

SNR_effective = L*SNR/Nsub;
BER_Theoretical = 0.5*(1-sqrt(SNR_effective./(2+SNR_effective))); %
Theoretical formula for OFDM...

... with BPSK mod at High SNR


semilogy(SNRdB,BER_Theoretical,'ro','linewidth',2.0); % Gives
Theoretical BER
axis tight;grid on;
legend('BER@ZF','BER@MF','BER@MMSE','Theoretical MIMO-
OFDM/ZF(BPSK)@HIGH SNR');
xlabel('SNR(dB)');
ylabel('BER');
title('BER vs SNR(dB)FOR 2X2 MIMO-OFDM WITH BPSK Modulation');

26
EC736 – Communication & Networking Lab Manual, II Semester M.Tech.(CE), Feb-June 2021

Procedure:
1. Type the MATLAB code in editor window.
2. Run the code and get the BER curves.
3. Calculate the BER for Various MIMO-OFDM Receivers, Modulation orders at a
given SNR and tabulate the results.
4. Compare theoretical and Simulated BER Curves for M- ary PSK Modulation
scheme.
Results:

27
EC736 – Communication & Networking Lab Manual, II Semester M.Tech.(CE), Feb-June 2021

S. SNR Modulation BER for BER for BER for BER for BER for BER for
no ZF ZF MF MF MMSE MMSE
dB Type
Theoretical Simulated Theoretical Simulated Theoretical Simulated
1 5 BPSK
2 10 BPSK
3 15 BPSK
4 5 QPSK
5 10 QPSK
6 15 QPSK
7 10 BQAM

Selected References:
1. NPTEL online course on Advanced 3G & 4G Wireless Communications by Prof. Aditya K.
Jagannatham (IIT Kanpur, EEE Dept.)
2. Aditya K. Jagannatham - Principles of Modern Wireless Communications Systems-MC GRAW
HILL INDIA (2015)
3. Wireless Communications Principles and practice by T S. Rappaport, Second edition.

28

You might also like