Header Ads

Header ADS

Pulse Width Modulation (PWM) Using MATLAB


1. To understand the basic theory of Pulse Width Modulation (PWM).
2. To understand the waveform Pulse Width Modulation (PWM) using Matlab.
Program Code:
clc;
clear all;
close all;
%% User Define
t=input('Enter the time: ');
fc=input('Enter frequency of carrier signal(sawtooth): ');
fm=input('Enter frequency of message signal(sine): ');
a=input('Enter the amplitude of carrier signal: ');
b=input('Enter the amplitude of message signal(should be < Carrier): ');

%% Code
vc=a.*sawtooth(2*pi*fc*t);
vm=b.*sin(2*pi*fm*t);
n=length(vc);
for i=1:n
if(vm(i)>=vc(i))
        pwm(i)=1;
else
        pwm(i)=0;
end
end
subplot(3,1,1);
plot(t,vm);
xlabel('Time');
ylabel('Amplitude');
title('Message Signal');
grid on;

subplot(3,1,2);
plot(t,vc);
xlabel('Time');
ylabel('Amplitude');
title('Carrier Signal');
grid on;

subplot(3,1,3);
plot(t,pwm);
xlabel('Time');
ylabel('Amplitude');
title('PWM Signal');
axis([0 1 0 2]);
grid on;


Result:
Enter the time: 0:0.001:1
Enter frequency of carrier signal(sawtooth): 10
Enter frequency of message signal(sine): 5
Enter the amplitude of carrier signal: 500
Enter the amplitude of message signal(should be < Carrier): 50



Report Result:
Enter the time: 0:0.001:1
Enter frequency of carrier signal(sawtooth): 30
Enter frequency of message signal(sine): 10
Enter the amplitude of carrier signal: 8
Enter the amplitude of message signal(should be < Carrier): 5




 We know about pulse wide modulation (PWM) and also understand the waveform of pulse wide modulation using MATLAB. First i write the given code in the MATLAB and get some waveform attach on the lab.PWM or PDM is a modulation technique can be used to encode information for transmission, its main use is to allow the control of the power supplied to electrical devices. So we get message signal first then carrier signal and finally we get the PMW signal.

No comments

Powered by Blogger.