0% found this document useful (0 votes)
141 views

ASK and PSK

The document contains Matlab code and diagrams related to amplitude-shift keying (ASK) and phase-shift keying (PSK) modulation and demodulation. It shows the output signals of ASK and PSK modulators and demodulators. It also includes Matlab code for simulating ASK and PSK modulation and demodulation of binary input signals. The code generates the modulated signals, applies noise, and recovers the original binary data using integration and thresholding for ASK and correlation for PSK.

Uploaded by

RaqibAhsan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
141 views

ASK and PSK

The document contains Matlab code and diagrams related to amplitude-shift keying (ASK) and phase-shift keying (PSK) modulation and demodulation. It shows the output signals of ASK and PSK modulators and demodulators. It also includes Matlab code for simulating ASK and PSK modulation and demodulation of binary input signals. The code generates the modulated signals, applies noise, and recovers the original binary data using integration and thresholding for ASK and correlation for PSK.

Uploaded by

RaqibAhsan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

1

Wave Shapes:

Figure: ASK modulator output

Figure: PSK modulator output


2



Figure: ASK Demodulation and Voltage Comparator Output




3



Figure: PSK Demodulation After passing through LPF

Figure: Output of Voltage comparator
Figure: PSK Demodulation


4
Matlab Code for ASK:
clear all;
clc;
close all;
F1=45;
F2=6;
A=3;%Amplitude
t=0:0.001:1;
x=A.*sin(2*pi*F1*t);%Carrier Sine wave
u=A/2.*square(2*pi*F2*t)+(A/2);%Square wave message
v=x.*u;
subplot(3,1,1);
plot(t,x);
xlabel('Time');
ylabel('Amplitude');
title('Carrier');
grid on;
subplot(3,1,2);
plot(t,u);
xlabel('Time');
ylabel('Amplitude');
title('Square Pulses');
grid on;subplot(3,1,3);
plot(t,v);
xlabel('Time');
ylabel('Amplitude');
title('ASK Signal');
grid on;

Matlab Code for ASK:
clear all;
clc;
close all;
set(0,'defaultlinelinewidth',2);
A=5;
t=0:.001:1;
f1=input('Carrier Sine wave frequency =');
f2=input('Message frequency =');
x=A.*sin(2*pi*f1*t);%Carrier Sine
subplot(3,1,1);
plot(t,x);
xlabel('time');
ylabel('Amplitude');
title('Carrier');
grid on;


5
u=square(2*pi*f2*t);%Message signal
subplot(3,1,2);
plot(t,u);
xlabel('time');
ylabel('Amplitude');
title('Message Signal');
grid on;

v=x.*u;%Sine wave multiplied with square wave
subplot(3,1,3);
plot(t,v);
axis([0 1 -6 6]);
xlabel('t');
ylabel('y');
title('PSK');
grid on;

Matlab Code for ASK 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(volt)');
xlabel(' time(sec)');
title('transmitting information as digital signal');





6

A1=10; % Amplitude of carrier signal for information 1
A2=5; % Amplitude of carrier signal for information 0
br=1/bp; % bit rate
f=br*10; % carrier frequency
t2=bp/99:bp/99:bp;
ss=length(t2);
m=[];
for (i=1:1:length(x))
if (x(i)==1)
y=A1*cos(2*pi*f*t2);
else
y=A2*cos(2*pi*f*t2);
end
m=[m y];
end
t3=bp/99:bp/99:bp*length(x);
subplot(3,1,2);
plot(t3,m);
xlabel('time(sec)');
ylabel('amplitude(volt)');
title('waveform for binary ASK modulation coresponding binary information');

mn=[];
for n=ss:ss:length(m)
t=bp/99:bp/99:bp;
y=cos(2*pi*f*t); % carrier siignal
mm=y.*m((n-(ss-1)):n);
t4=bp/99:bp/99:bp;
z=trapz(t4,mm) % intregation
zz=round((2*z/bp))
if(zz>7.5) % logic level = (A1+A2)/2=7.5
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(volt)');


7
xlabel(' time(sec)');
title('recived information as digital signal after binary ASK demodulation');

Matlab Code For PSK Demodulation:
x=[1 0 1 0 1];
N=length(x);
t=0.01:0.01:N;
c=2*sin(2*pi*t);
for i=1:1:N
m((i-1)*100+1:i*100)=x(i);
end
y=c.*m;
subplot(3,1,1);
plot(t,m);
xlabel('time');
ylabel('amplitude');
title('digital input signal');
subplot(3,1,2);
plot(t,c);
xlabel('time');
ylabel('amplitude');
title('sinusoidal signal');
subplot(3,1,3);
plot(t,y);
xlabel('time');
ylabel('amplitude');
title('PSK modulated signal');
r=randn(1,length(y));
k=y+r;
figure;

You might also like