This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

tunablePID2

Tunable two-degree-of-freedom PID controller

Syntax

blk = tunablePID2(name,type)
blk = tunablePID2(name,type,Ts)
blk = tunablePID2(name,sys)

Description

Model object for creating tunable two-degree-of-freedom PID controllers. tunablePID2 lets you parametrize a tunable SISO two-degree-of-freedom PID controller. You can use this parametrized controller for parameter studies or for automatic tuning with tuning commands such as systune, looptune, or the Robust Control Toolbox™ command hinfstruct.

tunablePID2 is part of the family of parametric Control Design Blocks. Other parametric Control Design Blocks include tunableGain, tunableSS, and tunableTF.

Construction

blk = tunablePID2(name,type) creates the two-degree-of-freedom continuous-time PID controller described by the equation:

u=Kp(bry)+Kis(ry)+Kds1+Tfs(cry).

r is the setpoint command, y is the measured response to that setpoint, and u is the control signal, as shown in the following illustration.

The tunable parameters of the block are:

  • Scalar gains Kp, Ki, and Kd

  • Filter time constant Tf

  • Scalar weights b and c

The type argument sets the controller type by fixing some of these values to zero (see Input Arguments).

blk = tunablePID2(name,type,Ts) creates a discrete-time PID controller with sample time Ts. The equation describing this controller is:

u=Kp(bry)+KiIF(z)(ry)+KdTf+DF(z)(cry).

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

blk = tunablePID2(name,sys) uses the dynamic system model, sys, to set the sample time, Ts, and the initial values of all the tunable parameters. The model sys must be compatible with the equation of a two-degree-of-freedom PID controller.

Input Arguments

name

PID controller Name, specified as a character vector such as 'C' or '2DOFPID1'. (See Properties.)

type

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.

Value for typeController TypeEffect on PID Parameters
'P'Proportional onlyKi and Kd are fixed to zero; Tf is fixed to 1; Kp is free
'PI'Proportional-integralKd is fixed to zero; Tf is fixed to 1; Kp and Ki are free
'PD'Proportional-derivative with first-order filter on derivative actionKi is fixed to zero; Kp, Kd, and Tf are free
'PID'Proportional-integral-derivative with first-order filter on derivative actionKp, Ki, Kd, and Tf are free

Ts

Sample time, specified as a scalar.

sys

Dynamic system model representing a two-degree-of-freedom PID controller.

Properties

Kp,Ki,Kd,Tf,b,c

Parametrization of the PID gains Kp, Ki, Kd, the filter time constant, Tf, and the scalar gains, b and c.

The following fields of blk.Kp, blk.Ki, blk.Kd, blk.Tf, blk.b, and blk.c are used when you tune blk using a tuning command such as systune:

FieldDescription
ValueCurrent value of the parameter. blk.b.Value, and blk.c.Value are always nonnegative.
Free

Logical value determining whether the parameter is fixed or tunable. For example:

  • If blk.Kp.Free = 1, then blk.Kp.Value is tunable.

  • If blk.Kp.Free = 0, then blk.Kp.Value is fixed.

Minimum

Minimum value of the parameter. This property places a lower bound on the tuned value of the parameter. For example, setting blk.Kp.Minimum = 0 ensures that Kp remains positive.

blk.Tf.Minimum must always be positive.

MaximumMaximum value of the parameter. This property places an upper bound on the tuned value of the parameter. For example, setting blk.c.Maximum = 1 ensures that c does not exceed unity.

blk.Kp, blk.Ki, blk.Kd, blk.Tf, blk.b, and blk.c are param.Continuous objects. For more information about the properties of these param.Continuous objects, see the param.Continuous object reference page.

IFormula, DFormula

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.

ValueIF(z) or DF(z) Formula
'ForwardEuler'

Tsz1

'BackwardEuler'

Tszz1

'Trapezoidal'

Ts2z+1z1

Default: 'ForwardEuler'

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. Unspecified sample time (Ts = -1) is not supported for PID blocks.

Changing this property does not discretize or resample the model.

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 plots

  • Specifying 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 plots

  • Specifying 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: []

Examples

Tunable Two-Degree-of-Freedom Controller with a Fixed Parameter

Create a tunable two-degree-of-freedom PD controller. Then, initialize the parameter values, and fix the filter time constant.

blk = tunablePID2('pdblock','PD');
blk.b.Value = 1;
blk.c.Value = 0.5;
blk.Tf.Value = 0.01;
blk.Tf.Free = false;
blk
blk =

  Parametric continuous-time 2-DOF PID controller "pdblock" with equation:

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

  where r,y are the controller inputs and Kp, Kd, b, c are tunable gains.

Type "showBlockValue(blk)" to see the current value and "get(blk)" to see all 
properties.

Controller Initialized by Dynamic System Model

Create a tunable two-degree-of-freedom PI controller. Use a two-input, one-output tf model to initialize the parameters and other properties.

s = tf('s');
Kp = 10;
Ki = 0.1;
b = 0.7;
sys = [(b*Kp + Ki/s), (-Kp - Ki/s)];
blk = tunablePID2('PI2dof',sys)
blk =

  Parametric continuous-time 2-DOF PID controller "PI2dof" with equation:

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

  where r,y are the controller inputs and Kp, Ki, b are tunable gains.

Type "showBlockValue(blk)" to see the current value and "get(blk)" to see all 
properties.

blk takes initial parameter values from sys.

If sys is a discrete-time system, blk takes the value of properties, such as Ts and IFormula, from sys.

Controller with Named Inputs and Output

Create a tunable PID controller, and assign names to the inputs and output.

blk = tunablePID2('pidblock','pid');   
blk.InputName = {'reference','measurement'};     
blk.OutputName = {'control'};

blk.InputName is a cell array containing two names, because a two-degree-of-freedom PID controller has two inputs.

Tips

  • You can modify the PID structure by fixing or freeing any of the parameters. For example, blk.Tf.Free = false fixes Tf to its current value.

  • To convert a tunablePID2 parametric model to a numeric (nontunable) model object, use model commands such as tf or ss. You can also use getValue to obtain the current value of a tunable model.

Compatibility Considerations

expand all

Behavior changed in R2016a

Introduced in R2016a