Main Content

我ntegrator

我ntegrate signal

  • Library:
  • Simulink / Commonly Used Blocks

    Simulink / Continuous

  • 我ntegrator block

Description

The我ntegratorblock outputs the value of the integral of its input signal with respect to time.

金宝app®treats the我ntegratorblock as a dynamic system with one state. The block dynamics are given by:

{ x ˙ ( t ) = u ( t ) y ( t ) = x ( t ) x ( t 0 ) = x 0

where:

  • uis the block input.

  • yis the block output.

  • xis the block state.

  • x0is the initial condition ofx.

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 theSolverpane of the Configuration Parameters dialog box (seeSolver Pane) to select the technique best suited to your application.

The selected solver computes the output of the我ntegratorblock 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我ntegratorblock 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 theDiscrete-Time Integratorblock 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我nitial condition sourceparameter asinternaland enter the value in the我nitial conditionfield.

  • To provide the initial conditions from an external source, specify the我nitial condition sourceparameter asexternal. An additional input port appears under the block input.

    Note

    我f the integrator limits its output (seeLimiting the Integral), the initial condition must fall inside the integrator's saturation limits. If the initial condition is outside the block saturation limits, the block displays an error message.

Limiting the Integral

To prevent the output from exceeding specifiable levels, select theLimit outputcheck box and enter the limits in the appropriate parameter fields. This action causes the block to function as a limited integrator. When the output reaches the limits, the integral action is turned off to prevent integral wind up. During a simulation, you can change the limits but you cannot change whether the output is limited. The block determines output as follows:

  • When the integral is less than or equal to theLower saturation limit, the output is held at theLower saturation limit.

  • 当之间的积分Lower saturation limitand theUpper saturation limit, the output is the integral.

  • When the integral is greater than or equal to theUpper saturation limit, the output is held at theUpper saturation limit.

To generate a signal that indicates when the state is being limited, select theShow saturation portcheck box. A saturation port appears below the block output port.

The signal has one of three values:

  • 1 indicates that the upper limit is being applied.

  • 0 indicates that the integral is not limited.

  • –1 indicates that the lower limit is being applied.

When you select this check box, the block has three zero crossings: one to detect when it enters the upper saturation limit, one to detect when it enters the lower saturation limit, and one to detect when it leaves saturation.

Note

For the我ntegrator Limitedblock, by default,Limit output被选中时,Upper saturation limitis set to1, andLower saturation limitis set to0.

Wrapping Cyclic States

Several physical phenomena are cyclic, periodic, or rotary in nature. Objects or machinery that exhibit rotational movement and oscillators are examples of such phenomena.

Modeling these phenomena in Simulink involves integrating the rate of change of the periodic or cyclic signals to obtain the state of the movement.

The drawback with this approach, however, is that over long simulation time spans, the states representing periodic or cyclic signals integrate to large values. Further, computing the sine or cosine of these signals takes an increasingly large amount of time because of angle reduction. The large signals values also negatively impact solver performance and accuracy.

One approach for overcoming this drawback is to reset the angular state to0when 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 zero-crossing 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 checkingWrap stateon the block parameter dialog box. When you enableWrap state, the block icon changes to indicate that the block has wrapping states.

Simulink allows 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 = { x x [ x l , x u ) x ( x u x l ) x x l x u x l otherwise

where:

  • xlis the lower value of the wrapped state.

  • xuis the upper value of the wrapped state.

  • yis the output.

The support for wrapping states provides these advantages.

  • 我t eliminates simulation instability when your model approaches large angles and large state values.

  • 我t reduces the number of solver resets during simulation and eliminates the need for zero-crossing detection, improving simulation time.

  • 我t eliminates large angle values, speeding up computation of trigonometric functions on angular states.

  • 我t 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 theExternal resetchoices. A trigger port appears below the block's input port and indicates the trigger type.

  • Selectrisingto reset the state when the reset signal rises from a negative or zero value to a positive value.

  • Selectfallingto reset the state when the reset signal falls from a positive value to a zero or negative value.

  • Selecteitherto reset the state when the reset signal changes from zero to a nonzero value, from a nonzero value to zero, or changes sign.

  • Selectlevelto 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.

  • Selectlevel holdto 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 (seeAlgebraic 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 theShow state portcheck 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:

  • Self-resetting integrators (seeCreating Self-Resetting Integrators)

  • Handing off a state from one enabled subsystem to another (seeHanding Off States Between Enabled Subsystems)

    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.

Creating Self-Resetting Integrators

The Integrator block's state port helps you avoid an algebraic loop when creating an integrator that resets itself based on the value of its output. Consider, for example, the following model.

This model tries to create a self-resetting integrator by feeding the integrator's output, subtracted from 1, back into the integrator's reset port. However, the model creates an algebraic loop. To compute the integrator block's output, Simulink software needs to know the value of the block's reset signal, and vice versa. Because the two values are mutually dependent, Simulink software cannot determine either. Therefore, an error message appears if you try to simulate or update this model.

The followingmodeluses the integrator's state port to avoid the algebraic loop.

我n this version, the value of the reset signal depends on the value of the state port. The value of the state port is available earlier in the current time step than the value of the integrator block's output port. Therefore, Simulink can determine whether the block needs to be reset before computing the block's output, thereby avoiding the algebraic loop.

Handing Off States Between Enabled Subsystems

The state port helps you avoid an algebraic loop when passing a state between two enabled subsystems. Consider, for example, the following model.

The enabled subsystems, A and B, contain the following blocks:

Subsystem A Subsystem B

我n this model, a constant input signal drives two enabled subsystems that integrate the signal. A pulse generator generates an enabling signal that causes execution to alternate between the two subsystems. The enable port of each subsystem is set to reset, which causes the subsystem to reset its integrator when it becomes active. Resetting the integrator causes the integrator to read the value of its initial condition port. The initial condition port of the integrator in each subsystem is connected to the output port of the integrator in the other subsystem.

This connection is intended to enable continuous integration of the input signal as execution alternates between two subsystems. However, the connection creates an algebraic loop. To compute the output of A, Simulink needs to know the output of B, and vice versa. Because the outputs are mutually dependent, Simulink cannot compute the output values. Therefore, an error message appears if you try to simulate or update this model.

The followingversionof the same model uses the integrator state port to avoid creating an algebraic loop when handing off the state.

The enabled subsystems, A and B, contain the following blocks:

Subsystem A Subsystem B

我n this model, the initial condition of the integrator in A depends on the value of the state port of the integrator in B, and vice versa. The values of the state ports are updated earlier in the simulation time step than the values of the integrator output ports. Therefore, Simulink can compute the initial condition of either integrator without knowing the final output value of the other integrator. For another example of using the state port to hand off states between conditionally executed subsystems, seeBuilding a Clutch Lock-Up 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 (seeError Tolerances for Variable-Step Solvers)计算积分器的输出块。我f this value does not provide sufficient error control, specify a more appropriate value in theAbsolute tolerancefield of the Integrator block dialog box. The value that you specify is used to compute all the block outputs.

Selecting All Options

When you select all options, the block icon looks like this.

Ports

The Integrator block accepts and outputs signals of typedoubleon its data ports. The external reset port accepts signals of typedoubleorBoolean.

我nput

expand all

Signal that needs to be integrated.

Data Types:double

Reset the state to the specified initial conditions based on an external signal. SeeResetting the State.

Dependencies

To enable this port, enable theExternal Resetparameter.

Data Types:Boolean

Set the initial condition of the block's state from an external signal.

Dependencies

To enable this port, set the初始条件parameter toexternal.

Data Types:double

Output

expand all

Output the integrated state.

Data Types:double

我ndicate when the state is being limited. The signal has a value of1when the integral is limited by the specifiedUpper saturation limit. When the signal is limited by theLower saturation limit, the signal value is-1. When the integral is between the saturation limits, the signal value is0. SeeLimiting the Integral.

Data Types:double

Output the state of the block. SeeAbout the State Port.

Dependencies

Enable this port by enabling theShow state portparameter.

Data Types:double

Parameters

expand all

Specify the type of trigger to use for the external reset signal.

  • Selectrisingto reset the state when the reset signal rises from a negative or zero value to a positive value, or a negative value to zero value.

  • Selectfallingto reset the state when the reset signal falls from a positive value to a zero or negative value, or from a zero value to negative value.

  • Selecteitherto reset the state when the reset signal changes from zero to a nonzero value, from a nonzero value to zero, or changes sign.

  • Selectlevelto 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.

  • Selectlevel holdto reset the state when the reset signal is nonzero at the current time step.

Programmatic Use

Block Parameter:ExternalReset
Type:character vector , string
Values:'none'|'rising'|'falling'|'either'|'level'|'level hold'
Default:'none'

Select source of initial condition:

  • internal— Get the initial conditions of the states from the我nitial conditionblock parameter.

  • external— Get the initial conditions of the states from an external block, via the我Cinput port.

Dependencies

Selectinginternalenables the我nitial conditionparameter.

Selectingexternaldisables the我nitial conditionparameter and enables the我Cinput port.

Programmatic Use

Block Parameter:我nitialConditionSource
Type:character vector, string
Values:'internal'|'external'
Default:'internal'

Set the initial state of the我ntegratorblock.

Tips

Simulink software does not allow the initial condition of this block to beinforNaN.

Dependencies

Setting我nitial condition sourcetointernalenables this parameter.

Setting我nitial condition sourcetoexternaldisables this parameter.

Programmatic Use

Block Parameter:我nitialCondition
Type:scalar or vector
Default:'0'

Limit the block's output to a value between theLower saturation limitandUpper saturation limitparameters.

  • Selecting this check box limits the block output to a value between theLower saturation limitandUpper saturation limitparameters.

  • Clearing this check box does not limit the block output values.

Dependencies

选择这个爸爸rameter enables theLower saturation limitandUpper saturation limitparameters.

Programmatic Use

Block Parameter:LimitOutput
Type:character vector , string
Values:'off'|'on'
Default:'off'

Specify the upper limit for the integral as a scalar, vector, or matrix. You must specify a value between theOutput minimumandOutput maximumparameter values.

Dependencies

To enable this parameter, select theLimit outputcheck box.

Programmatic Use

Block Parameter:UpperSaturationLimit
Type:character vector, string
Values:scalar | vector | matrix
Default:'inf'

Specify the lower limit for the integral as a scalar, vector, or matrix. You must specify a value between theOutput minimumandOutput maximumparameter values.

Dependencies

To enable this parameter, select theLimit outputcheck box.

Programmatic Use

Block Parameter:LowerSaturationLimit
Type:character vector , string
Values:scalar | vector | matrix
Default:'-inf'

Enable wrapping of states between theWrapped state upper valueandWrapped state lower valueparameters. Enabling wrap states eliminates the need for zero-crossing detection, reduces solver resets, improves solver performance and accuracy, and increases simulation time span when modeling rotary and cyclic state trajectories.

我f you specifyWrapped state upper valueasinfandWrapped state lower valueas-inf, wrapping does not occur.

Dependencies

选择这个爸爸rameter enablesWrapped state upper valueandWrapped state lower valueparameters.

Programmatic Use

Block Parameter:WrapState
Type:character vector, string
Values:'off'|'on'
Default:'off'

Upper limit of the block output.

Dependencies

SelectingWrap stateenables this parameter.

Programmatic Use

Block Parameter:WrappedStateUpperValue
Type:scalar or vector
Values:'2*pi'
Default:'pi'

Lower limit of the block output.

Dependencies

SelectingWrap stateenables this parameter.

Programmatic Use

Block Parameter:WrappedStateLowerValue
Type:scalar or vector
Values:'0'
Default:'-pi'

Select this check box to add a saturation output port to the block. When you clear this check box, the block does not have a saturation output port.

Dependencies

选择这个爸爸rameter enables a saturation output port.

Programmatic Use

Block Parameter:ShowSaturationPort
Type:character vector , string
Values:'off'|'on'
Default:'off'

Select this check box to add a state output port to the block. When you clear this check box, the block does not have a state output port.

Dependencies

选择这个爸爸rameter enables a state output port.

Programmatic Use

Block Parameter:ShowStatePort
Type:character vector , string
Values:'off'|'on'
Default:'off'
  • 我f you enterautoor –1, then Simulink uses the absolute tolerance value in the Configuration Parameters dialog box (seeSolver Pane) to compute block states.

  • 我f you enter a real scalar, then that value overrides the absolute tolerance in the Configuration Parameters dialog box for computing all block states.

  • 我f you enter a real vector, then the dimension of that vector must match the dimension of the continuous states in the block. These values override the absolute tolerance in the Configuration Parameters dialog box.

Programmatic Use

Block Parameter:AbsoluteTolerance
Type:character vector, string, scalar, or vector
Values:'auto'|'-1'| any positive real scalar or vector
Default:'auto'

Cause Simulink linearization commands to treat this block as unresettable and as having no limits on its output, regardless of the settings of the reset and output limitation options of the block.

Tip

Use this check box to linearize a model around an operating point that causes the integrator to reset or saturate.

Programmatic Use

Block Parameter:我gnoreLimit
Type:character vector, string
Values:'off'|'on'
Default:'off'

Select to enable zero-crossing detection. For more information, seeZero-Crossing Detection.

Programmatic Use

Block Parameter:ZeroCross
Type: character vector, string
Values:'off'|'on'
Default:'on'
  • 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.

  • The state names apply only to the selected block.

  • The number of states must divide evenly among the number of state names.

  • You can specify fewer names than states, but you cannot specify more names than states.

    For example, you can specify two names in a system with four states. The first name applies to the first two states and the second name to the last two states.

  • To assign state names with a variable in the MATLAB®workspace, enter the variable without quotes. A variable can be a character vector, string, cell array, or structure.

Programmatic Use

Block Parameter:ContinuousStateAttributes
Type:character vector, string
Values:' '| user-defined
Default:' '

Block Characteristics

Data Types

double

Direct Feedthrough

yes

Multidimensional Signals

no

Variable-Size Signals

no

Zero-Crossing Detection

yes

Extended Capabilities

我ntroduced before R2006a