# pid2

Create 2-DOF PID controller in parallel form, convert to parallel-form 2-DOF PID controller

## Syntax

C2 = pid2(Kp,Ki,Kd,Tf,b,c)
C2 = pid2(Kp,Ki,Kd,Tf,b,c,Ts)
C2 = pid2(sys)
C2 = pid2(___,Name,Value)

## Description

pid2 controller objects represent two-degree-of-freedom (2-DOF) PID controllers in parallel form. Use pid2 either to create a pid2 controller object from known coefficients or to convert a dynamic system model to a pid2 object.

Two-degree-of-freedom (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.

C2 = pid2(Kp,Ki,Kd,Tf,b,c) creates a continuous-time 2-DOF PID controller with proportional, integral, and derivative gains Kp, Ki, and Kd and first-order derivative filter time constant Tf. The controller also has setpoint weighting b on the proportional term, and setpoint weighting c on the derivative term. The relationship between the 2-DOF controller output (u) and its two inputs (r and y) is given by:

$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).$

This representation is in parallel form. If all coefficients are real-valued, then the resulting C2 is a pid2 controller object. If one or more of these coefficients is tunable (realp or genmat), then C2 is a tunable generalized state-space (genss) model object.

C2 = pid2(Kp,Ki,Kd,Tf,b,c,Ts) creates a discrete-time 2-DOF PID controller with sample time Ts. The relationship between the controller output and inputs is given by:

$u={K}_{p}\left(br-y\right)+{K}_{i}IF\left(z\right)\left(r-y\right)+\frac{{K}_{d}}{{T}_{f}+DF\left(z\right)}\left(cr-y\right).$

IF(z) and DF(z) are the discrete integrator formulas for the integrator and derivative filter. By default,

$IF\left(z\right)=DF\left(z\right)=\frac{{T}_{s}}{z-1}.$

To choose different discrete integrator formulas, use the IFormula and DFormula properties. (See Properties for more information). If DFormula = 'ForwardEuler' (the default value) and Tf ≠ 0, then Ts and Tf must satisfy Tf > Ts/2. This requirement ensures a stable derivative filter pole.

C2 = pid2(sys) converts the dynamic system sys to a parallel form pid2 controller object.

C2 = pid2(___,Name,Value) specifies additional properties as comma-separated pairs of Name,Value arguments.

## Input Arguments

 Kp Proportional gain. Kp can be: A real and finite value.An array of real and finite values.A tunable parameter (realp) or generalized matrix (genmat).A tunable surface for gain-scheduled tuning, created using tunableSurface. When Kp = 0, the controller has no proportional action. Default: 1 Ki Integral gain. Ki can be: A real and finite value.An array of real and finite values.A tunable parameter (realp) or generalized matrix (genmat).A tunable surface for gain-scheduled tuning, created using tunableSurface. When Ki = 0, the controller has no integral action. Default: 0 Kd Derivative gain. Kd can be: A real and finite value.An array of real and finite values.A tunable parameter (realp) or generalized matrix (genmat).A tunable surface for gain-scheduled tuning, created using tunableSurface. When Kd = 0, the controller has no derivative action. Default: 0 Tf Time constant of the first-order derivative filter. Tf can be: A real, finite, and nonnegative value.An array of real, finite, and nonnegative values.A tunable parameter (realp) or generalized matrix (genmat).A tunable surface for gain-scheduled tuning, created using tunableSurface. When Tf = 0, the controller has no filter on the derivative action. Default: 0 b Setpoint weighting on proportional term. b can be: A real, nonnegative, and finite value.An array of real, nonnegative, finite values.A tunable parameter (realp) or generalized matrix (genmat).A tunable surface for gain-scheduled tuning, created using tunableSurface. When b = 0, changes in setpoint do not feed directly into the proportional term. Default: 1 c Setpoint weighting on derivative term. c can be: A real, nonnegative, and finite value.An array of real, nonnegative, finite values.A tunable parameter (realp) or generalized matrix (genmat).A tunable surface for gain-scheduled tuning, created using tunableSurface. When c = 0, changes in setpoint do not feed directly into the derivative term. Default: 1 Ts Sample time. To create a discrete-time pid2 controller, provide a positive real value (Ts > 0). pid2 does not support discrete-time controllers with unspecified sample time (Ts = -1). Ts must be a scalar value. In an array of pid2 controllers, each controller must have the same Ts. Default: 0 (continuous time) sys SISO dynamic system to convert to parallel pid2 form. sys must be a two-input, one-output system. sys must represent a valid 2-DOF PID controller that can be written in parallel form with Tf ≥ 0. sys can also be an array of SISO dynamic systems.

### Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside quotes. You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Use Name,Value syntax to set the numerical integration formulas IFormula and DFormula of a discrete-time pid2 controller, or to set other object properties such as InputName and OutputName. For information about available properties of pid2 controller objects, see Properties.

## Output Arguments

 C2 2-DOF PID controller, returned as a pid2 controller object, an array of pid2 controller objects, a genss object, or a genss array. If all the coefficients have scalar numeric values, then C2 is a pid2 controller object. If one or more coefficients is a numeric array, C2 is an array of pid2 controller objects. The controller type (such as PI, PID, or PDF) depends upon the values of the gains. For example, when Kd = 0, but Kp and Ki are nonzero, C2 is a PI controller. If one or more coefficients is a tunable parameter (realp), generalized matrix (genmat), or tunable gain surface (tunableSurface), then C2 is a generalized state-space model (genss).

## Properties

 b, c Setpoint weights on the proportional and derivative terms, respectively. b and c values are real, finite, and positive. When you use the pid2 command to create a 2-DOF PID controller, the b, and c input arguments, respectively, set the initial values of these properties. Kp, Ki, Kd PID controller gains. Proportional, integral, and derivative gains, respectively. Kp, Ki, and Kd values are real and finite. When you use the pid2 command to create a 2-DOF PID controller, the Kp, Ki, and Kd input arguments, respectively, set the initial values of these properties. Tf Derivative filter time constant. The Tf property stores the derivative filter time constant of the pid2 controller object. Tf is real, finite, and greater than or equal to zero. When you create a 2-DOF PID controller using the pid2 command, the Tf input argument sets the initial value of this property. IFormula Discrete integrator formula IF(z) for the integrator of the discrete-time pid2 controller C2. The relationship between the inputs and output of C2 is given by: $u={K}_{p}\left(br-y\right)+{K}_{i}IF\left(z\right)\left(r-y\right)+\frac{{K}_{d}}{{T}_{f}+DF\left(z\right)}\left(cr-y\right).$ IFormula can take the following values: 'ForwardEuler' — IF(z) = $\frac{{T}_{s}}{z-1}.$This formula is best for small sample time, where the Nyquist limit is large compared to the bandwidth of the controller. For larger sample time, the ForwardEuler formula can result in instability, even when discretizing a system that is stable in continuous time.'BackwardEuler' — IF(z) = $\frac{{T}_{s}z}{z-1}.$An advantage of the BackwardEuler formula is that discretizing a stable continuous-time system using this formula always yields a stable discrete-time result.'Trapezoidal' — IF(z) = $\frac{{T}_{s}}{2}\frac{z+1}{z-1}.$An advantage of the Trapezoidal formula is that discretizing a stable continuous-time system using this formula always yields a stable discrete-time result. Of all available integration formulas, the Trapezoidal formula yields the closest match between frequency-domain properties of the discretized system and the corresponding continuous-time system. When C2 is a continuous-time controller, IFormula is ''. Default: 'ForwardEuler' DFormula Discrete integrator formula DF(z) for the derivative filter of the discrete-time pid2 controller C2. The relationship between the inputs and output of C2 is given by: $u={K}_{p}\left(br-y\right)+{K}_{i}IF\left(z\right)\left(r-y\right)+\frac{{K}_{d}}{{T}_{f}+DF\left(z\right)}\left(cr-y\right).$ DFormula can take the following values: 'ForwardEuler' — DF(z) = $\frac{{T}_{s}}{z-1}.$This formula is best for small sample time, where the Nyquist limit is large compared to the bandwidth of the controller. For larger sample time, the ForwardEuler formula can result in instability, even when discretizing a system that is stable in continuous time.'BackwardEuler' — DF(z) = $\frac{{T}_{s}z}{z-1}.$An advantage of the BackwardEuler formula is that discretizing a stable continuous-time system using this formula always yields a stable discrete-time result.'Trapezoidal' — DF(z) = $\frac{{T}_{s}}{2}\frac{z+1}{z-1}.$An advantage of the Trapezoidal formula is that discretizing a stable continuous-time system using this formula always yields a stable discrete-time result. Of all available integration formulas, the Trapezoidal formula yields the closest match between frequency-domain properties of the discretized system and the corresponding continuous-time system.The Trapezoidal value for DFormula is not available for a pid2 controller with no derivative filter (Tf = 0). When C2 is a continuous-time controller, DFormula is ''. Default: 'ForwardEuler' InputDelay Time delay on the system input. InputDelay is always 0 for a pid2 controller object. OutputDelay Time delay on the system Output. OutputDelay is always 0 for a pid2 controller object. Ts Sample time. For continuous-time models, Ts = 0. For discrete-time models, Ts is a positive scalar representing the sampling period. This value is expressed in the unit specified by the TimeUnit property of the model. PID controller models do not support unspecified sample time (Ts = -1). Changing this property does not discretize or resample the model. Use c2d and d2c to convert between continuous- and discrete-time representations. Use d2d to change the sample time of a discrete-time system. Default: 0 (continuous time) TimeUnit Units for the time variable, the sample time Ts, and any time delays in the model, specified as one of the following values:'nanoseconds''microseconds''milliseconds''seconds' 'minutes''hours''days''weeks''months''years' Changing this property has no effect on other properties, and therefore changes the overall system behavior. Use chgTimeUnit to convert between time units without modifying system behavior. Default: 'seconds' InputName Input channel name, specified as a character vector or a 2-by-1 cell array of character vectors. Use this property to name the input channels of the controller model. For example, assign the names setpoint and measurement to the inputs of a 2-DOF PID controller model C as follows. C.InputName = {'setpoint';'measurement'}; Alternatively, use automatic vector expansion to assign both input names. For example: C.InputName = 'C-input'; The input names automatically expand to {'C-input(1)';'C-input(2)'}. You can use the shorthand notation u to refer to the InputName property. For example, C.u is equivalent to C.InputName. Input channel names have several uses, including: Identifying channels on model display and plotsSpecifying connection points when interconnecting models Default: {'';''} InputUnit Input channel units, specified as a 2-by-1 cell array of character vectors. Use this property to track input signal units. For example, assign the units Volts to the reference input and the concentration units mol/m^3 to the measurement input of a 2-DOF PID controller model C as follows. C.InputUnit = {'Volts';'mol/m^3'}; InputUnit has no effect on system behavior. Default: {'';''} InputGroup Input channel groups. This property is not needed for PID controller models. Default: struct with no fields OutputName Output channel name, specified as a character vector. Use this property to name the output channel of the controller model. For example, assign the name control to the output of a controller model C as follows. C.OutputName = 'control'; You can use the shorthand notation y to refer to the OutputName property. For example, C.y is equivalent to C.OutputName. Input channel names have several uses, including: Identifying channels on model display and plotsSpecifying connection points when interconnecting models Default: Empty character vector, '' OutputUnit Output channel units, specified as a character vector. Use this property to track output signal units. For example, assign the unit Volts to the output of a controller model C as follows. C.OutputUnit = 'Volts'; OutputUnit has no effect on system behavior. Default: Empty character vector, '' OutputGroup Output channel groups. This property is not needed for PID controller models. Default: struct with no fields Name System name, specified as a character vector. For example, 'system_1'. Default: '' Notes Any text that you want to associate with the system, stored as a string or a cell array of character vectors. The property stores whichever data type you provide. For instance, if sys1 and sys2 are dynamic system models, you can set their Notes properties as follows: sys1.Notes = "sys1 has a string."; sys2.Notes = 'sys2 has a character vector.'; sys1.Notes sys2.Notes ans = "sys1 has a string." ans = 'sys2 has a character vector.' Default: [0×1 string] UserData Any type of data you want to associate with system, specified as any MATLAB® data type. Default: [] SamplingGrid Sampling grid for model arrays, specified as a data structure. For model arrays that are derived by sampling one or more independent variables, this property tracks the variable values associated with each model in the array. This information appears when you display or plot the model array. Use this information to trace results back to the independent variables. Set the field names of the data structure to the names of the sampling variables. Set the field values to the sampled variable values associated with each model in the array. All sampling variables should be numeric and scalar valued, and all arrays of sampled values should match the dimensions of the model array. For example, suppose you create a 11-by-1 array of linear models, sysarr, by taking snapshots of a linear time-varying system at times t = 0:10. The following code stores the time samples with the linear models. sysarr.SamplingGrid = struct('time',0:10) Similarly, suppose you create a 6-by-9 model array, M, by independently sampling two variables, zeta and w. The following code attaches the (zeta,w) values to M. [zeta,w] = ndgrid(<6 values of zeta>,<9 values of w>) M.SamplingGrid = struct('zeta',zeta,'w',w) When you display M, each entry in the array includes the corresponding zeta and w values. M M(:,:,1,1) [zeta=0.3, w=5] = 25 -------------- s^2 + 3 s + 25 M(:,:,2,1) [zeta=0.35, w=5] = 25 ---------------- s^2 + 3.5 s + 25 ... For model arrays generated by linearizing a Simulink® model at multiple parameter values or operating points, the software populates SamplingGrid automatically with the variable values that correspond to each entry in the array. For example, the Simulink Control Design™ commands linearize (Simulink Control Design) and slLinearizer (Simulink Control Design) populate SamplingGrid in this way. Default: []

## Examples

collapse all

Create a continuous-time 2-DOF controller with proportional and derivative gains and a filter on the derivative term. To do so, set the integral gain to zero. Set the other gains and the filter time constant to the desired values.

Kp = 1;
Ki = 0;   % No integrator
Kd = 3;
Tf = 0.1;
b = 0.5;    % setpoint weight on proportional term
c = 0.5;    % setpoint weight on derivative term
C2 = pid2(Kp,Ki,Kd,Tf,b,c)
C2 =

s
u = Kp (b*r-y) + Kd -------- (c*r-y)
Tf*s+1

with Kp = 1, Kd = 3, Tf = 0.1, b = 0.5, c = 0.5

Continuous-time 2-DOF PDF controller in parallel form.

The display shows the controller type, formula, and parameter values, and verifies that the controller has no integrator term.

Create a discrete-time 2-DOF PI controller using the trapezoidal discretization formula. Specify the formula using Name,Value syntax.

Kp = 5;
Ki = 2.4;
Kd = 0;
Tf = 0;
b = 0.5;
c = 0;
Ts = 0.1;
C2 = pid2(Kp,Ki,Kd,Tf,b,c,Ts,'IFormula','Trapezoidal')
C2 =

Ts*(z+1)
u = Kp (b*r-y) + Ki -------- (r-y)
2*(z-1)

with Kp = 5, Ki = 2.4, b = 0.5, Ts = 0.1

Sample time: 0.1 seconds
Discrete-time 2-DOF PI controller in parallel form.

Setting Kd = 0 specifies a PI controller with no derivative term. As the display shows, the values of Tf and c are not used in this controller. The display also shows that the trapezoidal formula is used for the integrator.

Create a 2-DOF PID controller, and set the dynamic system properties InputName and OutputName. Naming the inputs and the output is useful, for example, when you interconnect the PID controller with other dynamic system models using the connect command.

C2 = pid2(1,2,3,0,1,1,'InputName',{'r','y'},'OutputName','u')
C2 =

1
u = Kp (b*r-y) + Ki --- (r-y) + Kd*s (c*r-y)
s

with Kp = 1, Ki = 2, Kd = 3, b = 1, c = 1

Continuous-time 2-DOF PID controller in parallel form.

A 2-DOF PID controller has two inputs and one output. Therefore, the 'InputName' property is an array containing two names, one for each input. The model display does not show the input and output names for the PID controller, but you can examine the property values to see them. For instance, verify the input name of the controller.

C2.InputName
ans = 2x1 cell
{'r'}
{'y'}

Create a 2-by-3 grid of 2-DOF PI controllers with proportional gain ranging from 1–2 across the array rows and integral gain ranging from 5–9 across columns.

To build the array of PID controllers, start with arrays representing the gains.

Kp = [1 1 1;2 2 2];
Ki = [5:2:9;5:2:9];

When you pass these arrays to the pid2 command, the command returns the array of controllers.

pi_array = pid2(Kp,Ki,0,0,0.5,0,'Ts',0.1,'IFormula','BackwardEuler');
size(pi_array)
2x3 array of 2-DOF PID controller.
Each PID has 1 output and 2 inputs.

If you provide scalar values for some coefficients, pid2 automatically expands them and assigns the same value to all entries in the array. For instance, in this example, Kd = Tf = 0, so that all entries in the array are PI controllers. Also, all entries in the array have b = 0.5.

Access entries in the array using array indexing. For dynamic system arrays, the first two dimensions are the I/O dimensions of the model, and the remaining dimensions are the array dimensions. Therefore, the following command extracts the (2,3) entry in the array.

pi23 = pi_array(:,:,2,3)
pi23 =

Ts*z
u = Kp (b*r-y) + Ki ------ (r-y)
z-1

with Kp = 2, Ki = 9, b = 0.5, Ts = 0.1

Sample time: 0.1 seconds
Discrete-time 2-DOF PI controller in parallel form.

You can also build an array of PID controllers using the stack command.

C2 = pid2(1,5,0.1,0,0.5,0.5);         % PID controller
C2f = pid2(1,5,0.1,0.5,0.5,0.5);      % PID controller with filter
pid_array = stack(2,C2,C2f);          % stack along 2nd array dimension

These commands return a 1-by-2 array of controllers.

size(pid_array)
1x2 array of 2-DOF PID controller.
Each PID has 1 output and 2 inputs.

All PID controllers in an array must have the same sample time, discrete integrator formulas, and dynamic system properties such as InputName and OutputName.

Convert a standard-form pidstd2 controller to parallel form.

Standard PID form expresses the controller actions in terms of an overall proportional gain Kp, integrator and derivative time constants Ti and Td, and filter divisor N. You can convert any 2-DOF standard-form controller to parallel form using the pid2 command. For example, consider the following standard-form controller.

Kp = 2;
Ti = 3;
Td = 4;
N = 50;
b = 0.1;
c = 0.5;
C2_std = pidstd2(Kp,Ti,Td,N,b,c)
C2_std =

1      1                      s
u = Kp * [(b*r-y) + ---- * --- * (r-y) + Td * ------------ * (c*r-y)]
Ti     s                  (Td/N)*s+1

with Kp = 2, Ti = 3, Td = 4, N = 50, b = 0.1, c = 0.5

Continuous-time 2-DOF PIDF controller in standard form

Convert this controller to parallel form using pid2.

C2_par = pid2(C2_std)
C2_par =

1                s
u = Kp (b*r-y) + Ki --- (r-y) + Kd -------- (c*r-y)
s              Tf*s+1

with Kp = 2, Ki = 0.667, Kd = 8, Tf = 0.08, b = 0.1, c = 0.5

Continuous-time 2-DOF PIDF controller in parallel form.

A response plot confirms that the two forms are equivalent.

bodeplot(C2_par,'b-',C2_std,'r--')
legend('Parallel','Standard','Location','Southeast')

Convert a continuous-time dynamic system that represents a PID controller to parallel pid form.

The following dynamic system, with an integrator and two zeros, is equivalent to a PID controller.

$H\left(s\right)=\frac{3\left(s+1\right)\left(s+2\right)}{s}.$

Create a zpk model of H. Then use the pid command to obtain H in terms of the PID gains Kp, Ki, and Kd.

H = zpk([-1,-2],0,3);
C = pid(H)
C =

1
Kp + Ki * --- + Kd * s
s

with Kp = 9, Ki = 6, Kd = 3

Continuous-time PID controller in parallel form.

Convert a discrete-time dynamic system that represents a 2-DOF PID controller with derivative filter to parallel pid2 form.

The following state-space matrices represent a discrete-time 2-DOF PID controller with a sample time of 0.1 s.

A = [1,0;0,0.99];
B = [0.1,-0.1; -0.005,0.01];
C = [3,0.2];
D = [2.6,-5.2];
Ts = 0.1;
sys = ss(A,B,C,D,Ts);

When you convert sys to 2-DOF PID form, the result depends on which discrete integrator formulas you specify for the conversion. For instance, use the default, ForwardEuler, for both the integrator and the derivative.

C2fe = pid2(sys)
C2fe =

Ts                   1
u = Kp (b*r-y) + Ki ------ (r-y) + Kd ----------- (c*r-y)
z-1             Tf+Ts/(z-1)

with Kp = 5, Ki = 3, Kd = 2, Tf = 10, b = 0.5, c = 0.5, Ts = 0.1

Sample time: 0.1 seconds
Discrete-time 2-DOF PIDF controller in parallel form.

Now convert using the Trapezoidal formula.

C2trap = pid2(sys,'IFormula','Trapezoidal','DFormula','Trapezoidal')
C2trap =

Ts*(z+1)                     1
u = Kp (b*r-y) + Ki -------- (r-y) + Kd ------------------- (c*r-y)
2*(z-1)             Tf+Ts/2*(z+1)/(z-1)

with Kp = 4.85, Ki = 3, Kd = 2, Tf = 9.95, b = 0.485, c = 0.5, Ts = 0.1

Sample time: 0.1 seconds
Discrete-time 2-DOF PIDF controller in parallel form.

The displays show the difference in resulting coefficient values and functional form.

Discretize a continuous-time 2-DOF PID controller and specify the integral and derivative filter formulas.

Create a continuous-time controller and discretize it using the zero-order-hold method of the c2d command.

C2con = pid2(10,5,3,0.5,1,1);  % continuous-time 2-DOF PIDF controller
C2dis1 = c2d(C2con,0.1,'zoh')
C2dis1 =

Ts                   1
u = Kp (b*r-y) + Ki ------ (r-y) + Kd ----------- (c*r-y)
z-1             Tf+Ts/(z-1)

with Kp = 10, Ki = 5, Kd = 3.31, Tf = 0.552, b = 1, c = 1, Ts = 0.1

Sample time: 0.1 seconds
Discrete-time 2-DOF PIDF controller in parallel form.

The display shows that c2d computes new PID coefficients for the discrete-time controller.

The discrete integrator formulas of the discretized controller depend on the c2d discretization method, as described in Tips. For the zoh method, both IFormula and DFormula are ForwardEuler.

C2dis1.IFormula
ans =
'ForwardEuler'
C2dis1.DFormula
ans =
'ForwardEuler'

If you want to use different formulas from the ones returned by c2d, then you can directly set the Ts, IFormula, and DFormula properties of the controller to the desired values.

C2dis2 = C2con;
C2dis2.Ts = 0.1;
C2dis2.IFormula = 'BackwardEuler';
C2dis2.DFormula = 'BackwardEuler';

However, these commands do not compute new PID gains for the discretized controller. To see this, examine C2dis2 and compare the coefficients to C2con and C2dis1.

C2dis2
C2dis2 =

Ts*z                   1
u = Kp (b*r-y) + Ki ------ (r-y) + Kd ------------- (c*r-y)
z-1             Tf+Ts*z/(z-1)

with Kp = 10, Ki = 5, Kd = 3, Tf = 0.5, b = 1, c = 1, Ts = 0.1

Sample time: 0.1 seconds
Discrete-time 2-DOF PIDF controller in parallel form.

## Tips

• To design a PID controller for a particular plant, use pidtune or pidTuner. To create a tunable 2-DOF PID controller as a control design block, use tunablePID2.

• 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 pid2 controller objects by:

• Specifying array values for one or more of the coefficients Kp, Ki, Kd, Tf, 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 pid2 controllers, each controller must have the same sample time Ts and discrete integrator formulas IFormula and DFormula.

• To create or convert to a standard-form controller, use pidstd2. Standard form expresses the controller actions in terms of an overall proportional gain Kp, integral and derivative times Ti and Td, and filter divisor N. For example, the relationship between the inputs and output of a continuous-time standard-form 2-DOF PID controller is given by:

$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].$

• There are two ways to discretize a continuous-time pid2 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.

'zoh'ForwardEulerForwardEuler
'foh'TrapezoidalTrapezoidal
'tustin'TrapezoidalTrapezoidal
'impulse'ForwardEulerForwardEuler
'matched'ForwardEulerForwardEuler

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 Continuous-Time 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 pid2 controllers than using c2d.