pull down to refresh

A PLC (Programmable Logic Controller) is a rugged industrial computer that continuously reads sensors, runs your logic on a fixed cycle, and drives machinery. It exists because office-grade computers die on factory floors: PLCs tolerate heat, vibration, dust, and electrical noise, and they fail in predictable, safe ways.

The operating loop is simple and relentless - scan cycle:

  1. READ INPUTS. The PLC snapshots every input into memory: pushbuttons, limit switches, proximity sensors, temperature transmitters, analog levels (4-20mA, 0-10V).
  2. EXECUTE LOGIC. It solves your program once, top to bottom, using that frozen snapshot (ladder logic historically, now also structured text or function blocks).
  3. WRITE OUTPUTS. Results go to the output module: contactors, motor starters, valves, variable frequency drives, indicator lamps.
  4. HOUSEKEEPING. Communications, diagnostics, watchdog timer check - if the program hangs, the watchdog faults the unit and outputs go to a defined safe state.

Then it repeats, typically every 10-100 milliseconds.

Concrete example - a tank fill/drain station:

  • Inputs: float switch low (I0.0), float switch high (I0.1), start button (I0.2), emergency stop (I0.3)
  • Outputs: inlet valve (Q0.0), pump contactor (Q0.1)
  • Logic: when start is pressed and e-stop is healthy, open the inlet valve while the low float is uncovered. Once water reaches the high float, close valve, run the pump for 60 seconds to dose the tank downstream. Latch with an internal memory bit so releasing the button does not stop the sequence; break the latch on e-stop.

Why not a Raspberry Pi? Determinism and safety. A scan cycle with defined I/O update points means no race conditions between reading and writing, guaranteed response times, and hardware designed so that a crash opens the relay instead of leaving a pump running. That predictability is why PLCs still run factories 50 years after they replaced banks of relays.