Professional Documents
Culture Documents
Date: 04/01/2024
AIM:
Implement and simulate the various modulation schemes and analyze their performance.
THEORY:
Digital modulation schemes are techniques used to encode digital data onto an analog carrier
signal for transmission over communication channels. These schemes are essential in modern
communication systems, enabling efficient utilization of bandwidth and robust transmission of
data. Various digital modulation schemes differ in how they encode digital information onto the
carrier signal, each with its own advantages and disadvantages in terms of bandwidth efficiency,
power efficiency, and susceptibility to noise and interference. Here, we'll discuss some
commonly used digital modulation schemes and analyze their performance characteristics:
Amplitude Modulation (AM) is a modulation technique where the amplitude of a carrier signal
is varied in accordance with the amplitude of a modulating signal (message signal).
Frequency Modulation (FM) is a modulation technique where the frequency of a carrier signal is
varied in accordance with the amplitude of a modulating signal (message signal).
Frequency Shift Keying (FSK) is a digital modulation technique where the frequency of the
carrier signal is varied to represent digital data. In FSK modulation, different frequencies
represent different symbols.
Phase Shift Keying (PSK) is a digital modulation technique where the phase of the carrier signal
is varied to represent digital data. In PSK modulation, different phase shifts represent different
symbols.
CODE:
clc;
clear all;
for i=1:length_bitStream
for j=(i-1)*100:i*100
if bitStream(i)==1
g(j+1)=carrier1(j+1)./carrier1(j+1);
else
g(j+1)=0;
end
end
end
%FSK Plotting
subplot(5,1,1)
stairs(bitStream)
axis([1 7 -1 1])
title('Given Sequence U21EC109');
subplot(5,1,2)
plot(time,carrier1)
title('Carrier Signal of Frequencey 30');
subplot(5,1,3)
plot(time,carrier2)
title('Carrier Signal of Frequencey 60');
subplot(5,1,4)
plot(y)
title('FSK Modulation U21EC109');
axis([0 600 -6 6])
subplot(5,1,5)
plot(g)
title('FSK Demodulation U21EC109')
2
AM Modulation and Demodulation
clc;
clear all;
close all;
f = 1;
Fc = 10;
Fs = 100;
t = 0:1/Fs:5;
s = sin(2*pi*f*t); % Original signal
c = sin(2*pi*Fc*t);
subplot(4,1,1)
plot(t,s);
xlabel('time')
ylabel('amplitude')
title('original signal');
subplot(4,1,2)
plot(t,c);
xlabel('time')
ylabel('amplitude')
title('carrier signal');
y1 = ammod(s,Fc,Fs); % Modulate.
d1 = amdemod(y1,Fc,Fs); % Demodulate.
subplot(4,1,3)
plot(t,y1);
xlabel('time')
ylabel('amplitude')
title('AM modulated U21EC109')
subplot(4,1,4)
plot(t,d1);
xlabel('time')
ylabel('amplitude')
title('AM demodulated U21EC109')
figure;
3
Frequency Modulation and Demodulation
clc
close all;
subplot(4,1,1)
plot(t, s);
xlabel('Time')
ylabel('Amplitude')
title('Original Signal U21EC109')
subplot(4,1,2)
plot(t, c);
xlabel('Time')
ylabel('Amplitude')
title('Carrier Signal U21EC109')
subplot(4,1,3)
plot(t, y)
xlabel('Time')
ylabel('Amplitude')
title('Modulated FM Signal U21EC109')
subplot(4,1,4);
plot(t, z)
xlabel('Time')
ylabel('Amplitude')
title('Demodulated FM Signal U21EC109')
4
PSK Modulation and Demodulation
clc;
clear all;
close all;
x=[ 1 0 0 1 1 0 1]; % Binary Information
bp=.000001; % bit period
disp(' Binary information at Trans mitter :');
disp(x);
bit=[];
for n=1:1:length(x)
if x(n)==1;
se=ones(1,100);
else x(n)==0;
se=zeros(1,100);
end
bit=[bit se];
end
t1=bp/100:bp/100:100*length(x)*(bp/100);
subplot(3,1,1);
plot(t1,bit,'lineWidth',2.5);grid on;
axis([ 0 bp*length(x) -.5 1.5]);
ylabel('amplitude');
xlabel(' time');
title('Original Signal U21EC109');
a=1;
else
a=0;
end
mn=[mn a];
end
disp(' Binary information at Reciver :');
disp(mn);
bit=[];
for n=1:length(mn);
if mn(n)==1;
se=ones(1,100);
else mn(n)==0;
se=zeros(1,100);
end
bit=[bit se];
end
t4=bp/100:bp/100:100*length(mn)*(bp/100);
subplot(3,1,3)
plot(t4,bit,'LineWidth',2.5);grid on;
axis([ 0 bp*length(mn) -.5 1.5]);
ylabel('amplitude');
xlabel(' time');
title('Demodulated Signal U21EC109');
CONCLUSION:
6
7
Date: 09/01/2024
AIM
8
EXPERIMENT 2
AIM: Implement and simulate the M-PSK modulation technique with OFDM on an AWGN
channel with the help of MATLAB where M=2,4,16.Plot BER vs SNR.
THEORY
M-PSK Modulation:
M-PSK (M-Phase Shift Keying) is a digital modulation scheme where the phase of the carrier
signal is varied to represent different symbols. In M-PSK modulation, the carrier signal is
divided into M equidistant phase states, each representing a unique symbol. For example, in 4-
PSK, there are four phase states (0°, 90°, 180°, and 270°) representing four symbols.
OFDM is a modulation technique used in digital communication systems to transmit data over a
wide bandwidth efficiently. It divides the available spectrum into multiple orthogonal
subcarriers, each carrying a narrowband signal. By spacing the subcarriers at precise intervals,
OFDM can mitigate inter-symbol interference (ISI) and frequency-selective fading.
clc;
close all;
E = -10:2:10;
N = 1;
SNRdb = E/N;
i = 1000;
subc = 256;
modulation_orders = [2,4,16]; % modualtion order
num_modulations = length(modulation_orders);
BER = zeros(num_modulations, length(SNRdb)); % BER matrix
% Plot colors for different M values
CONCLUSION:
10
EXPERIMENT 3
Date: 16/01/2024
AIM
Implement and simulate the M-PSK modulation technique with OFDM on a single-tap Rayleigh
fading channel with AWGN where M=2,4,16.Plot BER vs SNR.
THEORY
M-PSK Modulation:
M-PSK (M-Phase Shift Keying) is a digital modulation technique where the phase of the carrier
signal is modulated to represent digital symbols. In M-PSK, the carrier signal is divided into M
equidistant phase states, each representing a unique symbol. For example, in 4-PSK, there are
four phase states (0°, 90°, 180°, and 270°) representing four symbols.
11
CODE:
clc;
close all;
E = -10:2:10;
N = 1;
SNRdb = E/N;
i = 1000;
subc = 256;
no_taps = 1;
12
bit_errors = sum(B ~= R2); %calculating error in bits recieved
BER(mod_index, m) = BER(mod_index, m) + bit_errors; %updating number of bit errors
end
end
BER(mod_index, :) = BER(mod_index, :) / (i * subc * log2(M)); %Normalizing BER in all elements present in row
% Plot SNR vs BER for the current modulation order on the same figure
semilogy(SNRdb, BER(mod_index, :), '-o', 'Color', colors{mod_index}, 'DisplayName', sprintf('M=%d', M));
hold on;
end
toc
hold on;
grid on;
xlabel('SNR (dB)');
ylabel('Bit Error Rate (BER)');
title('SNR vs BER for M=2,4,16 U21EC109');
legend('show');
CONCLUSION:
13
EXPERIMENT 4
Date: 23/01/2024
AIM
Implement and simulate the M-PSK modulation technique with OFDM on a single-tap Rician
fading channel with AWGN where M=2,4,16 for different values of the Rician k factor.Plot BER
vs SNR.
THEORY
Combining efficient M-PSK modulation (e.g., QPSK) with OFDM, we can send data over a
single-tap Rician fading channel (combining line-of-sight and scattered paths) with AWGN.
The modulated data spreads across multiple subcarriers, mitigating Rician fading's impact, but
higher-order M-PSK trades noise tolerance for spectral efficiency. We simulate this by
generating data, modulating it, transmitting through the modeled channel with noise, then
demodulating and comparing recovered data to evaluate performance (e.g., BER/SER) under
different scenarios. Remember, this theoretical foundation needs adjustments for real-world
complexities like imperfect channel estimation and synchronization errors.
CODE:
1) For Different K values
clc;
clear all;
figure;
E = -10:2:10;
N = 1;
SNRdb = E/N;
i = 1000;
subc = 256;
modulation_orders = 2;
z = [1 2 4];
num_modulations = length(z);
BER = zeros(num_modulations,length(SNRdb));
colors = {'b','g','r'};
14
d = bi2de(T);
D = d';
t = 1;
Y = pskmod(D,M);
noise = sqrt(N/2)*(randn(1,subc)+1j*randn(1,subc));
V = sqrt(2*k);
h_amp = (randn(1,t) + 1i*randn(1,t)) / sqrt(2) + V ;
h_mag = abs(h_amp);
theta = rand(1,t)*2*pi;
fadingChannel = h_mag.*(cos(theta) + 1i*sin(theta));
for m = 1:length(SNRdb)
SNR = 10^(SNRdb(m)/10);
scl = Y* sqrt(SNR);
inverse = sqrt(subc)*ifft(scl);
signal = inverse.*fadingChannel + noise;
reverse = sqrt(1/subc)*fft(signal);
for in = 1:t
reverse= reverse.*fadingChannel(in)*(1/(fadingChannel*fadingChannel));
end
demodulation = pskdemod(reverse,M);
D2 = demodulation;
d2 = de2bi(D2);
T2 = d2';
if log2(M) == 1
R2 = T2;
else
R2 = reshape(T2,1,[]);
end
bit_errors = sum(B~=R2);
BER(mod_index,m) = BER(mod_index,m) + bit_errors;
end
end
BER(mod_index, :) = BER(mod_index, :) /(i* subc*log2(M));
semilogy(SNRdb, BER(mod_index,:),'-o','Color',colors{mod_index},'DisplayName',sprintf('K=%d',k));
hold on;
end
hold off;
grid on;
xlabel('SNR(dB)');
ylabel('Bit Error Rate(BER)');
title('SNR vs BER for Different K U21EC109');
legend('show');
15
2) With Different modulation orders
clc;
clear all;
figure;
E = -10:2:10;
N = 1;
SNRdb = E/N;
i = 1000;
subc = 256;
modulation_orders = [2,4,16];
num_modulations = length(modulation_orders);
BER = zeros(num_modulations,length(SNRdb));
colors = {'b','g','r'};
for n = 1:i
B = randi([0 1],1,subc*log2(M));
R = reshape(B,log2(M),subc);
T = R';
d = bi2de(T);
D = d';
t = 1;
k = 4;
Y = pskmod(D,M);
noise = sqrt(N/2)*(randn(1,subc)+1j*randn(1,subc));
V = sqrt(2*k);
h_amp = (randn(1,t) + 1i*randn(1,t)) / sqrt(2) + V ;
h_mag = abs(h_amp);
theta = rand(1,t)*2*pi;
fadingChannel = h_mag.*(cos(theta) + 1i*sin(theta));
for m = 1:length(SNRdb)
SNR = 10^(SNRdb(m)/10);
scl = Y* sqrt(SNR);
inverse = sqrt(subc)*ifft(scl);
signal = inverse.*fadingChannel + noise;
reverse = sqrt(1/subc)*fft(signal);
for in = 1:t
reverse = reverse.*fadingChannel(in)*(1/(fadingChannel*fadingChannel));
end
demodulation = pskdemod(reverse,M);
D2 = demodulation;
d2 = de2bi(D2);
T2 = d2';
if log2(M) == 1
R2 = T2;
else
R2 = reshape(T2,1,[]);
end
bit_errors = sum(B~=R2);
16
BER(mod_index,m) = BER(mod_index,m) + bit_errors;
end
end
BER(mod_index, :) = BER(mod_index, :) /(i* subc*log2(M));
semilogy(SNRdb, BER(mod_index,:),'-o','Color',colors{mod_index},'DisplayName',sprintf('M=%d',M));
hold on;
end
hold off;
grid on;
xlabel('SNR(dB)');
ylabel('Bit Error Rate(BER)');
title('SNR vs BER for Different Modulation orders U21EC109');
legend('show');
clc;
close all;
E = -10:2:10;
N = 1;
SNRdb = E/N;
i = 1000;
subc = 256;
modulation_orders = [2];
num_modulations = length(modulation_orders);
BER = zeros(num_modulations,length(SNRdb));
BER_fadding = zeros(num_modulations,length(SNRdb));
BER_fadding1 = zeros(num_modulations,length(SNRdb));
colors = {'b','g','r'};
for n = 1:i
B = randi([0 1],1,subc*log2(M));
R = reshape(B,log2(M),subc);
T = R';
t = 1;
d = bi2de(T);
D = d';
Y = pskmod(D,M);
noise = sqrt(N/2)*(randn(1,subc)+1j*randn(1,subc));
fadingChannel = (randn(1,t)+ 1i * randn(1,t)) / sqrt(2);
k = 1;
V = sqrt(2*k);
h_amp = (randn(1,t) + 1i*randn(1,t)) / sqrt(2) + V ;
h_mag = abs(h_amp);
theta = rand(1,t)*2*pi;
fadingChannel1 = h_mag.*(cos(theta) + 1i*sin(theta));
for m = 1:length(SNRdb)
SNR = 10^(SNRdb(m)/10);
17
scl = Y* sqrt(SNR);
inverse = sqrt(subc)*ifft(scl);
signal2 = inverse.*fadingChannel1 + noise;
signal1 = inverse.*fadingChannel + noise;
signal = inverse + noise;
reverse2 = sqrt(1/subc)*fft(signal2);
reverse = sqrt(1/subc)*fft(signal);
reverse1 = sqrt(1/subc)*fft(signal1);
for in = 1:t
reverse1 = reverse1.*fadingChannel(in)*(1/(fadingChannel*fadingChannel));
reverse2 = reverse2.*fadingChannel1(in)*(1/(fadingChannel1*fadingChannel1));
end
demodulation = pskdemod(reverse,M);
demodulation1 = pskdemod(reverse1,M);
demodulation2 = pskdemod(reverse2,M);
D2 = demodulation;
d2 = de2bi(D2);
d3 = de2bi(demodulation1);
d4 = de2bi(demodulation2);
T2 = d2';
T3 = d3';
T4 = d4';
if log2(M) == 1
R2 = T2;
R3 = T3;
R4 = T4;
else
R2 = reshape(T2,1,[]);
R3 = reshape(T3,1,[]);
R4 = reshape(T4,1,[]);
end
bit_errors = sum(B~=R2);
bit_errors_fadding = sum(B~=R3);
bit_errors_fadding1 = sum(B~=R4);
BER(mod_index,m) = BER(mod_index,m) + bit_errors;
BER_fadding(mod_index,m) = BER_fadding(mod_index,m) + bit_errors_fadding;
BER_fadding1(mod_index,m) = BER_fadding1(mod_index,m) + bit_errors_fadding1;
end
end
BER(mod_index, :) = BER(mod_index, :) /(i* subc*log2(M));
BER_fadding(mod_index, :) = BER_fadding(mod_index, :) /(i* subc*log2(M));
BER_fadding1(mod_index, :) = BER_fadding1(mod_index, :) /(i* subc*log2(M));
end
hold off;
grid on;
xlabel('SNR(dB)');
18
ylabel('Bit Error Rate(BER)');
title('SNR vs BER for Different type of channel');
legend('show');
CONCLUSION:
19