← All resources

Topic

Fundamentals

How a PLC actually runs a program: the scan cycle, the output image, contacts and coils, memory and retentivity. The ideas every other article assumes.

10 articles

  1. Logic gates in ladder logic: AND, OR, NOT, NAND, NOR, XOR, XNOR

    In ladder logic, contacts in series make AND, contacts in parallel make OR, and an examine-off (XIO) contact makes NOT. The other gates are combinations: NAND is two XIO contacts in parallel, NOR is two XIO contacts in series, XOR is two parallel legs each with one XIC and one XIO, and XNOR is one leg of two XIC contacts beside one leg of two XIO contacts.

    9 min read
  2. What actually happens in one PLC scan

    A PLC repeats four steps forever: it copies every physical input into memory, solves the program top to bottom, writes the output image to the terminals, then does housekeeping. On a modern controller that loop takes one to twenty milliseconds. Three consequences follow: a pulse shorter than one scan is invisible, outputs do not change mid-scan, and rung order decides what sees what.

    7 min read
  3. The output image: why your coil did not work

    A coil writes to the output image in memory, not directly to the terminal. The whole image is copied to the physical outputs once, at the end of the scan. Within the program, a coil is visible immediately to any rung solved after it, and only on the next scan to any rung solved before it.

    6 min read
  4. Normally open and normally closed, in the field and in the code

    A normally open contact passes power when its bit is 1; a normally closed one passes power when its bit is 0. The confusion is that the same words describe the physical switch, and a normally closed stop button sends 1 when healthy. So a healthy stop button is read with a normally open instruction, which looks backwards until you separate the device from the instruction.

    6 min read
  5. Seal-in or latch: two ways to hold a motor on

    A seal-in holds an output on by routing the output's own contact in parallel with the start button, so the rung keeps conducting. A latch instruction sets a bit that stays set until explicitly unlatched. The critical difference is power loss: a seal-in drops out and does not restart, while a latched bit in retentive memory can come back on.

    7 min read
  6. BOOL, INT, DINT, REAL: choosing the right type

    The four that cover most work are BOOL for a single bit, INT for whole numbers from -32,768 to 32,767, DINT for a 32-bit integer up to about 2.1 billion, and REAL for a 32-bit floating point value. The common failure is INT overflow, which wraps silently to a negative number with no error and no warning.

    6 min read
  7. PLC or microcontroller: what actually decides it

    Use a PLC when the thing has to run for twenty years, be maintained by somebody who did not build it, and survive an industrial electrical environment. Use a microcontroller when cost dominates, volume is high, or the application is genuinely simple and disposable. The deciding factors are usually lifecycle and maintainability rather than capability.

    6 min read
  8. Retentive memory: what survives a power cycle

    Retentive memory keeps its value through a power cycle; non-retentive memory is cleared on restart. Which is which varies by platform and is often configurable per tag. The decision matters most for anything that drives an output, because a retentive bit holding a motor command can energise it the moment power returns.

    6 min read
  9. The first scan bit and what belongs in it

    The first scan bit is true for exactly one scan after the processor enters RUN, and false thereafter. It exists to give a program somewhere to initialise: clearing stale state, setting default values, and putting sequences back to a known step. Using it well is what makes a restart predictable.

    5 min read
  10. What a PLC is, for people arriving from software

    A programmable logic controller is an industrial computer that runs one program in an endless loop, reading inputs and writing outputs on a fixed cycle, with no operating system scheduling in the way. It is built for determinism and for twenty years of uninterrupted operation, which explains almost every difference from a general-purpose computer.

    6 min read