How to create variable-frequency PWM
67 views (last 30 days)
Show older comments
Hi all,
I am trying to create a variable-frequency PWM waveworm. That is, I want to be able to control frequency using an input signal or a variable that changes over time continuously.
I thought the easiest way to do this would be to use the "pulse generator" block and set the period to a variable. The next question of course is how to create a continuous time variable (such as a ramp) to dictate this. I don't know how to do this in either Matlab or Simulink.
I understand there are many ways to solve this problem. One way would be to stablish a variable name in Simulink that I can use as a variable in other blocks. Is this possible? If not, how else can I go about creating a variable frequency PWM waveworm (without getting too complicated creating my own subsystem). Should be very simple...
Thanks very much,
-Dan
1 Comment
Answers (2)
Dorai Yelaverthi
on 19 Feb 2018
Hi, These are the two methods(see screenshot below) I have figured out to do this.
The above two methods produce a sawtooth waveform that you can use as carrier for the PWM comparator. Just replace the constant (Frequency1 or Frequency2) blocks with any signal or variable you want to use to control the frequency. In the example simulink file variable frequency sawtooth (hyperlinked) a constant 100kHz sawtooth of amplitude 1 is generated.
0 Comments
rami ghali
on 9 Mar 2018
hello I have tried the above design however I am not getting a sawtooth at the scope
1 Comment
Dorai Yelaverthi
on 10 Mar 2018
I just verified and it works fine. If you download the simulink file (hyperlinked in my original answer) and run it without editing any thing it should generate a 100 kHz sawtooth. The same simulink model is submitted by me to Matlab File Exchange with name 'variable frequency sawtooth carrier for PWM'. Download this and just run.
One important parameter that you have to change would the max step size of the simulation. I recommend you setting it to atleast 10 times (preferably 100) lower than the time period of the sawtooth waveform. In the simulink file provided I set the maximum step size in solver options to be 1e-7 since the frequency of the carrier was 1e5. There isn't a lot that can go wrong here.
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!