Tune PID Controller
Tune PID Controller for LTI plant in the Live Editor
Description
The Tune PID Controller Live Editor task lets you interactively tune a PID controller for a plant. The task automatically generates MATLAB® code for your live script. For more information about Live Editor tasks generally, see Add Interactive Tasks to a Live Script.
Tune PID Controller automatically tunes the gains of a PID controller for a SISO plant to achieve a balance between performance and robustness. You can specify the controller type, such as PI, PD, or PID with or without a derivative filter. By default, Tune PID Controller assumes the following standard unit-feedback control configuration.

You can also use Tune PID Controller to design a 2-DOF PID controller for the feedback configuration of this illustration:

Tune PID Controller generates analysis plots that let you examine controller performance in the time and frequency domains. You can interactively refine the performance of the controller to adjust response time, loop bandwidth, or phase margin, or to favor setpoint tracking or disturbance rejection.
To get started with the Tune PID Controller task, select the plant model and specify the type of controller you want to design. Experiment with the sliders and observe their effect on the closed-loop system response. For an example, see PID Controller Design in the Live Editor.
Related Functionality
Tune PID Controller generates code using
pidtuneandpidtuneOptions.To perform interactive PID tuning in a standalone app, use PID Tuner.
Open the Task
To add the Tune PID Controller task to a live script in the MATLAB Editor:
On the Live Editor tab, select Task > Tune PID Controller.
In a code block in your script, type a relevant keyword, such as
tuneorPID. SelectTune PID Controllerfrom the suggested command completions.
Parameters
Tips
After you select a plant, the task creates the controller and stores it in the MATLAB workspace. The stored controller is a
pid,pidstd,pid2, orpidstd2model object, as specified by your selections for Form and Degrees of Freedom.The default variable name for the stored controller is
C. You can change the variable name by typing a new name into the task summary line.
The task also provides information about the performance and robustness of the closed-loop system in a structure called
pidInfoby default. For information about this structure, see theinfooutput argument on thepidtunereference page.
Algorithms
Tune PID Controller uses the algorithm discussed in PID Tuning Algorithm.
Version History
Introduced in R2019b



