Basic
40 min

Batch Mixer PLC Program & Ladder Logic (Run It Free Online)

This page walks through a full batch mixer PLC program — the kind of sequential, state-machine logic that controls a real mixing tank: fill with ingredient A, fill with ingredient B, agitate for a fixed time, drain, optionally run a clean-in-place (CIP) wash, then signal ready. Every rung described here maps to a live Batch Mixer scenario you can run directly in your browser. Write the ladder logic, press Run, and the simulated tank fills, mixes, and drains while an auto-grader checks your sequence, interlocks, and timing — no PLC hardware and no software install required.

sequencestate-machinepartial-wiring
Batch Mixer scenario preview

Ready to build this?

Sign up free — no credit card required. This scenario requires the Basic plan.

Sign up to play this scenario →

Already have an account? Log in

Briefing

A single-tank batch mixer that runs a scripted sequence: fill with ingredient A until its dedicated level switch trips, fill with ingredient B until the combined-level switch trips, agitate for exactly 30 seconds, drain the tank, and — if the operator has armed CIP — wash with CIP water for 45 seconds before ringing the READY lamp and parking at IDLE. The state machine is fully interlocked: no valve opens outside its own phase, mixing cannot be short-changed, CIP cannot start until the tank is physically empty, and STOP is treated as a latching fault. START is also the "next batch" trigger: pressing it from READY drops the lamp and re-enters FILLING_A.

Objectives

  • START moves IDLE → FILLING_A; VALVE_A runs until LEVEL_A_LS trips
  • FILLING_B follows FILLING_A and runs VALVE_B until LEVEL_B_LS trips
  • AGITATOR must run for at least 30 s (T_MIX) before DRAIN_VALVE is allowed to open
  • DRAIN_VALVE runs until TANK_EMPTY_LS trips — then branch on CIP_ENABLE
  • If CIP_ENABLE is high, CIP_VALVE runs for 45 s before READY_LAMP lights; otherwise jump straight to READY

Hints

  • Model the sequence as SET/RESET latches — S_IDLE / S_FILL_A / S_FILL_B / S_MIX / S_DRAIN / S_CIP / S_READY — with exactly one true at a time
  • Seed S_IDLE on the first scan with an INIT_DONE latch: `| /INIT_DONE | S= S_IDLE ; | /INIT_DONE | S= INIT_DONE ;`
  • Drive T_MIX (TON 30 000 ms) from S_MIX, T_CIP (TON 45 000 ms) from S_CIP — the .Q outputs advance the state
  • Split the DRAIN exit into two rungs so the CIP path and the skip-CIP path are disjoint: ANDed with CIP_ENABLE and /CIP_ENABLE respectively
  • Output coils are trivially tied to the state bits: `| S_FILL_A | := VALVE_A ;` etc.

I/O Table

Inputs

START

Start push-button (momentary)

BOOL · %I0.0

STOP

Stop push-button (momentary, latching fault)

BOOL · %I0.1

CIP_ENABLE

CIP enable selector switch (maintained)

BOOL · %I0.2

TANK_EMPTY_LS

Tank-empty level switch

BOOL · %I0.3

LEVEL_A_LS

Ingredient-A level switch (40% of tank)

BOOL · %I0.4

LEVEL_B_LS

Combined-level switch (80% of tank)

BOOL · %I0.5

Outputs

VALVE_A

Ingredient-A inlet valve

BOOL · %Q0.0

VALVE_B

Ingredient-B inlet valve

BOOL · %Q0.1

AGITATOR

Agitator motor contactor

BOOL · %Q0.2

DRAIN_VALVE

Tank drain valve

BOOL · %Q0.3

CIP_VALVE

Clean-in-place water inlet valve

BOOL · %Q0.4

READY_LAMP

Batch-ready indicator lamp

BOOL · %Q0.5

FAULT_LAMP

Fault indicator lamp

BOOL · %Q0.6

Your program will be tested against:

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

  1. #1Full batch: IDLE → FILL_A → FILL_B → MIX → DRAIN → READY lights

    Press START with CIP disabled, wait out the full sequence, READY_LAMP must be on at the end

  2. #2VALVE_A closes within 200 ms of LEVEL_A_LS tripping

    START, confirm VALVE_A on, force LEVEL_A_LS true, VALVE_A must close within 200 ms

  3. #3VALVE_B stays off until LEVEL_A_LS has tripped

    Press START, watch VALVE_B stay off while VALVE_A runs, then turn on once FILL_A completes

  4. #4AGITATOR runs ≥ 30 s before DRAIN_VALVE opens

    Start the sequence, verify AGITATOR is still on and DRAIN_VALVE still off 29 s into MIX

  5. #5CIP_VALVE does not open until TANK_EMPTY_LS is true

    Run a batch with CIP enabled; CIP_VALVE must stay off while draining (TANK_EMPTY still false) and only open once the tank is empty

How a batch mixer PLC program works

A batch process is sequential by nature: a defined recipe runs through a fixed series of phases, each phase enabling exactly one set of actuators, with hard interlocks preventing any phase from starting before its predecessor finishes. This is fundamentally different from continuous motor control — a batch mixing PLC programming problem is really a state-machine problem, and the cleanest ladder logic solution models it as exactly that.

The Batch Mixer scenario controls a single-tank mixer with six inputs and seven outputs, all defined for you. The inputs are START (%I0.0, momentary start / next-batch push-button), STOP (%I0.1, momentary, treated as a latching fault), CIP_ENABLE (%I0.2, maintained CIP selector switch), TANK_EMPTY_LS (%I0.3, tank-empty level switch), LEVEL_A_LS (%I0.4, ingredient-A level switch at 40% of tank) and LEVEL_B_LS (%I0.5, combined-level switch at 80% of tank). START, STOP, CIP_ENABLE and TANK_EMPTY_LS are pre-wired; you wire the two level switches yourself.

The outputs are VALVE_A (%Q0.0, ingredient-A inlet valve), VALVE_B (%Q0.1, ingredient-B inlet valve), AGITATOR (%Q0.2, agitator motor contactor), DRAIN_VALVE (%Q0.3, tank drain valve), CIP_VALVE (%Q0.4, clean-in-place water inlet valve), READY_LAMP (%Q0.5, batch-ready indicator) and FAULT_LAMP (%Q0.6, fault indicator). The whole exercise in batch process control using PLC logic is making each of these outputs turn on and off in the right phase, and never outside it.

The batch sequence as a state machine

The recipe runs through seven operating states plus a fault state: IDLE → FILLING_A → FILLING_B → MIX → DRAIN → (optional CIP) → READY. The cleanest way to write this batching process PLC ladder logic is one SET/RESET latch per state — S_IDLE, S_FILL_A, S_FILL_B, S_MIX, S_DRAIN, S_CIP, S_READY — with the invariant that exactly one latch is true at any instant. Each transition rung does two things on the same scan: SET the next state and RESET the current one.

Walking the sequence: START with the machine in IDLE moves it to FILLING_A. In FILLING_A, VALVE_A runs until LEVEL_A_LS trips (40% full), which transitions to FILLING_B. VALVE_B then runs until LEVEL_B_LS trips (80% combined), transitioning to MIX. The AGITATOR runs through MIX. When the mix timer expires the machine moves to DRAIN, where DRAIN_VALVE runs until TANK_EMPTY_LS confirms the tank is empty. From DRAIN the logic branches on CIP_ENABLE — to CIP if the operator armed it, straight to READY if not. READY lights READY_LAMP, and pressing START again drops the lamp and re-enters FILLING_A for the next batch.

One subtlety: on the very first scan every latch is false, so the machine would never boot. The canonical solution seeds S_IDLE with a one-shot INIT_DONE latch — on scan one INIT_DONE is still false, so a `/INIT_DONE` rung SETs S_IDLE and a second SETs INIT_DONE, after which both rungs go inert. Because outputs are tied one-to-one to state bits (S_FILL_A drives VALVE_A, S_MIX drives AGITATOR, and so on), getting the state latches right gets the actuators right for free.

Timed phases, the drain branch, and interlocks

Two phases are time-driven rather than sensor-driven, and both use TON (on-delay timer) instructions. In the MIX state, T_MIX is a TON with a 30,000 ms preset driven directly by the S_MIX bit; its .Q output is the condition that advances MIX → DRAIN. This enforces the objective that the AGITATOR must run for at least 30 seconds before DRAIN_VALVE is allowed to open — mixing cannot be short-changed. Likewise the optional CIP phase uses T_CIP, a TON with a 45,000 ms preset driven by S_CIP, and its .Q advances CIP → READY.

The DRAIN exit is the one place the sequence forks, and the clean way to write it is two disjoint transition rungs sharing the TANK_EMPTY_LS condition: one ANDed with CIP_ENABLE (DRAIN → CIP) and one ANDed with NOT CIP_ENABLE (DRAIN → READY). Splitting it this way guarantees the two paths are mutually exclusive and that CIP_VALVE can never open until the tank is physically empty — a real-world interlock, because washing a tank that still holds product is both wasteful and unsafe.

STOP is handled as a latching fault rather than a pause. A single STOP press SETs S_FAULT and RESETs every state latch in one rung group, which immediately drops all the actuator coils because each output is tied to its now-false state bit. FAULT_LAMP lights. This models the fail-safe expectation for batch process control using PLC logic: an abort condition collapses the machine to a known safe state — all valves shut, agitator off — rather than leaving a valve stranded open mid-phase.

Running and auto-grading the batch mixer in your browser

The Batch Mixer scenario is fully runnable in the browser — no PLC, no TIA Portal, no Studio 5000. You write the ladder logic (or structured-text-style state rungs), press Run, and a physics model simulates the tank: levels rise as VALVE_A and VALVE_B run, the level switches trip at their setpoints, the agitator timer counts, and the tank drains until TANK_EMPTY_LS fires.

Five auto-grader test cases check the program against the real specification. 'idle-to-ready-happy-path' runs a complete batch with CIP disabled and asserts READY_LAMP is on — with all valves and the agitator off — at the end. 'valve-a-off-when-level-a-reached' forces LEVEL_A_LS true and asserts VALVE_A closes within 200 ms. 'valve-b-only-after-a-complete' confirms VALVE_B stays off for the entire FILLING_A phase and only opens once LEVEL_A_LS has tripped. 'mix-time-minimum-30s' verifies the agitator is still running and the drain valve still shut 29 seconds into MIX, then opens the drain only after the full 30 seconds. 'cip-requires-empty-tank' runs a CIP-enabled batch and confirms CIP_VALVE stays off while the tank is still draining, opening only once TANK_EMPTY_LS trips.

Because the grader inspects both the output coils and internal physics state (level values, switch states), it catches the subtle mistakes that pass a casual eye test — a valve that opens a scan too early, a mix that ends a second short, a CIP wash that starts before the tank is empty. That feedback loop is what makes this a practical way to learn mixing tank PLC programming without a lab bench.

Frequently asked questions

How do you write a batch mixer PLC program in ladder logic?

Model the recipe as a state machine. Create one SET/RESET latch per phase — IDLE, FILLING_A, FILLING_B, MIX, DRAIN, CIP, READY — with exactly one true at a time. Each transition rung SETs the next state and RESETs the current one on the same scan, gated by the event that ends the phase (a level switch tripping, a timer's .Q going true, or a START press). Tie each actuator output one-to-one to its state bit: VALVE_A to FILLING_A, AGITATOR to MIX, DRAIN_VALVE to DRAIN, and so on. This keeps the batch mixing PLC programming clean, readable and easy to interlock.

What I/O does the batch mixer scenario use?

Six inputs and seven outputs. Inputs: START (%I0.0), STOP (%I0.1, latching fault), CIP_ENABLE (%I0.2), TANK_EMPTY_LS (%I0.3), LEVEL_A_LS (%I0.4, 40% setpoint) and LEVEL_B_LS (%I0.5, 80% combined setpoint). Outputs: VALVE_A (%Q0.0), VALVE_B (%Q0.1), AGITATOR (%Q0.2), DRAIN_VALVE (%Q0.3), CIP_VALVE (%Q0.4), READY_LAMP (%Q0.5) and FAULT_LAMP (%Q0.6). START, STOP, CIP_ENABLE and TANK_EMPTY_LS are pre-wired; you wire the two level switches and all outputs yourself.

How do timers control the mixing and CIP phases?

Both timed phases use TON (on-delay) timers in this batching process PLC ladder logic. T_MIX is a TON with a 30,000 ms preset driven by the MIX state bit; when its .Q output goes true after 30 seconds, the sequence advances from MIX to DRAIN — so the agitator is guaranteed to run a full 30 seconds before the drain valve opens. T_CIP is a TON with a 45,000 ms preset driven by the CIP state bit, and its .Q advances CIP to READY after the 45-second wash.

How does the CIP (clean-in-place) interlock work?

CIP is optional and tightly interlocked in this batch process control using PLC logic. The DRAIN phase exits down one of two mutually exclusive rungs, both requiring TANK_EMPTY_LS to confirm the tank is physically empty: one ANDed with CIP_ENABLE goes to the CIP phase, the other ANDed with NOT CIP_ENABLE skips straight to READY. Because both branches require TANK_EMPTY_LS, CIP_VALVE can never open while product is still in the tank. The auto-grader's 'cip-requires-empty-tank' test verifies exactly this.

Can I simulate a mixing tank PLC program without hardware?

Yes. The Batch Mixer scenario runs entirely in your browser. You write the ladder logic, press Run, and a physics model fills, mixes and drains a simulated tank — tripping the level switches at their setpoints and counting the mix and CIP timers in real time. Five auto-grader test cases then check your sequence, valve timing, mix-time minimum and CIP interlock against the real specification, so you get a complete mixing tank PLC program working without a PLC, a tank, or any installed software.

Ready to build this?

Sign up free — no credit card required. This scenario requires the Basic plan.

Sign up to play this scenario →

Already have an account? Log in