⇅

Relay

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

Implements a two-state hysteresis switch (bistable relay or Schmitt trigger). When the input signal rises above switchOnPoint, the output transitions to onValue. When the input falls below switchOffPoint, the output drops to offValue. While the input signal stays between these two thresholds, the relay holds its previous state. The hysteresis deadband prevents high-frequency chattering and contact bounce caused by sensor noise around a single transition threshold. Essential for modeling bang-bang controllers, thermostats, pressure limit switches, and digital Schmitt triggers.

Mathematical Model

The relay incorporates 1-bit discrete state memory. Its output trajectory is defined by:

y(t)={yon,if u(t)≥uonyoff,if u(t)≤uoffy(t−Δt),if uoff<u(t)<uony(t) = \begin{cases} y_{\text{on}}, & \text{if } u(t) \ge u_{\text{on}} \\ y_{\text{off}}, & \text{if } u(t) \le u_{\text{off}} \\ y(t - \Delta t), & \text{if } u_{\text{off}} < u(t) < u_{\text{on}} \end{cases}

where uonu_{\text{on}} is switchOnPoint, uoffu_{\text{off}} is switchOffPoint, yony_{\text{on}} is onValue, and yoffy_{\text{off}} is offValue.

The total hysteresis deadband width is given by:

Δuhyst=uon−uoff>0\Delta u_{\text{hyst}} = u_{\text{on}} - u_{\text{off}} > 0

Inputs & Outputs

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

Parameters

Parameters Label Type Default Description
switchOnPoint Switch On Point number 0.5
switchOffPoint Switch Off Point number -0.5
onValue On Value number 1
offValue Off Value number 0

Usage Examples

Example 1: Bang-Bang Thermostat Temperature Regulation

In thermal building HVAC modeling, an electric space heater maintains room temperature near a 20∘C20^\circ\text{C} setpoint without causing excessive mechanical relay cycling. Routing the temperature tracking error e(t)=Tset−T(t)e(t) = T_{\text{set}} - T(t) into a Relay with switchOnPoint = 0.5 °C, switchOffPoint = -0.5 °C, onValue = 2500 W, and offValue = 0 W turns the heater on when temperature drops below 19.5∘C19.5^\circ\text{C} and turns it off when temperature rises above 20.5∘C20.5^\circ\text{C}, producing a stable 1.0∘C1.0^\circ\text{C} limit-cycle.

Example 2: Schmitt Trigger Sensor Noise Rejection

In automotive wheel-speed or crankshaft sensing, inductive pickups generate low-amplitude sinusoids contaminated by electrical ripple. Passing the raw sensor voltage into a Relay with switchOnPoint = 1.8 V, switchOffPoint = 0.6 V, onValue = 5.0 V, and offValue = 0.0 V reconstructs a clean, bounce-free square wave pulse train, rejecting high-frequency noise spikes with amplitudes under 1.2 V1.2\text{ V}.

Remarks & Best Practices

  • Live Hysteresis Loop Preview: The property editor displays a real-time visualization of the bistable hysteresis loop, indicating switching thresholds, state levels, and transition directions.
  • Chatter Elimination: The hysteresis band (uon−uoffu_{\text{on}} - u_{\text{off}}) guarantees that signal noise fluctuations within the interval cannot cause rapid switching chatter or actuator wear.
  • Internal State Memory: The block retains its discrete state (y(t−Δt)y(t - \Delta t)) when the input resides within the hysteresis deadband.
  • Threshold Parameter Constraint: For normal hysteretic operation, switchOnPoint should be strictly greater than or equal to switchOffPoint.
  • Inverted Logic Capability: Setting onValue = 0.0 and offValue = 1.0 configures the block as an inverting normally-closed relay.

Related Components

  • Comparator: Single-threshold comparator without hysteresis deadband.
  • DeadZone: Continuous zero-output band without internal state memory.
  • Switch: Multiplexes between two independent input signals.
  • Backlash: Continuous mechanical hysteresis modeling gear play.