# tunablePID2

Tunable two-degree-of-freedom PID controller

## 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`

.

## Creation

### Description

creates the two-degree-of-freedom continuous-time PID controller described by the
equation:`blk`

= tunablePID2(`name`

,`type`

)

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

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

creates a discrete-time PID controller with sample time `blk`

= tunablePID2(`name`

,`type`

,`Ts`

)`Ts`

. The
equation describing this controller is:

$$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
integral and derivative terms, respectively. The values of the `IFormula`

and `DFormula`

properties set the discrete integrator formulas.

uses the dynamic system model, `blk`

= tunablePID2(`name`

,`sys`

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

## Properties

## Object Functions

## Examples

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

**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

**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

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

## Version History

**Introduced in R2016a**

## See Also

`tunablePID`

| `tunableGain`

| `tunableTF`

| `tunableSS`

| `systune`

| `looptune`

| `genss`

| `hinfstruct`

(Robust Control Toolbox)