≥

Comparator

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

Evaluates a relational comparison between an incoming input signal and a configurable reference threshold. Supports standard mathematical operators (≥,>,≤,<,=,≠\ge, >, \le, <, =, \ne) and flexible output modes (emitting fixed binary constants or passing through the raw input signal). Essential for threshold crossing detection, safety interlocks, over-temperature alarms, driving conditional Switch multiplexers, and converting continuous analog signals into discrete logic flags.

Mathematical Model

The boolean condition C(u)C(u) is determined by the selected operator and reference threshold TT:

C(u)={true,if u(t)opTfalse,otherwise,op∈{≥,>,≤,<,=,≠}C(u) = \begin{cases} \text{true}, & \text{if } u(t) \mathbin{\text{op}} T \\ \text{false}, & \text{otherwise} \end{cases}, \quad \text{op} \in \{\ge, >, \le, <, =, \ne\}

The output signal y(t)y(t) is assigned according to the boolean evaluation and the configured output modes:

y(t)={ytrue,if C(u) is trueyfalse,if C(u) is falsey(t) = \begin{cases} y_{\text{true}}, & \text{if } C(u) \text{ is true} \\ y_{\text{false}}, & \text{if } C(u) \text{ is false} \end{cases}

where:

  • ytruey_{\text{true}} equals trueValue when trueResultMode = "constant", or u(t)u(t) when trueResultMode = "input".
  • yfalsey_{\text{false}} equals falseValue when falseResultMode = "constant", or u(t)u(t) when falseResultMode = "input".

For equality (==) and inequality (!=) comparisons on floating-point signals, an internal numerical tolerance (ϵ=10−9\epsilon = 10^{-9}) is applied:

u=T  ⟺  ∣u−T∣≤10−9u = T \iff |u - T| \le 10^{-9}

Inputs & Outputs

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

Parameters

Parameters Label Type Default Description
operator Operator select >=
threshold Threshold number 0
trueResultMode True Output select constant
trueValue True Constant number 1
falseResultMode False Output select constant
falseValue False Constant number 0

Usage Examples

Example 1: Critical Over-Temperature Alarm and Safety Interlock

In battery energy storage systems (BESS), monitoring lithium-ion cell temperature T(t)T(t) requires an emergency trip when temperature exceeds 55∘C55^\circ\text{C}. Configuring a Comparator with operator = ">=", threshold = 55.0, trueValue = 1.0, and falseValue = 0.0 generates a clean binary shutdown flag (11) that directly commands contactor disconnection and cooling boost pumps.

Example 2: Piecewise Squelch Passthrough (Signal Gating)

To pass an analog acoustic sensor signal only when it exceeds an ambient background noise floor (1.5 V1.5\text{ V}) and mute it to zero otherwise, configure the Comparator with operator = ">", threshold = 1.5, trueResultMode = "input", and falseResultMode = "constant" with falseValue = 0.0. Transients above 1.5 V1.5\text{ V} pass through unattenuated, while baseline background noise is completely suppressed.

Remarks & Best Practices

  • Floating-Point Equality Tolerance: Direct equality (==) and inequality (!=) checks incorporate an internal tolerance band (ϵ=10−9\epsilon = 10^{-9}), preventing false negative drops caused by floating-point representation limits.
  • Zero-Latency Combinatorial Logic: Evaluated as an instantaneous algebraic operator with zero state memory or transport delay within the current simulation step.
  • Zero-Crossing Solver Synchronization: Abrupt state changes across the threshold trigger zero-crossing events, prompting adaptive solvers (such as RK45) to bisect step sizes and locate the exact boundary crossing timestamp.
  • Driving Conditional Logic: Commonly combined with Switch blocks and LogicGate elements (AND, OR, NOT) to construct multi-stage safety interlocks and finite state machines.

Related Components

  • Switch: Multiplexes between two continuous signals using a selector threshold.
  • Relay: Hysteretic two-state threshold switching that eliminates chatter on noisy inputs.
  • LogicGate: Evaluates boolean operations (AND, OR, XOR, NOT) on digital signals.
  • DeadZone: Suppresses signals within an insensitivity region around zero.