Discrete ∫
DiscreteComputes discrete-time numerical integration (accumulation) of a sampled input signal. Supports three classical discretization algorithms: Forward Euler (explicit with zero direct feedthrough), Backward Euler (implicit, highly stable for stiff dynamics), and Trapezoidal / Tustin (bilinear transform, providing optimal frequency fidelity). Essential for digital PID controllers, discrete state-space compensators, numerical dead-reckoning odometry from velocity sensors, and discrete accumulator registers in embedded DSP systems.
Mathematical Model
The discrete difference equation and corresponding -domain transfer function depend on the selected method:
- Forward Euler (
method = "forward"):
- Backward Euler (
method = "backward"):
- Trapezoidal / Tustin (
method = "trapezoidal"):
where denotes sampleTime and denotes initialCondition.
When the bottom reset terminal is driven (), the internal register resets synchronously to the initial condition:
Inputs & Outputs
| Direction | ID | Label | Type | Status |
|---|---|---|---|---|
| → In | in |
In | number | Required |
| → In | reset |
Reset | number | Optional |
| ← Out | out |
Out | number | Output |
Parameters
| Parameters | Label | Type | Default | Description |
|---|---|---|---|---|
method |
Integration Method | select | forward |
|
initialCondition |
Initial Condition | number | 0 |
|
sampleTime |
Sample Time | number | 0.01 |
Usage Examples
Example 1: Embedded Digital PID Integral Channel (Tustin Form)
In industrial microcontroller motion control, the integral error term must eliminate steady-state position offset without phase distortion. Wiring the tracking error into a DiscreteIntegrator configured with method = "trapezoidal" and sampleTime = 0.002 s ( loop rate) synthesizes the exact Tustin bilinear transform (), reproducing textbook digital integrator behavior with zero algebraic drift.
Example 2: Dead-Reckoning Distance Odometry from Velocity Telemetry
In autonomous mobile robotics (AGVs), wheel tachometers provide linear vehicle velocity every ( s). Routing the velocity signal through a DiscreteIntegrator block with method = "forward" evaluates cumulative position , providing dead-reckoning displacement feedback without creating algebraic loop dependencies in the motion controller.
Remarks & Best Practices
- Algebraic Loop Mechanics: Because Backward Euler and Trapezoidal methods depend on the current input sample (), placing them in algebraic feedback loops creates an instantaneous dependency that solvers must iterate to resolve. Forward Euler reads strictly from (), inherently breaking algebraic circular loops.
- Bilinear Tustin Mapping: The trapezoidal method maps the continuous imaginary frequency axis uniquely onto the discrete unit circle , preserving continuous system stability margins without aliasing.
- Embedded C Code Generation Parity: The difference equations implemented by this block map directly to scalar accumulator loops in C/Rust, facilitating rapid prototyping for embedded firmware targets.
- Synchronous Reset Functionality: Driving the optional bottom
resetterminal with a positive value () immediately reloadsinitialConditioninto the state register.
Frequently Asked Questions (FAQ)
Q: What are the numerical stability and accuracy differences between Forward Euler, Backward Euler, and Trapezoidal (Tustin) integration?
Forward Euler () maps the stable continuous left-half -plane into a circle shifted by 1 in the -plane; it can easily destabilize stable continuous poles if step size . Backward Euler () maps the left-half plane strictly inside a circle within the unit disk, providing artificial numerical damping (A-stable, unconditionally stable for linear systems). Trapezoidal / Tustin integration () provides a conformal bilinear mapping preserving exact frequency stability boundaries without artificial energy dissipation, offering second-order accuracy ().
Related Components
- Integrator: Continuous-time ODE integrator solved by variable-step continuous solvers.
- DiscreteDerivative: Evaluates backward difference derivatives ().
- UnitDelay: Fundamental single-sample delay operator ().
- PIDController: Full three-term controller supporting configurable discretization methods.