Main Content

Introduction to Model-Based PID Tuning in Simulink

You can use PID Tuner to interactively tune PID gains in a Simulink® model containing a PID Controller, Discrete PID Controller, PID Controller (2DOF), or Discrete PID Controller (2DOF) block. PID Tuner allows you to achieve a good balance between performance and robustness for either one-degree-of-freedom or two-degree-of-freedom PID controllers. When you use PID Tuner, it:

  • Automatically computes a linear model of the plant in your model. 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 PID Tuner See?.

  • Automatically computes an initial PID design with a balance between performance and robustness. PID Tuner bases the initial design upon the open-loop frequency response of the linearized plant. See PID Tuning Algorithm.

  • Provides tools and response plots to help you interactively refine the performance of the PID controller to meet your design requirements. See Open PID Tuner.

For plants that do not linearize or that linearize to zero, there are several alternatives for obtaining a plant model for tuning. These alternatives include:

  • Design PID Controller from Plant Frequency-Response Data — Use the frequency-response estimation command frestimate or the Frequency Response Based PID Tuner to obtain estimated frequency responses of the plant by simulation.

  • Interactively Estimate Plant from Measured or Simulated Response Data — If you have System Identification Toolbox™, you can use PID Tuner to estimate the parameters of a linear plant model based on time-domain response data. PID Tuner then tunes a PID controller for the resulting estimated model. The response data can be either measured from your real-world system, or obtained by simulating your Simulink model.

You can use PID Tuner to design one-degree-of-freedom 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 tradeoff 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:

What Plant Does PID Tuner See?

PID Tuner considers as the plant all blocks in the loop between the PID Controller block output and input. The blocks in your plant can include nonlinearities. Because automatic tuning requires a linear model, PID Tuner computes a linearized approximation of the plant in your model. This linearized model is an approximation to a nonlinear system, which is valid in a small region around a given operating point of the system.

By default, PID Tuner linearizes your plant using the initial conditions specified in your Simulink model as the operating point. The linearized plant can be of any order and can include any time delays. The PID tuner designs a controller for the linearized plant.

In some circumstances, however, you want to design a PID controller for a different operating point from the one defined by the model initial conditions. For example:

  • The Simulink model has not yet reached steady-state at the operating point specified by the model initial conditions, and you want to design a controller for steady-state operation.

  • You are designing multiple controllers for a gain-scheduling application and must design each controller for a different operating point.

In such cases, change the operating point used by PID Tuner. See Opening PID Tuner.

For more information about linearization, see Linearize Nonlinear Models.

PID Tuning Algorithm

Typical PID tuning objectives include:

  • Closed-loop stability — The closed-loop system output remains bounded for bounded input.

  • Adequate performance — The closed-loop system tracks reference changes and suppresses disturbances as rapidly as possible. The larger the loop bandwidth (the frequency of unity open-loop gain), the faster the controller responds to changes in the reference or disturbances in the loop.

  • Adequate robustness — The loop design has enough gain margin and phase margin to allow for modeling errors or variations in system dynamics.

MathWorks® algorithm for tuning PID controllers meets these objectives by tuning the PID gains to achieve a good balance between performance and robustness. By default, the algorithm chooses a crossover frequency (loop bandwidth) based on the plant dynamics, and designs for a target phase margin of 60°. When you interactively change the response time, bandwidth, transient response, or phase margin using the PID Tuner interface, the algorithm computes new PID gains.

For a given robustness (minimum phase margin), the tuning algorithm chooses a controller design that balances the two measures of performance, reference tracking and disturbance rejection. You can change the design focus to favor one of these performance measures. To do so, use the Options dialog box in PID Tuner.

When you change the design focus, the algorithm attempts to adjust the gains to favor either reference tracking or disturbance rejection, while achieving the same minimum phase margin. The more tunable parameters there are in the system, the more likely it is that the PID algorithm can achieve the desired design focus without sacrificing robustness. For example, setting the design focus is more likely to be effective for PID controllers than for P or PI controllers. In all cases, fine-tuning the performance of the system depends strongly on the properties of your plant. For some plants, changing the design focus has little or no effect.

See Also

Apps

Blocks

Related Topics