Experiment III Digital Communication
Experiment III Digital Communication
Experiment III Digital Communication
MATLAB Code:
Fc = 100;
Fs=4000;
ts = 1/Fs;
t=0:ts:1/Fc;
figure(1);
subplot(2,1,1);
x=0.5+0.4*sin(2*pi*Fc*t);
plot(t,x,'k');
grid on;
ylabel('Amplitude');
xlabel('Time in secs');
title('Modulating or Message Signal');
tt = (-4/1000:(ts/10):6/1000);
m=zeros(size(tt));
m(1:40)=ones(size(m(1:40)));
m(81:120)=ones(size(m(81:120)));
m(161:200)=ones(size(m(161:200)));
m(241:280)=ones(size(m(241:280)));
m(321:360)=ones(size(m(321:360)));
subplot(2,1,2);
plot(tt,m,'k');
ylim([0 1.2]);
ylabel('Amplitude');
xlabel('Time in ms');
title('Pulse Carrier Signal');
y=modulate(x,Fc,Fs,'pwm','centered');
k=1:1:length(y);
k=k/(length(y)*100);
figure(2);
subplot(2,2,1)
plot(t,x,'k')
grid on;
ylabel('Amplitude');
xlabel('Time in ms');
title('Modulating or Message Signal');
subplot(2,2,2);
plot(k,y,'k');
grid on;
ylabel('Amplitude');
xlabel('Time in ms');
title('PWM Modulated Signal');
ylim([0 1.2]);
m1 = demod(y,Fc,Fs,'pwm','centered');
subplot(2,2,3);
plot(t,m1,'k');
grid on;
ylabel('Amplitude');
xlabel('Time in ms');
title('PWM Demodulated Signal');
Sx = fftshift(abs(fft(y)));
f=-length(Sx)/2:1:length(Sx-1)/2-1;
subplot(2,2,4)
plot(f,Sx,'k')
grid on;
ylabel('Magnitude in dB');
xlabel('Frequency in Hz');
title('Magnitude Spectrum of PWM Modulated Signal');
y1 = modulate(x,Fc,Fs,'ppm');
k=1:1:length(Sx);
k=k/(length(Sx)*100);
figure(3);
subplot(2,2,1);
plot(t,x,'k');
grid on;
ylabel('Amplitude');
xlabel('Time in ms');
title('Modulating or Message Signal');
subplot(2,2,2);
plot(k,y1,'k');
grid on;
ylabel('Amplitude');
xlabel('Time in ms');
title('PPM Modulated Signal');
ylim([0 1.2]);
m2=demod(y1,Fc,Fs,'ppm');
subplot(2,2,3);
plot(t,m2,'k');
grid on;
ylabel('Amplitude');
xlabel('Time in ms');
title('PPM Demodulated Signal');
Sx1=fftshift(abs(fft(y1)));
f=-length(Sx1)/2:1:length(Sx1-1)/2-1;
subplot(2,2,4);
plot(f,Sx1,'k');
grid on;
ylabel('Magnitude in dB');
xlabel('Frequency in Hz');
title('Magnitude Spectrum of PPM Modulated Signal')
Observations: