-1

I need to generate a PWM signal with duty cycle after a sine. How I can do this in simulink and after this to simulate on a microcontroller F28027 PICCOLO ?

user
  • 9
  • 1
  • 6

1 Answers1

0

I am unsure about your requirement.I think the below codes might help you as first step. I think this must generate PWM signal.

percent=input('Enter the percentage:');
TimePeriod=input('Enter the time period:');
Cycles=input('Enter the number of cycles:');

x=0:0.01:Cycles*TimePeriod;
t=(percent/100)*TimePeriod;

for n=0:Cycles
    y(((n*TimePeriod)< x) & (x<(n*TimePeriod+t))) = 1;
    y(((n*TimePeriod+t)< x)& (x<((n+1)*TimePeriod))) = 0;

    plot(y,'b','LineWidth',2)
    grid on
end
HEMS
  • 187
  • 1
  • 5
  • 17