tunablePID
Tunable PID controller
Syntax
blk = tunablePID(name,type)
blk = tunablePID(name,type,Ts)
blk = tunablePID(name,sys)
Description
Model object for creating tunable onedegreeoffreedom PID
controllers. tunablePID
lets you parametrize
a tunable SISO PID controller for parameter studies or for automatic
tuning with tuning commands such as systune
, looptune
,
or the Robust Control Toolbox™ command, hinfstruct
.
tunablePID
is part of the family of parametric Control
Design Blocks. Other parametric Control Design Blocks include tunableGain
, tunableSS
,
and tunableTF
.
Construction
creates
the onedegreeoffreedom continuoustime PID controller:blk
= tunablePID(name
,type
)
$$blk={K}_{p}+\frac{{K}_{i}}{s}+\frac{{K}_{d}s}{1+{T}_{f}s},$$
with tunable parameters Kp
, Ki
, Kd
,
and Tf
. The type
argument
sets the controller type by fixing some of these values to zero (see Input Arguments).
creates
a discretetime PID controller with sample time blk
= tunablePID(name
,type
,Ts
)Ts
:
$$blk={K}_{p}+{K}_{i}IF\left(z\right)+\frac{{K}_{d}}{{T}_{f}+DF\left(z\right)},$$
where IF(z) and DF(z)
are the discrete integrator formulas for the integral and derivative
terms, respectively. The values of the IFormula
and DFormula
properties
set the discrete integrator formulas (see Properties).
uses
the dynamic system model, blk
= tunablePID(name
,sys
)sys
, to set the sample
time, Ts
, and the initial values of the parameters Kp
, Ki
, Kd
,
and Tf
.
Input Arguments

PID controller  

Controller type, specified as one of the values in the following table. Specifying a controller type fixes up to three of the PID controller parameters.
 

Sample time, specified as a scalar.  

Dynamic system model representing a PID controller. 
Properties

Parametrization of the PID gains The following fields of
 

Discrete integrator formulas IF(z) and DF(z) for the integral and derivative terms, respectively, specified as one of the values in the following table.
Default:  

Sample time. For continuoustime models, Changing this property does not discretize or resample the model. 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: 
Examples
Tunable Controller with a Fixed Parameter
Create a tunable PD controller. Then, initialize the parameter values, and fix the filter time constant.
blk = tunablePID('pdblock','PD'); blk.Kp.Value = 4; % initialize Kp to 4 blk.Kd.Value = 0.7; % initialize Kd to 0.7 blk.Tf.Value = 0.01; % set parameter Tf to 0.01 blk.Tf.Free = false; % fix parameter Tf to this value blk
blk = Parametric continuoustime PID controller "pdblock" with formula: s Kp + Kd *  Tf*s+1 and tunable parameters Kp, Kd. Type "pid(blk)" to see the current value and "get(blk)" to see all properties.
Controller Initialized by Dynamic System Model
Create a tunable discretetime PI controller. Use a pid
object to initialize the parameters
and other properties.
C = pid(5,2.2,'Ts',0.1,'IFormula','BackwardEuler'); blk = tunablePID('piblock',C)
blk = Parametric discretetime PID controller "piblock" with formula: Ts*z Kp + Ki *  z1 and tunable parameters Kp, Ki. Type "pid(blk)" to see the current value and "get(blk)" to see all properties.
blk
takes the value of properties, such as Ts
and IFormula
,
from C
.
Controller with Named Input and Output
Create a tunable PID controller, and assign names to the input and output.
blk = tunablePID('pidblock','pid') blk.InputName = {'error'} % assign input name blk.OutputName = {'control'} % assign output name
Tips
You can modify the PID structure by fixing or freeing any of the parameters
Kp
,Ki
,Kd
, andTf
. For example,blk.Tf.Free = false
fixesTf
to its current value.To convert a
tunablePID
parametric model to a numeric (nontunable) model object, use model commands such aspid
,pidstd
,tf
, orss
. You can also usegetValue
to obtain the current value of a tunable model.
Compatibility Considerations
See Also
tunablePID2
 tunableGain
 tunableTF
 tunableSS
 systune
 looptune
 genss
 hinfstruct
(Robust Control Toolbox)