This example shows how to use PID Tuner to design a controller for the plant:
The design requirements are for the closed loop system to track a reference input with a rise time less than 1.5 s, and settling time less than 6 s.
In this example, you represent the plant as an LTI model. For information about using PID Tuner to tune a PID Controller block in a Simulink® model, see Tune PID Controller to Favor Reference Tracking or Disturbance Rejection (Simulink Control Design).
Create the plant model and open PID Tuner to design a PI controller for a first pass design.
sys = zpk(,[-1 -1 -1],1); pidTuner(sys,'pi')
When you open PID Tuner, it automatically designs a controller of the type you specify (here, PI). The controller is designed for a balance between performance (response time) and robustness (stability margins). PID Tuner displays the closed-loop step response of the system with the designed controller.
You can also open PID Tuner from the MATLAB® desktop, in the Apps tab. When you do so, use the Plant menu in PID Tuner to specify your plant model.
Examine the reference tracking rise time and settling time.
Right-click on the plot and select
> Rise Time to mark the rise time as a blue dot on
the plot. Select
Characteristics > Settling Time to
mark the settling time. To see tool-tips with numerical values, click
each of the blue dots.
The initial PI controller design provides a rise time of 2.35 s and settling time of 10.7 s. Both results are slower than the design requirements.
To display the performance metrics in a table instead of in tool-tips on the plot, click Show parameters. This action opens a display containing performance and robustness metrics and the tuned controller gains.
Slide the Response time slider to the right to try to improve the loop performance. The response plot automatically updates with the new design.
Moving the Response time slider far enough to meet the rise time requirement of less than 1.5 s results in more oscillation. Additionally, the parameters display shows that the new response has an unacceptably long settling time.
To achieve the faster response speed, the algorithm must sacrifice stability.
Change the controller type to improve the response.
Adding derivative action to the controller gives PID Tuner more freedom to achieve adequate phase margin with the desired response speed.
In the Type menu, select
Tuner designs a new PIDF controller. (See PID Controller Type for more information about available
The rise time and settling time now meet the design requirements. You can use the Response time slider to make further adjustments to the response. To revert to the default automated tuning result, click Reset Design.
To adjust the closed-loop bandwidth instead of the response
Frequency domain from the Design
mode menu . The bandwidth is inversely proportional to
the response time.
Analyze other system responses, if appropriate.
To analyze other system responses, click Add Plot. Select the system response you want to analyze.
For example, to observe the closed-loop step response to disturbance
at the plant input, in the Step section of the Add
Plot menu, select
Input disturbance rejection.
The disturbance rejection response appears in a new figure.
See Analyze Design in PID Tuner for more information about available response plots.
Use the options in the View tab to change how PID Tuner displays multiple plots.
Export your controller design to the MATLAB workspace.
To export your final controller design to the MATLAB workspace, click Export. PID Tuner exports the controller as a
Alternatively, you can export a model using the right-click menu in the Data Browser. To do so, click the Data Browser tab.
Then, right-click the model and select Export.