Open PID Tuner for PID tuning
pidtool(sys,Cbase) launches the GUI with a baseline controller Cbase so that you can compare performance between the designed controller and the baseline controller. If Cbase is a pid or pidstd controller object, the PID Tuner designs a controller of the same form, type, and discrete integrator formulas as Cbase.
pidtool(sys) designs a parallel-form PI controller.
pidtool launches the GUI with default plant of 1 and proportional (P) controller of 1.
Plant model for controller design. sys can be:
If the plant has unstable poles, and sys is either:
then you must specify the number of unstable poles in the plant. To do this, After launching the PID Tuner GUI, click the button to open the Import Linear System dialog box. In that dialog box, you can reimport sys, specifying the number of unstable poles where prompted.
Controller type (actions) of the controller you are designing, specified as one of the following strings:
When you use the type input, the PID Tuner designs a controller in parallel form. If you want to design a controller in standard form, Use the input Cbase instead of type, or select Standard from the Form menu. For more information about parallel and standard forms, see the pid and pidstd reference pages.
If sys is a discrete-time model with sampling time Ts, the PID Tuner designs a discrete-time pid controller using the ForwardEuler discrete integrator formula. If you want to design a controller having a different discrete integrator formula, use the input Cbase instead of type or the Preferences dialog box. For more information about discrete integrator formulas, see the pid and pidstd reference pages.
A dynamic system representing a baseline controller, permitting comparison of the performance of the designed controller to the performance of Cbase.
If Cbase is any other dynamic system, the PID Tuner designs a parallel-form PI controller. You can change the controller form and type using the Form and Type menus after launching the PID Tuner.
Interactive PID Tuning of Parallel-Form Controller
Launch the PID Tuner to design a parallel-form PIDF controller for a discrete-time plant:
Gc = zpk(,[-1 -1 -1],1); Gd = c2d(Gc,0.1); % Create discrete-time plant pidtool(Gd,'pidf') % Launch PID Tuner
Interactive PID Tuning of Standard-Form Controller Using Integrator Discretization Method
Design a standard-form PIDF controller using BackwardEuler discrete integrator formula:
Gc = zpk(,[-1 -1 -1],1); Gd = c2d(Gc,0.1); % Create discrete-time plant % Create baseline controller. Cbase = pidstd(1,2,3,4,'Ts',0.1,... 'IFormula','BackwardEuler','DFormula','BackwardEuler') pidtool(Gd,Cbase) % Launch PID Tuner
The PID Tuner designs a controller for Gd having the same form, type, and discrete integrator formulas as Cbase. For comparison, you can display the response plots of Cbase with the response plots of the designed controller by clicking the Show baseline checkbox on the PID Tuner GUI.
For PID tuning at the command line, use pidtune. pidtune can design controllers for multiple plants at once.
The PID Tuner designs a controller in the feedforward path of a single control loop with unit feedback:
The PID Tuner has a default target phase margin of 60 degrees and automatically tunes the PID gains to balance performance (response time) and robustness (stability margins). Use the Response time or Bandwidth and Phase Margin sliders to tune the controller's performance to your requirements. Increasing performance typically decreases robustness, and vice versa.
Select response plots from the Response menu to analyze the controller's performance.
If you provide Cbase, check Show baseline to display the response of the baseline controller.
For more detailed information about using the PID Tuner, see Designing PID Controllers with the PID Tuner.
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 first frequency at which the open-loop gain is unity), the faster the controller responds to changes in the reference or disturbances in the loop.
Adequate robustness — The loop design has enough phase margin and gain margin to allow for modeling errors or variations in system dynamics.
The MathWorks algorithm for tuning PID controllers helps you meet these objectives by automatically tuning the PID gains to balance performance (response time) and robustness (stability margins).
By default, the algorithm chooses a crossover frequency (loop bandwidth) based upon the plant dynamics, and designs for a target phase margin of 60°. If you change the bandwidth or phase margin using the sliders in the PID Tuner GUI, the algorithm computes PID gains that best meet those targets.
Åström, K. J. and Hägglund, T. Advanced PID Control, Research Triangle Park, NC: Instrumentation, Systems, and Automation Society, 2006.