The threeterm controller
Openloop step response
Proportional control
PD control
PI control
PID control
In this tutorial, we will consider the following unity feedback system:
Generally speaking,
for an openloop transfer function which has the canonical
secondorder form of:


Note that these correlations are not exactly accurate, because Kp, Ki, Kd are related to each other. Changing one of these variables can change the effect of the other two. For this reason, the table should only be used as a reference when you are determining the values for Ki, Kp and Kd by trial & error.
Many PID controllers are designed by the trial & error selection of the variables Kp, Ki, and Kd. There are some rules of thumb that you can consult to determine good values to start from; see your controls book for some explanations of these recommendations.
Suppose we have a secondorder plant transfer function:
The DC gain of the plant transfer function is 1/20, so 0.05 is the final value of the output for a unit step input. This corresponds to a steadystate error of 0.95, quite large indeed. Furthermore, the rise time is about one second, and the settling time is about 1.5 seconds. Most likely, this response will not be adequate. Therefore, we need to add some control.
num=1; den=[1 10 20]; Kp=10; [numCL,denCL]=cloop(Kp*num,den, 1); t=0:0.01:2; step(numCL, denCL,t)The cloop command in Matlab is used to convert the open loop transfer function into a closedloop one. Since the cloop command only accepts one transfer function, the plant and controller transfer functions have to be multiplied together before the loop is closed. It should also be noted that it is not a good idea to use proportional control to reduce the steadystate error, because you will never be able to eliminate the error completely. This fact will become evident below. If you rerun you mfile, you should get the following plot:
Now, the rise time has been reduced and the steadystate error is smaller, if we use a greater Kp, the rise time and steadystate error will become even smaller. Change the Kp value in the mfile:
Kp=500;Rerun the mfile and you should get the following plot:
This time we see that the rise time is now about 0.1 second and the steadystate error is much smaller. But the overshoot has gotten very large. From this example we see a large proportional gain will reduce the steadystate error but at the same time, worsen the transient response. If we want a small overshoot and a small steadystate error, a proportional gain alone is not enough.
The rise time is now probably satisfactory (rise time is about 0.1 second). Now let's add a derivative controller to the system to see if the overshoot can be reduced. Add another variable, Kd, to the mfile, set it equal to 10 and rerun the mfile:
Kp=500; Kd=10; numc=[Kd Kp]; [numCL, denCL]=cloop(conv(num,numc),den);step(numCL, denCL,t)
The overshoot is much less then before. It is now only twenty percent instead of almost fortyfive percent. We can now try to improve that even more. Try increasing Kd to 100, you will see the overshoot eliminated completely.
We now have a system with a fast rise time and no overshoot. Unfortunately, there is still about a 5 percent steadystate error. It would seem that a PD controller is not satisfactory for this system. Let's try a PI controller instead.
As we have seen, proportional control will reduce the steadystate error, but at the cost of a larger overshoot. Furthermore, proportional gain will never completely eliminate the steadystate error. For that we need to try integral control. Let's implement a PI controller and start with a small Ki. Go back to the mfile and change it so it looks like the following (note the t input is removed from the step command so more of the response can be seen):
The Ki controller really slows down the response. The settling time becomes more than 500 seconds. To reduce the settling time, we can increase Ki, but by doing this, the transient response will get worse (e.g. large overshoot). Try Ki=10, by changing the Ki variable. The plot can be see better if an axis command is added after the step response. Your mfile should now look like the following:
Now we have a large overshoot again, while the settling time is still long. To reduce both settling time and overshoot, a PI controller by itself is not enough.
From the two controllers above, we see that if we want a fast response, small overshoot, and no steadystate error, neither a PI nor a PD controller will suffice. Let's implement both controllers and design a PID controller to see if combining the two controllers will yield the desired response. Recalling that our PD controller gave us a pretty good response, except for a little steadystate error. Let's start from there, and add a small Ki (1). Change your mfile to the following to implement the PID controller and plot the closedloop response:
KP=500; KI=1; KD=100; numc=[KD KP KI]; denc=[1 0]; [numCL, denCL]=cloop(conv(num,numc),conv(den,denc)); step(numCL, denCL)
The settling time is still very long. Increase Ki to 100.
The settling time is much shorter, but still not small enough. Increase Ki to 500 and change the step command to step(numCL, denCL,t):
Now the settling time reduces to only 1.5 seconds. This is probably an acceptable response for this system. To design a PID controller, the general rule is to add proportional control to get the desired rise time, add derivative control to get the desired overshoot, and then add integral control (if needed) to eliminate the steadystate error. You may have to go back and readjust all three variables to finetune the response.