# PID Controller (2 DOF), Discrete PID Controller (2 DOF)

Simulate continuous- or discrete-time two-degree-of-freedom PID controllers

## Library

Continuous, Discrete

## Description

Implement a continuous- or discrete-time two-degree-of-freedom controller (PID, PI, or PD) in your Simulink® model. The PID Controller (2DOF) block allows you to implement setpoint weighting in your controller to achieve both smooth setpoint tracking and good disturbance rejection.

The PID Controller (2DOF) block generates an output signal based on the difference between a reference signal and a measured system output. The block computes a weighted difference signal for each of the proportional, integral, and derivative actions according to the setpoint weights you specify. The block output is the sum of the proportional, integral, and derivative actions on the respective difference signals, where each action is weighted according to the gain parameters. A first-order pole filters the derivative action. Controller gains are tunable either manually or automatically. Automatic tuning requires Simulink Control Design™ software.

Configurable options in the PID Controller (2DOF) block include:

• Controller type (PID, PI, or PD)

• Controller form (Parallel or Ideal)

• Time domain (continuous or discrete)

• Initial conditions and reset trigger

• Output saturation limits and built-in anti-windup mechanism

• Signal tracking for bumpless control transfer and multiloop control

In one common implementation, the PID Controller (2DOF) block operates in the feedforward path of the feedback loop. The block receives a reference signal at the `Ref` input and a measured system output at the other input. For example:

For a single-input block that accepts an error signal (a difference between a setpoint and a system output), see the PID Controller, block reference page.

You can generate code to implement your controller using any Simulink data type, including fixed-point data types. (Code generation requires Simulink Coder™ software; fixed-point implementation requires the Fixed-Point Designer™ product.)

For an example illustrating an application of the PID Controller (2 DOF) block, see the Simulink example Two Degree-of-Freedom PID Control for Setpoint Tracking.

## Data Type Support

The PID Controller (2DOF) block accepts real signals of any numeric data type that Simulink software supports, including fixed-point data types. See Data Types Supported by Simulink in the Simulink documentation for more information.

## Parameters

The following table summarizes the PID Controller (2DOF)block parameters, accessible via the block parameter dialog box.

Choose controller form and type.
Choose discrete or continuous time.
Choose an integration method (discrete time).
Set and tune controller gains.
Set integrator and filter initial conditions.
Limit block output.
Configure anti-windup mechanism (when you limit block output).
Enable signal tracking.
Configure data types.
Configure block for code generation.

### Controller form

Select the controller form.

#### Settings

`Parallel` (Default)

Selects a controller form in which the proportional, integral, and derivative gains P, I, and D operate independently. The filter coefficient N sets the location of the pole in the derivative filter.

Parallel two-degree-of-freedom PID controller, where input 1 receives a reference signal and input 2 receives feedback from the measured system output:

The parallel two-degree-of-freedom PID controller can be equivalently modeled by the following block diagram:

`R(s)` represents the reference signal and `Y(s)` represents the feedback from measured system output. In this model, `C(s)` is a single degree-of-freedom controller, and `F(s)` acts as a prefilter on the reference signal. For a parallel two-degree-of-freedom PID controller in the `Continuous-time` Time-domain, the transfer functions `F(s)` and `C(s)` are:

`$\begin{array}{l}{F}_{par}\left(s\right)=\frac{\left(bP+cDN\right){s}^{2}+\left(bPN+I\right)s+IN}{\left(P+DN\right){s}^{2}+\left(PN+I\right)s+IN}\\ {C}_{par}\left(s\right)=\frac{\left(P+DN\right){s}^{2}+\left(PN+I\right)s+IN}{s\left(s+N\right)}\end{array}$`

where `b` and `c` are the Setpoint weight parameters.

Alternatively, the parallel two-degree-of-freedom PID controller can be modeled by the following block diagram:

`R(s)`, `Y(s)`, and `C(s)` are as discussed previously. In this realization, `Q(s)` acts as feed-forward conditioning on the reference signal `R(s)`. For a parallel PID controller in the `Continuous-time` Time-domain, the transfer function `Q(s)` is:

`${Q}_{par}\left(s\right)=\frac{\left(\left(b-1\right)P+\left(c-1\right)DN\right)s+\left(b-1\right)PN}{s+N}$`
`Ideal`

Selects a controller form in which the proportional gain `P` acts on the sum of all actions.

Ideal two-degree-of-freedom PID controller, where input 1 receives a reference signal and input 2 receives feedback from the measured system output:

Similarly to the parallel controller form discussed previously, the ideal two-degree-of-freedom PID controller can be modeled as a single degree-of-freedom controller `C(s)` with a prefilter `F(s)`. For an ideal two-degree-of-freedom PID controller in the `Continuous-time` Time-domain, the transfer functions `F(s)` and `C(s)` are:

`$\begin{array}{l}{F}_{id}\left(s\right)=\frac{\left(b+cDN\right){s}^{2}+\left(bN+I\right)s+IN}{\left(1+DN\right){s}^{2}+\left(N+I\right)s+IN}\\ {C}_{id}\left(s\right)=P\frac{\left(1+DN\right){s}^{2}+\left(N+I\right)s+IN}{s\left(s+N\right)}\end{array}$`

where `b` and `c` are the Setpoint weight parameters.

Alternatively, modeling the ideal two-degree-of-freedom PID controller as a one-degree-of-freedom controller `C(s)` with feed-forward conditioning `Q(s)` on the reference signal gives, in continuous-time:

`${Q}_{id}\left(s\right)=P\frac{\left(\left(b-1\right)+\left(c-1\right)DN\right)s+\left(b-1\right)N}{s+N}$`

The controller transfer function for the current settings is displayed in the block dialog box.

### Controller

Specify the controller type.

#### Settings

`PID ` (Default)

Implements a controller with proportional, integral, and derivative action.

`PI`

Implements a controller with proportional and integral action.

`PD`

Implements a controller with proportional and derivative action.

The controller transfer function for the current settings is displayed in the block dialog box.

### Time-domain

Select continuous or discrete time domain. The appearance of the block changes to reflect your selection.

#### Settings

`Continuous-time` (Default)

Selects the continuous-time representation.

When the PID Controller (2DOF) block is in a model with synchronous state control (see the State Control block), you cannot select `Continuous-time`.

`Discrete-time`

Selects the discrete-time representation. Selecting `Discrete-time` also allows you to specify the:

• Sample time, which is the discrete interval between samples.

• Discrete integration methods for the integrator and the derivative filter using the Integrator method and Filter method menus.

### Integrator method

(Available only when you set Time-domain to `Discrete-time`.) Specify the method used to compute the integrator output. For more information about discrete-time integration methods, see the Discrete-Time Integrator block reference page.

#### Settings

`Forward Euler` (Default)

Selects the Forward Rectangular (left-hand) approximation.

This method is best for small sampling times, where the Nyquist limit is large compared to the bandwidth of the controller. For larger sampling times, the `Forward Euler` method can result in instability, even when discretizing a system that is stable in continuous time.

`Backward Euler`

Selects the Backward Rectangular (right-hand) approximation.

An advantage of the `Backward Euler` method is that discretizing a stable continuous-time system using this method always yields a stable discrete-time result.

`Trapezoidal`

Selects the Bilinear approximation.

An advantage of the `Trapezoidal` method is that discretizing a stable continuous-time system using this method always yields a stable discrete-time result. Of all available integration methods, the `Trapezoidal` method yields the closest match between frequency-domain properties of the discretized system and the corresponding continuous-time system.

### Note

For integrator methods `BackwardEuler` or `Trapezoidal`, you cannot generate HDL code for the block if either:

• Limit output is selected and Anti-windup method is set to `back-calculation` or `clamping`.

• Enable tracking mode is selected.

### Filter method

(Available only when you set Time-domain to `Discrete-time`.) Specify the method used to compute the derivative filter output. For more information about discrete-time integration methods, see the Discrete-Time Integrator block reference page.

#### Settings

`Forward Euler` (Default)

Selects the Forward Rectangular (left-hand) approximation.

This method is best for small sampling times, where the Nyquist limit is large compared to the bandwidth of the controller. For larger sampling times, the `Forward Euler` method can result in instability, even when discretizing a system that is stable in continuous time.

`Backward Euler`

Selects the Backward Rectangular (right-hand) approximation.

An advantage of the `Backward Euler` method is that discretizing a stable continuous-time system using this method always yields a stable discrete-time result. Any filter parameter value `N > 0` yields a stable result with this method.

`Trapezoidal`

Selects the Bilinear approximation.

An advantage of the `Trapezoidal` method is that discretizing a stable continuous-time system using this method always yields a stable discrete-time result. Any filter parameter value `N > 0` yields a stable result with this method. Of all available filter methods, the `Trapezoidal` method yields the closest match between frequency-domain properties of the discretized system and the corresponding continuous-time system.

### Sample time (-1 for inherited)

(Available only when you set Time-domain to `Discrete-time`.) Specify the discrete interval between samples.

#### Settings

Default: 1

By default, the block uses a discrete sample time of 1. To specify a different sample time, enter another discrete value, such as 0.1.

If you specify a value of –1, the PID Controller (2DOF) block inherits the sample time from upstream blocks. Do not enter a value of 0; to implement a continuous-time controller, select the Time-domain `Continuous-time`.

### Controller Parameters Source

Select the source of the controller gains, filter coefficient, and setpoint weights. You can provide these parameters explicitly in the block dialog box, or enable external inputs for them on the block. Enabling external inputs for the parameters allows you to compute PID gains and filter coefficients externally to the block and provide them to the block as signal inputs.

External gain input is useful, for example, when you want to map a different PID parameterization to the PID gains of the block. You can also use external gain input to implement gain-scheduled PID control, in which controller gains are determined by logic or other calculation in the Simulink model and passed to the block.

#### Settings

`internal` (Default)

Specify the PID gains and filter coefficient explicitly using the P, I, D, N, b, and c parameters.

`external`

Specify the PID gains and filter coefficient externally. An additional input port appears under the block input for each parameter that is required for the current controller type:

When you supply gains externally, time variations in the integral and derivative gain values are integrated and differentiated, respectively. This result occurs because of the way the PID gains are implemented within the block. For example, for a continuous-time PID controller with external inputs, the integrator term is implemented as shown in the following illustration.

Within the block, the signal to be integrated is multiplied by the externally-supplied integrator gain, I, before integration. This implementation yields:

`${y}_{i}=\int uI\text{\hspace{0.17em}}dt.$`

Thus, the integrator gain is included in the integral. Similarly, in the derivative term of the block, multiplication by the derivative gain precedes the differentiation, which causes the derivative gain D to be differentiated.

### Proportional (P)

Specify the proportional gain `P`.

Default: 1

Enter a finite, real gain value into the Proportional (P) field. Use either scalar or vector gain values. For a `parallel` PID Controller form, the proportional action is independent of the integral and derivative actions. For an `ideal ` PID Controller form, the proportional action acts on the integral and derivative actions. See Controller form for more information about the role of `P` in the controller transfer function.

When you have Simulink Control Design software installed, you can automatically tune the controller gains. See Choose a Control Design Approach (Simulink Control Design).

### Integral (I)

(Available for PID and PI controllers.) Specify the integral gain `I`.

Default: 1

Enter a finite, real gain value into the Integral (I) field. Use either scalar or vector gain values.

When you have Simulink Control Design software installed, you can automatically tune the controller gains. See Choose a Control Design Approach (Simulink Control Design).

### Derivative (D)

(Available for PID and PD controllers.) Specify the derivative gain `D`.

Default: 0

Enter a finite, real gain value into the Derivative (D) field. Use either scalar or vector gain values.

When you have Simulink Control Design software installed, you can automatically tune the controller gains using. See Choose a Control Design Approach (Simulink Control Design).

### Filter coefficient (N)

Specifies the filter coefficient of the controller.

(Available for PID and PD controllers, when Use filtered derivative is checked.) Specify the filter coefficient `N`, which determines the pole location of the filter in the derivative action:

The filter pole falls at `s = -N` in the `Continuous-time` Time-domain. For `Discrete-time`, the location of the pole depends on which Filter method you select (for sampling time `Ts`):

• `Forward Euler`:

${z}_{pole}=1-N{T}_{s}$

• `Backward Euler`:

${z}_{pole}=\frac{1}{1+N{T}_{s}}$

• `Trapezoidal`:

${z}_{pole}=\frac{1-N{T}_{s}/2}{1+N{T}_{s}/2}$

Default: 100.

Enter a finite, real gain value into the Filter Coefficient (N) field. Use either scalar or vector gain values. Note that the PID controller (2DOF) block does not support ```N = inf``` (ideal unfiltered derivative).

When you have Simulink Control Design software installed, you can automatically tune the controller gains. See Choose a Control Design Approach (Simulink Control Design). Automatic tuning requires ```N > 0```.

### Use Filtered Derivative

Specify whether derivative term is filtered (finite `N`) or unfiltered. Unfiltered derivative is available only for discrete-time controllers.

Unchecking this option replaces the filtered derivative with a discrete differentiator. For example, if Filter Method is ```Forward Euler```, then the filtered derivative term is represented by:

When you uncheck Use filtered derivative, the derivative term becomes:

#### Settings

`On` (Default)

Use derivative filter (finite `N`).

`Off`

Derivative is unfiltered.

### Setpoint weight (b)

Specify the proportional setpoint weight `b`.

Default: 1

Enter the proportional setpoint weight value into the Setpoint weight (b) field. Setting `b = 0` eliminates the proportional action on the reference signal, which can reduce overshoot in the system response to step changes in the setpoint.

The following diagrams show the role of Setpoint weight (b) in PID controllers of `Parallel` and `Ideal` form. See Controller form for a discussion of the corresponding transfer functions.

Parallel Two-Degree-of-Freedom PID Controller

Ideal Two-Degree-of-Freedom PID Controller

### Setpoint weight (c)

(Available for PID and PD controllers.) Specify the derivative setpoint weight `c`.

Enter the derivative setpoint weight value into the Setpoint weight (c) field. To implement a controller that achieves both effective disturbance rejection and smooth setpoint tracking without excessive transient response, set `c = 0`. Setting `c = 0` yields a controller with derivative action on the measured system response but not on the reference input.

The following diagrams show the role of Setpoint weight (c) in `Parallel` and `Ideal` PID controllers. See Controller form for a discussion of the corresponding transfer functions.

Parallel Two-Degree-of-Freedom PID Controller

Ideal Two-Degree-of-Freedom PID Controller

### Select Tuning Method

(Requires Simulink Control Design) Select a PID tuning tool. The specified tool opens when you click Tune.

#### Settings

`Transfer Function Based (PID Tuner App)` (Default)

Clicking Tune opens the PID Tuner, which lets you interactively tune PID gains while examining relevant system responses to validate performance. By default, PID Tuner works with a linearization of your plant model. For models that cannot be linearized, you can tune PID gains against a plant model estimated from simulated or measured response data. For more information, see Introduction to Model-Based PID Tuning in Simulink (Simulink Control Design).

`Frequency Response Based`

Clicking Tune opens the Frequency Response Based PID Tuner, which tunes PID controller gains based on a frequency-response estimation experiment. Frequency Response Based PID Tuner is especiallly useful for plants that are not linearizable. For more information, see Design PID Controller from Plant Frequency-Response Data (Simulink Control Design).

### Initial conditions Source

Select the source of the integrator and filter initial conditions. Simulink uses initial conditions to initialize the integrator and filter output at the start of a simulation or at a specified trigger event (see External reset). The integrator and filter initial conditions in turn determine the initial block output.

#### Settings

`internal` (Default)

Specifies the integrator and filter initial conditions explicitly using the Integrator Initial condition and Filter Initial condition parameters.

`external`

Specifies the integrator and filter initial conditions externally. An additional input port appears under the block inputs for each initial condition: `I0` for the integrator and `D0` for the filter:

### Integrator Initial condition

(Available only when Initial conditions Source is `internal` and the controller includes integral action.) Specify the integrator initial value. Simulink uses the initial condition to initialize the integrator output at the start of a simulation or at a specified trigger event (see External reset). The integrator initial condition, together with the filter initial condition, determines the initial output of the PID Controller (2DOF) block.

Default: 0

Simulink does not permit the integrator initial condition to be `inf` or `NaN`.

### Filter Initial condition

(Available only when Initial conditions Source is `internal`, the controller includes derivative action, and Use filtered derivative is checked.) Specify the filter initial value. Simulink uses the initial condition to initialize the filter output at the start of a simulation or at a specified trigger event (see External reset). The filter initial condition, together with the integrator initial condition, determines the initial output of the PID Controller (2DOF) block.

Default: 0

Simulink does not permit the filter initial condition to be `inf` or `NaN`.

### Initial condition setting

Specify whether to apply the Integrator Initial condition and Filter Initial condition parameter to the corresponding block state or output. This parameter can be changed only at the command line using `set_param` to set the `InitialConditionSetting` parameter of the block.

#### Settings

`State (most efficient)` (Default)

Use this option in all situations except when the block is in a triggered subsystem or a function-call subsystem and simplified initialization mode is enabled.

`Output`

Use this option when the block is in a triggered subsystem or a function-call subsystem and simplified initialization mode is enabled.

### External reset

Select the trigger event that resets the integrator and filter outputs to the initial conditions you specify in the Integrator Initial condition and Filter Initial condition fields. Selecting any option other than `none` enables a reset input on the block for the external reset signal, as shown:

Or, if the Initial conditions Source is `External`:

The reset signal must be a scalar of type `single`, `double`, `boolean`, or `integer`. Fixed point data types, except for `ufix1`, are not supported.

### Note

To be compliant with the Motor Industry Software Reliability Association (MISRA®) software standard, your model must use Boolean signals to drive the external reset ports of the PID controller (2DOF) block.

#### Settings

`none ` (Default)

Does not reset the integrator and filter outputs to initial conditions.

`rising`

Resets the outputs when the reset signal has a rising edge.

`falling`

Resets the outputs when the reset signal has a falling edge.

`either`

Resets the outputs when the reset signal either rises or falls.

`level`

Resets and holds the outputs to the initial conditions while the reset signal is nonzero.

### Ignore reset when linearizing

Force Simulink linearization commands to ignore any reset mechanism that you have chosen with the External reset menu. Ignoring reset states allows you to linearize a model around an operating point even if that operating point causes the PID Controller (2DOF) block to reset.

#### Settings

`Off` (Default)

Simulink linearization commands do not ignore states corresponding to the reset mechanism.

`On `

Simulink linearization commands ignore states corresponding to the reset mechanism.

### Enable zero-crossing detection

Enable zero-crossing detection in continuous-time models upon reset and upon entering or leaving a saturation state.

Zero-crossing detection can accurately locate signal discontinuities without resorting to excessively small time steps that can lead to lengthy simulation times. If you select Limit output or activate an External reset in your PID Controller (2DOF) block, activating zero-crossing detection can reduce computation time in your simulation. For more information, see Zero-Crossing Detection.

#### Settings

`On` (Default)

Uses zero-crossing detection at any of the following events: reset; entering or leaving an upper saturation state; and entering or leaving a lower saturation state.

`Off`

Does not use zero-crossing detection.

Enabling zero-crossing detection for the PID Controller (2DOF) block also enables zero-crossing detection for all under-mask blocks that include the zero-crossing detection feature.

### Limit output

Limit the block output to values you specify as the Lower saturation limit and Upper saturation limit parameters.

Activating this option limits the block output internally to the block, obviating the need for a separate Saturation block after the controller in your Simulink model. It also allows you to activate the built-in anti-windup mechanism (see Anti-windup method).

#### Settings

`Off` (Default)

Does not limit the block output, which is the weighted sum of the proportional, integral, and derivative actions.

`On`

Limits the block output to the Lower saturation limit or the Upper saturation limit whenever the weighted sum exceeds those limits. Allows you to select an Anti-windup method.

### Lower saturation limit

(Available only when you select the Limit Output box.) Specify the lower limit for the block output. The block output is held at the Lower saturation limit whenever the weighted sum of the proportional, integral, and derivative actions goes below that value.

Default: `-inf`

### Upper saturation limit

(Available only when you select the Limit Output box.) Specify the upper limit for the block output. The block output is held at the Upper saturation limit whenever the weighted sum of the proportional, integral, and derivative actions exceeds that value.

Default: `inf`

### Anti-windup method

(Available only when you select the Limit Output option and the controller includes integral action.) Select an anti-windup mechanism to discharge the integrator when the block is saturated, which occurs when the sum of the block components exceeds the output limits.

When you select the Limit output check box and the weighted sum of the controller components exceeds the specified output limits, the block output holds at the specified limit. However, the integrator output can continue to grow (integrator wind-up), increasing the difference between the block output and the sum of the block components. Without a mechanism to prevent integrator wind-up, two results are possible:

• If the sign of the input signal never changes, the integrator continues to integrate until it overflows. The overflow value is the maximum or minimum value for the data type of the integrator output.

• If the sign of the input signal changes once the weighted sum has grown beyond the output limits, it can take a long time to discharge the integrator and return the weighted sum within the block saturation limit.

In both cases, controller performance can suffer. To combat the effects of wind-up without an anti-windup mechanism, it may be necessary to detune the controller (for example, by reducing the controller gains), resulting in a sluggish controller. Activating an anti-windup mechanism can improve controller performance.

#### Settings

`none` (Default)

Does not use an anti-windup mechanism. This setting can cause the block's internal signals to be unbounded even if the output appears to be bounded by the saturation limits. This can result in slow recovery from saturation or unexpected overflows.

`back-calculation`

Discharges the integrator when the block output saturates using the integral-gain feedback loop:

You can also specify a value for the Back-calculation coefficient (Kb).

`clamping`

Stops integration when the sum of the block components exceeds the output limits and the integrator output and block input have the same sign. Resumes integration when the sum of the block components exceeds the output limits and the integrator output and block input have opposite sign. The integrator portion of the block is:

The clamping circuit implements the logic necessary to determine whether integration continues.

### Back-calculation gain (Kb)

(Available only when the `back-calculation` Anti-windup method is active.) Specify the gain coefficient of the anti-windup feedback loop.

The `back-calculation` anti-windup method discharges the integrator on block saturation using a feedback loop having gain coefficient `Kb`.

Default: 1

### Ignore saturation when linearizing

Force Simulink linearization commands ignore PID Controller (2DOF) block output limits. Ignoring output limits allows you to linearize a model around an operating point even if that operating point causes the PID Controller (2DOF) block to exceed the output limits.

#### Settings

`On ` (Default)

Simulink linearization commands ignore states corresponding to saturation.

`Off`

Simulink linearization commands do not ignore states corresponding to saturation.

### Enable tracking mode

(Available for any controller with integral action.) Activate signal tracking, which lets the output of the PID Controller (2DOF) block follow a tracking signal. Provide the tracking signal to the block at the `TR` port, which becomes active when you select Enable tracking mode.

When signal tracking is active, the difference between the tracked signal and the block output is fed back to the integrator input with a gain `Kt`. You can also specify the value of the Tracking coefficient (Kt).

For information about using tracking mode to implement bumpless control transfer scenarios and multiloop controllers, see Enable tracking mode in the PID Controller reference page.

#### Settings

`Off ` (Default)

Disables signal tracking and removes `TR` block input.

`On `

Enables signal tracking and activates `TR` input.

### Tracking gain (Kt)

(Available only when you select Enable tracking mode.) Specify `Kt`, which is the gain of the signal tracking feedback loop.

Default: 1

### Parameter data type

Select the data type of the gain parameters P, I, D, N, Kb, and Kt and the setpoint weighting parameters b and c.

#### Settings

`Inherit: Inherit via internal rule` (Default)

Simulink chooses a data type to balance numerical accuracy, performance, and generated code size, while taking into account the properties of the embedded target hardware. If you change the embedded target settings, the data type selected by the internal rule might change. It is not always possible for the software to optimize code efficiency and numerical accuracy at the same time. If the internal rule doesn’t meet your specific needs for numerical accuracy or performance, use one of the following options:

• Specify the output data type explicitly.

• Use the simple choice of ```Inherit: Same as input```.

• Explicitly specify a default data type such as `fixdt(1,32,16)` and then use the Fixed-Point Tool to propose data types for your model. For more information, see `fxptdlg`.

• To specify your own inheritance rule, use ```Inherit: Inherit via back propagation``` and then use a Data Type Propagation block. Examples of how to use this block are available in the Signal Attributes library Data Type Propagation Examples block.

`Inherit: Inherit via back propagation`

Use data type of the driving block.

`Inherit: Same as input`

Use data type of input signal.

`double`

`single`

`int8`

`uint8`

`int16`

`uint16`

`int32`

`uint32`

`fixdt(1,16)`

`fixdt(1,16,0)`

`fixdt(1,16,2^0,0)`

`<data type expression>`

Name of a data type object. For example, `Simulink.NumericType`.

### Product output data type

Select the product output data type of the gain parameters P, I, D, N, Kb, and Kt, the setpoint weighting parameters b and c, or the product output data type of the derivative filter numerator and denominator.

#### Settings

`Inherit: Inherit via internal rule` (Default)

Simulink chooses a data type to balance numerical accuracy, performance, and generated code size, while taking into account the properties of the embedded target hardware. If you change the embedded target settings, the data type selected by the internal rule might change. It is not always possible for the software to optimize code efficiency and numerical accuracy at the same time. If the internal rule doesn’t meet your specific needs for numerical accuracy or performance, use one of the following options:

• Specify the output data type explicitly.

• Use the simple choice of ```Inherit: Same as input```.

• Explicitly specify a default data type such as `fixdt(1,32,16)` and then use the Fixed-Point Tool to propose data types for your model. For more information, see `fxptdlg`.

• To specify your own inheritance rule, use ```Inherit: Inherit via back propagation``` and then use a Data Type Propagation block. Examples of how to use this block are available in the Signal Attributes library Data Type Propagation Examples block.

`Inherit: Inherit via back propagation`

Use data type of the driving block.

`Inherit: Same as input`

Use data type of input signal.

`double`

`single`

`int8`

`uint8`

`int16`

`uint16 `

`int32`

`uint32`

`fixdt(1,16)`

`fixdt(1,16,0)`

`fixdt(1,16,2^0,0)`

`<data type expression>`

Name of a data type object. For example, `Simulink.NumericType`.

### Summation output data type

Select the summation output data type of the sums Sum, Sum D, Sum I1 , SumI2 , SumI3, and the summations in the trapezoidal discrete filter numerator and denominator, SumNum and SumDen. These sums are computed internally within the block, and might not all be present, depending upon the controller configuration. To see where Simulink computes each of these sums , right-click the PID Controller (2 DOF) block in your model and select `Look Under Mask`:

• Sum is the weighted sum of the proportional, derivative, and integral signals.

• Sum1 is the difference between the reference input weighted by b and the measured system response.

• Sum2 is the difference between the reference input weighted by c and the measured system response.

• Sum3 is the difference between the unweighted reference input and the measured system response.

• SumD is the sum in the derivative filter feedback loop.

• SumI1 is the sum of the block input signal (weighted by the integral gain `I`) and SumI2. SumI1 is computed only when Limit output and Anti-windup method `back-calculation` are active.

• SumI2 is the difference between the weighted sum Sum and the limited block output. SumI2 is computed only when Limit output and Anti-windup method `back-calculation` are active.

• SumI3 is the difference between the block output and the signal at the block's tracking input. SumI3 is computed only when you select the Enable tracking mode box.

#### Settings

`Inherit: Inherit via internal rule` (Default)

Simulink chooses a data type to balance numerical accuracy, performance, and generated code size, while taking into account the properties of the embedded target hardware. If you change the embedded target settings, the data type selected by the internal rule might change. It is not always possible for the software to optimize code efficiency and numerical accuracy at the same time. If the internal rule doesn’t meet your specific needs for numerical accuracy or performance, use one of the following options:

• Specify the output data type explicitly.

• Use the simple choice of ```Inherit: Same as first input```.

• Explicitly specify a default data type such as `fixdt(1,32,16)` and then use the Fixed-Point Tool to propose data types for your model. For more information, see `fxptdlg`.

### Note

The accumulator internal rule favors greater numerical accuracy, possibly at the cost of less efficient generated code. To get the same accuracy for the output, set the output data type to ```Inherit: Same as accumulator```.

`Inherit: Inherit via back propagation`

Use data type of the driving block.

`Inherit: Same as first input`

Use data type of first input signal.

`Inherit: Same as accumulator`

Use the same data type as the corresponding accumulator.

`double`

`single`

`int8`

`uint8`

`int16`

`uint16`

`int32`

`uint32 `

`fixdt(1,16)`

`fixdt(1,16,0)`

`fixdt(1,16,2^0,0)`

`<data type expression>`

Name of a data type object. For example, `Simulink.NumericType`.

### Accumulator data type

Specify the accumulator data type.

#### Settings

Default: ```Inherit: Inherit via internal rule```

`Inherit: Inherit via internal rule`

Use internal rule to determine accumulator data type.

`Inherit: Same as first input`

Use data type of first input signal.

`double`

Accumulator data type is `double`.

`single`

Accumulator data type is `single`.

`int8`

Accumulator data type is `int8`.

`uint8`

Accumulator data type is `uint8`.

`int16`

Accumulator data type is `int16`.

`uint16`

Accumulator data type is `uint16`.

`int32`

Accumulator data type is `int32`.

`uint32`

Accumulator data type is `uint32`.

`fixdt(1,16,0)`

Accumulator data type is fixed point `fixdt(1,16,0)`.

`fixdt(1,16,2^0,0)`

Accumulator data type is fixed point `fixdt(1,16,2^0,0)`.

`<data type expression>`

The name of a data type object, for example `Simulink.NumericType`

#### Command-Line Information

See Block-Specific Parameters for the command-line information.

### Integrator output data type

Select the data type of the integrator output.

#### Settings

`Inherit: Inherit via internal rule` (Default)

Simulink chooses a data type to balance numerical accuracy, performance, and generated code size, while taking into account the properties of the embedded target hardware. If you change the embedded target settings, the data type selected by the internal rule might change. It is not always possible for the software to optimize code efficiency and numerical accuracy at the same time. If the internal rule doesn’t meet your specific needs for numerical accuracy or performance, use one of the following options:

• Specify the output data type explicitly.

• Use `Inherit: Inherit via back propagation`.

• Explicitly specify a default data type such as `fixdt(1,32,16)` and then use the Fixed-Point Tool to propose data types for your model. For more information, see `fxptdlg`.

`Inherit: Inherit via back propagation`

Use data type of the driving block.

`double`

`single `

`int8`

`uint8`

`int16`

`uint16`

`int32`

`uint32`

`fixdt(1,16)`

`fixdt(1,16,0)`

`fixdt(1,16,2^0,0)`

`<data type expression>`

Name of a data type object. For example, `Simulink.NumericType`.

### Filter output data type

Select the data type of the filter output.

#### Settings

`Inherit: Inherit via internal rule` (Default)

Simulink chooses a data type to balance numerical accuracy, performance, and generated code size, while taking into account the properties of the embedded target hardware. If you change the embedded target settings, the data type selected by the internal rule might change. It is not always possible for the software to optimize code efficiency and numerical accuracy at the same time. If the internal rule doesn’t meet your specific needs for numerical accuracy or performance, use one of the following options:

• Specify the output data type explicitly.

• Use `Inherit: Inherit via back propagation`.

• Explicitly specify a default data type such as `fixdt(1,32,16)` and then use the Fixed-Point Tool to propose data types for your model. For more information, see `fxptdlg`.

`Inherit: Inherit via back propagation`

Use data type of the driving block.

`double`

`single `

`int8`

`uint8`

`int16`

`uint16`

`int32`

`uint32`

`fixdt(1,16)`

`fixdt(1,16,0)`

`fixdt(1,16,2^0,0)`

`<data type expression>`

Name of a data type object. For example, `Simulink.NumericType`.

### Saturation output data type

Select the saturation output data type.

#### Settings

`Inherit: Same as input` (Default)

Use data type of input signal.

`Inherit: Inherit via back propagation`

Use data type of the driving block.

`double`

`single`

`int8`

`uint8`

`int16`

`uint16`

`int32`

`uint32`

`fixdt(1,16)`

`fixdt(1,16,0)`

`fixdt(1,16,2^0,0)`

`<data type expression>`

Name of a data type object. For example, `Simulink.NumericType`.

### Mode

Select the category of data to specify.

#### Settings

Default: `Inherit`

`Inherit`

Inheritance rules for data types. Selecting `Inherit` enables a second menu/text box to the right. Select one of the following choices:

• `Inherit via internal rule` (default)

• `Inherit via back propagation`

• `Same as first input`

• `Same as accumulator`

`Built in`

Built-in data types. Selecting `Built in` enables a second menu/text box to the right. Select one of the following choices:

• `double` (default)

• `single`

• `int8`

• `uint8`

• `int16`

• `uint16`

• `int32`

• `uint32`

`Fixed point`

Fixed-point data types.

`Expression`

Expressions that evaluate to data types. Selecting `Expression` enables a second menu/text box to the right, where you can enter the expression.

#### Dependency

Clicking the button enables this parameter.

#### Command-Line Information

See Block-Specific Parameters for the command-line information.

### Mode

Select the category of data to specify.

#### Settings

Default: `Inherit`

`Inherit`

Inheritance rules for data types. Selecting `Inherit` enables a second menu/text box to the right. Select one of the following choices:

• `Inherit via back propagation`

• `Same as input` (default)

`Built in`

Built-in data types. Selecting `Built in` enables a second menu/text box to the right. Select one of the following choices:

• `double` (default)

• `single`

• `int8`

• `uint8`

• `int16`

• `uint16`

• `int32`

• `uint32`

`Fixed point`

Fixed-point data types.

`Expression`

Expressions that evaluate to data types. Selecting `Expression` enables a second menu/text box to the right, where you can enter the expression.

#### Dependency

Clicking the button enables this parameter.

#### Command-Line Information

See Block-Specific Parameters for the command-line information.

### Mode

Select the category of accumulator data to specify

#### Settings

Default: `Inherit`

`Inherit`

Specifies inheritance rules for data types. Selecting `Inherit` enables a list of possible values:

• `Inherit via internal rule` (default)

• `Same as first input`

`Built in`

Specifies built-in data types. Selecting ```Built in``` enables a list of possible values:

• `double` (default)

• `single`

• `int8`

• `uint8`

• `int16`

• `uint16`

• `int32`

• `uint32`

`Fixed point`

Specifies fixed-point data types.

`Expression`

Specifies expressions that evaluate to data types. Selecting `Expression` enables you to enter an expression.

#### Dependency

Clicking the button for the accumulator data type enables this parameter.

#### Command-Line Information

See Block-Specific Parameters for the command-line information.

### Data type override

Specify data type override mode for this signal.

#### Settings

Default: `Inherit`

`Inherit`

Inherits the data type override setting from its context, that is, from the block, `Simulink.Signal` object or Stateflow® chart in Simulink that is using the signal.

`Off`

Ignores the data type override setting of its context and uses the fixed-point data type specified for the signal.

#### Tip

The ability to turn off data type override for an individual data type provides greater control over the data types in your model when you apply data type override. For example, you can use this option to ensure that data types meet the requirements of downstream blocks regardless of the data type override setting.

#### Dependency

This parameter appears only when the Mode is ```Built in``` or `Fixed point`.

### Signedness

Specify whether you want the fixed-point data as signed or unsigned.

#### Settings

Default: `Signed`

`Signed`

Specify the fixed-point data as signed.

`Unsigned`

Specify the fixed-point data as unsigned.

#### Dependencies

Selecting Mode > ```Fixed point``` enables this parameter.

### Signedness

Specify whether you want the fixed-point data to be signed or unsigned.

#### Settings

Default: `Signed`

`Signed`

Specify the fixed-point data to be signed.

`Unsigned`

Specify the fixed-point data to be unsigned.

#### Dependencies

Selecting Mode > ```Fixed point``` for the accumulator data type enables this parameter.

#### Command-Line Information

See Block-Specific Parameters for the command-line information.

### Scaling

Specify the method for scaling your fixed-point data to avoid overflow conditions and minimize quantization errors.

#### Settings

Default: ```Best precision```, `Binary point`, `Integer`

`Binary point`

Specify binary point location.

`Slope and bias`

Enter slope and bias.

`Best precision`

Specify best-precision values. This option appears for some blocks.

`Integer`

Specify integer. This setting has the same result as specifying a binary point location and setting fraction length to 0. This option appears for some blocks.

#### Dependencies

Selecting Mode > ```Fixed point``` enables this parameter.

Selecting `Binary point` enables:

• Fraction length

Selecting `Slope and bias` enables:

• Slope

• Bias

#### Command-Line Information

See Block-Specific Parameters for the command-line information.

### Scaling

Specify the method for scaling your fixed-point data to avoid overflow conditions and minimize quantization errors.

#### Settings

Default: ```Binary point```

`Binary point`

Specify binary point location.

`Slope and bias`

Enter slope and bias.

#### Dependencies

Selecting Mode > ```Fixed point``` for the accumulator data type enables this parameter.

Selecting `Binary point` enables:

• Fraction length

Selecting `Slope and bias` enables:

• Slope

• Bias

#### Command-Line Information

See Block-Specific Parameters for the command-line information.

### Word length

Specify the bit size of the word that holds the quantized integer.

#### Settings

Default: `16`

Minimum: `0`

Maximum: `32`

#### Dependencies

Selecting Mode > ```Fixed point``` enables this parameter.

### Word length

Specify the bit size of the word that will hold the quantized integer.

#### Settings

Default: `16`

Minimum: `0`

Maximum: `32`

Large word sizes represent large values with greater precision than small word sizes.

#### Dependencies

Selecting Mode > ```Fixed point``` for the accumulator data type enables this parameter.

#### Command-Line Information

See Block-Specific Parameters for the command-line information.

### Fraction length

Specify fraction length for fixed-point data type.

#### Settings

Default: `0`

Binary points can be positive or negative integers.

#### Dependencies

Selecting Scaling > ```Binary point``` enables this parameter.

### Fraction length

Specify fraction length for fixed-point data type.

#### Settings

Default: `0`

Binary points can be positive or negative integers.

#### Dependencies

Selecting Scaling > ```Binary point``` for the accumulator data type enables this parameter.

#### Command-Line Information

See Block-Specific Parameters for the command-line information.

### Slope

Specify slope for the fixed-point data type.

#### Settings

Default: `2^0`

Specify any positive real number.

#### Dependencies

Selecting Scaling > ```Slope and bias``` enables this parameter.

### Slope

Specify slope for the fixed-point data type.

#### Settings

Default: `2^0`

Specify any positive real number.

#### Dependencies

Selecting Scaling > ```Slope and bias``` for the accumulator data type enables this parameter.

#### Command-Line Information

See Block-Specific Parameters for the command-line information.

### Bias

Specify bias for the fixed-point data type.

#### Settings

Default: `0`

Specify any real number.

#### Dependencies

Selecting Scaling > ```Slope and bias``` enables this parameter.

### Bias

Specify bias for the fixed-point data type.

#### Settings

Default: `0`

Specify any real number.

#### Dependencies

Selecting Scaling > ```Slope and bias``` for the accumulator data type enables this parameter.

#### Command-Line Information

See Block-Specific Parameters for the command-line information.

### Lock output data type setting against changes by the fixed-point tools

Select to lock the output data type setting of this block against changes by the Fixed-Point Tool and the Fixed-Point Advisor.

#### Settings

Default: Off

On

Locks the output data type setting for this block.

Off

Allows the Fixed-Point Tool and the Fixed-Point Advisor to change the output data type setting for this block.

#### Command-Line Information

 Parameter: `LockScale` Type: character vector Value: `'off'` | `'on'` Default: `'off'`

For more information, see Use Lock Output Data Type Setting (Fixed-Point Designer).

### Saturate on integer overflow

Specify whether overflows saturate.

#### Settings

Default: Off

On

Overflows saturate to either the minimum or maximum value that the data type can represent.

For example, an overflow associated with a signed 8-bit integer can saturate to -128 or 127.

Off

Overflows wrap to the appropriate value that the data type can represent.

For example, the number 130 does not fit in a signed 8-bit integer and wraps to -126.

#### Tips

• Consider selecting this check box when your model has a possible overflow and you want explicit saturation protection in the generated code.

• Consider clearing this check box when you want to optimize efficiency of your generated code.

Clearing this check box also helps you to avoid overspecifying how a block handles out-of-range signals. For more information, see Check for Signal Range Errors.

• When you select this check box, saturation applies to every internal operation on the block, not just the output or result.

• In general, the code generation process can detect when overflow is not possible. In this case, the code generator does not produce saturation code.

#### Command-Line Information

 Parameter: `SaturateOnIntegerOverflow` Type: character vector Value: `'off'` | `'on'` Default: `'off'`

### Integer rounding mode

Specify the rounding mode for fixed-point operations.

#### Settings

Default: `Floor`

`Ceiling`

Rounds both positive and negative numbers toward positive infinity. Equivalent to the MATLAB® `ceil` function.

`Convergent`

Rounds number to the nearest representable value. If a tie occurs, rounds to the nearest even integer. Equivalent to the Fixed-Point Designer `convergent` function.

`Floor`

Rounds both positive and negative numbers toward negative infinity. Equivalent to the MATLAB `floor` function.

`Nearest`

Rounds number to the nearest representable value. If a tie occurs, rounds toward positive infinity. Equivalent to the Fixed-Point Designer `nearest` function.

`Round`

Rounds number to the nearest representable value. If a tie occurs, rounds positive numbers toward positive infinity and rounds negative numbers toward negative infinity. Equivalent to the Fixed-Point Designer `round` function.

`Simplest`

Automatically chooses between round toward floor and round toward zero to generate rounding code that is as efficient as possible.

`Zero`

Rounds number toward zero. Equivalent to the MATLAB `fix` function.

#### Command-Line Information

 Parameter: `RndMeth` Type: character vector Value: `'Ceiling'` | `'Convergent'` | `'Floor'` | `'Nearest'` | `'Round'` | `'Simplest'` | `'Zero'` Default: `'Floor'`

For more information, see Rounding (Fixed-Point Designer) in the Fixed-Point Designer documentation.

### State name

Assign unique name to each state. The state names apply only to the selected block.

To assign a name to a single state, enter the name between quotes; for example, `'velocity'`.

To assign names to multiple states, enter a comma-delimited list surrounded by braces; for example, `{'a', 'b', 'c'}`. Each name must be unique. To assign state names with a variable that has been defined in the MATLAB workspace, enter the variable without quotes. The variable can be a character vector, cell, or structure.

#### Settings

Default: `' '` (no name)

### State name must resolve to Simulink signal object

Require that state name resolve to Simulink signal object.

#### Settings

Default: Off

On

Require that state name resolve to Simulink signal object.

Off

Do not require that state name resolve to Simulink signal object.

#### Dependencies

State name enables this parameter. This parameter appears only if you set the model configuration parameter Signal resolution to a value other than `None`.

Selecting this check box disables Code generation storage class.

#### Command-Line Information

 Parameter: `StateMustResolveToSignalObject` Type: character vector Value: `'off'` | `'on'` Default: `'off'`

### Code generation storage class

Select state storage class for code generation.

#### Settings

Default: `Auto`

`Auto`

`Auto` is the appropriate storage class for states that you do not need to interface to external code.

`StorageClass`

Applies the storage class or custom storage class that you select from the list. For information about storage classes, see Control Signals and States in Code by Applying Storage Classes (Simulink Coder). For information about custom storage classes, see Control Data Representation by Applying Custom Storage Classes (Embedded Coder).

Use Signal object class to select custom storage classes from a package other than `Simulink`.

#### Dependencies

State name enables this parameter.

#### Command-Line Information

Command-Line Information

 Parameter: `StateStorageClass` Type: character vector Value: `'Auto'` | `'ExportedGlobal'` | `'ImportedExtern'` | `'ImportedExternPointer'` | `'SimulinkGlobal'` | `'Custom'` Default: `'Auto'`

### Note

TypeQualifier will be removed in a future release. To apply storage type qualifiers to data, use custom storage classes and memory sections. Unless you use an ERT-based code generation target with Embedded Coder®, custom storage classes and memory sections do not affect the generated code.

Specify a storage type qualifier such as `const` or `volatile`.

#### Settings

• Default: ```' '``` (empty character vector)

• `const`

• `volatile`

#### Dependency

Setting Code generation storage class to `ExportedGlobal`, `ImportedExtern`, `ImportedExternPointer`, or `SimulinkGlobal` enables this parameter. This parameter is hidden unless you previously set its value.

#### Command-Line Information

 Parameter Name: `RTWStateStorageTypeQualifier` Value Type: character vector Default: `' '` (empty character vector)

## Characteristics

 Direct Feedthrough The following ports support direct feedthrough: Reset portIntegrator and filter initial condition portInput port, for every integration method except Forward Euler Sample Time Specified in the Sample time parameter Scalar Expansion Supported for gain parameters P, I, and D and for filter coefficient N, and for setpoint weights b and c States Inherited from driving block and parameters Dimensionalized Yes Zero-Crossing Detection Yes (in continuous-time domain)