A transfer function is given. Use MATLAB Simulink to design a PID controller.
Answers
First, let's take a look at how the PID controller works in a closed-loop system using the schematic shown above. The variable ($e$) represents the tracking error, the difference between the desired output ($r$) and the actual output ($y$). This error signal ($e$) is fed to the PID controller, and the controller computes both the derivative and the integral of this error signal with respect to time. The control signal ($u$) to the plant is equal to the proportional gain ($K_p$) times the magnitude of the error plus the integral gain ($K_i$) times the integral of the error plus the derivative gain ($K_d$) times the derivative of the error.
This control signal ($u$) is fed to the plant and the new output ($y$) is obtained. The new output ($y$) is then fed back and compared to the reference to find the new error signal ($e$). The controller takes this new error signal and computes an update of the control input. This process continues while the controller is in effect.
where $K_p$ = proportional gain, $K_i$ = integral gain, and $K_d$ = derivative gain.
We can define a PID controller in MATLAB using a transfer function model directly, for example:
Kp = 1;
Ki = 1;
Kd = 1;
s = tf('s');
C = Kp + Ki/s + Kd*s
C =
s^2 + s + 1
-----------
s
Continuous-time transfer function.
Alternatively, we may use MATLAB's pid object to generate an equivalent continuous-time controller as follows:
C = pid(Kp,Ki,Kd)
C =
1
Kp + Ki * --- + Kd * s
s
with Kp = 1, Ki = 1, Kd = 1
Continuous-time PID controller in parallel form.
Let's convert the pid object to a transfer function to verify that it yields the same result as above:
tf(C)
ans =
s^2 + s + 1
-----------
s
Continuous-time transfer function.