Skip to Main Content Skip to Search
Product Documentation

Designing PID Controllers

Control System Toolbox software gives you several tools for designing PID controllers.

ToolWhen to use

Use to design a SISO PID controller in the feed-forward path of single-loop, unity-feedback control configuration.

SISO Design ToolUse to design a SISO PID controller in any other loop configuration.

Designing PID Controllers with the PID Tuner GUI

PID Tuner Overview

Use the PID Tuner GUI to interactively design a SISO PID controller in the feed-forward path of single-loop, unity-feedback control configuration.

The PID Tuner automatically designs a controller for your plant. You specify the controller type (P, I, PI, PD, PDF, PID, PIDF) and form (parallel or standard). You can analyze the design using a variety of response plots, and interactively adjust the design to meet your performance requirements.

To launch the PID Tuner, use the pidtool command:

pidtool(sys,type)

where sys is a linear model of the plant you want to control, and type is a string indicating the controller type to design.

Alternatively, enter

pidtool(sys,Cbase)

where Cbase is a baseline controller, allowing you to compare the performance of the designed controller to the performance of Cbase.

For more information about sys and Cbase, see the pidtool reference page.

PID Controller Type

The PID Tuner can tune up to seven types of controllers. To select the controller type, use one of these methods:

type input to pidtoolEntry in Type menuController TypeContinuous-time Controller Formula (parallel form)Discrete-time Controller Formula (parallel form, ForwardEuler integrator formulas)
'p'PProportional onlyKpKp
'i'IIntegral only

'pi'PIProportional and integral

'pd'PDProportional and derivative

'pdf'PDFProportional and derivative with first-order filter on derivative term

'pid'PIDProportional, integral, and derivative

'pidf'PIDFProportional, integral, and derivative with first-order filter on derivative term

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. To design a controller that has different discrete integrator formulas, use one of the following methods:

For more information about discrete integrator formulas, see the pid and pidstd reference pages.

PID Controller Form

When you use the type input to launch the PID Tuner, the PID Tuner designs a controller in parallel form. To design a controller in standard form, use one of the following methods:

For more information about parallel and standard controller forms, see the pid and pidstd reference pages.

Analyzing Your Design Using Response Plots

Select response plots from the Response menu to analyze the controller's performance. The PID Tuner computes the system responses assuming the following architecture:

The following table summarizes the available response plots.

ResponsePlotted System Description
Reference tracking

(from r to y)

Shows the closed-loop system response to a change in setpoint. Use when your design specifications include setpoint tracking.
Controller effort

(from r to u)

Shows the closed-loop controller output response to a change in setpoint. Use when your design is limited by practical constraints, such as controller saturation.
Input disturbance Rejection

(from d1 to y)

Shows the closed-loop system response to load disturbance (a disturbance at the plant input). Use when your design specifications include input disturbance rejection.
Output disturbance Rejection

(from d2 to y)

Shows the closed-loop system response to measurement noise.
Open-loopC*sysShows response of the open-loop controller-plant system. Use for frequency-domain design.
Use when your design specifications include robustness criteria such as open-loop gain margin and phase margin.
PlantsysShows the plant response. Use to examine plant dynamics.

Choose time-domain (Step) or frequency-domain (Bode) responses from the Plot menu.

If you provide Cbase, check Show baseline to display the response of the baseline controller.

Example: Designing a Controller for Fast Reference Tracking

In this example, you use the 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.

  1. Launch the PID Tuner to design a PI controller for a first pass design.

    sys = zpk([],[-1 -1 -1],1);  % create the plant model
    pidtool(sys,'pi')

    Upon launch, the PID Tuner displays the closed-loop step response of the system with a PI controller designed for a balance between performance (response time) and robustness (stability margins).

  2. Examine the reference tracking rise time and settling time.

    Right-click on the plot and select Characteristics > 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 PID Tuner default PI controller provides a rise time of 2.35 s and settling time of 10.7 s. Both results are slower than the design requirements.

      Note   To display the performance metrics in a table instead of in tool-tips on the plot, click the Show parameters button . This action expands the GUI to show performance and robustness metrics. It also displays the controller gains.

  3. Use the Response time slider to try to improve the loop performance.

    Slide the slider to the right to make the loop faster. The response plot automatically updates with the new design.

    Moving the slider far enough to meet the rise time requirement of less than 1.5 s, however, results in unacceptably long settling time. There is also more oscillation. To achieve the faster response speed, the algorithm must sacrifice stability.

  4. Change the controller type to improve the response.

    Adding derivative action to the controller gives the PID Tuner more freedom to achieve adequate phase margin with the desired response speed.

    Select PIDF from the Type menu. The PID Tuner designs a new PIDF controller. (See PID Controller Type for more information about available controller types.)

    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 the button.

      Note   To adjust the closed-loop bandwidth and phase margin separately, select Extended from the Design mode menu . The bandwidth is inversely proportional to the response time.

  5. Analyze other system responses, if appropriate.

    To analyze other system responses, use the Response menu to choose a response plot and the Plot menu to choose time-domain (Step) or frequency-domain (Bode) responses.

    For example, to observe the closed-loop system response to disturbance at the plant input, select Input disturbance rejection from the Response menu.

    See Analyzing Your Design Using Response Plots for more information about available response plots.

  6. Export your controller design to the MATLAB workspace.

    To export your final controller design to the MATLAB workspace, click . The PID Tuner GUI exports the controller as a

    • pid controller object, if the Form is Parallel

    • pidstd controller object, if the Form is Standard

For more examples of controller design using the PID Tuner, see the Control System Toolbox demo, Designing PID for Disturbance Rejection with PID Tuner

Designing PID Controllers at the Command Line

To design PID Controllers at the command line, use the pidtune command. For more information and examples, see:

  


Free Control Systems Interactive Kit

Learn more about resources for designing, testing, and implementing control systems.

Get free kit

Trials Available

Try the latest control systems products.

Get trial software
 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS