Inverter with C-Script-Based PWM Modulator
Overview
This demonstration shows an ideal MOSFET inverter that is controlled by a custom PWM scheme. The switching strategy creates a bipolar output voltage of Vdc or -Vdc and is implemented as a state machine using the C-Script block.
Power circuit
An idealized full-bridge single-phase MOSFET inverter is modulated to create a 400 VDC square wave from a 400 VDC source. The square wave is then conditioned to represent a sinusoidal waveform of approximately 230 VAC using an LCL filter.

Control
A dead time is added between switching transitions to ensure that short circuits across the DC bus do not occur. A minimum on-time requirement for each switch has also been included. Both of these parameters, along with the switching frequency, are masked parameters for the PWM subsystem. Since they are directly passed to the C-Script block as inputs, the values can be changed at the top level of the schematic for analyzing various effects.

The figure above shows the timing of a single switching cycle with blanking time td between switching transitions. The state machine concept is not only useful for pattern generation but can easily be adapted to respond to external rather than internal events for applications such as control system sequencing.
Simulation
Increase the dead time ratio and monitor the load voltage to observe the dead time effects of distortion and attenuation on the output waveform.