# pidstd2

2-DOF PID controller in standard form

## Description

Use `pidstd2`

to create standard-form, two-degree-of-freedom
(2-DOF) proportional-integral-derivative (PID) controller model objects, or to convert dynamic system models to standard 2-DOF PID controller
form.

2-DOF PID controllers include setpoint weighting on the proportional and derivative terms. A 2-DOF PID controller can achieve fast disturbance rejection without significant increase of overshoot in setpoint tracking. 2-DOF PID controllers are also useful to mitigate the influence of changes in the reference signal on the control signal. The following illustration shows a typical control architecture using a 2-DOF PID controller.

The `pidstd2`

controller model object can represent standard-form PID
controllers in continuous time or discrete time.

Continuous time — $$u={K}_{p}\left[\left(br-y\right)+\frac{1}{{T}_{i}s}\left(r-y\right)+\frac{{T}_{d}s}{\frac{{T}_{d}}{N}s+1}\left(cr-y\right)\right]$$

Discrete time — $$u={K}_{p}\left[\left(br-y\right)+\frac{1}{{T}_{i}}IF\left(z\right)\left(r-y\right)+\frac{{T}_{d}}{\frac{{T}_{d}}{N}+DF\left(z\right)}\left(cr-y\right)\right]$$

Here:

*b*is the setpoint weighting on the proportional term.*c*is the setpoint weighting on the derivative term.*K*is the proportional gain._{p}*T*is the integral time._{i}*T*is the derivative time._{d}*N*is the first-order derivative filter divisor.*IF*(*z*) is the integrator method for computing the integral in the discrete-time controller.*DF*(*z*) is the integrator method for computing the derivative filter in the discrete-time controller.

You can then combine this object with other components of a control architecture, such as the plant, actuators, and sensors to represent your control system. For more information, see Control System Modeling with Model Objects.

You can create a PID controller model object by either specifying the controller
parameters directly, or by converting a model of another type (such as a transfer function
model `tf`

) to PID controller form.

You can also use `pidstd2`

to create generalized state-space (`genss`

) models or uncertain state-space (`uss`

(Robust Control Toolbox)) models.

## Creation

You can obtain `pidstd2`

controller models in one of the following
ways.

Create a model using the

`pidstd2`

function.Use the

`pidtune`

function to tune PID controllers for a plant model. Specify a baseline standard-form 2-DOF PID controller type using the`C0`

argument of the`pidtune`

function. For example:sys = zpk([],[-1 -1 -1],1); C0 = pidstd2(1,1,1); C2 = pidtune(sys,C0)

Interactively tune the PID controller for a plant model using:

The Tune PID Controller Live Editor task.

The PID Tuner app.

### Syntax

### Description

### Input Arguments

### Output Arguments

## Properties

## Object Functions

The following lists contain a representative subset of the functions you can use with `pidstd2`

models. In general, any function applicable to Dynamic System Models is applicable to a `pidstd2`

object.

## Examples

## Tips

To break a 2-DOF controller into two SISO control components, such as a feedback controller and a feedforward controller, use

`getComponents`

.Create arrays of

`pidstd2`

controllers by:Specifying array values for one or more of the coefficients

`Kp`

,`Ti`

,`Td`

,`N`

,`b`

, and`c`

.Specifying an array of dynamic systems

`sys`

to convert to`pid2`

controller objects.Using

`stack`

to build arrays from individual controllers or smaller arrays.Passing an array of plant models to

`pidtune`

.

In an array of

`pidstd2`

controllers, each controller must have the same sample time`Ts`

and discrete integrator formulas`IFormula`

and`DFormula`

.To create or convert to a parallel-form controller, use

`pid2`

. Parallel form expresses the controller actions in terms of proportional, integral, and derivative gains*K*,_{p}*K*and_{i}*K*, and a filter time constant_{d}*T*. For example, the relationship between the inputs and output of a continuous-time parallel-form 2-DOF PID controller is given by:_{f}$$u={K}_{p}\left(br-y\right)+\frac{{K}_{i}}{s}\left(r-y\right)+\frac{{K}_{d}s}{{T}_{f}s+1}\left(cr-y\right)$$

There are two ways to discretize a continuous-time

`pidstd2`

controller:Use the

`c2d`

command.`c2d`

computes new parameter values for the discretized controller. The discrete integrator formulas of the discretized controller depend upon the`c2d`

discretization method you use, as shown in the following table.`c2d`

Discretization Method`IFormula`

`DFormula`

`'zoh'`

`ForwardEuler`

`ForwardEuler`

`'foh'`

`Trapezoidal`

`Trapezoidal`

`'tustin'`

`Trapezoidal`

`Trapezoidal`

`'impulse'`

`ForwardEuler`

`ForwardEuler`

`'matched'`

`ForwardEuler`

`ForwardEuler`

For more information about

`c2d`

discretization methods, See the`c2d`

reference page. For more information about`IFormula`

and`DFormula`

, see Properties.If you require different discrete integrator formulas, you can discretize the controller by directly setting

`Ts`

,`IFormula`

, and`DFormula`

to the desired values. (See Discretize a Standard-Form 2-DOF PID Controller.) However, this method does not compute new gain and filter-constant values for the discretized controller. Therefore, this method might yield a poorer match between the continuous- and discrete-time`pidstd2`

controllers than using`c2d`

.

## Version History

**Introduced in R2015b**