Appearance
Pwm Power Control
A closed-loop PWM power controller that holds its output at a setpoint with a PID.
The measured output is compared against a reference, a PID drives the duty cycle of a PWM stage that switches an IGBT, and a first-order transfer function stands in for the plant being driven. Run it and watch the plot as the controller pushes the error toward zero and tracks the setpoint despite the switching.
The controlled quantity here is power: the load voltage V_R and current I_R are multiplied to get instantaneous power, then a first-order filter averages out the switching ripple to give P_avg. The PID nudges the PWM duty until P_avg matches the 30 setpoint, so the IGBT delivers exactly that much average power to the 5 Ω load (R_s = 0.1 Ω is a small series sense resistor). The run is a long 2 s window (1 µs step) so you can watch the loop acquire the setpoint and hold it — the error trace collapsing toward zero is the loop doing its job.
