Engee documentation

Integrator

Integration of the input signal.

blockType: Integrator

Path in the library:

/Basic/Continuous/Integrator

Description

The Integrator block calculates the time integral value of the input signal.

Block Integrator can be considered as a dynamic system with one state. The block behaviour is described by the following equations:

,

where

  • - is the input signal;

  • - output signal;

  • - state;

  • - initial state .

These equations describe the exact dependence of the output on the input in continuous time; numerical approximation methods are used to estimate them with finite accuracy. There are several types of solvers in Engee that implement different numerical integration methods to compute the output of a block. Each solver has its own advantages depending on the specific problem.

The selected solver calculates the output of block Integrator at the current time step using the current input value and the state value at the previous time step. To do this, the Integrator block stores the output value at the current time step for usage by the solver at the next time step. The block also provides the solver with an initial state to calculate the state of the block at the start of the simulation. By default, the initial state value is 0. Using the block parameters window it is possible to set a different value of the initial state.

To create a fully discrete system it is recommended to use the block Discrete-Time Integrator.

Definition of initial states

You can define the initial states as parameters in the block dialogue box or enter them from an external signal:

  • To define the initial states as a block parameter, specify Initial condition source as a internal and enter a value in the field Initial condition.

  • To get the initial states from an external source, specify Initial condition source as a external. An additional input port appears below the input port.

If the integrator limits its output signal (see Sect. Integrator limiting), the initial state must be within the saturation limits of the integrator. If the initial state is outside the saturation limits of the block, the block displays an error message.

Integrator limiting

To ensure that the output does not exceed specified levels, select the Limit output check box and enter limits in the appropriate parameters fields. This action causes the block to function as a limited integrator. When the output reaches the limits, the integrator action is terminated.

You can change the limits during simulation, but you cannot turn the integrator limits on or off. The block defines the output as follows:

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

  • When the integral is between Lower saturation limit and Upper saturation limit, the output is held at the integral.

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

To generate a signal indicating when the state is limited, check Show saturation port. The saturation port appears below the block output port.

integrator 2

The signal takes one of three values:

  • 1 indicates that the upper limit applies.

  • 0 indicates that the integral is unbounded.

  • -1 indicates that the lower limit applies.

When this checkbox is selected, the block has three zero crossings:

  • To determine when it enters the upper saturation limit.

  • To determine when it enters the lower saturation limit.

  • To determine when it leaves the saturation zone.

Resetting cyclic states

Some physical phenomena are cyclic, periodic, or rotational in nature. Modelling these phenomena involves integrating the rate of change of periodic or cyclic signals to obtain a state variable.

The disadvantage of this approach is that over long simulation times, the states representing periodic or cyclic signals are integrated to very large values. In addition, calculating the sine or cosine of these signals takes increasingly longer time. Large values of the signals also negatively affect the performance and accuracy of the solver.

One approach to overcome this drawback is to reset the angular state to 0 when it reaches 2π (or to -π when it reaches π, for numerical symmetry) using additional algorithms in the model. This approach improves the accuracy of the sine and cosine calculations. But note that it leads to resetting the solver, which slows down the modelling for a variable step solver, especially in large models.

To prevent the solver from resetting when the output value is reset, the Integrator block contains a built-in state reset mechanism, which you can enable by checking the Wrap state checkbox in the block parameters dialogue box.

When you enable the Wrap state parameters , the block icon changes to indicate that cyclic state reset is enabled for the block.

When cyclic state reset is enabled, the state value is determined by the following expressions:

,

where:

  • - is the lower limit of the state value;

  • - upper limit of the state value;

  • - result (state).

Resetting cyclic states has the following advantages:

  • Eliminates modelling instability when the model approaches large angles and large state values.

  • Reduces the number of solver resets during simulation, which reduces simulation time.

  • Eliminates large angle values, speeding up the computation of trigonometric functions over angular states.

  • Improves solver accuracy and performance and provides unlimited simulation time.

Reset state

The unit resets its state to the initial state by an external signal. The reset trigger type is determined by the parameters External reset. If a value other than none, the unit has a reset port with the reset trigger type labelled next to it.

Reset Trigger Types

The External reset parameters allows you to define the attribute of the reset signal that is the reset trigger. The following triggers are possible:

  • rising - resets the state when the reset signal passes an edge, i.e. rises from a negative or zero value to a positive value.

  • falling - resets the state when the reset signal passes the cutoff, i.e. drops from a positive value to a zero or negative value.

  • either - resets the state when the reset signal goes up or down, i.e. changes from zero to a non-zero value, from a non-zero value to zero, or changes sign.

  • level - resets and holds the output in the initial state until the reset signal is equal to zero, i.e. different from zero at the current time step or changes from a non-zero value at the previous time step to zero at the current time step.

  • level hold - resets the output signal to the initial state when the reset signal is different from zero.

The reset port has a direct input. If the block output signal is fed back to this port, either directly or through a series of direct-input blocks, an algebraic loop is produced. Use the block status port of Integrator to feedback the block output without creating an algebraic loop.

About the status port

Checking Show state port in the block parameters dialogue box Integrator results in an additional output port, the status port, at the top of the integrator block.

integrator 1

The output of the status port is the same as the standard block output port, except in the following case. If the block is reset at the current time step, the status port output represents the value that would have appeared on the standard block output if the block had not been reset.

The output of the status port appears earlier in the time step than the output of the integrator block output port. Use the status port to open algebraic circuits in these simulation scenarios:

Creating self resetting integrators

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

This model attempts to create a self-setting integrator by feeding the integrator output subtracted from 1 back into the integrator reset port. However, the model creates an algebraic loop. To calculate the integrator block output, the software must know the value of the block reset signal, and vice versa. Since these two values are interdependent, the software cannot determine either value. Therefore, an error message appears when attempting to model or update this model.

The following model uses the integrator state port to avoid the occurrence of an algebraic loop.

In 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 output port of the integrator block. Consequently, can determine whether the block should be reset before calculating the block output, thus avoiding an algebraic loop.

Transfer of states between enabled subsystems

The state port helps to avoid the occurrence of an algebraic loop when transferring state between two enabled subsystems. Consider, for example, the following model.

Enabled subsystems A and B contain the following blocks:

Subsystem A Subsystem B

In this model, a constant input signal drives two enabled subsystems that integrate the signal. A pulse generator generates an enable signal that alternates execution between the subsystems. The Enabled 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 state port. The initial state port of the integrator in each subsystem is connected to the output port of the integrator in the other subsystem.

This interconnection is intended to provide continuous integration of the input signal while alternating execution between the two subsystems. However, the connection creates an algebraic loop. To compute the output data A, one must know the output data B, and vice versa. Since the outputs are interdependent, it is not possible to compute the output values. Therefore, an error message appears when trying to model or update this model.

This version of the same model uses the state port of the integrator to avoid creating an algebraic loop during state transfer.

Enabled subsystems A and B contain the following blocks:

Subsystem A Subsystem B

In this model, the initial state 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 time step of the simulation than the values of the output ports of the integrator. Hence, it is possible to calculate the initial state of any integrator without knowing the final output value of another integrator.

Ports

Output

# OUT_1 — output signal
scalar | vector | matrix

Details

Integration result.

Data types

Float64.

Complex numbers support

No

# OUT_2 — output signal limitation sign
scalar | vector | matrix

Details

A saturation output signal, specified as a scalar, vector or matrix, which indicates when the output signal is bounded by an upper or lower saturation limit.

  • If the integral is bounded at Upper saturation limit, the output signal is 1.

  • If the integral is bounded at Lower saturation limit, the output signal is -1.

  • If the integral is between these limits, the output signal is 0. For more information, refer to Integrator Limit.

Data types

Float64.

Complex numbers support

No

# OUT_3 — state
scalar | vector | matrix

Details

Outputs the status of the block. For more information, refer to About the Status Port.

Dependencies

To use this port, select the check box for the parameters Show state port.

Data types

Float64.

Complex numbers support

No

Input

# IN_1 — input signal
scalar | vector | matrix

Details

The signal to be integrated.

Data types

Float64.

Complex numbers support

No

# x0 — initial state
scalar | vector | matrix

Details

The initial state of the block specified by an external signal. Refer to Defining initial states.

Dependencies

To use this port, set the Initial condition source parameters to . external.

Data types

Float64.

Complex numbers support

No

# External Reset — reset
scalar | vector | matrix

Details

Resets the state of the unit to the preset initial state by an external signal. Refer to Reset Status.

Dependencies

To use this port, set the parameters External reset to any value other than none.

Data types

Float64, Bool.

Complex numbers support

No

Parameters

Main

# External reset — reset to initial state
none | rising | falling | either | level | level hold

Details

Specify the type of trigger to be used for the external reset signal.

  • rising - resets the state when the reset signal passes the edge.

  • falling - resets the state when the reset signal passes the slice.

  • either - resets the state when the reset signal is rising or falling (passing an edge or a slice).

  • level - resets and holds the output in the initial state when the reset signal is different from zero at the current time step or changes from a non-zero value at the previous time step to zero at the current time step.

  • level hold - resets the output to the initial state when the reset signal is different from zero at the current time step.

Values

none | rising | falling | either | level | level hold

Default value

none

Program usage name

ExternalReset

Tunable

No

Evaluatable

No

# Initial condition source — selecting the source of the initial state
internal | external

Details

Select the source of the initial state:

  • internal - get initial states from the parameters Initial condition.

  • external - receiving initial states from an external source via input port x0.

Values

internal | external

Default value

internal

Program usage name

InitialConditionSource

Tunable

No

Evaluatable

No

# Initial condition — initial state
Scalar / array of real numbers

Details

Initial state of block Integrator.

Dependencies

To use this parameter, set the Initial condition source parameters to internal.

Default value

0.0

Program usage name

InitialCondition

Tunable

Yes

Evaluatable

Yes

# Limit output — Limiting the output values of the block to the specified range
Logical

Details

Limit the block output to a value between the parameters Lower saturation limit and Upper saturation limit.

  • Checking this box limits the block output to a value between the parameters Lower saturation limit and Upper saturation limit.

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

Dependencies

Selecting this option includes the parameters Lower saturation limit and Upper saturation limit.

Default value

false (switched off)

Program usage name

LimitOutput

Tunable

No

Evaluatable

No

# Upper saturation limit — upper limit for the integral
Scalar / array of real numbers

Details

State the upper limit for an integral in the form of a scalar, vector, or matrix.

Dependencies

To use this parameter, select the checkbox Limit output.

Default value

Inf

Program usage name

UpperSaturationLimit

Tunable

Yes

Evaluatable

Yes

# Lower saturation limit — lower bound for the integral
Scalar / array of real numbers

Details

State the lower limit for an integral in the form of a scalar, vector, or matrix.

Dependencies

To use this parameter, select the checkbox Limit output.

Default value

-Inf

Program usage name

LowerSaturationLimit

Tunable

Yes

Evaluatable

Yes

# Wrap state — cycle reset
Logical

Details

Reset cyclic states between parameters Wrapped state upper value and Wrapped state lower value. Enabling this parameters reduces the number of solver resets, improves the performance and accuracy of calculations, and increases the allowable simulation time for rotational and cyclic states.

If you specify Wrapped state upper value as inf and Wrapped state lower value as -inf, no reset will occur.

Dependencies

Selecting this parameter allows you to set the parameters Wrapped state upper value and Wrapped state lower value.

Default value

false (switched off)

Program usage name

WrapState

Tunable

No

Evaluatable

No

# Wrapped state upper value — upper limit for resetting cyclic states
Scalar / array of real numbers

Details

Upper limit of the block output signal (for resetting cyclic states).

Dependencies

To use this parameter, select the check box Wrap state.

Default value

pi

Program usage name

WrappedStateUpperValue

Tunable

No

Evaluatable

Yes

# Wrapped state lower value — lower limit for resetting cyclic states
Scalar / array of real numbers

Details

The lower limit of the block output signal (for resetting cyclic states).

Dependencies

To use this parameter, select the check box Wrap state.

Default value

-pi

Program usage name

WrappedStateLowerValue

Tunable

No

Evaluatable

Yes

# Show saturation port — switching on the saturation output port
Logical

Details

Select this check box to add a saturation output port to the block.

Dependencies

Selecting this parameter enables the saturation output port.

Default value

false (switched off)

Program usage name

ShowSaturationPort

Tunable

No

Evaluatable

No

# Show state port — switching on the status output port
Logical

Details

Select this check box to add a status output port to the block.

Dependencies

Selecting this parameter enables the status output port.

Default value

false (switched off)

Program usage name

ShowStatePort

Tunable

No

Evaluatable

No