Integrator
Integrate signal
Libraries:
Simulink /
Commonly Used Blocks
Simulink /
Continuous
Description
The Integrator block integrates an input signal with respect to time and provides the result as an output signal.
Simulink^{®} treats the Integrator block as a dynamic system with one state. The block dynamics are given by:
$$\{\begin{array}{c}\dot{x}(t)=u(t)\\ y(t)=x(t)\end{array}\text{}x({t}_{0})={x}_{0}$$
where:
u is the block input.
y is the block output.
x is the block state.
x_{0} is the initial condition of x.
While these equations define an exact relationship in continuous time, Simulink uses numerical approximation methods to evaluate them with finite precision. Simulink can use several different numerical integration methods to compute the output of the block, each with advantages in particular applications. Use the Solver pane of the Configuration Parameters dialog box (see Solver Pane) to select the technique best suited to your application.
The selected solver computes the output of the Integrator block at the current time step, using the current input value and the value of the state at the previous time step. To support this computational model, the Integrator block saves its output at the current time step for use by the solver to compute its output at the next time step. The block also provides the solver with an initial condition for use in computing the block's initial state at the beginning of a simulation. The default value of the initial condition is 0. Use the block parameter dialog box to specify another value for the initial condition or create an initial value input port on the block.
Use the parameter dialog box to:
Define upper and lower limits on the integral
Create an input that resets the block's output (state) to its initial value, depending on how the input changes
Create an optional state output so that the value of the block's output can trigger a block reset
Use the DiscreteTime Integrator block to create a purely discrete system.
Defining Initial Conditions
You can define the initial conditions as a parameter on the block dialog box or input them from an external signal:
To define the initial conditions as a block parameter, specify the Initial condition source parameter as
internal
and enter the value in the Initial condition field.To provide the initial conditions from an external source, set the Initial condition source parameter to
external
. An additional input port appears on the block.Note
If you select the Limit output parameter, the initial condition must be within the saturation limits. If the initial condition is not within the block saturation limits, the block displays an error message.
Limiting the Integral
To limit the output signal to a specified range of values, select Limit output and specify the saturation limits. When the output reaches one of the limits, the integral action is disabled to prevent integral wind up. During a simulation, you can change the limits but not whether the output is limited. The block determines output signal value using these criteria:
When the integral value is less than or equal to the lower saturation limit, the output signal value is the lower saturation limit.
When the integral value is between the lower saturation limit and the upper saturation limit, the output is the integral value.
When the integral value is greater than or equal to the upper saturation limit, the output signal value is the upper saturation limit.
To generate a signal that indicates when the state is limited by the saturation limits, select Show saturation port. A second output port appears on the block.
The saturation signal has one of three values:
1
— State limited by upper saturation limit0
— State not limited–1
— State limited by lower saturation limit
When you limit the Integrator block output, the block has three zero crossing signals: one to detect when the integral value exceeds the upper saturation limit, one to detect when the integral value is less than the lower saturation limit, and one to detect when the integral value changes from being saturated to not being saturated.
Note
By default, the Limit output parameter is enabled for the
Integrator Limited block, with the Upper saturation
limit parameter value set to 1
, and the
Lower saturation limit parameter value set to
0
.
Wrapping Cyclic States
Several physical phenomena, such as oscillators and machinery that exhibits rotational movement, are cyclic, periodic, or rotary in nature. Modeling these phenomena in a Simulink block diagram involves integrating the rate of change for the periodic or cyclic signals to obtain the state of the movement. Over long simulation time spans, this approach can result in the states that represent periodic or cyclic signals integrating to large values. Computing trigonometric values, such as sine or cosine, for these signals takes longer as the values become larger due to angle reduction. As the signal values become larger, solver performance and accuracy degrades.
One approach for overcoming this drawback is to reset the angular state to
0
when it reaches 2π (or to –π when it reaches π, for numerical
symmetry). This approach improves the accuracy of sine and cosine computations and reduces
angle reduction time. But it also requires zerocrossing detection and introduces solver
resets, which slow down the simulation for variable step solvers, particularly in large
models.
To eliminate solver resets at wrap points, the Integrator block supports wrapped states that you can enable by checking Wrap state on the block parameter dialog box. When you enable Wrap state, the block icon changes to indicate that the block has wrapping states.
The Integrator block supports wrapping states that are bounded by upper and lower values parameters of the wrapped state. The algorithm for determining wrapping states is given by:
$$y=\{\begin{array}{cc}x& x\in [{x}_{l},{x}_{u})\\ x({x}_{u}{x}_{l})\lfloor \frac{x{x}_{l}}{{x}_{u}{x}_{l}}\rfloor & \text{otherwise}\end{array}$$
where:
x_{l} is the lower value of the wrapped state.
x_{u} is the upper value of the wrapped state.
y is the output.
The support for wrapping states provides these advantages.
It eliminates simulation instability when your model approaches large angles and large state values.
It reduces the number of solver resets during simulation and eliminates the need for zerocrossing detection, improving simulation time.
It eliminates large angle values, speeding up computation of trigonometric functions on angular states.
It improves solver accuracy and performance and enables unlimited simulation time.
Resetting the State
The block can reset its state to the specified initial condition based on an external signal. To cause the block to reset its state, select one of the External reset choices. A trigger port appears below the block's input port and indicates the trigger type.
Select
rising
to reset the state when the reset signal rises from a negative or zero value to a positive value.Select
falling
to reset the state when the reset signal falls from a positive value to a zero or negative value.Select
either
to reset the state when the reset signal changes from zero to a nonzero value, from a nonzero value to zero, or changes sign.Select
level
to reset the state when the reset signal is nonzero at the current time step or changes from nonzero at the previous time step to zero at the current time step.Select
level hold
to reset the state when the reset signal is nonzero at the current time step.
The reset port has direct feedthrough. If the block output feeds back into this port, either directly or through a series of blocks with direct feedthrough, an algebraic loop results (see Algebraic Loop Concepts). Use the Integrator block's state port to feed back the block's output without creating an algebraic loop.
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 Integrator blocks.
About the State Port
Selecting the Show state port check box on the Integrator block's parameter dialog box causes an additional output port, the state port, to appear at the top of the Integrator block.
The output of the state port is the same as the output of the block's standard output port except for the following case. If the block is reset in the current time step, the output of the state port is the value that would have appeared at the block's standard output if the block had not been reset. The state port's output appears earlier in the time step than the output of the Integrator block's output port. Use the state port to avoid creating algebraic loops in these modeling scenarios:
Systems that use selfresetting integrators
Passing states from one enabled subsystem to another
Note
When updating a model, Simulink checks that the state port applies to one of these two scenarios. If not, an error message appears. Also, you cannot log the output of this port in a referenced model that executes in Accelerator mode. If logging is enabled for the port, Simulink generates a "signal not found" warning during execution of the referenced model.
Specifying the Absolute Tolerance for the Block Outputs
By default Simulink software uses the absolute tolerance value specified in the Configuration Parameters dialog box (see Error Tolerances for VariableStep Solvers) to compute the output of the Integrator block. If this value does not provide sufficient error control, specify a more appropriate value in the Absolute tolerance field of the Integrator block dialog box. The value that you specify is used to compute all the block outputs.
Examples
Extended Examples
Ports
Input
Output
Parameters
Block Characteristics
Data Types 

Direct Feedthrough 

Multidimensional Signals 

VariableSize Signals 

ZeroCrossing Detection 

^{a} Ports of this block have different direct feedthrough characteristics. 
Extended Capabilities
Version History
Introduced before R2006a