Subtraction
MathThe Subtraction block performs algebraic subtraction between two input signals: output = in1 − in2 (minuend minus subtrahend). Multiple connections to either port are automatically summed according to their respective signs.
In feedback control loops, the Subtraction block is the canonical comparison node where the measured plant output is subtracted from the command setpoint to generate the primary control error . It provides an explicit, readable alternative to configuring a generic Sum block with negative signs.
Mathematical Model
For multi-wire bus inputs connected to each terminal:
Inputs & Outputs
| Direction | ID | Label | Type | Status |
|---|---|---|---|---|
| → In | in1 |
+ | number | Required |
| → In | in2 |
− | number | Required |
| ← Out | out |
Output | number | Output |
Usage Examples
Example 1: Closed-Loop Feedback Error Calculation
In a position control loop, a Step block setpoint connects to the positive port in1, and the measured output of an Integrator block connects to the negative port in2. The resulting error signal drives the input of a PIDController block, decreasing from to as the plant tracks the setpoint.
Example 2: Differential Voltage and Common-Mode Rejection
In instrumentation circuits, sensing small signals across a bridge requires rejecting common-mode noise: and . Connecting to in1 and to in2 eliminates completely, outputting the pure differential voltage .
Remarks & Best Practices
- Polarity Assignment: Port
in1(top left, labeled+) represents the positive term; portin2(bottom left, labeled−) represents the negative term. - Feedback Loop Conventions: In block diagrams, negative feedback lines traditionally enter
in2from underneath or right-to-left, maintaining clean visual orientation. - Zero Latency: Executed as a direct SIMD scalar operation (
in1 - in2) inside the Rust WASM evaluation step with zero numerical delay. - Multi-signal Summing: Supports multiple input wires on both ports with automatic algebraic reduction prior to subtraction.
Related Components
- Sum: Multi-input addition with arbitrary sign configurations
- Gain: Signal scaling and inversion (Gain = -1)
- PIDController: Standard controller block accepting error signals
- Saturation: Output limiting to model actuator force/torque boundaries