Tank Level Alarms with Hysteresis
Ready to build this?
Sign up free — no credit card required. This scenario requires the Pro plan.
Sign up to play this scenario →Already have an account? Log in
Briefing
A level transmitter returns raw ADC counts (0–10 000) proportional to tank fill. The formula: **Level % = LT_RAW / 10 000 × 100** gives 0 = empty, 5 000 = 50%, 10 000 = full. Simple threshold detection chatters: if the level sits at exactly 90% the alarm fires and clears every scan. **Hysteresis** solves this by using two setpoints — the alarm **sets** above 90% but only **clears** below 80%. The physics engine computes and publishes four BOOL signals: - **HIGH_SET** (level > 90%) — use this to S= HIGH_ALARM - **HIGH_CLEAR** (level < 80%) — use this to R= HIGH_ALARM - **LOW_SET** (level < 10%) — use this to S= LOW_ALARM - **LOW_CLEAR** (level > 20%) — use this to R= LOW_ALARM Your task is to implement the four-rung latch logic.
Objectives
- HIGH_ALARM latches when level rises above 90% (HIGH_SET), clears below 80% (HIGH_CLEAR)
- LOW_ALARM latches when level falls below 10% (LOW_SET), clears above 20% (LOW_CLEAR)
Hints
- Use SET/RESET latch pairs: | HIGH_SET | S= HIGH_ALARM ; and | HIGH_CLEAR | R= HIGH_ALARM ;
- The SET rung must come BEFORE the RESET rung for correct scan-order behaviour
- For LOW_ALARM: | LOW_SET | S= LOW_ALARM ; and | LOW_CLEAR | R= LOW_ALARM ;
I/O Table
Inputs
LT_RAWLevel transmitter raw counts (0–10000)
INT · %IW0
HIGH_SETPhysics: level > 90% — set high alarm
BOOL · %I0.0
HIGH_CLEARPhysics: level < 80% — clear high alarm
BOOL · %I0.1
LOW_SETPhysics: level < 10% — set low alarm
BOOL · %I0.2
LOW_CLEARPhysics: level > 20% — clear low alarm
BOOL · %I0.3
Outputs
HIGH_ALARMHigh-level alarm (latching with hysteresis)
BOOL · %Q0.0
LOW_ALARMLow-level alarm (latching with hysteresis)
BOOL · %Q0.1
Your program will be tested against:
All test cases run automatically when you submit. Assertions are hidden until you pass.
- #1Level rises above 90% → HIGH_ALARM latches
LT_RAW = 9100 (91%) → HIGH_SET true → HIGH_ALARM latches on
- #2Level drops to 85% (inside hysteresis band) → HIGH_ALARM stays on
After HIGH_ALARM latches, level drops to 85% (between 80 and 90) — alarm must remain on
- #3Level drops below 80% → HIGH_ALARM clears
After HIGH_ALARM latches, level drops to 75% (below HIGH_CLEAR) — alarm clears
- #4Level drops below 10% → LOW_ALARM latches
LT_RAW = 800 (8%) → LOW_SET true → LOW_ALARM latches on
- #5Level recovers above 20% → LOW_ALARM clears
LOW_ALARM latched; level rises to 25% (above LOW_CLEAR) — alarm clears
Related scenarios
Ready to build this?
Sign up free — no credit card required. This scenario requires the Pro plan.
Sign up to play this scenario →Already have an account? Log in