Engee documentation

Discrete-Time Integrator

Discrete integration or signal accumulation.

discrete time integrator

Description

Use the block Discrete-Time Integrator instead of the Integrator block to create a fully discrete model.

Output equations

In the first time step, i.e., at the state of block , the output value .

For a given time step with simulation time , the output data is updated depending on the selected method as follows:

  • Euler’s direct method:

    .

  • Euler’s inverse method:

    .

  • Trapezium method:

    .

The realisation of these output equations in the state space is automatically selected depending on the block calculation step, which can be explicit or inherited. The usage of an explicitly defined calculation step reduces to the calculation step for all .

Integration and accumulation methods

This block can integrate or accumulate a signal using the forward Euler method, the inverse Euler method, or the trapezoid method. Assume that is the input, is the output, and is the state. For a given step is updated with and . In integration mode, is the step of the block calculation. In accumulation mode, . The block calculation step determines when the output is calculated, but not the output value. - gain. Values are trimmed according to the upper or lower limit.

Euler’s direct method

Euler’s direct method (used by default), also known as direct rectangular or left approximation.

The block approximates as . Expressions for the block output at step :

,

.

The block uses these steps to calculate the output signal:

Step 0:

(limited if necessary)

Step 1:

Step n:

(limited if necessary)

Euler’s inverse method

Euler’s inverse method, also known as the inverse rectangular or right-handed approximation.

The block approximates as . Expressions for the block output at step :

,

.

The block uses these steps to calculate the output signal:

Step 0:

(limited if necessary)

Step 1:

Step n:

Trapezoid method

For this method, the block approximates as .

Expressions for calculating the output signal: ,

.

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 initial states as a block parameter, specify Initial condition source as internal and enter the value in the field Initial condition.

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

discrete time integrator 1

When to use the status port

Use the status port instead of the output port in the following cases:

  • When the block output returns to the block through the reset port or initial state port, causing an algebraic loop.

  • When you need to transfer state from one conditionally executing subsystem to another, which can cause synchronisation problems.

It is possible to circumvent these problems by passing state through the state port rather than the output port. Engee generates state at a slightly different time than the output, which protects the model from such problems. To output the state of a block, tick the checkbox Show state port. The state port will appear at the top of the block.

discrete time integrator 2

Integrator’s limitation

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

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 и Upper saturation limit, an integral is obtained at the output.

  • 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, tick the checkbox Show saturation port. The saturation port appears below the block output port.

discrete time integrator 3

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.

Resetting the 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 block has a reset port with the reset trigger type labelled next to it.

discrete time integrator 4

Types of reset triggers

Parameters External reset 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. For example, the figure below shows the effect of the reset trigger rising on integration by the inverse Euler method.

    discrete time integrator rising reset

  • falling - resets the state when the reset signal passes a cut-off, i.e. drops from a positive value to zero or negative value. For example, the figure below shows the effect of the reset trigger falling on integration by the inverse Euler method.

    discrete time integrator falling reset

  • 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. For example, the following figure shows the effect of the reset trigger either on integration by the inverse Euler method.

    discrete time integrator either reset

  • level - resets and holds the output in the initial state until the reset signal is 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. For example, this figure shows the effect of the reset trigger level on integration by the inverse Euler method.

    discrete time integrator level reset

  • sampled level - resets the output signal to its initial state when the reset signal is different from zero. For example, this figure shows the effect of the reset trigger sampled level on integration by the inverse Euler method.

    discrete time integrator sampled level reset

The option sampled level requires less computation, making it more efficient than the option level.

For a block Discrete-Time Integrator all triggers are defined by signals with positive values. For example, a signal changing from -1 to 0 is not considered a rising edge, but a signal changing from 0 to 1 is.

Ports

Output

# Port_1 — integral over discrete time or accumulated value of the input signal
scalar | vector | matrix

Details

The integral over discrete time or the accumulated value of an input signal.

Data types

Float64.

Complex numbers support

No

# Port_2 — saturation port
scalar | vector | matrix

Details

A signal indicating a state constraint is specified as a scalar, vector or matrix. The signal takes one of three values:

  • 1 indicates that the upper limit applies.

  • 0 indicates that the integral is unconstrained.

  • -1 indicates that the lower limit applies.

Dependencies

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

Data types

Float64.

Complex numbers support

No

# Port_3 — status port
scalar | vector | matrix

Details

Block states output as a scalar, vector, or matrix. The state port is output at the top of the block.

Dependencies

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

Data types

Float64.

Complex numbers support

No

Input

# Port_1 — input signal
scalar | vector | matrix

Details

An input signal specified as a scalar, vector or matrix.

Data types

Float16, Float32, Float64, Int8, Int16, Int32, Int64, Int128, UInt8, UInt16, UInt32, UInt64, UInt128, Bool.

Complex numbers support

No

# x0 — initial state
scalar | vector | matrix

Details

The initial state of the block set by an external signal.

Dependencies

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

Data types

Float16, Float32, Float64, Int8, Int16, Int32, Int64, Int128, UInt8, UInt16, UInt32, UInt64, UInt128, Bool

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 a value for the parameters External reset.

Data types

Float16, Float32, Float64, Int8, Int16, Int32, Int64, Int128, UInt8, UInt16, UInt32, UInt64, UInt128, Bool.

Complex numbers support

No

Parameters

Main

# Integrator Method — integration method
Integration: Forward Euler | Integration: Backward Euler | Integration: Trapezoidal | Accumulation: Forward Euler | Accumulation: Backward Euler | Accumulation: Trapezoidal

Details

The method of integration or accumulation.

Values

Integration: Forward Euler | Integration: Backward Euler | Integration: Trapezoidal | Accumulation: Forward Euler | Accumulation: Backward Euler | Accumulation: Trapezoidal

Default value

Integration: Forward Euler

Program usage name

IntegratorMethod

Tunable

No

Evaluatable

No

# Gain Value — integrator gain
Scalar / array of real numbers

Details

Specifies the scalar, vector or matrix by which the integrator input signal is multiplied. Each element of the gain must be a positive real number.

  • Specifying a value other than 1.0 (value by default) is semantically equivalent to connecting the Gain block to the integrator input.

Valid values: [1.1 2.2 3.3 4.4], [1.1 2.2; 3.3 4.4].

Usage of this parameter to specify the input gain eliminates the multiplication operation in the generated code. However, this parameter must be non-configurable to realise this benefit. If you want to change the gain, set this parameter to 1.0 and use the external block Gain to specify the gain.
Default value

1.0

Program usage name

gainval

Tunable

No

Evaluatable

Yes

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

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 until the reset signal is zero.

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

For more information, refer to Reset State and Reset Trigger Types.

Values

none | rising | falling | either | level | sampled level

Default value

none

Program usage name

ExternalReset

Tunable

No

Evaluatable

No

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

Details

Initial state source. Defined as:

  • internal - obtaining initial states from parameters Initial condition.

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

Dependencies

Selection internal enables usage of the parameters Initial condition in the simulation.

Selection external disables usage of the parameters Initial condition and enables the X_0 input port.

Values

internal | external

Default value

internal

Program usage name

InitialConditionSource

Tunable

No

Evaluatable

No

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

Details

The initial state of the block.

Dependencies

To use this parameter, set parameter Initial condition source value internal.

Default value

0.0

Program usage name

InitialCondition

Tunable

Yes

Evaluatable

Yes

# Initial condition setting — selecting the application of the initial state
Auto | Output

Details

Select whether to apply the parameter value Initial condition to a block state or to a block output. The initial state is also the reset value.

  • Auto - block applies the parameter value Initial condition to the block input.

    Set the initial states:

    `x(0) = IC

    At reset:

    x(n) = IC

  • Output - the block applies the value of the parameters Initial condition to the block output.

    Set the initial states:

    `y(0) = IC

    At reset:

    y(n) = IC

Values

Auto | Output

Default value

Auto

Program usage name

InitialConditionSetting

Tunable

No

Evaluatable

No

# Sample time — interval between calculation steps
SampleTime (real number / vector of two real numbers)

Details

Specify the interval between calculation steps as a non-negative number. To inherit a calculation step, set this parameter to -1.

Do not specify a calculation step equal to 0. This value specifies a continuous calculation step, which the block Discrete-Time Integrator does not support. Do not specify a calculation step of inf or NaN because these values are not discrete. If you specify -1 to inherit a calculation step from a higher-level block, ensure that the higher-level block uses a discrete calculation step. For example, a block Discrete-Time Integrator cannot inherit a calculation step equal to 0.
Default value

-1

Program usage name

SampleTime

Tunable

No

Evaluatable

Yes

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

Details

Limits the output signal to the parameters Lower saturation limit и Upper saturation limit.

  • Selecting this checkbox limits the output signal to the values of parameters Lower saturation limit и Upper saturation limit.

  • Unchecking this box removes the restrictions on the output signal.

Dependencies

Selecting this option enables usage of the parameters Lower saturation limit и 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

Sets the upper limit for the output value as a scalar, vector or matrix.

Dependencies

To use this parameter, tick the checkbox of the parameters Limit output.

Default value

Inf

Program usage name

UpperSaturationLimit

Tunable

No

Evaluatable

Yes

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

Details

Sets the lower limit for the output value as a scalar, vector or matrix.

Dependencies

To use this parameter, tick the checkbox of the parameters Limit output.

Default value

-Inf

Program usage name

LowerSaturationLimit

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. When you clear this check box, the block does not have a saturation output port.

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. When you clear this check box, the block does not have a status output port.

Dependencies

Selecting this parameter enables the status output port.

Default value

false (switched off)

Program usage name

ShowStatePort

Tunable

No

Evaluatable

No

Additional options

C code generation: Yes