← All exercises

Hysteresis

medium

Applies hysteresis to an analog input, setting the output true at the high limit and false at the low limit.

What it teaches

Use two different thresholds — one to turn on, a lower one to turn off — so the output doesn't flicker when the input wobbles near a single value. Picture an air conditioner: it switches on at 20 °C and keeps cooling until the room falls back to 18 °C.

Inputs and outputs

TagTypeDefaultDescription
In_ValueREAL
Cfg_HighLimitREAL20
Cfg_LowLimitREAL18
Out_ActiveBOOL

Required behavior

  • Cfg_LowLimit must be less than Cfg_HighLimit.
  • Out_Active is set to 1 when In_Value is greater than or equal to Cfg_HighLimit.
  • Out_Active is set to 0 when In_Value is less than or equal to Cfg_LowLimit.
  • Out_Active remains unchanged when In_Value is strictly between Cfg_LowLimit and Cfg_HighLimit.