Watch a PLC scan, solve ladder rungs and fill bottles. Slow it down, then break it.
Tap any part
The line is already running, part-way through a batch of 6. Tap a part, or a chip below, to see what it does. Slow time down to watch the scan.
The program, solved live
Scan cycle
-
1 Start clears a finished batch, so the line can run again
Start I0.0 AND Batch done C1.DN → RES C1 -
2 Run latch: Start seals in through Run. Stop or E-stop breaks it, and so does a finished batch once the last bottle has left
(Start I0.0 OR Run M0.0) AND Stop I0.1 AND E-stop I0.4 AND (NOT Batch done C1.DN OR Bottle I0.2) → OTE M0.0 -
3 A bottle at the nozzle whose neck reads full is marked Filled
Bottle I0.2 AND Full I0.3 → SET M0.1 -
4 Filled is forgotten once the bottle has left the eye, ready for the next one
NOT Bottle I0.2 → RES M0.1 -
5 Fill valve opens while running, with a bottle in place that is not yet full
Run M0.0 AND Bottle I0.2 AND NOT Filled M0.1 AND NOT Full I0.3 → OTE Q0.1 -
6 After filling, wait 0.8 s for the nozzle to stop dripping
Bottle I0.2 AND Filled M0.1 → TON T1 -
7 Conveyor runs until a bottle reaches the nozzle, then again once it has drained
Run M0.0 AND (NOT Bottle I0.2 OR Drip done T1.DN) → OTE Q0.0 -
8 Count each filled bottle once (rising edge of Filled)
Filled M0.1 → CTU C1 -
9 Green Run lamp follows Run
Run M0.0 → OTE Q0.2
Terminal vs image table
The program only sees the image table, copied from the terminals once per scan. Rows light up while the two disagree.
| Address | Tag | Terminal | Image |
|---|---|---|---|
| I0.0 | Start | 0 | 0 |
| I0.1 | Stop | 0 | 0 |
| I0.2 | Bottle | 0 | 0 |
| I0.3 | Full | 0 | 0 |
| I0.4 | E-stop | 0 | 0 |
| Q0.0 | Conveyor | 0 | 0 |
| Q0.1 | Fill valve | 0 | 0 |
| Q0.2 | Run lamp | 0 | 0 |
Fault lab
Break something, watch the symptom, then read how a technician finds it.
Every part, explained
- Product tank
Holds the liquid above the fill valve, so gravity does the filling. Real fillers keep the head constant with a level controller, because the flow rate, and with it the fill time, depends on the liquid height.
- Fill valve Y1 (Q0.1)
A 24 V DC solenoid valve, normally closed: no power, no flow. The PLC output Q0.1 energises the coil.
Normally closed is the safe choice. A broken wire, a tripped fuse or an E-stop all close it.- Level probe B2 (I0.3)
A conductive probe that dips into the bottle neck. When the liquid touches it, its output switches on: Full.
It is set a little below the brim on purpose: the PLC needs one or two scans to react, and the valve takes a moment to close, so a few millilitres still flow after the signal.- Photo eye B1 (I0.2)
A diffuse photoelectric sensor at neck height, PNP output into a sinking input. It sees a bottle only while the neck is right under the nozzle, so a bottle that has stopped anywhere else can never open the valve.
Its window is a few millimetres wider than the neck: two scans of reaction time at belt speed still leave the neck under the nozzle.- Conveyor
A flat belt that carries the bottles at a steady speed. In this model it stops instantly; a real one coasts a little, which is why the sensor window has some tolerance.
- Conveyor motor M1 (Q0.0)
The PLC output does not run the motor directly. Q0.0 switches the coil of contactor K1, and K1's main contacts switch the motor, with an overload relay in between.
PLC outputs are rated for an amp or two at 24 V; a motor needs a contactor.- Bottle
500 ml. It stops under the nozzle, fills to the probe, waits for the drip timer and moves on. The number in the readouts counts each one once.
- Power supply 24 V DC
Turns mains AC into the 24 V DC that the PLC, sensors, buttons and valve run on. 24 V is safe to touch and is the industry standard for control circuits.
- CPU
Runs the program in an endless scan: read every input into the image table, solve every rung from top to bottom, write the outputs, then housekeeping. Here one scan takes 20 ms.
The watchdog stops the CPU and switches the outputs off if a scan ever takes too long.- Digital input module
Each LED shows the voltage at its terminal, not what the program sees. The program only sees the image table, updated once per scan. Use 1/100 speed to watch the two disagree for a moment.
- Digital output module
Transistor outputs, 24 V DC. They change only at the write step of the scan, so a rung that turns an output on takes effect at the end of that scan. Worst-case reaction time is about two scans.
- Start button S1 (I0.0)
Momentary and normally open: it is only on while you hold it. Rung 2 seals it in through Run, so the line keeps going after you let go.
In slow motion this model holds your press until one input read has seen it. A real PLC can miss a pulse shorter than one scan.- Stop button S0 (I0.1)
Wired normally closed, so the input is 1 while nobody presses it. That is why the program uses a normally open contact for Stop.
If the wire breaks, the input drops to 0 and the line stops: the failure is safe. Try it in the fault lab.- Emergency stop (I0.4)
Latching mushroom button. In a real machine it is hardwired through a safety relay that removes power from the outputs (IEC 60204-1, ISO 13849); here too, the valve and motor stop even before the program reacts.
The PLC is only told, through a monitoring contact. Twist to release, then press Start.- Run lamp H1 (Q0.2)
Green pilot lamp: the line is in Run. Operators read the machine state from lamps long before they look at a screen.
- Run (M0.0) (M0.0)
An internal memory bit, not a terminal. It holds the "line is running" state and every other rung asks it before doing anything.
- Filled (M0.1) (M0.1)
Remembers that the bottle under the nozzle is done, set by the probe and reset when the bottle leaves.
Without it the valve would reopen when the level drops by a drip, and the counter could count one bottle twice.- Drip timer T1 (T1)
An on-delay timer (TON). It times while its rung is true and sets DN after 0.8 s, which is when the conveyor moves the full bottle on. If the rung goes false first, it resets to zero.
- Batch counter C1 (C1)
An up counter (CTU). It adds one on each rising edge of Filled and sets DN at 6. Batch done stops the line, but only after the last bottle has left the nozzle, so it is never left half-way.
- Spill
Product on the floor: the valve was open with no bottle under it, or a bottle overflowed. Try the fault lab to make one.
Where this fits
This is level 0 and 1 of the automation pyramid (ISA-95): field devices and the controller. Above it, an HMI shows the batch count and alarms, and a production system plans the batches.
The program is ladder diagram, one of the IEC 61131-3 languages; the same logic in structured text or function block diagram would run exactly the same scan. The E-stop follows IEC 60204-1: hardwired, with the PLC only informed.
