PLC Memory Types Explained
A PLC is built around a small set of memory areas, each with a specific purpose. Understanding the difference between input image, output image, retentive and non-retentive memory is the key to predictable PLC behaviour — and the cause of many beginner bugs when it's misunderstood.
The five memory areas every PLC has
| Area | Updated when | Survives power cycle | Purpose |
|---|---|---|---|
| Input image table | Phase 1 of scan | No | Snapshot of every physical input at scan start |
| Output image table | Phase 3 of scan | No | Buffer of output bits; copied to output cards at scan end |
| Retentive memory | Whenever code writes | Yes | Battery-backed RAM or flash. Preserves values across power cycles, faults and reprogramming |
| Non-retentive memory | Whenever code writes | No (cleared on power-up) | Internal flags, scratch values, working variables |
| System memory | By firmware | Yes (firmware-managed) | Diagnostics, fault codes, scan-cycle stats, force tables |
Retentive memory — the critical concept
Retentive memory means PLC data memory that preserves its value across power cycles, processor restarts, and program transitions to STOP mode. Battery-backed RAM, non-volatile flash, or supercapacitor-backed cache holds the data; non-retentive memory is cleared to zero on power-up.
Why this matters in practice:
- Counter values for production totals must be retentive. Losing yesterday's output count after a power blip is unacceptable.
- Run-time totalisers for maintenance intervals must be retentive. The motor's "hours since last service" can't reset to zero on every brownout.
- Recipe and setpoint values entered by operators must be retentive. Operators don't want to re-enter the batch recipe after every controller reboot.
- Latched alarm states are typically retentive. An alarm that triggered during a power outage should still require operator acknowledgement after restoration.
- Internal scratch flags should be non-retentive. "Was the start button pressed?" should be FALSE after power-up regardless of state at shutdown.
Vendor-specific memory areas
Allen-Bradley ControlLogix / CompactLogix
- Tag-based memory — no fixed addresses. Tags are named (
Conv1_Run,Tank1_Level) and the compiler allocates memory. - Each tag has a Retain checkbox in Studio 5000. Default is non-retentive; enable Retain for values that must survive power cycles.
- Controller scope vs Program scope — controller-scope tags are visible plant-wide; program-scope tags are private to one program.
Siemens S7-1500 / TIA Portal
- Inputs (I) — input image table
- Outputs (Q) — output image table
- Memory bits (M) — non-retentive flag area by default; retain settings configurable
- Data Blocks (DB) — structured persistent data; can be retentive or non-retentive per DB
- Timers (T) and Counters (C) — separate areas with their own retain settings
- Local data (L) — temporary stack memory inside FBs/FCs; non-retentive
Mitsubishi MELSEC iQ-R / GX Works3
- X / Y — physical inputs and outputs
- M — internal relays (some retentive, some not — configured per range)
- D — data registers (most are non-retentive; D-Latch ranges are retentive)
- L — Latch relays (always retentive)
- R / ZR — file registers (retentive, large memory areas)
Common memory bugs
- Reading the output image inside the same scan it was set. The output bit reflects the previous scan's value until phase 3. Use input states or internal flags that update synchronously.
- Forgetting to mark counters retentive. Production count goes to zero on every reboot. Symptom: missing 8-hour shifts of data.
- Marking everything retentive. Internal scratch flags retain stale values from before the power-up, causing weird startup behaviour.
- Battery dead. On older PLCs (Siemens S7-300, AB SLC-500, AB PLC-5) battery-backed retentive memory loses data when the battery dies. Check battery status routinely; modern PLCs use supercaps or flash and don't have this issue.
- Mixing scopes — Allen-Bradley program-scope tag with the same name as a controller-scope tag is a bug magnet.