You can use the Simulink® Control Design™ PID Tuner to tune PID gains automatically in a Simulink model containing a PID Controller or PID Controller (2DOF) block. The PID Tuner allows you to achieve a good balance between performance and robustness for either one- or two-degree-of-freedom PID controllers.
The PID Tuner:
Automatically computes a linear model of the plant in your model. The PID Tuner considers the plant to be the combination of all blocks between the PID controller output and input. Thus, the plant includes all blocks in the control loop, other than the controller itself. See What Plant Does the PID Tuner See?.
Automatically computes an initial PID design with a balance between performance and robustness. The PID Tuner bases the initial design upon the open-loop frequency response of the linearized plant. See PID Tuning Algorithm.
Provides the PID Tuner GUI to help you interactively refine the performance of the PID controller to meet your design requirements. See Open the PID Tuner.
You can use the PID Tuner to design one- or two-degree-of-freedom PID controllers. You can often achieve both good setpoint tracking and good disturbance rejection using a one-degree-of-freedom PID controller. However, depending upon the dynamics in your model, using a one-degree-of-freedom PID controller can require a trade-off between setpoint tracking and disturbance rejection. In such cases, if you need both good setpoint tracking and good disturbance rejection, use a two-degree-of-freedom PID Controller.
For examples of tuning one- and two-degree-of-freedom PID compensators, see: