Problem in generating PWM pulses for DC-DC converter
2 ビュー (過去 30 日間)
古いコメントを表示
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
2013 年 10 月 3 日
What error message do you get where, or what difference do you observe between the desired and actual output ?
回答 (1 件)
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));
0 件のコメント
コミュニティ
その他の回答 パワー エレクトロニクス コミュニティ
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!