This example shows how to model a switching power supply that converts a 30V DC supply into a regulated 15V DC supply. The model can be used to both size the inductance L and smoothing capacitor C, as well as to design the feedback controller. By selecting between continuous and discrete controllers, the impact of discretization can be explored.
Modeling the switching devices as MOSFETs rather than ideal switches ensures that device on-resistances are correctly represented. The model also captures the switch-on/switch-off timing of the devices, this depending primarily on the gate capacitance values and the PWM driver output resistance.
See example model power_switching_power_supply for an abstracted version of this model that uses ideal switching to give faster simulation times. The model here can be used to determine the on-resistance values required for the ideal switches, plus timing offsets if necessary. Using the ideal switching approach of power_switching_power_supply can be used to simulate more complex power converters.
Workspace variables T_junction1 and T_junction2 are used to define the temperatures at which the two MOSFETs are simulated. Companion models ee_switching_power_supply_thermal and ee_switching_power_supply_thermal_only are used to determine these temperatures.
Simulation Results from Simscape Logging
The plot below shows the output voltage as compared to the reference voltage. It also shows the changing load current and the dissipated power of the two MOSFETS averaged over the PWM cycle.
The plot below shows the switch-on/switch off timing of the two MOSFETS and the drain-source current.
The plots below show the behavior of the different implementations of the PI controller.