PLC Sim Lab

Learn industrial automation by running a plant

A metal / non-metal sorting line controlled by a simulated PLC. Press START, watch the sensors fire, follow the ladder logic rung by rung, then break things with fault injection and see what happens.

Open the Playground → wire your own panel and write your own ladder logic

Sorting line simulator

Inductive proximity sensor PX1 flags metal parts. A FIFO shift register tracks every part down the belt until photo-eye PE2 tells the PLC it has reached the pneumatic diverter. Capacitive level sensors stop the line when a bin is full. Click any component on the machine to learn what it is.

Tip: click a component on the machine (sensor, cylinder, motor, bin, stack light...) to see how it works.
Operator panel (HMI)
Rated Sn = 8 mm on steel. Aluminium only reaches 0.4 × Sn – widen the gap and watch aluminium get mis-sorted.
0C0 metal
0C1 non-metal
0mis-sorts
Fault injection
PLC I/O image table
Part tracking FIFO (1 = metal → divert) · oldest on the left
Scan #0 · scan time 0 ms
Ladder logic – live power flow (green = true)

Sensor lab

Each sensor on its own test bench. Move the target, change the material, and watch the output LED.

Inductive proximity sensor

An oscillator coil creates a high-frequency magnetic field at the sensor face. A metal target lets eddy currents flow, which damps the oscillation. When the amplitude falls below a threshold, the output switches. Non-ferrous metals damp less, so the working range is multiplied by a correction factor. A small hysteresis band stops the output chattering at the edge.

Capacitive proximity sensor

The sensor face is one plate of a capacitor and the surroundings are the other. Anything with a dielectric constant higher than air raises the capacitance. That's why it detects plastic, wood, powder and liquid, even through a non-metal tank wall. You tune the sensitivity pot so the wall is ignored and the product is detected. The simulator uses two of these as bin-full level switches.

Photoelectric sensor (photo-eye)

Through-beam uses a separate emitter and receiver. It has the longest range and is the most reliable. Retro-reflective uses one housing plus a reflector; a polarizing filter helps with shiny objects, but clear bottles can still fool it. Diffuse relies on the object reflecting light back, so dark or clear objects may be missed. Dark-ON means the output is ON when the beam is blocked.

Ultrasonic level sensor (analog 4–20 mA)

The sensor sends an ultrasonic burst and times the echo: distance = speed of sound × time / 2. It outputs a 4–20 mA current loop. 4 mA is a "live zero", so 0 mA means a broken wire. The PLC analog input card converts the current to a raw count (for example 0–27648 on Siemens S7). The program then scales that count to engineering units.

Wiring a 3-wire DC sensor: PNP vs NPN

Most DC proximity sensors have three wires: brown +24 V, blue 0 V and black output. The output transistor either sources +24 V to the load (PNP) or sinks the load to 0 V (NPN). The PLC input card must be the opposite type.

Field equipment reference

What each device does and how it connects to the PLC.

How a PLC works: the scan cycle

A PLC doesn't react to inputs the moment they change. It runs one loop forever, typically every 1–20 ms. The simulator above runs exactly this loop.

  1. Read inputs. The state of every input terminal is copied into the input image table. The program only sees this snapshot, so an input that flickers mid-scan can't confuse it.
  2. Execute program. Rungs are solved top-to-bottom, left-to-right. Results are written to the output image table and to internal memory bits (M / markers).
  3. Write outputs. The output image is copied to the physical output terminals, which switch contactors, solenoid valves and lamps.
  4. Housekeeping. Communications (HMI, SCADA, fieldbus), diagnostics and the watchdog timer run here. If a scan takes too long, the watchdog faults the CPU and the outputs drop to a safe state.

Common ladder instructions

SymbolNameMeaning
--] [--XIC / NO contactTrue when the bit is 1
--]/[--XIO / NC contactTrue when the bit is 0
--( )--OTE / output coilBit follows the rung condition
--(S)-- --(R)--Set / Reset (Latch / Unlatch)Bit stays on until it is explicitly reset
--|P|-- --|N|--Rising / falling edge (one-shot)True for exactly one scan on the edge
TONOn-delay timerQ / DN turns on after the input has been true for the preset time
CTUCount upAccumulator +1 on each false→true transition
FFL / FFUFIFO load / unloadQueue used to track parts between stations

Note on Stop and E-Stop: they are wired normally closed, so the input reads 1 when healthy and the program uses a normally-open contact. If a wire breaks, the input drops to 0 and the machine stops. This is called fail-safe wiring. Real E-stops also cut power through a safety relay, not just through the PLC program.