Create PID controller in parallel form, convert to parallelform PID controller
C = pid(Kp,Ki,Kd,Tf)
C = pid(Kp,Ki,Kd,Tf,Ts)
C = pid(sys)
C = pid(Kp)
C = pid(Kp,Ki)
C = pid(Kp,Ki,Kd)
C = pid(...,Name,Value)
C = pid
creates
a continuoustime PID controller with proportional, integral, and
derivative gains C
= pid(Kp
,Ki
,Kd
,Tf
)Kp
, Ki
,
and Kd
and firstorder derivative filter time
constant Tf
:
$$C={K}_{p}+\frac{{K}_{i}}{s}+\frac{{K}_{d}s}{{T}_{f}s+1}.$$
This representation is in parallel form.
If all of Kp
, Ki
, Kd
,
and Tf
are real, then the resulting C
is
a pid
controller object. If one or more of these
coefficients is tunable (realp
or genmat
),
then C
is a tunable generalized statespace (genss
)
model object.
creates
a discretetime PID controller with sample time C
= pid(Kp
,Ki
,Kd
,Tf
,Ts
)Ts
.
The controller is:
$$C={K}_{p}+{K}_{i}IF\left(z\right)+\frac{{K}_{d}}{{T}_{f}+DF\left(z\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}}{z1}.$$
To choose different discrete integrator formulas, use the IFormula
and DFormula
properties.
(See Properties for more information
about IFormula
and DFormula
).
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.
converts
the dynamic system C
= pid(sys
)sys
to a parallel form pid
controller
object.
creates
a continuoustime proportional (P) controller with C
= pid(Kp
)Ki
= 0, Kd
= 0, and Tf
= 0.
creates
a proportional and integral (PI) controller with C
= pid(Kp
,Ki
)Kd
= 0 and Tf
= 0.
creates
a proportional, integral, and derivative (PID) controller with C
= pid(Kp
,Ki
,Kd
)Tf
= 0.
creates
a controller or converts a dynamic system to a C
= pid(...,Name,Value
)pid
controller
object with additional options specified by one or more Name,Value
pair
arguments.

Proportional gain.
When Default: 1 

Integral gain.
When Default: 0 

Derivative gain.
When Default: 0 

Time constant of the firstorder derivative filter.
When Default: 0 

Sample time. To create a discretetime
Default: 0 (continuous time) 

SISO dynamic system to convert to parallel

Specify optional
commaseparated pairs of Name,Value
arguments. Name
is
the argument name and Value
is the corresponding value.
Name
must appear inside single 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 discretetime pid
controller, or to set other
object properties such as InputName
and OutputName
.
For information about available properties of pid
controller
objects, see Properties.

PID controller, represented as a


PID controller gains. The 

Derivative filter time constant. The 

Discrete integrator formula IF(z)
for the integrator of the discretetime $$C={K}_{p}+{K}_{i}IF\left(z\right)+\frac{{K}_{d}}{{T}_{f}+DF\left(z\right)}.$$
When Default: 

Discrete integrator formula DF(z)
for the derivative filter of the discretetime $$C={K}_{p}+{K}_{i}IF\left(z\right)+\frac{{K}_{d}}{{T}_{f}+DF\left(z\right)}.$$
When Default: 

Time delay on the system input. 

Time delay on the system Output. 

Sample time. For continuoustime models, Changing this property does not discretize or resample the model.
Use Default: 

Units for the time variable, the sample time
Changing this property has no effect on other properties, and
therefore changes the overall system behavior. Use Default: 

Input channel name, specified as a character vector. Use this
property to name the input channel of the controller model. For example,
assign the name C.InputName = 'error'; You can use the shorthand notation Input channel names have several uses, including:
Default: Empty character vector, 

Input channel units, specified as a character vector. Use this
property to track input signal units. For example, assign the concentration
units C.InputUnit = 'mol/m^3';
Default: Empty character vector, 

Input channel groups. This property is not needed for PID controller models. Default: 

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 C.OutputName = 'control'; You can use the shorthand notation Input channel names have several uses, including:
Default: Empty character vector, 

Output channel units, specified as a character vector. Use this
property to track output signal units. For example, assign the unit C.OutputUnit = 'Volts';
Default: Empty character vector, 

Output channel groups. This property is not needed for PID controller models. Default: 

System name, specified as a character vector. For example, Default: 

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.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: 

Any type of data you want to associate with system, specified as any MATLAB^{®} data type. Default: 

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 11by1
array of linear models, sysarr.SamplingGrid = struct('time',0:10) Similarly, suppose you create a 6by9
model array, [zeta,w] = ndgrid(<6 values of zeta>,<9 values of w>) M.SamplingGrid = struct('zeta',zeta,'w',w) When you display 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 Default: 
Use pid
to:
Create a pid
controller object
from known PID gains and filter time constant.
Convert a pidstd
controller object
to a standardform pid
controller object.
Convert other types of dynamic system models to a pid
controller
object.
To design a PID controller for a particular plant, use pidtune
or pidTuner
. To create a tunable PID
controller as a control design block, use tunablePID
.
Create arrays of pid
controller
objects by:
In an array of pid
controllers, each controller
must have the same sample time Ts
and discrete
integrator formulas IFormula
and DFormula
.
To create or convert to a standardform controller,
use pidstd
. Standard form
expresses the controller actions in terms of an overall proportional
gain K_{p}, integral and derivative
times T_{i} and T_{d},
and filter divisor N:
$$C={K}_{p}\left(1+\frac{1}{{T}_{i}}\frac{1}{s}+\frac{{T}_{d}s}{\frac{{T}_{d}}{N}s+1}\right).$$
There are two ways to discretize a continuoustime pid
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 ContinuousTime PID Controller.)
However, this method does not compute new gain and filterconstant
values for the discretized controller. Therefore, this method might
yield a poorer match between the continuous and discretetime pid
controllers
than using c2d
.