i want to generate a pwm of variable duty cycle
3 views (last 30 days)
Show older comments
i want to generate a pwm of variable duty cycle like first 200 ms duty cycle should be 35%,for next 250 ms duty cycle should be 50%, for next 500 ms duty cycle should be 80% and for rest of time is 100%.How to acheive this function.Thanks in advance.
0 Comments
Answers (2)
VBBV
on 10 Oct 2021
Edited: VBBV
on 10 Oct 2021
A = 1;% normalized amplitude
T = 0:0.1:2000; % millisec
Sx = zeros(length(T),1);
i = 1;
while i<=length(T)
if T(i)<200
Sx(i) = 0.35*A;
elseif T(i)>=200 & T(i)<=450
Sx(i) = 0.5*A;
elseif T(i)>=450 & T(i)<= 950
Sx(i) = 0.8*A;
elseif T(i)>=950 & T(i)<=1000
Sx(i) = 0;
elseif T(i)<1000+200
Sx(i) = 0.35*A;
elseif T(i)>=1000+200 & T(i)<1000+450
Sx(i) = 0.5*A;
elseif T(i)>=1000+450 & T(i)<1000+950
Sx(i) = 0.8*A;
else
Sx(i) = 0;
end
i = i+1;
end
plot(T,Sx,'linewidth',2)
axis([0 2000 0 1.5]);
grid
you can try this, but using Simulink generator would be good option
0 Comments
Communities
More Answers in the Power Electronics Control
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!