In this video, we will tune the gains of a PID Controller for a buck converter.
Buck converter steps down the input voltage to desired value and automatically compensates for changes in the source voltage
and load current.
This compensation is done by quickly switching power transistors on and off as needed using pulse-width modulation.
In this example, we use a buck converter modeled in Simscape Electronics.
In the model, we have source voltage, MOSFETS, passive components, and a variable load.
The source voltage stays fixed at 30 volts in this simulation, but can easily be setup to change.
The PID controller inside of the Feedback Controller subsystem compares the output voltage to the reference signal
and calculates the PWM signal that can vary from 1% to 95%.
PID controller gains are set to initial guesses that do not provide particularly good controller performance.
We can see that by simulating the model and looking at simulation results.
In the top plot, we see the reference voltage, which changes from 15 to 25 volts and the output voltage.
In the second plot, we see the PWM signal and in the third plot we see load current.
We can notice that the system has slow and underdamped response and significant overshoot.
We want to tune the PID controller gains to improve the performance: make the response faster,
reduce overshoot and minimize the oscillations.
To do this we will use a new capability in Simulink Control Design in Release 2017b,
called Frequency Response Based PID Tuning.
To use this capability, we open PID Controller block dialog and select Frequency Response Based PID Tuning method.
The other option here, Transfer Function based PID Tuning is what was already available prior to release 2017b.
With Transfer Function Based tuning, Simulink Control Design attempts to linearize Simulink model,
and uses the resulting transfer function to tune PID gains.
For this particular model, and other models with discontinuities such as PWM,
linearization will be zero, and you will need to use an alternative method.
There are several such alternatives, and Frequency Response Based PID Tuning is now one of them.
When you select it, and press “Tune”, a window comes up explaining how this tuning method works.
It involves injecting an excitation signal at plant input .
The excitation signal consists of sine waves and a step and is needed to compute frequency response of the plant at several frequency points
around desired bandwidth.
There are several parameters we need to specify here.
First, we need to specify when to start injecting excitation signal.
From simulating the model with initial controller gains, we see that at 2 milliseconds, the system is close to a steady state,
so we will start injecting the excitation signal then.
We also need to specify the duration of the excitation signal, the desired bandwidth for our closed loop system,
and the amplitudes of the sine waves and step signal we will use to excite plant dynamics.
In this example, we will try to get a rise time of 0.25 milliseconds.
This corresponds to a bandwidth of 8,000 rad/sec.
We computed this number by dividing 2 by the rise time.
For the duration, a good rule of thumb is to divide 100 by the bandwidth, so 100/8000 gives us 0.0125 – 12.5 milliseconds.
Now let’s specify the amplitude of the step and sine waves we will inject.
In this example the control signal, PWM command, changes between 1% and 95%
and when we start the experiment, and our output voltage is at 15 volts, the PWM command is at 0.5, 50%.
so we will specify the amplitude at 0.1 for sine waves and step as well.
We are now ready to tune.
We press the "Tune" button.
The tool runs the model twice.
In the first simulation the model is run as is, to establish baseline performance and to capture the effect of any disturbances we might have,
like the variable load current in this case.
In the second run, the feedback loop is opened, and sine waves and a step signal are injected into the plant input.
The excitation signal is added to the control signal saved from the first run.
This way the tool can compute the plan output purely due to the injected excitation signal, and cancel out the effect of any disturbances
present in the model.
Once two simulation runs are completed, the tool uses simulation data to estimate plant frequency response.
It then uses this frequency response to automatically compute PID gains.
We can use them to update PID Controller block, and run the simulation to verify the performance.
As we can see we have much improved response, with faster rise time, lower overshoot, and no oscillations.
In summary, starting with release R2017b Simulink Control design provides a new option for automatically tuning PID Controller gains
for Simulink models that do not linearize.
This capability should be particularly useful for applications such as motor and power control
and for complex models that might be difficult to linearize.