You are on page 1of 15

Name: Dev Mehta Date: 7th September, 2021

Registration no.: 19BEC1300


Experiment 6
Bandpass Modulation and Demodulation Technique

Aim: To illustrate the following binary bandpass modulation


1. Binary amplitude shift keying
2. Binary frequency shift keying
3. Binary phase shift keying
To illustrate AWGN for various SNR values and demodulation of the binary
bandpass modulated signal.

MATLAB Code:

clc;
clear all;
close all;
%initaize
b=[1 0 1 0 1 1 0 0];
f1=100;
f2=50;
fs=1000;
%generating carrier signal
t=0:1/10000:2/f1;
c1=cos(2*pi*f1*t);
%carrier 1
c2=cos(2*pi*f2*t);
%carrier 2
%defining the energy of carrier E=inegtral(x^2)t
e1=sum(c1.^2);
%energy of carrier 1
e2=sum(c2.^2);
%energy of carrier 1
%define the signal ASK, PSK,and FSK in normalized energy
%ASK
Sa1=1*c1/sqrt(e1);
Sa0=0*c1/sqrt(e1);
%FSK
Sf1=1*c1/sqrt(e1);
Sf0=1*c2/sqrt(e2);
%PSK
Sp1=1*c1/sqrt(e1);
Sp0=-1*c1/sqrt(e1);
%binary modulation
ask=[];
fsk=[];
psk=[];
for i=1:length(b)
if b(i)==1
ask=[ask,Sa1]
fsk=[fsk,Sf1]
psk=[psk,Sp1]
else
ask=[ask,Sa0]
fsk=[fsk,Sf0]
psk=[psk,Sp0]
end
end
figure(1)
subplot(6,1,1)
stem(b,'b','linewidth',2);
title('Binary signal ')
xlabel('Time ')
ylabel('Amplitude')

subplot(6,1,2)
plot(c1,'g','linewidth',2);
xlim([0,200]);
title('carrier 1')
xlabel('Time ')
ylabel('Amplitude')

subplot(6,1,3)
plot(c2,'y','linewidth',2);
xlim([0,200]);
title('carrier 2')
xlabel('Time ')
ylabel('Amplitude')

subplot(6,1,4)
plot(ask,'g','linewidth',2);
xlim([0,1600]);
title('Amplitude shift key')
xlabel('Time ')
ylabel('Amplitude')

subplot(6,1,5)
plot(fsk,'m','linewidth',2);
xlim([0,1600]);
title('frequency shift key')
xlabel('Time ')
ylabel('Amplitude')

subplot(6,1,6)
plot(psk,'c','linewidth',2);
xlim([0,1600]);
title('phase shift key')
xlabel('Time ')
ylabel('Amplitude')

%modulation and detection


askd=[];fskd=[];pskd=[];
SNR=2;
askn=awgn(ask,SNR)
fskn=awgn(fsk,SNR)
pskn=awgn(psk,SNR)
l=length(c1);
%ask
for i=1:length(b)
y1=sum(c1.*askn(1+l*(i-1):l*i))
if(y1>0.5)
askd=[askd,1]
else
askd=[askd,0]
end
end
%decision device with thresold o.5

%fsk
for i=1:length(b)
l1=sum(c1.*fskn(1+l*(i-1):l*i))
l2=sum(c2.*fskn(1+l*(i-1):l*i))
y1=l1-l2
if (y1>0)
fskd=[fskd,1]
else
fskd=[fskd,0]
end
end

%psk
for i=1:length(b)
y1=sum(c1.*pskn(1+l*(i-1):l*i))
if(y1>0)
pskd=[pskd,1]
else
pskd=[pskd,0]
end
end
%ask
figure(2)
subplot(4,1,1)
stem(b,'m','linewidth',2);
title('Binary signal ')
xlabel('Time ')
ylabel('Amplitude')
subplot(4,1,2)
plot(ask,'b','linewidth',2);
xlim([0,1600]);
title('Amplitude shift key')
xlabel('Time ')
ylabel('Amplitude')
subplot(4,1,3)
plot(askn,'g','linewidth',2);
xlim([0,1600]);
title('Amplitude shift key with AWGN for noise SNR=2')
xlabel('Time ')
ylabel('Amplitude')
subplot(4,1,4)
stem(askd,'r','linewidth',2);
title('Demodulation for ASK ')
xlabel('Time ')
ylabel('Amplitude')

%psk
figure(3)
subplot(4,1,1)
stem(b,'m','linewidth',2);
title('Binary signal ')
xlabel('Time ')
ylabel('Amplitude')
subplot(4,1,2)
plot(psk,'b','linewidth',2);
xlim([0,1600]);
title('Phase shift key')
xlabel('Time ')
ylabel('Amplitude')
subplot(4,1,3)
plot(pskn,'g','linewidth',2);
xlim([0,1600]);
title('Phase shift key with AWGN for noise SNR=2')
xlabel('Time ')
ylabel('Amplitude')
subplot(4,1,4)
stem(pskd,'r','linewidth',2);
title('Demodulation for PSK ')
xlabel('Time ')
ylabel('Amplitude')

%fsk
figure(4)
subplot(4,1,1)
stem(b,'m','linewidth',2);
title('Binary signal ')
xlabel('Time ')
ylabel('Amplitude')
subplot(4,1,2)
plot(fsk,'b','linewidth',2);
xlim([0,1600]);
title('Frequency shift key')
xlabel('Time ')
ylabel('Amplitude')
subplot(4,1,3)
plot(fskn,'g','linewidth',2);
xlim([0,1600]);
title('Frequency shift key with AWGN for noise SNR=2')
xlabel('Time ')
ylabel('Amplitude')
subplot(4,1,4)
stem(fskd,'r','linewidth',2);
title('Demodulation for FSK ')
xlabel('Time ')
ylabel('Amplitude')

%SNR=5
askd=[];fskd=[];pskd=[];
SNR=5;
askn=awgn(ask,SNR)
fskn=awgn(fsk,SNR)
pskn=awgn(psk,SNR)

%ask
for i=1:length(b)
y1=sum(c1.*askn(1+l*(i-1):l*i))
if(y1>0.5)
askd=[askd,1]
else
askd=[askd,0]
end
end
%decision device with thresold o.5

%fsk
for i=1:length(b)
l1=sum(c1.*fskn(1+l*(i-1):l*i))
l2=sum(c2.*fskn(1+l*(i-1):l*i))
y1=l1-l2
if (y1>0)
fskd=[fskd,1]
else
fskd=[fskd,0]
end
end

%psk
for i=1:length(b)
y1=sum(c1.*pskn(1+l*(i-1):l*i))
if(y1>0)
pskd=[pskd,1]
else
pskd=[pskd,0]
end
end
%ask
figure(5)
subplot(4,1,1)
stem(b,'m','linewidth',2);
title('Binary signal ')
xlabel('Time ')
ylabel('Amplitude')
subplot(4,1,2)
plot(ask,'b','linewidth',2);
xlim([0,1600]);
title('Amplitude shift key')
xlabel('Time ')
ylabel('Amplitude')
subplot(4,1,3)
plot(askn,'g','linewidth',2);
xlim([0,1600]);
title('Amplitude shift key with AWGN for noise SNR=5')
xlabel('Time ')
ylabel('Amplitude')
subplot(4,1,4)
stem(askd,'r','linewidth',2);
title('Demodulation for ASK ')
xlabel('Time ')
ylabel('Amplitude')

%psk
figure(6)
subplot(4,1,1)
stem(b,'m','linewidth',2);
title('Binary signal ')
xlabel('Time ')
ylabel('Amplitude')
subplot(4,1,2)
plot(psk,'b','linewidth',2);
xlim([0,1600]);
title('Phase shift key')
xlabel('Time ')
ylabel('Amplitude')
subplot(4,1,3)
plot(pskn,'g','linewidth',2);
xlim([0,1600]);
title('Phase shift key with AWGN for noise SNR=5')
xlabel('Time ')
ylabel('Amplitude')
subplot(4,1,4)
stem(pskd,'r','linewidth',2);
title('Demodulation for PSK ')
xlabel('Time ')
ylabel('Amplitude')

%fsk
figure(7)
subplot(4,1,1)
stem(b,'m','linewidth',2);
title('Binary signal ')
xlabel('Time ')
ylabel('Amplitude')
subplot(4,1,2)
plot(fsk,'b','linewidth',2);
xlim([0,1600]);
title('Frequency shift key')
xlabel('Time ')
ylabel('Amplitude')
subplot(4,1,3)
plot(fskn,'g','linewidth',2);
xlim([0,1600]);
title('Frequency shift key with AWGN for noise SNR=5')
xlabel('Time ')
ylabel('Amplitude')
subplot(4,1,4)
stem(fskd,'r','linewidth',2);
title('Demodulation for FSK ')
xlabel('Time ')
ylabel('Amplitude')

%SNR=20
askd=[];fskd=[];pskd=[];
SNR=40;
askn=awgn(ask,SNR)
fskn=awgn(fsk,SNR)
pskn=awgn(psk,SNR)

%ask
for i=1:length(b)
y1=sum(c1.*askn(1+l*(i-1):l*i))
if(y1>0.5)
askd=[askd,1]
else
askd=[askd,0]
end
end
%decision device with thresold o.5

%fsk
for i=1:length(b)
l1=sum(c1.*fskn(1+l*(i-1):l*i))
l2=sum(c2.*fskn(1+l*(i-1):l*i))
y1=l1-l2
if (y1>0)
fskd=[fskd,1]
else
fskd=[fskd,0]
end
end

%psk
for i=1:length(b)
y1=sum(c1.*pskn(1+l*(i-1):l*i))
if(y1>0)
pskd=[pskd,1]
else
pskd=[pskd,0]
end
end
%ask
figure(8)
subplot(4,1,1)
stem(b,'m','linewidth',2);
title('Binary signal ')
xlabel('Time ')
ylabel('Amplitude')
subplot(4,1,2)
plot(ask,'b','linewidth',2);
xlim([0,1600]);
title('Amplitude shift key')
xlabel('Time ')
ylabel('Amplitude')
subplot(4,1,3)
plot(askn,'g','linewidth',2);
xlim([0,1600]);
title('Amplitude shift key with AWGN for noise SNR=20')
xlabel('Time ')
ylabel('Amplitude')
subplot(4,1,4)
stem(askd,'r','linewidth',2);
title('Demodulation for ASK ')
xlabel('Time ')
ylabel('Amplitude')

%psk
figure(9)
subplot(4,1,1)
stem(b,'m','linewidth',2);
title('Binary signal ')
xlabel('Time ')
ylabel('Amplitude')
subplot(4,1,2)
plot(psk,'b','linewidth',2);
xlim([0,1600]);
title('Phase shift key')
xlabel('Time ')
ylabel('Amplitude')
subplot(4,1,3)
plot(pskn,'g','linewidth',2);
xlim([0,1600]);
title('Phase shift key with AWGN for noise SNR=20')
xlabel('Time ')
ylabel('Amplitude')
subplot(4,1,4)
stem(pskd,'r','linewidth',2);
title('Demodulation for PSK ')
xlabel('Time ')
ylabel('Amplitude')

%fsk
figure(10)
subplot(4,1,1)
stem(b,'m','linewidth',2);
title('Binary signal ')
xlabel('Time ')
ylabel('Amplitude')
subplot(4,1,2)
plot(fsk,'b','linewidth',2);
xlim([0,1600]);
title('Frequency shift key')
xlabel('Time ')
ylabel('Amplitude')
subplot(4,1,3)
plot(fskn,'g','linewidth',2);
xlim([0,1600]);
title('Frequency shift key with AWGN for noise SNR=20')
xlabel('Time ')
ylabel('Amplitude')
subplot(4,1,4)
stem(fskd,'r','linewidth',2);
title('Demodulation for FSK ')
xlabel('Time ')
ylabel('Amplitude')

Output Waveforms:
INFERENCE: Generation of the following binary bandpass modulation
 Binary amplitude shift keying
 Binary frequency shift keying
 Binary phase shift keying
Plotting various AWGN signal for various SNR values and demodulated signal.
The demodulated signal in few cases is not similar to the original binary signal
because of too much noise.

You might also like