0% found this document useful (0 votes)
34 views25 pages

A9 Exp3

The document describes an experiment to evaluate and compare digital modulation schemes M-ary Phase Shift Keying (MPSK) and M-ary Quadrature Amplitude Modulation (M-QAM) over an additive white gaussian noise (AWGN) channel. It includes the theoretical background of AWGN channels, M-PSK, M-QAM modulation techniques, and a pseudocode to simulate the modulation schemes over an AWGN channel and calculate their bit error rates.
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)
34 views25 pages

A9 Exp3

The document describes an experiment to evaluate and compare digital modulation schemes M-ary Phase Shift Keying (MPSK) and M-ary Quadrature Amplitude Modulation (M-QAM) over an additive white gaussian noise (AWGN) channel. It includes the theoretical background of AWGN channels, M-PSK, M-QAM modulation techniques, and a pseudocode to simulate the modulation schemes over an AWGN channel and calculate their bit error rates.
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/ 25

Experiment - 3

Group: A9
02-09-2022

Group Members Roll No. Email ID

Chanda Vamshi B191231EC [email protected]


Vardhan

Chandra Sekhar Kanuru B190470EC [email protected]

Claret Thanikkal B191031EC [email protected]

Dadireddy Jahnavi B190181EC [email protected]

David Joy B190825EC [email protected]

a) Objective:
To evaluate and compare the following digital modulation schemes over an additive white
gaussian noise channel.
a) M-ary Phase Shift Keying (MPSK)
b) M-ary Quadrature Amplitude Modulation (M-QAM).
b) Theoretical background:
a. Block diagram of the system:

b. AWGN channel:
The most prevalent type of noise added over the channel in communication systems is
additive white gaussian noise (AWGN). AWGN is the result of thermal noise produced by the
thermal motion of electrons in all resistors, wires, and other dissipative electrical
components. Mathematically, AWGN is modeled as a zero-mean Gaussian random process
where the random signal “z” is the summation of the random noise variable “n” and a direct
current signal “a” that is
𝑧 = 𝑎 + 𝑛
The probability distribution function for this Gaussian noise can be represented as follows
1 −1 𝑧−𝑎 2
𝑝(𝑧) = 𝑒𝑥𝑝[( 2
)( σ
) ]
σ 2π

c. M-PSK:

When using M-ary Phase Shift Keying, data bits choose one of M phase-shifted carriers to
transfer the data over. Thus, each of the M possible waveforms has a distinct phase but the
same amplitude and frequency. The signal constellations consist of M equally spaced points
on a circle of radius ϵ𝑠centered at the origin where ϵ𝑠, is the common energy of the PSK
waveform. In general, PSK waveforms are of the following form:
𝑢𝑚(𝑡) = 𝑝(𝑡)𝑐𝑜𝑠(2π𝑓𝑐𝑡 + ϕ𝑚)
2π𝑚
where ϕ𝑚 = 𝑀
, m = 0,1,2..., M-1
for the special case where p(t) is a rectangular baseband pulse, we have

by expanding the cosine term we may express 𝑢𝑚(𝑡) as


𝑢𝑚(𝑡) = 𝑔𝑇 (𝑡)𝑐𝑜𝑠(2π𝑚/𝑀)𝑐𝑜𝑠(2π𝑓𝑐𝑡) − 𝑔𝑇 (𝑡)𝑠𝑖𝑛(2π𝑚/𝑀)𝑠𝑖𝑛(2π𝑓𝑐𝑡)

Geometric Representation:
Digital phase-modulated signals can be represented geometrically as two-dimensional
vectors with components ϵ𝑠𝑐𝑜𝑠(2π𝑚/𝑀) and ϵ𝑠𝑠𝑖𝑛(2π𝑚/𝑀)

𝑠𝑚 = ( ϵ𝑠𝑐𝑜𝑠(2π𝑚/𝑀), ϵ𝑠𝑠𝑖𝑛(2π𝑚/𝑀))
Thus we can find the Euclidean distance between two signal points in a constellation
2
𝑑𝑚 = ||𝑠𝑚 − 𝑠𝑛||
2π(𝑚 − 𝑛)
= 2ϵ𝑠(1 − 𝑐𝑜𝑠( 𝑀
)
for adjacent signal points the minimum Euclidean distance
π
𝑑𝑚𝑖𝑛 = 2 ϵ𝑠𝑠𝑖𝑛 𝑀

Demodulation and Detection:

The received bandpass signal from an AWGN channel in a signalling interval 0 ≤ 𝑡 ≤ 𝑇, may
be expressed as:
𝑟(𝑡) = 𝑢𝑚(𝑡) + 𝑛(𝑡)
= [𝐴𝑚𝑐𝑔𝑇 (𝑡) + 𝑛𝑐(𝑡)]𝑐𝑜𝑠(2𝑓𝑐𝑡) − [𝐴𝑚𝑠𝑔𝑇 (𝑡) + 𝑛𝑠(𝑡)]𝑠𝑖𝑛(2𝑓𝑐𝑡)
m = 0, 2, ..., M − 1
where 𝑛(𝑡) is the additive bandpass Gaussian noise and 𝐴𝑚𝑐 and 𝐴𝑚𝑠 are the information
bearing signal components that are related to the transmitted carrier phase.

Because all signals have equal energy, an equivalent detector metric for digital phase
modulation is to compute the phase of the received signal vector and select the signal from
the set sm whose phase is closest to r.
𝑟2
𝑟 = (𝑟1, 𝑟2)𝑟 = 𝑡𝑎𝑛 − 1 ( 𝑟1
)

We evaluate the probability of error based on this phase metric.

Probability of Error in AWGN:

In this calculation, the best detector will be chosen based on the phase metric described in
the subsection above. The received carrier phase may be perfectly estimated, it is
presumed.

The probability of a symbol error is


π/2
𝑃𝑀 = 1 ∫ 𝑓(θ𝑟)(θ) 𝑑θ
π/2

d. M-QAM:

QAM is the encoding of the information into a carrier wave by variation of the amplitude of
both the carrier wave and a “quadrature” carrier that is 90° out of phase with the main carrier
in accordance with two input signals. That is, the amplitude and the phase of the carrier
wave are simultaneously changed according to the information needed to transmit. It is such
a class of non-constant envelope schemes that can achieve higher bandwidth efficiency than
M-PSK with the same average signal power. Thus, the transmitted QAM signal waveforms
may be expressed as

𝑢𝑚𝑛 = 𝐴𝑚𝑔𝑇 (𝑡)𝑐𝑜𝑠(2𝑓𝑐𝑡 + θ𝑛)

Geometric Representation

The geometric signal representation of the signals is in terms of two-dimensional signal


vectors of the form
𝑠𝑚 = ( ϵ𝑠𝑐𝑜𝑠(2π𝑚/𝑀), ϵ𝑠𝑠𝑖𝑛(2π𝑚/𝑀))

Demodulation and Detection

The received QAM signal is corrupted by additive Gaussian noise. The received signal r(t) is
cross-correlated with the orthogonal basis functions, and the output of the cross correlators
is sampled at time t = T to yield the vector. The optimum detector computes the distance
metrics and selects the signal corresponding to the smallest value If a correlation metric is
used in place of a distance metric, it is important to recognize that correlation metrics must
employ bias correction because the QAM signals are not equal to energy signal

Probability of Error in AWGN

To determine the probability of error for QAM, we must specify the signal-point constellation.
The average transmitted signal energy is where (amc, ams) are the normalized coordinates
of the signal locations, assuming that the signal sites are equally probable. Because they are
so simple to create, rectangular QAM signal constellations offer the clear advantage of
being.

In addition, they are easily demodulated. Although they are not the best Mary QAM signal
constellations for M-16, the average transmitted energy required to achieve a given
minimum distance is only slightly greater than the average energy required for the best M
-ary QAM signal constellation. For these reasons, rectangular M -ary QAM signals are most
frequently used in practice. For rectangular signal constellations in which M =K, K is even,
𝑘
𝑀 = 2 the QAM signal constellation is equivalent to two PAM signals in quadrature
carriers, each having a signal point imprinted on phase-quadrature carriers are two PAM
signals.

c) Pseudocode:
For BPSK:
clear cache and screen

generate random inputs of a large size with zeros and ones as input

modify input data with relation 2*input_data -1 for mapping it to 1,-1

generate an array of ones and zeros based on the boolean expression bpsk_mod == 1
generate constellation values of-1,1

declare snr from 1 to desired value

loop from 1 to snr values

generate channel output of constellation after passing through awgn channel

generate error values using channel input and channel output

compute bit error rate using formula sum(error)/length(error)

compute bit error rate using inbuilt function

end loop

plot graphs of snr and manually computed BER on log scale

plot graphs of snr and Theoretical BER on log scale

plot scatterplots of constellation diagrams with noise and without noise

For QPSK:
clear cache and screen

generate random inputs of a large size with zeros and ones as input

loop from 1 to number of input values with increment 2


calculate decimal values from binary input with block size two

map the complex constellation values from the generated decimal values

end loop

declare snr from 1 to desired value

loop from 1 to snr value

generate channel output of constellation after passing through awgn channel

generate error values for real part and imaginary part from the constellation input and
output of the channel

if (real part error or imaginary part error <=0)


error is present

compute bit error rate using formula sum(error)/length(error)

compute bit error rate using inbuilt function


end loop

plot graphs of snr and manually computed BER on log scale

plot graphs of snr and Theoretical BER on log scale

plot scatterplots of constellation diagrams with noise and without noise

For 8-PSK:
clear cache and screen

generate random inputs of a large size with zeros and ones as input

loop from 1 to number of input values with increment 3

calculate decimal values from binary input with block size three

map the complex constellation values from the generated decimal values

end loop

calculate phase value of the generated complex constellation values

declare snr from 1 to desired value

loop from 1 to snr value

generate channel output of constellation after passing through awgn channel

compute phase of constellation after adding noise

calculate error from the absolute difference of phase values before and after adding noise

if(error > pi/8)


error is present

compute bit error rate using formula sum(error)/length(error)

compute bit error rate using inbuilt function

end loop

plot graphs of snr and manually computed BER on log scale

plot graphs of snr and Theoretical BER on log scale

plot scatterplots of constellation diagrams with noise and without noise

For 4-QAM:
clear cache and screen
generate random inputs of a large size with zeros and ones as input

modify input data with relation 2*input_data -1 for mapping it to 1,-1

generate two carrier signals with phase difference 90 degrees

loop from 1 to to half of input data count


store the odd_indexed_input and even_indexed_input separately
end loop

generate qam with relation odd_indexed_input*carrier_wave_1 +


even_indexed_input*carrier_wave_2

generate the phase of the complex qam values

declare snr from 1 to desired value

loop from 1 to snr value

generate channel output of constellation after passing through awgn channel

compute phase of constellation after adding noise

calculate error from the absolute difference of phase values before and after adding noise

if(error > pi/4)


error is present

compute bit error rate using formula sum(error)/length(error)

compute bit error rate using inbuilt function

end loop

plot graphs of snr and manually computed BER on log scale

plot graphs of snr and Theoretical BER on log scale

plot scatterplots of constellation diagrams with noise and without noise

For 16-QAM:
clear cache and screen

generate random inputs of a large size with zeros and ones as input

generate the input data

generate the qam modulated signal

declare snr from 1 to desired value

loop from 1 to snr value


generate channel output qam modulated signal after passing through awgn channel
demodulate the channel output

calculate the error from the demodulated output and input

compute the theoretical bit error

end loop

plot graphs of snr and manually computed BER on log scale

plot graphs of snr and Theoretical BER on log scale

plot scatterplots of constellation diagrams with noise and without noise

d) Settings and results:


a)Discussion of settings used in simulation:
For all kinds of modulations:
● Number of input data samples: 20000
● To generate the binary input data, MATLAB function “randi” is used.
● MATLAB function “awgn” is used to create a noisy channel.
● SNR(Signal to Noise ratio) is varied from 1 to 10.
● MATLAB function “berawgn” is used to obtain the theoretical SNR plot.
b) Results:
For Phase Shift Keying:
Constellation diagram of BPSK (without noise):
Constellation diagram of BPSK (with noise):
For SNR = 5dB:

For SNR = 25dB:


Constellation diagram of QPSK (without noise):

Constellation diagram of QPSK (with noise):


For SNR = 5dB:
For SNR = 25dB:

Constellation diagram of 8-PSK (without noise):


Constellation diagram of 8-PSK (with noise):
For SNR = 5dB:

For SNR = 25dB:


SNR vs BER plot for BPSK compared with the theoretical curve:

SNR vs BER plot for QPSK compared with the theoretical curve:
SNR vs BER plot for 8-PSK compared with the theoretical curve:

SNR vs BER plots for different PSK schemes:


For Quadrature Amplitude Modulation:
Constellation diagram of 4-QAM (without noise):

Constellation diagram of 4-QAM (with noise):


For SNR = 5dB:
For SNR = 25dB:

For Qaudrature Amplitude Modulation:


Constellation diagram of 16-QAM (without noise):
Constellation diagram of 16-QAM (with noise):
For SNR = 5dB:

For SNR = 25dB:


SNR vs BER plot for 4-QAM compared with the theoretical curve:

SNR vs BER plot for 16-QAM compared with the theoretical curve:
e) Conclusion:
For M-PSK:
● We can observe from the constellation diagrams of the M-PSK that for higher SNR
values constellation diagrams look more similar to the theoretical ones this can be
evident from the fact that for higher SNR, signal power will be high compared to
noise power so the information can be made decoded more accurately.
● When we observe the SNR vs BER curves for M-PSK’s compared with the
theoretical curves we can see that when M = 2 the curve looks more similar to the
theoretical one but when M = 4 or 8 there is a significant difference in the two curves
this is because the obtained curve is a more approximated compared to the
theoretical one.
● When we put all the SNR vs BER curves in one frame we can see that for the same
BER the value of SNR is increasing for higher orders of M, which implies that more
power is required to maintain the same BER for higher orders of M.
For M-QAM:
● We can observe from the constellation diagram that a similar inference can be drawn
for QAM compared to PSK,
● We can observe from the plots that for QAM, as the M value increases, a higher
amount of power is required to achieve the same amount of BER. We can also see
that QPSK and 4QAM are identical. One of the main advantages of QAM lies in the
fact that it modulates both amplitudes as well as phase, making QAM more spectrally
efficient than PSK. This means that QAM can transmit more bits per second over the
same channel width.
● BER is inversely proportional to the minimum distance between two adjacent
symbols (dmin). So, decreasing dmin will increase BER. For an M value greater than
4, QAM has a greater dmin than PSK, resulting in a lower BER and better
performance.

f) Appendix:
Code for BPSK:
close all;

clear all;

clc;

% bpsk without noise

M = 2;

num_data = 20000;

input_data= randi([0 1],1,num_data);

bpsk_mod = 2*input_data -1;

m = (bpsk_mod == 1);

constellation = exp(-1j*2*pi*m/M);

% snr = 25;

ber = zeros(1,10);

bert = zeros(1,10);

i = 1;

snr = 1:1:10;
for out = snr

% bpsk with noise

constellation_noise = awgn(constellation, out, 'measured');

% ber

error = constellation_noise.*constellation;

error = (error<0);

ber(i) = sum(error)/length(error);

bert(i) = berawgn(out,'psk',M,'non-diff');

i = i +1;

end

semilogy(snr,ber);

hold on

semilogy(snr,bert);

legend('ber bpsk','ber therotical');

hold off

title("SNR vs BER");

scatterplot(constellation);

scatterplot(constellation_noise);

Code for QPSK:


close all;

clear all;

clc;

% qpsk without noise

M = 4;

m = [0,1,2,3];

num_data = 10000;

input_data= randi([0 1],1,num_data);

constellation = [];

for i = 1:2:num_data

switch(input_data(i)*1 + input_data(i+1)*2)

case 0

m = 0;

case 1

m = 1;

case 2

m = 2;
case 3

m = 3;

end

constellation = [constellation exp(-1j*2*pi*m/M)];

end

snr = 5;

ber = zeros(1,10);

bert = zeros(1,10);

% qpsk with noise

constellation_noise = awgn(constellation, snr, 'measured');

i = 1;

snr = 1:1:10;

% demodulation

for out = snr

% qpsk with noise

constellation_noise = awgn(constellation, out, 'measured');

% ber

error1 = real(constellation_noise).* real(constellation);

error2 = imag(constellation_noise).*imag(constellation);

error = ((error1<-1.2246e-16) | (error2<-1.2246e-16)) ;

ber(i) = sum(error)/length(error);

bert(i) = berawgn(out,'psk',M,'non-diff');

i = i+1;

end

semilogy(snr,ber);

hold on

semilogy(snr,bert);

legend('ber qpsk','ber therotical');

hold off

title("SNR vs BER");

scatterplot(constellation);

scatterplot(constellation_noise);

Code for 8-PSK:


close all;

clear all;
clc;

% qpsk without noise

M = 8;

m = [0,1,2,3];

num_data = 3*10000;

input_data= randi([0 1],1,num_data);

constellation = [];

for i = 1:3:num_data

switch(input_data(i)*1 + input_data(i+1)*2+input_data(i+2)*4)

case 0

m = 0;

case 1

m = 1;

case 2

m = 2;

case 3

m = 3;

case 4

m = 4;

case 5

m = 5;

case 6

m = 6;

case 7

m = 7;

end

constellation = [constellation exp(-1j*2*pi*m/M)];

end

phase_without_noise = atan(imag(constellation)./real(constellation));

snr = 5;

ber = zeros(1,10);

bert = zeros(1,10);

% qpsk with noise

constellation_noise = awgn(constellation, snr, 'measured');

i = 1;

theta = pi/M;

snr = 1:1:10;
% demodulation

for out = snr

% bpsk with noise

constellation_noise = awgn(constellation, out, 'measured');

phase_with_noise =
atan(imag(constellation_noise)./real(constellation_noise));

error1 = abs(mod(phase_with_noise,2*pi) -
mod(phase_without_noise,2*pi));

error = (error1 > theta) ;

ber(i) = sum(error)/length(error);

bert(i) = berawgn(out,'psk',M,'non-diff');

i = i+1;

end

semilogy(snr,ber);

hold on

semilogy(snr,bert);

legend('ber 8psk','ber therotical');

hold off

title("SNR vs BER");

scatterplot(constellation);

scatterplot(constellation_noise);

Code for 4-QAM:


clc;

close all;

clear all;

%QAM with out noise

M = 4;

num_data = 20000;

input_data= randi([0,1],1,num_data);

q = 2*input_data -1;

qam_mod = zeros(1,num_data/2);

inp_q = zeros(1,num_data/2);

inp_i = zeros(1,num_data/2);

%QAM modulation

p = 1;

k = 2;

% carq = cos(2*pi/M);
carq = 1j;

cari = 1;

% cari = sin(2*pi/M);

for i = 1:1:num_data/2

inp_i(i) = q(p);

inp_q(i) = q(k);

k = k+2;

p = p+2;

end

qam_mod = inp_i.*cari + inp_q.*carq;

phase_without_noise = atan(imag(qam_mod)./real(qam_mod));

snr = 10;

constellation_noise = awgn(qam_mod, snr, 'measured');

%ber

i = 1;

theta = pi/M;

snr = 1:1:10;

% demodulation

for out = snr

% bpsk with noise

constellation_noise = awgn(qam_mod, out, 'measured');

phase_with_noise =
atan(imag(constellation_noise)./real(constellation_noise));

error1 = abs(mod(phase_with_noise,2*pi) -
mod(phase_without_noise,2*pi));

error = (error1 > theta) ;

ber(i) = sum(error)/length(error);

bert(i) = berawgn(out,'qam',M,'non-diff');

i = i+1;

end

semilogy(snr,ber);

hold on

semilogy(snr,bert);

legend('ber 4qam','ber therotical');

hold off

title("SNR vs BER");

scatterplot(qam_mod);
scatterplot(constellation_noise);

Code for 16-QAM:


clc;

clear all;

close all;

%16-QAM

M = 16;

num_data = 20000;

input_data= randi([0,M-1],1,num_data);

qam_mod = qammod(input_data,M);

snr = 35;

qam_mod_noise = awgn(qam_mod, snr, 'measured');

i = 1;

snr = 1:1:10;

% demodulation

for out = snr

qam_mod_noise = awgn(qam_mod, out, 'measured');

qamout = qamdemod(qam_mod_noise,M);

[num ,ber(out)] = biterr(input_data,qamout);

bert(out) = berawgn(out,'qam',M,'non-diff');

end

figure();

semilogy(snr,ber);

hold on

semilogy(snr,bert);

legend('ber 16qam','ber therotical');

hold off

title("SNR vs BER");

scatterplot(qam_mod);

scatterplot(qam_mod_noise);

You might also like