Simulink PWM-Generator block

I needed a Simulink block that generates a PWM with variable frequency and duty cycle. The toolboxes I have don’t contain a suitable block and therefore I had to create my own one. I’d like to share the result here in case of anybody else has the need for such a block.
Feel free to use this information for whatever you like. Just note that I won’t be responsible for anything.

The block consists of a ramp generator and a comparator. The ramp generator has been realized with a wrapping integrator and the comparator in form of a sum– and a sign-block. However, as the sign-block doesn’t have configurable outputs (it’s fixed to the output values of -1 and 1) we have to scale the output signal back to [0..1].

It’s important that you enable the Wrap state feature of the integrator. This causes the integrator to reset back to 0 once it hit the upper limit which we set to 1.

This block has been tested successfully with Matlab R2016a (Simulink 8.7).

Leave a Comment

Your email address will not be published.

3 Trackbacks

  1. C─▒vata (Pingback)
  2. Astropay (Pingback)
  3. Paykasa (Pingback)