Twodegreeoffreedom (2DOF) PID controllers include setpoint weighting on the proportional and derivative terms. A 2DOF PID controller is capable of fast disturbance rejection without significant increase of overshoot in setpoint tracking. 2DOF PID controllers are also useful to mitigate the influence of changes in the reference signal on the control signal.
You can represent PID controllers using the specialized model objects
pid2
and pidstd2
. This topic describes the
representation of 2DOF PID controllers in MATLAB^{®}. For information about automatic PID controller tuning, see PID Controller Tuning.
This illustration shows a typical control architecture using a 2DOF PID controller.
The relationship between the 2DOF controller’s output (u) and its two inputs (r and y) can be represented in either parallel or standard form. The two forms differ in the parameters used to express the proportional, integral, and derivative actions of the controller, as expressed in the following table.
Form  Formula 

Parallel (pid2
object) 
$$u={K}_{p}\left(bry\right)+\frac{{K}_{i}}{s}\left(ry\right)+\frac{{K}_{d}s}{{T}_{f}s+1}\left(cry\right).$$ In this representation:

Standard (pidstd2
object) 
$$u={K}_{p}\left[\left(bry\right)+\frac{1}{{T}_{i}s}\left(ry\right)+\frac{{T}_{d}s}{\frac{{T}_{d}}{N}s+1}\left(cry\right)\right].$$ In this representation:

Use a controller form that is convenient for your application. For instance, if
you want to express the integrator and derivative actions in terms of time
constants, use standard form. For examples showing how to create parallelform and
standardform controllers, see the pid2
and pidstd2
reference pages,
respectively.
For information on representing PID Controllers in discrete time, see DiscreteTime ProportionalIntegralDerivative (PID) Controllers.
The 2DOF PID controller is a twoinput, one output controller of the form C_{2}(s), as shown in the following figure. The transfer function from each input to the output is itself a PID controller.
Each of the components C_{r}(s) and C_{y}(s) is a PID controller, with different weights on the proportional and derivative terms. For example, in continuous time, these components are given by:
$$\begin{array}{l}{C}_{r}\left(s\right)=b{K}_{p}+\frac{{K}_{i}}{s}+\frac{c{K}_{d}s}{{T}_{f}s+1},\\ {C}_{y}\left(s\right)=\left[{K}_{p}+\frac{{K}_{i}}{s}+\frac{{K}_{d}s}{{T}_{f}s+1}\right].\end{array}$$
You can access these components by converting the PID controller into a twoinput,
oneoutput transfer function. For example, suppose that C2
is a
2DOF PID controller, stored as a pid2
object.
C2tf = tf(C2); Cr = C2tf(1); Cy = C2tf(2);
C_{r}(s) is the transfer
function from the first input of C2
to the output. Similarly,
C_{y}(s) is the
transfer function from the second input of C2
to the
output.
Suppose that G
is a dynamic system model, such as a zpk
model, representing the plant.
Build the closedloop transfer function from r to
y. Note that the
C_{y}(s) loop has
positive feedback, by the definition of
C_{y}(s).
T = Cr*feedback(G,Cy,+1)
Alternatively, use the connect
command to build an
equivalent closedloop system directly with the 2DOF controller
C2
. To do so, set the InputName
and
OutputName
properties of G
and
C2
.
G.InputName = 'u'; G.OutputName = 'y'; C2.Inputname = {'r','y'}; C2.OutputName = 'u'; T = connect(G,C2,'r','y');
There are other configurations in which you can decompose a 2DOF PID controller
into SISO components. For particular choices of
C(s) and
X(s), each of the following configurations
is equivalent to the 2DOF architecture with
C_{2}(s). You can
obtain C(s) and
X(s) for each of these configurations
using the getComponents
command.
In the feedforward configuration, the 2DOF PID controller is decomposed into a conventional SISO PID controller that takes the error signal as its input, and a feedforward controller.
For a continuoustime, parallelform 2DOF PID controller, the components are given by:
$$\begin{array}{c}C\left(s\right)={K}_{p}+\frac{{K}_{i}}{s}+\frac{{K}_{d}s}{{T}_{f}s+1},\\ X\left(s\right)=\left(b1\right){K}_{p}+\frac{\left(c1\right){K}_{d}s}{{T}_{f}s+1}.\end{array}$$
Access these components using getComponents
.
[C,X] = getComponents(C2,'feedforward');
The following command constructs the closedloop system from r to y for the feedforward configuration.
T = G*(C+X)*feedback(1,G*C);
In the feedback configuration, the 2DOF PID controller is decomposed into a conventional SISO PID controller and a feedback controller.
For a continuoustime, parallelform 2DOF PID controller, the components are given by:
$$\begin{array}{c}C\left(s\right)=b{K}_{p}+\frac{{K}_{i}}{s}+\frac{c{K}_{d}s}{{T}_{f}s+1},\\ X\left(s\right)=\left(1b\right){K}_{p}+\frac{\left(1c\right){K}_{d}s}{{T}_{f}s+1}.\end{array}$$
Access these components using getComponents
.
[C,X] = getComponents(C2,'feedback');
The following command constructs the closedloop system from r to y for the feedback configuration.
T = G*C*feedback(1,G*(C+X));
In the filter configuration, the 2DOF PID controller is decomposed into a conventional SISO PID controller and a prefilter on the reference signal.
For a continuoustime, parallelform 2DOF PID controller, the components are given by:
$$\begin{array}{c}C\left(s\right)={K}_{p}+\frac{{K}_{i}}{s}+\frac{{K}_{d}s}{{T}_{f}s+1},\\ X\left(s\right)=\frac{\left(b{K}_{p}{T}_{f}+c{K}_{d}\right){s}^{2}+\left(b{K}_{p}+{K}_{i}{T}_{f}\right)s+{K}_{i}}{\left({K}_{p}{T}_{f}+{K}_{d}\right){s}^{2}+\left({K}_{p}+{K}_{i}{T}_{f}\right)s+{K}_{i}}.\end{array}$$
The filter X(s) can also be expressed as the ratio: –[C_{r}(s)/C_{y}(s)].
The following command constructs the closedloop system from r to y for the filter configuration.
T = X*feedback(G*C,1);
For an example illustrating the decomposition of a 2DOF PID controller into these configurations, see Decompose a 2DOF PID Controller into SISO Components.
The formulas shown above pertain to continuoustime, parallelform
controllers. Standardform controllers and controllers in discrete time can be
decomposed into analogous configurations. The getComponents
command works on
all 2DOF PID controller objects.
getComponents
 pid2
 pidstd2
 pidtune
 pidTuner