Schmitt Trigger

Shippingstateful
schmitt_trigger

Hysteresis comparator with state persistence across blocks

Signature

Inputs

  • signalSignalrequired

Outputs

  • resultSignal

Parameters

KeyTypeDefaultNotes
high_thresholdfloat0.6
low_thresholdfloat0.4
high_valuefloat1.0
low_valuefloat0.0

Description

The Schmitt Trigger is a hysteresis comparator that maps a continuous signal to a two-level output (high_value / low_value), using two distinct switching thresholds instead of one. The output flips to high_value only when the input rises above high_threshold, and flips back to low_value only when the input falls below low_threshold. Between the two thresholds the output holds its previous level. With , the difference is the hysteresis band, which rejects chatter that a plain comparator would produce on noisy or slowly-varying signals crossing a single threshold.

The node is stateful (SchmittState): it remembers the last emitted level so that hysteresis is honored continuously across streamed blocks, not just within a single sample buffer. The very first sample is resolved by direct comparison against the thresholds; thereafter each output depends on both the current sample and the persisted level.

Thresholds carry the units of the incoming signal (they are compared directly against sample values), while high_value and low_value set the output's levels. Because the output is a hard-quantized decision, input measurement uncertainty () does not propagate as a level on the output; near a threshold, however, sigma reflects the probability that the crossing decision could flip — treat outputs within roughly a few of a threshold as decision-ambiguous.

Mathematics

Examples

Debouncing a noisy level crossing

A sensor riding on noise crosses 0.5 repeatedly. A single-threshold comparator would toggle on every wiggle. Configure the Schmitt Trigger with high_threshold = 0.6, low_threshold = 0.4 so the input must move a full 0.2 band to switch, suppressing spurious toggles:

signal -> schmitt_trigger(high_threshold=0.6, low_threshold=0.4,
                          high_value=1.0, low_value=0.0) -> result

The output stays latched until the input clears the opposite threshold.

Bipolar output for control logic

Set high_value = 1.0 and low_value = -1.0 to produce a clean bang-bang command from a measured error signal, with the band acting as a deadband around the setpoint to prevent limit-cycle chatter.

Applications

  • Debouncing noisy digital or threshold-crossing signals before edge detection or event counting.
  • Bang-bang / relay control (thermostats, hysteretic regulators) where a deadband prevents rapid on/off cycling.
  • Cleaning up slow analog transitions into clean logic levels for downstream logic_gate or state-machine processing.
  • Zero-crossing or level-crossing detection on measured signals where measurement noise would otherwise cause false crossings.

Neat

Setting `high_threshold == low_threshold` degenerates the node into an ordinary single-threshold comparator with zero hysteresis and no chatter rejection.

The hysteresis is purely amplitude-based, but it introduces an effective input-rate-dependent delay: faster inputs cross the band sooner, so switching timing shifts with signal slope, not just level.

Known issues

Configuring `low_threshold > high_threshold` inverts the intended geometry: the 'hold' region vanishes and the two conditions can overlap, producing behavior that no longer suppresses chatter — keep `high_threshold > low_threshold`.

Because state persists across blocks, the first output after a reset or stream restart is decided by direct comparison with no prior level; a signal that starts inside the hysteresis band will latch to whichever threshold it first clears.

See also

hysteresiscomparatordebouncethresholdstatefuldigital