Experiment No.2: Aim: To Generate PWM Waves Using MATLAB Theory

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

1

EXPERIMENT NO.2
Aim: To generate PWM waves using MATLAB.
Theory: General concept:PWM or Pulse width Modulation is used in the electronics majorly to control the voltage
at the input of the electronic device .
We control the width of the input signal before powering the electronic equipment
Advantages:It works as if a switch is connected to the input signal and the output of the switch
connects the electronic equipment to the switch .
We continuously turn the switch ON and OFF so as to control the effective time the
input goes to the output .
Disadvantages:Again in the whole time period of the input wave if we dont continuously do it then we
would generate an effect that would show discontinuous ON and OFF periods which is
not the idea behind PWM .We need a continuous effect so the switching is really fast
and is not perceptible to human.
Miscellaneous:The following equation is important:
Duty cycle =(Ton)/(Ton+Toff)
Duty cycle the percentage of on Time period to the Total Time Period.

MATLAB CODE:

clear all;
t=1:200;
m=sin(4*pi*t/200);
t=0:0.1:200;
s=2.*sawtooth(2*pi*t);
for t=1:200
if (m(t)>=s(t))
p(t)=1;
elseif (m(t)<=s(t))
p(t)=0;
end
end
t =1:200;
subplot(3,1,1);
plot(t,m(t));
ylabel('Amplitude');
xlabel('Time ');
subplot(3,1,2);
plot(t,s(t));
ylabel('Amplitude');
xlabel('Time ');
subplot(3,1,3);
plot(t,p(t));
ylabel('Amplitude');
xlabel('Time ');
axis([1 200 0 1.5]);
title('PWM Wave');

%regular sinewave message signal


%sawtooth signal

OUTPUT:-

LEARNING OUTCOME:
After performing the above experiment, I learntUsing PWM technique, any type of analog signal can be converted into a pulsating
signal with the help of pulse train(carrier).
Applications
As power loss is minimum in PWM, it can be used in designing switching circuits.
PWM technique can also be used to control power supplied to electrical devices like
motors.

You might also like