Pro
40 min

Tank Level Control PLC Ladder Diagram (Run It Free Online)

Tank level control is the cornerstone process-control scenario for any PLC programmer: a real installation must handle hysteresis between the LOW and HIGH float switches, alternate between two pumps so their run-hours stay balanced, and latch an overflow alarm the moment a HIGH_HIGH switch trips. Below is the full ladder diagram, I/O table and timing chart — and because this is a live scenario, you can write the logic yourself and watch the tank fill, drain and alarm in your browser without installing anything.

processhysteresisalarmlead-lagalternation
Tank Fill Station scenario preview

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 dual-pump tank fill station with lead/lag alternation. Pressing START arms the controller; the *lead* pump then fills the tank whenever the LOW level switch is made, and drops out at the HIGH switch — classic hysteresis. At the end of every fill cycle the lead pump swaps with the lag pump (PUMP_A → PUMP_B → PUMP_A …) so their cumulative runtimes stay balanced. The downstream process continuously draws product from the tank, so level slowly falls between cycles. HIGH_HIGH_SW is the overflow safety interlock: when the level exceeds HIGH_HIGH the ALARM latches, BOTH pumps trip off together, and the emergency DRAIN_VALVE opens. The alarm clears only when STOP is pressed with the level already back below HIGH_HIGH.

Objectives

  • START arms the controller; STOP stops both pumps and clears a recovered alarm
  • PUMP_A leads the first fill cycle; PUMP_B leads the second; they alternate thereafter
  • The lead pump turns on at LOW_LEVEL_SW and off at HIGH_LEVEL_SW (hysteresis — does not restart until LOW is made again)
  • HIGH_HIGH_SW latches ALARM; ALARM drops BOTH pumps and stays on until STOP clears it
  • DRAIN_VALVE opens whenever ALARM is latched

Hints

  • Use a RUN_BIT latch: SET on START, RESET on STOP
  • Use a T-flipflop bit (e.g. LEAD_IS_B) that toggles on every rising edge of HIGH_LEVEL_SW — standard pattern: | EDGE AND /BIT | S= BIT ; | EDGE AND BIT | R= BIT ;
  • A FILLING latch captures the "below HIGH until we hit it" cycle state — SET at LOW, RESET at HIGH / HIGH_HIGH / STOP / ALARM
  • Pump outputs: PUMP_A := FILLING AND NOT LEAD_IS_B AND safety contacts; PUMP_B := FILLING AND LEAD_IS_B AND safety contacts
  • ALARM latches on HIGH_HIGH_SW and only resets on STOP once HIGH_HIGH has released; tie DRAIN_VALVE directly to ALARM

I/O Table

Inputs

START

Start push-button (momentary)

BOOL · %I0.0

STOP

Stop push-button (momentary)

BOOL · %I0.1

LOW_LEVEL_SW

Low-level float switch (true when low)

BOOL · %I0.2

HIGH_LEVEL_SW

High-level float switch (true when high)

BOOL · %I0.3

HIGH_HIGH_SW

High-high overflow switch

BOOL · %I0.4

Outputs

PUMP_A

Fill pump A contactor

BOOL · %Q0.0

PUMP_B

Fill pump B contactor

BOOL · %Q0.1

ALARM

Overflow alarm lamp (latching)

BOOL · %Q0.2

DRAIN_VALVE

Emergency drain solenoid

BOOL · %Q0.3

Your program will be tested against:

All test cases run automatically when you submit. Assertions are hidden until you pass.

  1. #1Lead pump (PUMP_A) turns on when the tank is empty

    START while the tank is empty -> LOW is true -> PUMP_A on within one scan, PUMP_B off

  2. #2Lead pump turns off when high-level switch is made

    Start filling; wait for level to reach HIGH_SP; PUMP_A must drop out

  3. #3Lead pump alternates between PUMP_A and PUMP_B on successive fill cycles

    Complete one fill cycle (PUMP_A leads) then wait for level to fall back to LOW and complete a second cycle (PUMP_B leads)

  4. #4HIGH_HIGH_SW drops BOTH pumps and latches the alarm

    Force HIGH_HIGH_SW true while the lead pump is running; both pumps must trip off together and ALARM must latch

  5. #5STOP button drops both pumps immediately

    Lead pump is running; press STOP -> both pumps off within one scan

I/O table: float switches, pumps and alarm

A dual-pump tank fill station uses five digital inputs and four digital outputs. The two level inputs that matter most are LOW_LEVEL_SW and HIGH_LEVEL_SW: the pump turns on when the level falls to LOW and turns off when it rises to HIGH — that gap between the two setpoints is the hysteresis band, and it is what prevents the pump from rapid-cycling at a single setpoint.

HIGH_HIGH_SW is a separate safety switch mounted above HIGH. When it trips, all pumps must stop immediately and the alarm must latch — it does not clear until an operator presses STOP after the level has fallen back below HIGH_HIGH.

tank level control PLC I/O table float switches pump outputs alarm
The dual-pump tank fill I/O: LOW and HIGH float switches, HIGH_HIGH overflow, two pump contactors, alarm lamp and emergency drain valve.

Pump control rung with hysteresis seal-in

The pump rung uses a FILLING latch bit to implement hysteresis. When the tank falls to LOW_LEVEL_SW the FILLING bit is SET, which turns the lead pump on. The pump stays on — sealed in — even after LOW_LEVEL_SW releases as the level rises. It only drops out when HIGH_LEVEL_SW is made, which RESETs the FILLING latch.

This start-at-LOW / stop-at-HIGH pattern means the pump never toggles at a single level point. The rung also includes normally-closed contacts for HIGH_LEVEL_SW, HIGH_HIGH_SW and ALARM in series with the coil, so any safety condition drops the pump immediately in the same scan — there is no one-scan lag.

tank level control PLC ladder diagram pump rung hysteresis seal-in LOW HIGH
The pump control rung: FILLING latch gives hysteresis — pump starts at LOW, seals in, and stops at HIGH or any alarm condition.

HIGH_HIGH overflow alarm latch rung

The alarm rung is a latching SET/RESET pair. HIGH_HIGH_SW SETs the ALARM bit on the scan it goes true. ALARM then RESETs the FILLING latch and opens a normally-closed ALARM contact in series with both pump coils — both pumps drop out in the same scan.

The ALARM bit can only be cleared by the STOP button, and only when HIGH_HIGH_SW is already released. This ensures an operator cannot silently restart the pumps while the tank is still overflowing. The DRAIN_VALVE output is wired directly to ALARM so the emergency drain solenoid opens the instant the alarm latches.

PLC ladder logic HIGH HIGH overflow alarm latch rung DRAIN_VALVE
The alarm latch rung: HIGH_HIGH_SW sets ALARM; STOP clears it only after HIGH_HIGH releases; DRAIN_VALVE follows ALARM directly.

Level and pump timing diagram — hysteresis band

The timing diagram shows one complete fill-and-drain cycle. The pump turns on the moment level crosses LOW (20 % of tank), runs while the level climbs through the hysteresis band, and turns off the moment level crosses HIGH (80 %). The downstream process then slowly draws product from the tank until the level falls back to LOW and the next fill cycle begins.

The band between LOW and HIGH is what makes the system stable: a wider band means fewer pump starts per hour and longer, more efficient pump runs. A narrower band gives tighter level control but more frequent cycling. In a real water tank PLC program the band is tuned to the process draw rate and the pump's minimum run time.

tank level plc ladder logic timing diagram hysteresis band pump on off LOW HIGH
The hysteresis timing: pump on at LOW, off at HIGH — the band between the two setpoints prevents rapid cycling.

Lead/lag pump alternation

Running two pumps in a lead/lag arrangement keeps their cumulative run-hours balanced, which extends service life and avoids one pump seizing from under-use. In this program a LEAD_IS_B flip-flop toggles on the rising edge of HIGH_LEVEL_SW: at the end of every fill cycle the lead role passes from PUMP_A to PUMP_B, then back to PUMP_A, alternating indefinitely.

The flip-flop uses a standard SET/RESET pair on the same edge bit so exactly one pump is designated lead per scan, with no race condition. When ALARM latches, both pumps trip regardless of which one is currently leading — safety always takes priority over alternation logic.

lead lag pump alternation PLC water tank fill station
Lead/lag alternation: the LEAD_IS_B flip-flop swaps lead responsibility on every HIGH rising edge so both pumps accumulate equal run-hours.

How to build a tank level control PLC program step by step

Start with the RUN_BIT: SET on START, RESET on STOP — the standard 3-wire latching pattern. Add the ALARM SET rung (HIGH_HIGH_SW sets ALARM; STOP clears it only when HIGH_HIGH is released). Then add the FILLING latch (LOW_LEVEL_SW sets it; HIGH_LEVEL_SW, ALARM and STOP each reset it). Next write the pump output rungs: PUMP_A := FILLING AND NOT LEAD_IS_B AND NOT HIGH and NOT ALARM; PUMP_B mirrors it with LEAD_IS_B. Finally add the LEAD_IS_B alternation flip-flop on the HIGH_LEVEL_SW rising edge and wire DRAIN_VALVE directly to ALARM.

Run the simulator and verify in sequence: PUMP_A starts at LOW → drops at HIGH → PUMP_B leads the second cycle → HIGH_HIGH trips both pumps and opens drain → STOP clears alarm only after level recovers.

Automatic water level controller using PLC and float switches

Stripped to its essentials, this scenario is an automatic water level controller using a PLC and two float switches — the same logic that runs an overhead water tank, a sump or a reservoir. The LOW_LEVEL_SW float closes when the water drops to the low probe and SETs the FILLING latch, turning the pump on; the HIGH_LEVEL_SW float closes when the water rises to the high probe and RESETs the latch, turning the pump off. The gap between the two floats is the hysteresis band that stops the pump from rapid-cycling, and the HIGH_HIGH float gives a latched overflow trip on top. That two-float SET/RESET pair is the entire plc tank filling ladder logic — everything else (lead/lag alternation, the alarm, the drain valve) is built around it.

This water tank level control PLC program is runnable and auto-graded right here in your browser: the physics model drives a real fill rate and draw rate so the float switches trip exactly as they would on hardware. To keep a copy of this tank level control PLC ladder diagram (I/O table plus every rung) beside you while you build, press Ctrl/Cmd+P on this page and choose Save as PDF.

Frequently asked questions

What is hysteresis in a PLC tank level control program?

Hysteresis means the pump starts at one setpoint (LOW) and stops at a different, higher setpoint (HIGH). The gap between them — the hysteresis band — prevents the pump from rapid-cycling. Without it, a pump running at a single setpoint would start and stop many times per minute as small level fluctuations cross the threshold.

How do I wire LOW and HIGH float switches in a water tank PLC program?

LOW_LEVEL_SW is typically normally-open and closes (goes true) when the water level falls to the low-level probe. HIGH_LEVEL_SW closes when the level rises to the high probe. In the ladder logic, LOW_LEVEL_SW SETs the FILLING latch and HIGH_LEVEL_SW RESETs it — that pair of rungs is the hysteresis pump control.

What is lead/lag alternation in a dual-pump tank fill station?

Lead/lag alternation means the two pumps take turns being the active (lead) pump. At the end of each fill cycle a flip-flop bit toggles and assigns the lead role to the other pump. This keeps their cumulative run-hours roughly equal, reducing maintenance costs and preventing standby-pump seizure from inactivity.

How does a HIGH_HIGH alarm latch work in ladder logic?

A latching SET rung turns on the ALARM bit the moment HIGH_HIGH_SW closes. A separate RESET rung can only clear ALARM when the operator presses STOP AND HIGH_HIGH_SW has already released. Because ALARM holds even after the switch releases, the operator must physically intervene — the pumps cannot automatically restart after an overflow.

Can I run a tank level PLC ladder diagram without a real PLC?

Yes. This page is a live browser scenario: write the ladder logic, press Run, and watch the tank fill, drain and alarm on a simulated dual-pump station. The simulator runs a physics model with a real fill rate and draw rate, so the hysteresis, alternation and alarm behaviours play out exactly as they would on hardware — no PLC, no install, no licence required.

What PLC instructions are used in a tank level ladder program?

The core instructions are: SET and RESET coils for latching (FILLING, ALARM, LEAD_IS_B), normally-open and normally-closed contacts for float switch inputs and safety conditions, a rising-edge detector (R_TRIG) on HIGH_LEVEL_SW to clock the alternation flip-flop, and an output coil for DRAIN_VALVE. No timers are needed — level control is purely event-driven by the float switches.

How do you do tank level control using a PLC?

Tank level control using a PLC is a hysteresis loop between two setpoints: a float or sensor at the LOW level SETs a FILLING latch to start the pump, and a float or sensor at the HIGH level RESETs it to stop the pump. The gap between LOW and HIGH stops the pump rapid-cycling. Add a HIGH_HIGH safety switch that latches an overflow alarm and trips the pumps, and for two pumps add a lead/lag flip-flop so they share run-hours. You can write and run exactly this control loop in the browser scenario on this page.

What is the PLC tank filling ladder logic?

The plc tank filling ladder logic is two rungs at its core: LOW_LEVEL_SW (gated by RUN and NOT ALARM) SETs the FILLING latch, and HIGH_LEVEL_SW (plus ALARM and STOP) RESETs it. The pump output is then driven by FILLING with normally-closed HIGH, HIGH_HIGH and ALARM contacts in series so any safety condition drops the pump in the same scan. That SET/RESET pair gives the start-at-LOW, stop-at-HIGH hysteresis behaviour that defines tank filling control.

How do you build an automatic water level controller using a PLC?

An automatic water level controller using a PLC reads two float switches — one at the low water level, one at the high level — and runs the pump between them with a SET/RESET latch (SET at LOW, RESET at HIGH). Add a HIGH_HIGH float for a latched overflow alarm and an emergency drain valve, and the controller fills and protects the tank with no operator input. The live scenario on this page is exactly this water tank level control PLC program, graded automatically against a physics model with real fill and draw rates.

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