← All exercises

Level Alarm

medium

Generates high and low alarms based on a level input, configurable setpoints, and a deadband to prevent chatter.

What it teaches

Two independent latched alarms, one on each side of the process. The Hi alarm raises at its setpoint and only clears once the level falls a deadband below it; the Lo alarm mirrors that, clearing once the level rises a deadband above. That gap is what stops a level parked on a setpoint from reporting over and over.

Inputs and outputs

TagTypeDefaultDescription
In_LevelREAL50Process variable level
Cfg_HiSPREAL80High alarm setpoint
Cfg_LoSPREAL20Low alarm setpoint
Cfg_DeadbandREAL5Deadband applied to clearing alarms
Sts_HiAlarmBOOLHigh alarm flag
Sts_LoAlarmBOOLLow alarm flag

Required behavior

  • Cfg_Deadband must be 0 or greater.
  • Cfg_LoSP must be less than Cfg_HiSP.
  • Sts_HiAlarm sets to 1 when In_Level is greater than or equal to Cfg_HiSP.
  • Sts_HiAlarm clears to 0 when In_Level is less than Cfg_HiSP minus Cfg_Deadband.
  • Sts_HiAlarm remains unchanged between its clear threshold and Cfg_HiSP.
  • Sts_LoAlarm sets to 1 when In_Level is less than or equal to Cfg_LoSP.
  • Sts_LoAlarm clears to 0 when In_Level is greater than Cfg_LoSP plus Cfg_Deadband.
  • Sts_LoAlarm remains unchanged between Cfg_LoSP and its clear threshold.