You are on page 1of 28

EXPERIMENT 10 Date Perform: ________________

To Demonstrate the ASK Modulation & Demodulation


10.1 OBJECTIVE:
 To perform Amplitude Shift Keying modulation and demodulation of signals in
MATLAB

10.2 EQUIPMENT:
 MATLAB

10.3 BACKGROUND:
Experiment 10 in lab manual.

10.4 Procedure:
First of all, we need to see how to generate the digital data in the form of bits. As ASK is
performed on digital input. If we use a simple combination of 1s and 0s then it will be a
momentary signal and won’t serve our purpose. Like shown in the following figure.
[1 0 1 0 1 1 0 1]
1

0.9

0.8

0.7

0.6

0.5

0.4

0.3

0.2

0.1

0
1 2 3 4 5 6 7 8

What we need is a continues patch of data like shown below:


How we’ll generate this in MATLAB? Let’s have a look at the code below:
clear all
close all
clc;
b = input('Enter the Bit stream \n ')
n = length(b);
t = 0:.01:n;
x = 1:1:(n+1)*100;
for i = 1:n
for j = i:.1:i+1
bw(x(i*100:(i+1)*100)) = b(i);
end
end
bw = bw(100:end);%this is our required digital wave that we'll use for modulation

plot(bw)

t2=linspace(-4,4,1);

0.9

0.8

0.7

0.6

0.5

0.4

0.3

0.2

0.1

0
0 100 200 300 400 500 600 700 800

The above plot shows the required digital data that we need for ASK modulation. When you’ll
execute the above code, you’ll need to insert the input sequence on command window using
brackets as follows:
Whatever sequence of input you want to apply just use brackets and press enter.

10.5 Task:
Generate an input sequence of 0s and 1s according to your roll number, as explained at the last of
the manual. Use the above given code to generate binary input and for the carrier signal use the
following waves in order to apply ASK modulation.
a) A carrier signal
Cos (2*pi*f*t)
where f=10 HZ

AT 5

Plot of b
Code for carrier & message signal & resultant
clear all
close all
clc;
b = [0 1 0 1]
n = length(b);
t = 0:.01:n;
f=10;
a=2;
x = 1:1:(n+1)*100;
for i = 1:n
for j = i:.1:i+1
bw(x(i*100:(i+1)*100)) = b(i);
end
end
bw = bw(100:end);%this is our required digital wave that we'll use for
modulation
carrier=a*cos(2*pi*f*t);
ask=carrier.*bw;
subplot(3,1,1)
plot(t,bw)
title('18f0535 si')
subplot(3,1,2)
plot(t,carrier)
title('18f0535 carrier')
subplot(3,1,3)
plot(t,ask)
title('18f0535 new')
plot

AT 3 [0011]
Plot b

Code for carrier & message signal & resultant


clear all
close all
clc;
b = [0 0 1 1]
n = length(b);
t = 0:.01:n;
f=10;
a=2;
x = 1:1:(n+1)*100;
for i = 1:n
for j = i:.1:i+1
bw(x(i*100:(i+1)*100)) = b(i);
end
end
bw = bw(100:end);%this is our required digital wave that we'll use for
modulation
carrier=a*cos(2*pi*f*t);
ask=carrier.*bw;
subplot(3,1,1)
plot(t,bw)
grid on
xlabel('time')
ylabel('amp')
title('18f0535 message signal')
subplot(3,1,2)
plot(t,carrier)
grid on
xlabel('time')
ylabel('amp')
title('18f0535 carrier')
subplot(3,1,3)
plot(t,ask)
grid on
xlabel('time')
ylabel('amp')
title('18f0535 modulatig singnal')
AT 5

Plot of b
Code for carrier & message signal & resultant
clear all
close all
clc;
b = [0 1 0 1]
n = length(b);
t = 0:.01:n;
f=10;
a=2;
x = 1:1:(n+1)*100;
for i = 1:n
for j = i:.1:i+1
bw(x(i*100:(i+1)*100)) = b(i);
end
end
bw = bw(100:end);%this is our required digital wave that we'll use for
modulation
carrier=a*cos(2*pi*f*t);
ask=carrier.*bw;
subplot(3,1,1)
plot(t,bw)
title('18f0535 si')
subplot(3,1,2)
plot(t,carrier)
title('18f0535 carrier')
subplot(3,1,3)
plot(t,ask)
title('18f0535 new')
plot

AT (A)

Code for carrier & message signal & resultant


clear all
close all
clc;
b = [1 0 1 0]
n = length(b);
t = 0:.01:n;
f=10;
a=2;
x = 1:1:(n+1)*100;
for i = 1:n
for j = i:.1:i+1
bw(x(i*100:(i+1)*100)) = b(i);
end
end
bw = bw(100:end);%this is our required digital wave that we'll use for
modulation
carrier=a*cos(2*pi*f*t);
ask=carrier.*bw;
subplot(3,1,1)
plot(t,bw)
grid on
xlabel('time')
ylabel('amp')
title('18f0535 message signal')
subplot(3,1,2)
plot(t,carrier)
grid on
xlabel('time')
ylabel('amp')
title('18f0535 carrier')
subplot(3,1,3)
plot(t,ask)
grid on
xlabel('time')
ylabel('amp')
title('18f0535 modulatig singnal')

plot

b) A carrier signal
Sin (2*pi*f*t)
where f=last one or two digit of your roll number (depending upon the outlook of your
signal). Choose second-last if last digit is zero!
Test your system for both frequencies on the binary 4-bit binary equivalent of your roll number’s
each digit. That for 4 digits of your roll number, you need to attach 8 graphs.

If your roll number is 18F-0120, then


3 = 0011
2 = 0010
1 = 0001

If there is zero in your roll number, then in case of:


1st Zero, use hexadecimal A
2nd Zero, use hexadecimal B
3rd Zero, use hexadecimal C

Each of your 8 graph must include your input message, carrier signal, modulated ASK signal.

AT 5[0101]

Code for carrier & message signal & resultant

clear all
close all
clc;
b = [0 1 0 1]
n = length(b);
t = 0:.01:n;
f=5;
a=2;
x = 1:1:(n+1)*100;
for i = 1:n
for j = i:.1:i+1
bw(x(i*100:(i+1)*100)) = b(i);
end
end
bw = bw(100:end);%this is our required digital wave that we'll use for
modulation
carrier=a*sin(2*pi*f*t);
ask=carrier.*bw;
subplot(3,1,1)
plot(t,bw)
grid on
xlabel('time')
ylabel('amp')
title('18f0535 message signal')
subplot(3,1,2)
plot(t,carrier)
grid on
xlabel('time')
ylabel('amp')
title('18f0535 carrier')
subplot(3,1,3)
plot(t,ask)
grid on
xlabel('time')
ylabel('amp')
title('18f0535 modulatig singnal')

At 3[0011]

Code for carrier & message signal & resultant


clear all
close all
clc;
b = [0 0 1 1]
n = length(b);
t = 0:.01:n;
f=5;
a=2;
x = 1:1:(n+1)*100;
for i = 1:n
for j = i:.1:i+1
bw(x(i*100:(i+1)*100)) = b(i);
end
end
bw = bw(100:end);%this is our required digital wave that we'll use for
modulation
carrier=a*sin(2*pi*f*t);
ask=carrier.*bw;
subplot(3,1,1)
plot(t,bw)
grid on
xlabel('time')
ylabel('amp')
title('18f0535 message signal')
subplot(3,1,2)
plot(t,carrier)
grid on
xlabel('time')
ylabel('amp')
title('18f0535 carrier')
subplot(3,1,3)
plot(t,ask)
grid on
xlabel('time')
ylabel('amp')
title('18f0535 modulatig singnal')

At 5[0101]

Code for carrier & message signal & resultant


clear all
close all
clc;
b = [0 1 0 1]
n = length(b);
t = 0:.01:n;
f=5;
a=2;
x = 1:1:(n+1)*100;
for i = 1:n
for j = i:.1:i+1
bw(x(i*100:(i+1)*100)) = b(i);
end
end
bw = bw(100:end);%this is our required digital wave that we'll use for
modulation
carrier=a*sin(2*pi*f*t);
ask=carrier.*bw;
subplot(3,1,1)
plot(t,bw)
grid on
xlabel('time')
ylabel('amp')
title('18f0535 message signal')
subplot(3,1,2)
plot(t,carrier)
grid on
xlabel('time')
ylabel('amp')
title('18f0535 carrier')
subplot(3,1,3)
plot(t,ask)
grid on
xlabel('time')
ylabel('amp')
title('18f0535 modulatig singnal')
At A[1010]

Code for carrier & message signal & resultant


clear all
close all
clc;
b = [1 0 1 0]
n = length(b);
t = 0:.01:n;
f=5;
a=2;
x = 1:1:(n+1)*100;
for i = 1:n
for j = i:.1:i+1
bw(x(i*100:(i+1)*100)) = b(i);
end
end
bw = bw(100:end);%this is our required digital wave that we'll use for
modulation
carrier=a*sin(2*pi*f*t);
ask=carrier.*bw;
subplot(3,1,1)
plot(t,bw)
grid on
xlabel('time')
ylabel('amp')
title('18f0535 message signal')
subplot(3,1,2)
plot(t,carrier)
grid on
xlabel('time')
ylabel('amp')
title('18f0535 carrier')
subplot(3,1,3)
plot(t,ask)
grid on
xlabel('time')
ylabel('amp')
title('18f0535 modulatig singnal')

10.6 Demodulation of ASK signal:


For the eight signals generated in the above task, apply ASK demodulation and reconstruct your
original message.

demodulation

At 5[0101]
Code and graph

clear all
close all
clc;
b = [0 1 0 1]
n = length(b);
t = 0:.01:n;
f=10;
a=2;
x = 1:1:(n+1)*100;
for i = 1:n
for j = i:.1:i+1
bw(x(i*100:(i+1)*100)) = b(i);
end
end
bw = bw(100:end);%this is our required digital wave that we'll use for
modulation
carrier=a*cos(2*pi*f*t);
ask=carrier.*bw
d=ask
message=d./carrier
subplot(4,1,1)
plot(t,bw)
grid on
xlabel('time')
ylabel('amp')
title('18f0535 message signal')
subplot(4,1,2)
plot(t,carrier)
grid on
xlabel('time')
ylabel('amp')
title('18f0535 carrier')
subplot(4,1,3)
plot(t,ask)
grid on
xlabel('time')
ylabel('amp')
title('18f0535 modulatig singnal')
subplot(4,1,4)
plot(t,message)
grid on
xlabel('time')
ylabel('amp')
title('18f0535 demodulatig singnal')
At 3[0011]

Code and graph


clear all
close all
clc;
b = [0 0 1 1]
n = length(b);
t = 0:.01:n;
f=10;
a=2;
x = 1:1:(n+1)*100;
for i = 1:n
for j = i:.1:i+1
bw(x(i*100:(i+1)*100)) = b(i);
end
end
bw = bw(100:end);%this is our required digital wave that we'll use for
modulation
carrier=a*cos(2*pi*f*t);
ask=carrier.*bw
d=ask
message=d./carrier
subplot(4,1,1)
plot(t,bw)
grid on
xlabel('time')
ylabel('amp')
title('18f0535 message signal')
subplot(4,1,2)
plot(t,carrier)
grid on
xlabel('time')
ylabel('amp')
title('18f0535 carrier')
subplot(4,1,3)
plot(t,ask)
grid on
xlabel('time')
ylabel('amp')
title('18f0535 modulatig singnal')
subplot(4,1,4)
plot(t,message)
grid on
xlabel('time')
ylabel('amp')
title('18f0535 demodulatig singnal')

At 5[0101]

Code and graph

clear all
close all
clc;
b = [0 1 0 1]
n = length(b);
t = 0:.01:n;
f=10;
a=2;
x = 1:1:(n+1)*100;
for i = 1:n
for j = i:.1:i+1
bw(x(i*100:(i+1)*100)) = b(i);
end
end
bw = bw(100:end);%this is our required digital wave that we'll use for
modulation
carrier=a*cos(2*pi*f*t);
ask=carrier.*bw
d=ask
message=d./carrier
subplot(4,1,1)
plot(t,bw)
grid on
xlabel('time')
ylabel('amp')
title('18f0535 message signal')
subplot(4,1,2)
plot(t,carrier)
grid on
xlabel('time')
ylabel('amp')
title('18f0535 carrier')
subplot(4,1,3)
plot(t,ask)
grid on
xlabel('time')
ylabel('amp')
title('18f0535 modulatig singnal')
subplot(4,1,4)
plot(t,message)
grid on
xlabel('time')
ylabel('amp')
title('18f0535 demodulatig singnal')
At A[1010]
Code and graph
clear all
close all
clc;
b = [1 0 1 0]
n = length(b);
t = 0:.01:n;
f=10;
a=2;
x = 1:1:(n+1)*100;
for i = 1:n
for j = i:.1:i+1
bw(x(i*100:(i+1)*100)) = b(i);
end
end
bw = bw(100:end);%this is our required digital wave that we'll use for
modulation
carrier=a*cos(2*pi*f*t);
ask=carrier.*bw
d=ask
message=d./carrier
subplot(4,1,1)
plot(t,bw)
grid on
xlabel('time')
ylabel('amp')
title('18f0535 message signal')
subplot(4,1,2)
plot(t,carrier)
grid on
xlabel('time')
ylabel('amp')
title('18f0535 carrier')
subplot(4,1,3)
plot(t,ask)
grid on
xlabel('time')
ylabel('amp')
title('18f0535 modulatig singnal')
subplot(4,1,4)
plot(t,message)
grid on
xlabel('time')
ylabel('amp')
title('18f0535 demodulatig singnal')

AT 5[0101] WITH SIN AND F=5

clear all
close all
clc;
b = [0 1 0 1]
n = length(b);
t = 0:.01:n;
f=5;
a=2;
x = 1:1:(n+1)*100;
for i = 1:n
for j = i:.1:i+1
bw(x(i*100:(i+1)*100)) = b(i);
end
end
bw = bw(100:end);%this is our required digital wave that we'll use for
modulation
carrier=a*sin(2*pi*f*t);
ask=carrier.*bw
d=ask
message=d./carrier
subplot(4,1,1)
plot(t,bw)
grid on
xlabel('time')
ylabel('amp')
title('18f0535 message signal')
subplot(4,1,2)
plot(t,carrier)
grid on
xlabel('time')
ylabel('amp')
title('18f0535 carrier')
subplot(4,1,3)
plot(t,ask)
grid on
xlabel('time')
ylabel('amp')
title('18f0535 modulatig singnal')
subplot(4,1,4)
plot(t,message)
grid on
xlabel('time')
ylabel('amp')
title('18f0535 demodulatig singnal')
AT 3[0011] WITH SIN AND F=5
clear all
close all
clc;
b = [0 0 1 1]
n = length(b);
t = 0:.01:n;
f=5;
a=2;
x = 1:1:(n+1)*100;
for i = 1:n
for j = i:.1:i+1
bw(x(i*100:(i+1)*100)) = b(i);
end
end
bw = bw(100:end);%this is our required digital wave that we'll use for
modulation
carrier=a*sin(2*pi*f*t);
ask=carrier.*bw
d=ask
message=d./carrier
subplot(4,1,1)
plot(t,bw)
grid on
xlabel('time')
ylabel('amp')
title('18f0535 message signal')
subplot(4,1,2)
plot(t,carrier)
grid on
xlabel('time')
ylabel('amp')
title('18f0535 carrier')
subplot(4,1,3)
plot(t,ask)
grid on
xlabel('time')
ylabel('amp')
title('18f0535 modulatig singnal')
subplot(4,1,4)
plot(t,message)
grid on
xlabel('time')
ylabel('amp')
title('18f0535 demodulatig singnal')

AT 5[0101] WITH SIN AND F=5

clear all
close all
clc;
b = [0 1 0 1]
n = length(b);
t = 0:.01:n;
f=5;
a=2;
x = 1:1:(n+1)*100;
for i = 1:n
for j = i:.1:i+1
bw(x(i*100:(i+1)*100)) = b(i);
end
end
bw = bw(100:end);%this is our required digital wave that we'll use for
modulation
carrier=a*sin(2*pi*f*t);
ask=carrier.*bw
d=ask
message=d./carrier
subplot(4,1,1)
plot(t,bw)
grid on
xlabel('time')
ylabel('amp')
title('18f0535 message signal')
subplot(4,1,2)
plot(t,carrier)
grid on
xlabel('time')
ylabel('amp')
title('18f0535 carrier')
subplot(4,1,3)
plot(t,ask)
grid on
xlabel('time')
ylabel('amp')
title('18f0535 modulatig singnal')
subplot(4,1,4)
plot(t,message)
grid on
xlabel('time')
ylabel('amp')
title('18f0535 demodulatig singnal')
AT A[1010] WITH SIN AND F=5
clear all
close all
clc;
b = [1 0 1 0]
n = length(b);
t = 0:.01:n;
f=5;
a=2;
x = 1:1:(n+1)*100;
for i = 1:n
for j = i:.1:i+1
bw(x(i*100:(i+1)*100)) = b(i);
end
end
bw = bw(100:end);%this is our required digital wave that we'll use for
modulation
carrier=a*sin(2*pi*f*t);
ask=carrier.*bw
d=ask
message=d./carrier
subplot(4,1,1)
plot(t,bw)
grid on
xlabel('time')
ylabel('amp')
title('18f0535 message signal')
subplot(4,1,2)
plot(t,carrier)
grid on
xlabel('time')
ylabel('amp')
title('18f0535 carrier')
subplot(4,1,3)
plot(t,ask)
grid on
xlabel('time')
ylabel('amp')
title('18f0535 modulatig singnal')
subplot(4,1,4)
plot(t,message)
grid on
xlabel('time')
ylabel('amp')
title('18f0535 demodulatig singnal')

You might also like