In this video you will see how to design and implement a gain-scheduled PID controller in MATLAB and Simulink.
The plant is continuous stirred tank reactor modeled in Simulink model in front of you.
The input to the plant is coolant temperature. The output is output concentration.
If you look inside the subsystem here, you see the equations governing the dynamics of the plant.
These equations are nonlinear as evidenced by this block highlighted in red here.
This nonlinear behavior causes the dynamics of the plant to change significantly from low concentration values to high concentration
values, and that is why we will design a gain- scheduled PID controller to effectively control the plant.
Let’s close this model now and go to MATLAB. We’ll use this script here to linearize the plant and design our PID controllers.
We will linearize the plant by specifying the name of Simulink model to work with. We’ll specify the values of output concentration:
2,3,4,5,6,7,8,and 9 – where we want to linearize our plant.
We will use functions from Simulink Control Design to trim the model and then to linearize it at the trimmed conditions.
These functions are findop and linearize. Let’s execute this cell.
When the calculations are done, we see new variable called Plants.
Plants is an array of 8 state-space systems, as you can see here, and you can see the corresponding a,b,c,d matrices.
We also get a vector C, which is an array of concentration values where we linearize the plant at.
Let’s analyze plant dynamics at different concentration values.
We’ll create a Bode plot, and if you look at it, you see that both the magnitude and the phase are changing significantly from one operating
condition to another. That’s why we can’t get away with just one PID controller, but need to design a gain-scheduled
PID controller instead. We also see that our plant is stable at low and high values of concentration,
but is unstable in the middle.
Again, this tells us we need to design a gain- scheduled PID controller.
We’ll tune our PID controller gains at all 8 different operating conditions using one function, called pidtune.
We’ll supply an array of state-space models to this function.
We’ll also tell it that we want PID controller with derivative filter, and our target bandwidth is 10 rad/sec.
When we execute this cell we get an array of 8 PID controllers. You see them here, and you see there are 8 of them.
So now we need to implement this array of PID controllers in Simulink. To do that, we’ll switch to a different model, called “Gain Scheduling�?.
We still have our plant model here, but now we added the feedback loop. We take the output concentration and feed it back to the summation
junction, where we subtract output concentration from the setpoint value.
The error signal goes to the PID block. We also use the output concentration signal here to drive the gains of the PID controller.
They are now going to change at different operating conditions, and they are going to change according to these look-up tables here.
So let’s look at the look-up table for the proportional gain. The x axis for this look-up table is the vector of concentrations, C.
And the y axis is the vector of Kp gains that we just designed. We use the same blocks with the same idea for the integral gain, derivative gain,
and the N gain that goes into the PID controller. And here, it’s just 1 divided by the time constant of the derivative filter.
So now we have our gain-scheduled PID controller implemented in Simulink, and we can run the simulation, and look at the results.
We look at them in Simulation Data Inspector.
Here is our concentration setpoint. You see that we start at the high value of 9, and we do a set of small steps down,
followed by a set of small steps up, followed by big transient down, and big step up.
Let’s look at how our controller fares. And we see that our gain-scheduled controller provides fast and stable performance with
minimal overshoot. So this concludes the video which showed you how to design and implement
gain-scheduled PID controller in MATLAB and Simulink.