Skip to content

PWM subsystem ​

Open in simulator →

A closed-loop PWM power regulator whose switching stage runs in a faster Subsystem.

Same power loop as the PWM power controller, but the power stage, the PWM and the whole power measurement (the VRIR multiply and its low-pass filter) run inside a Subsystem at 20 sub-steps per main step. Only the smooth filtered power Pavg leaves through a GoTo / From pair; the PID outside sends the duty back in.

A PID compares the measured power against a setpoint and trims the duty of a PWM stage that switches an IGBT into a 5 Ω load. This is the same regulator as the PWM power controller, rearranged to show a multi-rate Subsystem: the switching stage runs at a finer time step than the controller around it.

The main time step is 50 µs and the Subsystem runs 20 sub-steps per main step, so everything inside it (the 50 V bus, Rs, the IGBT, the load, the PWM, the VR⋅IR multiply and the 0.1 s low-pass filter) advances at 2.5 µs. That resolution matters: the 1.1 kHz PWM needs a duty of only about 0.068 to put 30 W into the load, and at 2.5 µs each pulse edge lands within 0.00275 of the commanded duty. At the 50 µs main step a pulse can only be whole 50 µs steps long (a duty quantum of 0.055), and the regulated power swings by more than ±1 W.

Signals cross the Subsystem boundary through GoTo / From pairs, never through wires. The whole power measurement stays inside: the instantaneous power P_inst is formed and filtered at every sub-step, so the filter sees the real switching waveform. Only the smooth P_avg crosses out, read with a From whose rate_policy is average (the mean over each 50 µs main step; with a signal this smooth it is practically the same as the default last). The duty travels the other way through another GoTo / From pair. Over the 3 s run P_avg settles within about ±0.15 W of the 30 W setpoint and the duty settles near 0.068; probe inside and outside the Subsystem to compare the 2.5 µs and 50 µs traces.