+

Sum

Math
Run the live example Free · no sign-up · runs in your browser

Calculates the algebraic sum of all connected input signals. Features a multi-wire input terminal (multiple: true), enabling an arbitrary number of signals to be wired into a single summing junction without cascading separate two-input blocks. Serves as the universal summing node in feedback control loops, feedforward disturbance compensation networks, sensor signal aggregators, and Newton-Euler mechanical force balance models.

[!TIP]
Looking for a Feedback Error Junction (e=r−ye = r - y)?
The Sum block assigns positive signs (++) to all connected inputs. For a standard negative-feedback summing junction where the feedback signal must be subtracted (e=r−ye = r - y), use the dedicated Subtraction block (which features distinct (+)(+) and (−)(-) input ports), or insert a Gain block set to −1-1 in the feedback path.

Mathematical Model

For an arbitrary set of NN active input signals u1(t),u2(t),…,uN(t)u_1(t), u_2(t), \dots, u_N(t), the output represents the linear superposition:

y(t)=∑i=1Nui(t)=u1(t)+u2(t)+⋯+uN(t)y(t) = \sum_{i=1}^N u_i(t) = u_1(t) + u_2(t) + \dots + u_N(t)

In the boundary case where no input wires are connected (N=0N = 0), the block outputs zero:

y(t)=0.0y(t) = 0.0

By passing inverted signals (using a Gain block with K=−1K = -1) into the summing junction, the block implements generalized multi-input addition and subtraction:

y(t)=∑juj(t)−∑kvk(t)y(t) = \sum_{j} u_j(t) - \sum_{k} v_k(t)

Inputs & Outputs

Direction ID Label Type Status
→ In in + number Required
← Out out Sum number Output

Usage Examples

Example 1: Feedback Control Summing Junction with Disturbance Feedforward

In a high-bandwidth servomechanism, a feedback error signal e(t)=r(t)−y(t)e(t) = r(t) - y(t) is combined with an anticipatory feedforward disturbance compensation signal uff(t)u_{\text{ff}}(t) to reject load torque spikes. Connecting both the feedback controller output and the feedforward signal into a single Sum block drives the actuator with the composite command u(t)=ufb(t)+uff(t)u(t) = u_{\text{fb}}(t) + u_{\text{ff}}(t), improving rejection of sudden load changes.

Example 2: Newton's Second Law Net Force Summation

In vehicle dynamics simulation, accelerating a vehicle mass (mx¨=∑Fm \ddot{x} = \sum F) requires evaluating the net force from multiple independent physical sources: engine traction force FdriveF_{\text{drive}}, aerodynamic drag −Faero-F_{\text{aero}}, rolling tire resistance −Froll-F_{\text{roll}}, and gravitational slope resistance −Fgrade-F_{\text{grade}}. Wiring each individual force component into a single Sum block produces the net resultant force before feeding an Integrator chain to compute vehicle velocity and position.

Remarks & Best Practices

  • Multi-Wire Input Architecture: The input terminal accepts multiple simultaneous connections (multiple: true), eliminating diagram clutter and avoiding long cascades of binary summing blocks.
  • Linear Superposition: Summation is strictly commutative and associative, ensuring that wire connection order does not alter the mathematical outcome.
  • Double-Precision Floating Point: Evaluated in Rust using IEEE-754 64-bit floats (f64), preserving numerical precision when adding tiny perturbation signals to large static operating points.
  • Comparison with Subtraction Block: The Sum block assigns positive signs (++) to all connected inputs. For traditional closed-loop control with distinct positive reference (++) and negative feedback (−-) terminals, use the Subtraction block.

Related Components

  • Subtraction: Dedicated subtraction node with dedicated (+)(+) and (−)(-) input ports.
  • Product: Multiplies multiple signals together.
  • Gain: Scales individual signals with positive or negative multipliers.
  • Constant: Injects fixed numeric biases or setpoint levels.