Engee documentation

Discrete-Time Integrator

Discrete integration or signal accumulation.

discrete time integrator

Description

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

Output equations

At 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:

  • The trapezoid 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. When using an explicitly defined calculation step, is reduced 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 to calculate the output signal:

Definition of initial states

You can define the initial states as a parameter 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 a value in the Initial condition field.

  • To get initial conditions from an external source, specify Initial condition source as external. The optional input port appears below the input port.

Resetting a condition

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

discrete time integrator 1

Types of reset triggers

The External reset parameter 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 rising reset trigger 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. falls from a positive value to zero or negative value. For example, the figure below shows the effect of the falling reset trigger on integration by the inverse Euler method.

    discrete time integrator falling reset

  • either - resets the state when the reset signal rises or falls, 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 either reset trigger 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 level reset trigger on integration by the inverse Euler method.

    discrete time integrator level reset

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

    discrete time integrator sampled level reset

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

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

Ports

Input

Port_1 - input signal
scalar | vector | matrix

Input signal as a scalar, vector or matrix.

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

IC - initial state
scalar | vector | matrix

Initial state of the block set by an external signal.

Dependencies

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

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

External Reset - reset state to initial state
scalar | vector | matrix

Resetting the block state to the set initial state by external signal. See section [Сброс состояния].

Dependencies

To use this port, select the External Reset checkbox.

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

Output

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

Integral over discrete time or accumulated value of the input signal.

Data types: Float64.

Parameters

Integrator method - integration method
Integration: Forward Euler (by default) | Integration: Backward Euler | Integration: Trapezoidal | Accumulation: Forward Euler | Accumulation: Backward Euler | Accumulation: Trapezoidal

Integration or Accumulation Method.

Usage in program code

Block parameter

IntegratorMethod

Values

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

* By default*

Integration: Forward Euler Integration: Forward Euler

Gain value - integrator gain value
1.0 (by default) | scalar | vector | matrix

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]

Hint

Using 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.

Usage in program code

Block parameter

gainval

Values

scalar | vector

* By default*

1.0

Initial condition source - selection of initial condition source
internal (by default) | external

Select the initial condition source:

  • internal - get initial states from the Initial condition block parameter.

  • external - receiving initial states from an external source through the IC input port.

Dependencies

Selecting internal enables the use of the Initial condition parameter in the simulation.

Selecting external disables the use of the Initial condition parameter and enables the IC input port.

Usage in program code

Block Parameter

InitialConditionSource

Values

internal | external

By default

internal

Initial condition - initial condition
`0.0 (by default)
| scalar | vector | matrix

Initial state of the block.

Dependencies

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

Usage in program code

Block parameter

InitialCondition

Values

scalar | vector | matrix

By default

0.0

Initial condition setting - selection of initial condition setting application
Auto (By default) | `Output `

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

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

    Set the initial states:

    x(0) = IC.

    At reset:

    x(n) = IC

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

    Set the initial conditions:

    y(0) = IC.

    At reset:

    y(n) = IC

Usage in program code

Block parameter

InitialConditionSetting

Values

Auto | Output

By default

Auto

Limit output - limit block output values to the specified range
off (by default) | on

Limits the output signal to the values of Lower saturation limit and Upper saturation limit parameters.

  • Selecting this check box limits the output signal to Lower saturation limit and Upper saturation limit.

  • Unchecking this box clears the output signal limits.

Dependencies

Selecting this option enables the Lower saturation limit and Upper saturation limit settings.

Usage in program code

Block parameter

LimitOutput

Values

off | on

By default

off

Lower saturation limit - lower limit for integral
-inf (by default) | scalar | vector | matrix

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

Dependencies

To use this parameter, select the Limit output checkbox.

Usage in program code

Block parameter

LowerSaturationLimit

Values

scalar | vector | matrix

By default

inf

Upper saturation limit - upper limit for integral
inf (by default) | scalar | vector | matrix

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

Dependencies

To use this parameter, select the Limit output checkbox.

Usage in program code

Block parameter

UpperSaturationLimit

Values

scalar | vector | matrix

By default

inf

Sample time (-1 for inherited) - interval between calculation steps
-1.0 (by default) | scalar

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

Hint

  • Do not specify a calculation step equal to 0. This value specifies a continuous calculation step, which the Discrete-Time Integrator block does not support.

  • Do not specify a calculation step of inf or NaN as these values are not discrete.

  • If you specify -1 to inherit a calculation step from a superior block, make sure that the superior block uses a discrete calculation step. For example, a Discrete-Time Integrator block cannot inherit a calculation step equal to 0.

Usage in program code

Block parameter

SampleTime

Values

scalar | vector

By default

-1.0

External reset - reset to initial state
none (by default) | rising | falling | either | level | sampled level

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.

Usage in program code

Block parameter

ExternalReset

Values

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

By default

none

Additional options

C code generation: Yes