Problem in generating PWM pulses for DC-DC converter
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Walter Roberson
am 3 Okt. 2013
What error message do you get where, or what difference do you observe between the desired and actual output ?
Antworten (1)
Sabin
am 23 Jan. 2024
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 Kommentare
Communitys
Weitere Antworten in Power Electronics Control
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!