Problem in generating PWM pulses for DC-DC converter

조회 수: 1 (최근 30일)
Rajkiran Singh
Rajkiran Singh 2013년 10월 3일
답변: Sabin 2024년 1월 23일
Below is the code that I used to generate the PWM pulse for dc-dc converter. There is an error in the codes. Basically I would like to generate the pwm pulses by comparing carrier signal with straight line. Anyone could enlighten me pls? thank you.
clc;
clear all;
close all;
F1=input('Carrier Sawtooth frequency=');
A=1;
t=0:0.00001:0.002;
c=A.*sawtooth(2*pi*F1*t);%Carrier sawtooth
subplot(3,1,1);
plot(t,c);
xlabel('time');
ylabel('Amplitude');
title('Carrier sawtooth wave');
grid on;
m=[0 1],[0.5 0.5];%Message amplitude must be less than Sawtooth
subplot(3,1,2);
plot(t,m);
xlabel('Time');
ylabel('Amplitude');
title('Message Signal');
grid on;
n=length(c);%Length of carrier sawtooth is stored to 'n'
for i=1:n%Comparing Message and Sawtooth amplitudes
if (m(i)>=c(i))
pwm(i)=1;
else
pwm(i)=0;
end
end
subplot(3,1,3);
plot(t,pwm);
xlabel('Time');
ylabel('Amplitude');
title('plot of PWM');
axis([0 0.002 0 2]);%X-Axis varies from 0 to 1 & Y-Axis from 0 to 2
grid on;
  댓글 수: 2
Walter Roberson
Walter Roberson 2013년 10월 3일
What error message do you get where, or what difference do you observe between the desired and actual output ?
Rajkiran Singh
Rajkiran Singh 2013년 10월 3일
Below line suppose to generate horizontal line but it's not plotting it. m=[0 1],[0.5 0.5];%Message amplitude must be less than Sawtooth

댓글을 달려면 로그인하십시오.

답변 (1개)

Sabin
Sabin 2024년 1월 23일
This line of code is not doing what is intended:
m=[0 1],[0.5 0.5];%Message amplitude must be less than Sawtooth
to make it work replace it with something like (0.5 is the duty cycle):
m = 0.5*ones(1, length(t));

커뮤니티

더 많은 답변 보기:  Power Electronics Community

카테고리

Help CenterFile Exchange에서 Pulse width modulation (PWM)에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by