D Com Experiment 03

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 11

Experiment No: 03

Experiment Name: Experiment on Pulse Amplitude Modulation using MATLAB.

Objectives:
The purpose of this experiment is to analyze the concept of Pulse Amplitude Modulation using
MATLAB Software which is the language of technical computing. It presents the MATLAB
programming for PAM modulation technique. The PAM waveform obtained in accordance with
the variations of the continuous varying information signal along with the carrier signal is also
studied. It also describes the different types of PAM signals and their applications in various
systems.

Theoretical Concept:
Pulse-amplitude modulation (PAM): Pulse amplitude modulation is a technique in which the
amplitude of each pulse is controlled by the instantaneous amplitude of the modulation signal. It
is a modulation system in which the signal is sampled at regular intervals and each sample is
made proportional to the amplitude of the signal at the instant of sampling. This technique
transmits the data by encoding in the amplitude of a series of signal pulses.

Figure 01: Pulse Amplitude Modulation Signal


There are two types of sampling techniques for transmitting a signal using PAM.

1. Flat Top PAM


2. Natural PAM

Flat Top PAM:


The amplitude of each pulse is directly proportional to modulating signal amplitude at the time of
pulse occurrence. The amplitude of the signal cannot be changed with respect to the analog
signal to be sampled. The tops of the amplitude remain flat.

Figure 02: Flat Top PAM


Natural PAM:
The amplitude of each pulse is directly proportional to modulating signal amplitude at the time of
pulse occurrence. Then follows the amplitude of the pulse for the rest of the half-cycle.

Figure 03: Natural PAM


Apparatus:

 A Computer
 MATLAB software.

MATLAB code for PAM operation (01) >>

Input Code:
clc;
clear all;
close all;
wm=1.05*pi;
res=0.01;
fs=1;
sam=floor(1/(fs*res));
t=0:res:10-res;
m=sin(wm*t);
allT=[0.05,.1,.2,.3,.4,.5];
f=(1/res)*([0:1/(length(t)-1):1]-.5);
figure
subplot(1,1,1);
plot(t,m);
title(['Sampling frequency='num2str(fs)'Hz']);
xlabel('Time(s)');
ylabel('Magnitude');
advance=33;
for k=1:6;
T=allT(k);
durInSam=floor(T/res);
sm=zeros(size(t));
for i=0:floor(length(t)/sam)-1,sm(advance+(i*sam)+1:advance+(i*sam)
+durInSam)=m(i*sam+1+advance);
end
y=fftshift(abs(fft(sm)));
figure
subplot(2,1,1);
plot(t,m,'-.');
hold on;
plot(t,sm);
axis([0 10 -1.2 1.2]);
xlabel('Time(s)');
ylabel('Magnitude');
legend('Signal','PAM-Signal');
title(['T='num2str(T)'s']);
subplot(2,1,2);
plot(f,y);
xlabel('Frequency(Hz)');
ylabel('Magnitude');
end
Outputs:

Figure 04: Input Signal

Figure 05: Pulse Amplitude Modulation Signal 1


Figure 06: Pulse Amplitude Modulation Signal 2

Figure 07: Pulse Amplitude Modulation Signal 3


Figure 08: Pulse Amplitude Modulation Signal 4

Figure 09: Pulse Amplitude Modulation Signal 5


Figure 10: Pulse Amplitude Modulation Signal 6

MATLAB code for PAM operation (02) >>


Input Code:
clc
close all;
clear all;
%continuous signal
L=1025;
fsim=2225; %sampling frequency of the continuous signal
fc=fsim/L; %fc allows to get 1 cycle of L samples
Tcycle=1/fc; % 1 period
Tcont=1/fsim; %sampling period
continuous_time_axis=[0:Tcont:Tcycle]; %a period of the signal
ycont=sin(2*pi*fc*continuous_time_axis); % a cycle of a continuos sinusoid
%ideal sampled signal
num_samples_cycle=16;
Tm=Tcont*L/num_samples_cycle; %sampling period of the sampled signal
discrete_time_axis=[0:Tm:Tcycle];
ysampled=sin(2*pi*fc*discrete_time_axis);
figure(1);
plot(continuous_time_axis,ycont); title('Cycle of the continuous signal with 8 samples');
xlabel('n');
hold on;
stem(discrete_time_axis,ysampled);
hold off;
%PAM Signal
N=length(ycont); %we take the length of the continuous signal
z=zeros(1,N); % we create an N-length vector of zeros
n=floor(Tm/Tcont); % we divide the period of the discrete signal between the
% period of the continuous signal (we round it). This
% will be the increment between the samples of the
% sampled signal
z(1:n:N)=ysampled; %we put the values of ysampled in the vector of zeros every n samples;
%so we are adding zeros between the samples of the
%sampled signal
h=zeros(1,100);
h(1:10)=1; %we create a pulse with a duration of 10 samples
pamreal=conv(h,z); % we convolve the pulse with the sampled signal which contains
% the zeros between each sample
figure()
plot(pamreal(1:L));title('PAM Signal'); xlabel('n')
figure(); %we are going to plot the continuous signal and the PAM signal overlapped
plot(continuous_time_axis, pamreal(1:N));title('PAM signal and continuous signal overlapped');
xlabel('n')
hold on;
plot(continuous_time_axis, ycont)
%FREQUENCY DOMAIN
freq_axis=[-fsim/2:fc:fsim/2];
YCONT=fft(ycont); %spectrum of the continuous signal
figure()
subplot(3,1,1)
stem(freq_axis, fftshift(abs(YCONT)));title('Spectrum of the continuous sinusoide');xlabel('f')
freq_axis2=[-fsim/2:fsim/16:fsim/2];
YSAMPLED=fft(ysampled); %spectrum of the discrete signal which represents 8
%8 samples of the continous signal
subplot(3,1,2)
stem(freq_axis2,fftshift(abs(YSAMPLED)));title('Spectrum of the discrete sinusoide');xlabel('f')
subplot(3,1,3)
stem((-50:49),fftshift(abs(fft(h))));title('Spectrum of the rectangular pulse');xlabel('f')
figure()
stem((-L/2: L/2-1),fftshift(abs(fft(pamreal(1:L)))));title('Spectrum of the PAM signal'); xlabel('f')
figure()
stem(freq_axis, fftshift(abs(YCONT)));title('Spectrum of the continuous sinusoide and the PAM
signal');xlabel('f')
hold on;
stem(freq_axis, fftshift(abs(fft(pamreal(1:N)))))
Outputs:

Figure 11: Cycle of the continuous signal, when L=1025 and fsim=2225

Figure 12: PAM signal, when L=1025 and fsim=2225


Figure 13: PAM and Continuous signal overlapped, when L=1025 and fsim=2225

Figure 14: Spectrum of continuous sinusoid, when L=1025 and fsim=2225


Figure 15: Spectrum of PAM signal, when L=1025 and fsim=2225

Figure 16: Spectrum of continuous sinusoid & PAM signal, when L=1025 and
fsim=2225

Discussion:

You might also like