Download as pdf or txt
Download as pdf or txt
You are on page 1of 12

NATIONAL INSTITUTE OF TECHNOLOGY

WARANGAL

ELECTRONICS AND COMMUNICATION ENGINEERING

III Year, II Semester

CS lab report - III

Name: C SAI BHAVANA Sec: B


Roll No.: 184213
AIM: To develop a MATLAB program for PAM (Pulse Amplitude Modulation) of a
message signal.

TOOLS USED: MATLAB R2016a


PROCEDURE:
 Consider a sinusoidal message signal of frequency fm, which has to be pulse
amplitude modulated.
 Let the carrier be an impulse signal (in case of the ideal sampling) and square wave
(of frequency fc, in case of Natural sampling).
 These two signals are multiplicated and sampled at a higher sampling frequency fs.
 This gives a Pulse Amplitude Modulated Signal output whose amplitude is in
proportion to that of the message signal.
 To get the demodulated wave or message signal again multiply the modulated signal
with the carrier signal and pass the resultant signal through a suitable filter (low pass
filter).
 Hence the original message signal is obtained.

THEORY:
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.

Demodulation of PAM

For the demodulation of the PAM signal, the PAM signal is fed to the Low Pass Filter. The
low pass filter eliminates the high-frequency ripples and generates the demodulated signal.
This signal is then applied to the inverting amplifier to amplify its signal level to have the
demodulated output with almost equal amplitude with the modulating signal.

Pulse Modulation is mainly used for transmitting analog data like data otherwise continuous
speech signal.

Matlab Code:

Ideal Sampling:
% Ideal Sampling PAM
clc;
close all;
clear all;
a = 4;
f = 1;
t = 0:0.02:2;
x1 = 1; %generation of an impulse signal
x2 = a*sin(2*pi*f*t); %generation of sine wave
y = x1.*x2; %modulation step
subplot(3,1,1); %for impulse signal plot
stem(x1);
title('Impulse Signal');
xlabel('Time');
ylabel('Amplitude ');
subplot(3,1,2) %for sine wave plot
plot(t,x2);
title('Sine Wave');
xlabel('Time ');
ylabel('Amplitude ');
subplot(3,1,3) %for PAM wave plot
stem(t,y);
title('PAM Wave');
xlabel('Time');
ylabel('Amplitude');

Output Graphs:
Natural Sampling:

% PAM using Natural Sampling


clc;
clear all;
close all;
fc= 100
fm= fc/10
fs= 100*fc
t=0:1/fs:4/fm;
Msg_sgl= cos(2*pi*fm*t);
Carr_sgl= 0.5*square(2*pi*fc*t)+0.5
Mod_sgl= Msg_sgl.*Carr_sgl;
tt= [];
for i=1:length(Mod_sgl);
if Mod_sgl(i)==0;
tt=[tt,Mod_sgl(i)];
else
tt=[tt,Mod_sgl(i)+2];
end
end
figure(1)
subplot(2,1,1);
plot(t,Msg_sgl);
title('Message Signal');
xlabel('Time Period');
ylabel('Amplitude');
subplot(2,1,2);
plot(t,Carr_sgl);
title('Carrier Signal')
xlabel('Time Period');
ylabel('Amplitude');
figure(2)
subplot(2,1,1);
plot(t,Mod_sgl);
title('PAM Modulated signal')
xlabel('Time Period');
ylabel('Amplitude');
subplot(2,1,2);
plot(t,tt);
title('PAM')
xlabel('Time Period');
ylabel('Amplitude');
AIM: To develop a MATLAB program for PWM (Pulse Width Modulation) of a message
signal.

TOOLS USED: MATLAB R2016a


Procedure:
 Let’s consider a saw tooth wave and a sinusoidal message signal.
 This message signal is compared with the saw tooth carrier.
 When the message signal is greater than the carrier ,the output becomes high
band vice versa;
 The heights and the lows can be represented by +1 and -1 respectively.
 The resultant output will be the pulse width modulated signal.

Theory:
Pulse Width Modulation (PWM) encodes a signal into periodic pulses of equal magnitude but
varying width. The width of a pulse at a given point of time is proportional to the amplitude
of the message signal at that time. For example large value of the message yields a narrow
pulse.
To implement the PWM, the message signal is compared with the saw tooth carrier. When
the message signal is greater than the carrier, the comparator output becomes high band vice
versa; the heights and the lows can be represented by +1 and -1 respectively. The comparator
output will be the pulse width modulated signal.

Uses:

Pulse Width Modulation (PWM) is a nifty current control technique that enables you to

control the speed of motors, heat output of heaters, and much more in an energy-efficient

(and usually quieter) manner. Existing applications for PWM include, but are not limited to:

 Variable speed fan controllers.

 VRF HVAC compressor drives.

 Hybrid and electric vehicle motor drive circuits.

 LED Dimmers.
Matlab Code:
% PWM Signal
clc;
close all;
clear all;
t=0:0.0001:1;
s=sawtooth(2*pi*10*t+pi);
figure(1)
subplot(2,1,1);
plot(t,s);
title('sawtooth Signal');
xlabel('Time Period');
ylabel('Amplitude');

m=0.75*sin(2*pi*1*t);
subplot(2,1,2);
plot(t,m);
title('Message Signal');
xlabel('Time Period');
ylabel('Amplitude');

n=length(s);
for i=1:n
if (m(i)>=s(i))
pwm(i)=1;
elseif (m(i)<=s(i))
pwm(i)=0;
end
end
figure(2)
plot(t,pwm);
ylabel('Amplitude');
axis([0 1 -1.5 1.5]);
xlabel('Time index');
title('PWM Wave');
grid on;
Output Graphs:

Output of PWM WAVE:


AIM: To develop a MATLAB program for PPM (Pulse Position Modulation) of a message
signal.

TOOLS USED: MATLAB R2016a


Procedure:
Theory:

A modulation technique that allows variation in the position of the pulses according to the
amplitude of the sampled modulating signal is known as Pulse Position Modulation (PPM). It
is another type of PTM, where the amplitude and width of the pulses are kept constant and
only the position of the pulses is varied.

Simply put, the pulse displacement is directly proportional to the sampled value of the
message signal.
Matlab Code:

% PPM Signal
clc;
clear all;
close all;
fc=1000;
fs=10000;
fm=200;
t=0:1/fs:((2/fm)-(1/fs));
X= 0.5*cos(2*pi*fm*t)+0.5;
Y= modulate(X,fc,fs,'PPM');
subplot(2,2,1);
plot(X);
title('Msg Signal');
subplot(2,2,2);
plot(Y);
axis([0 500 -0.2 1.2]);
title('PPM');
Output Graphs:

You might also like