A9 Exp3
A9 Exp3
Group: A9
02-09-2022
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
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 ϵ𝑠𝑠𝑖𝑛 𝑀
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
)
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.
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
Geometric Representation
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
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
generate an array of ones and zeros based on the boolean expression bpsk_mod == 1
generate constellation values of-1,1
end loop
For QPSK:
clear cache and screen
generate random inputs of a large size with zeros and ones as input
map the complex constellation values from the generated decimal values
end loop
generate error values for real part and imaginary part from the constellation input and
output of the channel
For 8-PSK:
clear cache and screen
generate random inputs of a large size with zeros and ones as input
calculate decimal values from binary input with block size three
map the complex constellation values from the generated decimal values
end loop
calculate error from the absolute difference of phase values before and after adding noise
end loop
For 4-QAM:
clear cache and screen
generate random inputs of a large size with zeros and ones as input
calculate error from the absolute difference of phase values before and after adding noise
end loop
For 16-QAM:
clear cache and screen
generate random inputs of a large size with zeros and ones as input
end loop
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 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;
M = 2;
num_data = 20000;
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
% 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);
hold off
title("SNR vs BER");
scatterplot(constellation);
scatterplot(constellation_noise);
clear all;
clc;
M = 4;
m = [0,1,2,3];
num_data = 10000;
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
end
snr = 5;
ber = zeros(1,10);
bert = zeros(1,10);
i = 1;
snr = 1:1:10;
% demodulation
% ber
error2 = imag(constellation_noise).*imag(constellation);
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);
hold off
title("SNR vs BER");
scatterplot(constellation);
scatterplot(constellation_noise);
clear all;
clc;
M = 8;
m = [0,1,2,3];
num_data = 3*10000;
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
end
phase_without_noise = atan(imag(constellation)./real(constellation));
snr = 5;
ber = zeros(1,10);
bert = zeros(1,10);
i = 1;
theta = pi/M;
snr = 1:1:10;
% demodulation
phase_with_noise =
atan(imag(constellation_noise)./real(constellation_noise));
error1 = abs(mod(phase_with_noise,2*pi) -
mod(phase_without_noise,2*pi));
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);
hold off
title("SNR vs BER");
scatterplot(constellation);
scatterplot(constellation_noise);
close all;
clear all;
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
phase_without_noise = atan(imag(qam_mod)./real(qam_mod));
snr = 10;
%ber
i = 1;
theta = pi/M;
snr = 1:1:10;
% demodulation
phase_with_noise =
atan(imag(constellation_noise)./real(constellation_noise));
error1 = abs(mod(phase_with_noise,2*pi) -
mod(phase_without_noise,2*pi));
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);
hold off
title("SNR vs BER");
scatterplot(qam_mod);
scatterplot(constellation_noise);
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;
i = 1;
snr = 1:1:10;
% demodulation
qamout = qamdemod(qam_mod_noise,M);
bert(out) = berawgn(out,'qam',M,'non-diff');
end
figure();
semilogy(snr,ber);
hold on
semilogy(snr,bert);
hold off
title("SNR vs BER");
scatterplot(qam_mod);
scatterplot(qam_mod_noise);