PLCProgrammable Logic Controller
A PLC is the deterministic, real-time controller that actually opens the valve, runs the motor and reads the sensor — the bottom rung of the automation pyramid. This page covers the scan cycle, I/O and IEC 61131-3 programming languages, where a PLC sits versus a PAC, DCS, SCADA and MES, why the ISA-95 level model exists and why MES logic must never live inside ladder code, how tag mapping and OPC-UA/MQTT turn PLC registers into batch-record data, GAMP 5 categorisation and IQ/OQ/PQ for PLC validation, Part 11 exposure when a PLC or HMI holds GxP records, change control on PLC programs, alarm handling, the failure modes inspectors actually cite, and how an MES consumes PLC data without becoming a second control system.
On this page · 12 sections
- 1What a PLC is
- 2The scan cycle and I/O
- 3Ladder logic, Structured Text and IEC 61131-3
- 4PLC vs PAC vs DCS vs SCADA vs MES
- 5The ISA-95 level model, and why MES must not be written in ladder logic
- 6Tag mapping and OPC-UA/MQTT data acquisition
- 7GAMP 5 software categories and PLC validation (IQ/OQ/PQ)
- 8Part 11 implications of PLC-held records
- 9Change control on PLC programs
- 10Alarm handling at the PLC/HMI layer
- 11Common failure modes inspectors actually cite
- 12How an MES consumes PLC data without becoming the control system
How does PLC apply to your shop floor?
Pick your industry and scale — Ask V5 rewrites the definition in your context, gives a worked example, and shows what V5 does on day one.
01What a PLC is
A Programmable Logic Controller is an industrial computer purpose-built to read physical inputs, execute a stored logic program, and drive physical outputs, deterministically and continuously, in an environment far harsher than an office server room — vibration, temperature swings, electrical noise, dust and washdown. It was invented in the late 1960s (Modicon 084, for General Motors) explicitly to replace racks of relay panels with something that could be reprogrammed instead of rewired.
In a regulated plant, the PLC is almost always the layer that actually does something: it opens a valve, starts a motor, drives a temperature loop, reads a load cell, latches an interlock. Everything above it — SCADA, MES, ERP — is watching, aggregating and directing, but the PLC is where electrons meet the process.
- Central Processing Unit (CPU) — executes the program on a fixed scan cycle.
- I/O modules — digital and analog inputs (sensors, switches, 4-20mA transmitters) and outputs (actuators, motor starters, valves, drives).
- Power supply — typically 24VDC field-side, isolated from the backplane.
- Communication modules — Ethernet/IP, Profinet, Modbus TCP, DeviceNet, and increasingly OPC-UA or MQTT for northbound data.
- Memory — program memory (the logic itself) and data memory (the live tag/register values).
02The scan cycle and I/O
Unlike a general-purpose computer running an operating system with pre-emptive multitasking, a PLC executes a repeating scan cycle, typically measured in single-digit to tens of milliseconds:
- Input scan — read all physical inputs into an internal input image table (a snapshot, not a live read, so the logic sees a consistent picture for the whole scan).
- Program execution — run the user logic top to bottom (or per configured task priority), using the input image and internal memory, writing results to an output image table.
- Output scan — write the output image table to the physical output modules.
- Housekeeping / communications servicing — process comms requests (HMI polls, OPC-UA reads, diagnostics) in the remaining scan time.
This 'freeze the inputs, run the logic, write the outputs' model is what makes PLC behaviour deterministic and testable: the same input pattern always produces the same output pattern, and a bench test with forced inputs will predict field behaviour precisely. It's also why scan-time budget matters — an overloaded CPU with too much logic per scan will lengthen the cycle, and safety-critical logic (E-stops, interlocks) is usually run at faster/higher-priority tasks or offloaded to a dedicated safety PLC certified to IEC 61508 / IEC 62061 / ISO 13849.
| I/O type | Example | Typical signal |
|---|---|---|
| Digital input | Door switch, proximity sensor, palm-button | 24VDC on/off |
| Digital output | Solenoid valve, indicator lamp, motor starter contactor | 24VDC / relay dry contact |
| Analog input | Load cell, pressure transmitter, RTD/thermocouple | 4-20mA, 0-10V, or direct thermocouple mV |
| Analog output | VFD speed reference, control valve positioner | 4-20mA, 0-10V |
| High-speed / specialty | Encoder pulse train, weigh-scale serial link | Dedicated counter or serial module |
03Ladder logic, Structured Text and IEC 61131-3
IEC 61131-3 standardises five PLC programming languages so logic (mostly) portable across vendors conceptually, even though the runtimes themselves are proprietary:
- Ladder Diagram (LD) — the original and still the most common on the factory floor; models relay logic visually as rungs of contacts and coils. Easy for electricians to read; awkward for complex math, string handling, or state machines.
- Function Block Diagram (FBD) — wires reusable blocks (PID, timers, counters) together; common in continuous-process and packaging logic.
- Structured Text (ST) — a Pascal-like text language; the right tool for recipe math, string/array manipulation, and anything a spreadsheet-style ladder rung struggles to express cleanly.
- Instruction List (IL) — a low-level assembly-like language; deprecated in the 2013 edition of the standard and rarely used in new work.
- Sequential Function Chart (SFC) — models a process as a sequence of steps and transitions; the natural fit for ISA-88 phase logic (state machine: idle → running → held → aborted → complete).
A well-structured batch or packaging PLC program typically mixes these: SFC for the phase state machine, ladder or FBD for the interlocks and discrete I/O, and ST for the setpoint/recipe calculations — rather than forcing everything into ladder because that's what the original programmer knew.
04PLC vs PAC vs DCS vs SCADA vs MES
These five terms get used loosely on the floor and precisely in an audit. Knowing the boundary matters because crossing it in the wrong direction is the single most common architecture mistake in regulated automation.
| System | What it is | What it's good at | What it must not do |
|---|---|---|---|
| PLC | Discrete/hybrid controller executing a fixed logic program on a scan cycle. | Deterministic real-time control of a machine, skid or line. | Hold enterprise data models, run business rules, manage users/permissions at scale. |
| PAC (Programmable Automation Controller) | A PLC with more compute, native motion/analytics, often a real-time OS. | Complex motion, higher I/O counts, on-board analytics on a single controller. | Replace the need for a supervisory or MES layer on multi-line sites. |
| DCS (Distributed Control System) | A network of controllers with a unified engineering/operator environment, built for continuous process. | Large continuous processes (chemical, refining, some bio) with thousands of loops. | Be treated as interchangeable with a PLC on discrete/batch/packaging lines — different design centre. |
| SCADA | Supervisory layer that polls PLCs/RTUs over a wide area, visualises and historises. | Wide-area or multi-site visibility, historian trending, operator HMI screens. | Own GMP records of quality decisions — it's a view and a data pipe, not the QMS. |
| MES | Level 3 system: orchestrates work orders, e-records, genealogy, exception handling, e-signatures. | Batch/device records, recipe management, deviations, CAPA, release, traceability. | Directly actuate equipment or replace the interlock logic that keeps people and product safe. |
05The ISA-95 level model, and why MES must not be written in ladder logic
ISA-95 (IEC 62264) formalises the automation pyramid into levels, precisely so organisations stop arguing about where a given piece of logic should live:
| Level | Layer | Time horizon | Example |
|---|---|---|---|
| L0 | The physical process | Milliseconds | The tablet press, the fermenter, the conveyor. |
| L1 | Sensing and manipulation — PLC / DCS | Milliseconds–seconds | Interlocks, PID loops, motor control, safety logic. |
| L2 | Monitoring and supervisory control — SCADA / HMI | Seconds–minutes | Operator screens, alarms, local trending, batch sequencing HMI. |
| L3 | Manufacturing operations management — MES | Minutes–shifts | Work order dispatch, e-batch record, genealogy, deviations, e-signatures, scheduling. |
| L4 | Business planning and logistics — ERP | Days–months | Demand planning, procurement, finance, master data. |
The reason MES logic must never be written in ladder is not stylistic — it's a validation and maintainability argument. Ladder logic is designed for I/O-scale, deterministic, single-machine control; it has no native concept of a user account, an e-signature, a document version, a genealogy tree, or a multi-step approval workflow, and it is validated and change-controlled by the automation engineering team on a completely different cadence than QA-owned business logic. Bury an e-signature requirement or a lot-release rule inside a PLC program and you've created a GxP business rule that: (1) only automation engineers can read or modify, (2) has no audit trail of who approved the logic change and why, (3) can't be unit-tested the way application code can, and (4) is invisible to the people who actually own that regulatory requirement. The ISA-95 boundary exists to keep the accountable owner of a rule and the system that enforces it aligned.
06Tag mapping and OPC-UA/MQTT data acquisition
A PLC's internal memory is just addresses and registers — DB1.DBD20, %MW100, Tag_Weight_Actual — meaningless outside the program that wrote them. Turning that into usable process data for a historian, SCADA screen or MES requires tag mapping: an explicit, documented crosswalk between a PLC address and a named, typed, unit-of-measure-tagged data point (e.g. Line3.Mixer.Temp_PV, °C, float32, updates every 250ms).
- OPC-UA is the dominant standard for this handoff today: a PLC or an OPC-UA server sitting in front of it exposes an address space of typed nodes that a client (SCADA, historian, MES) can browse, subscribe to, and read/write with built-in security (certificates, encryption) — a major upgrade over the older OPC Classic (DA/HDA) which relied on Windows DCOM.
- MQTT (often with Sparkplug B for payload structure) is the common choice for lightweight, publish/subscribe telemetry, especially from remote or edge devices where a persistent broker connection is more practical than polling.
- Legacy protocols (Modbus TCP/RTU, Ethernet/IP explicit messaging, proprietary vendor drivers) remain common on older equipment and usually route through a gateway that republishes as OPC-UA or MQTT for the modern stack to consume.
Good tag-mapping discipline treats the map itself as a controlled document: every tag has an owner, a data type, an engineering unit, an update rate, a description, and — critically for a regulated environment — a statement of which tags are GxP-relevant (feed a batch record, a CQA/CPP, or an alarm that requires investigation) versus purely diagnostic. Undocumented or 'orphan' tags (see below) are one of the most common findings when a site tries to reconstruct exactly what data an MES or historian is actually consuming.
07GAMP 5 software categories and PLC validation (IQ/OQ/PQ)
GAMP 5 categorises automated systems by configurability and risk to scope validation effort proportionately, and PLC-based systems typically land in one of two buckets:
- Category 3 — Non-configured products. Off-the-shelf instrumentation or a PLC running only vendor firmware with no custom application logic (e.g. a fixed-function weigh indicator). Validation focuses on verifying the product operates per the vendor's published functional spec in the actual use environment.
- Category 4 — Configured products. A PLC or SCADA platform where the vendor supplies the runtime/engine but the site has written custom application logic (ladder/ST/SFC programs, HMI screens, alarm configuration, recipe parameters). This is where most process-control PLCs sit, and it drives full URS → FS → DS → code review → IQ/OQ/PQ.
- Category 5 — Custom application code is rare at the pure-PLC layer (more common at MES/data-layer) but appears when a site writes bespoke drivers, custom OPC-UA server logic, or non-standard communication middleware.
| Stage | What it verifies for a PLC-controlled system | Typical evidence |
|---|---|---|
| IQ (Installation Qualification) | Correct hardware, firmware revision, network config, I/O wiring matches the design, backup of the as-built program exists. | Installation checklist, firmware/version log, wiring verification, program backup with checksum. |
| OQ (Operational Qualification) | Every discrete function operates correctly across its specified range: interlocks trip at the right condition, alarms fire at set limits, PID loops hold setpoint within tolerance, forced I/O tests. | Test scripts with expected vs actual results, forced-input traceability to logic branches, alarm test log. |
| PQ (Performance Qualification) | The controlled process performs consistently under real production conditions across representative runs/lots. | Production run data, CPP/CQA trend review, three-consecutive-run (or risk-justified) acceptance. |
A common audit gap is qualifying the PLC hardware and I/O (IQ) thoroughly, then treating OQ as 'the vendor's factory acceptance test was fine' — skipping site-specific OQ against the as-installed, as-configured logic. Interlocks and alarm setpoints must be challenged in the qualified environment, not assumed from the FAT.
08Part 11 implications of PLC-held records
21 CFR Part 11 applies the moment a PLC, its HMI, or its historian is the system of record for a GxP decision — not just when a document explicitly says 'electronic record.' If the only place a critical process value (mixing time, autoclave temperature, tablet-press compression force) is captured is an HMI trend or a PLC-resident recipe, that HMI/PLC combination is in scope for electronic-record and, where applicable, electronic-signature controls: secure, computer-generated, time-stamped audit trails for operator actions that create, modify or delete GxP records; access controls tied to individual identity, not shared operator logins; and record retention that survives a PLC firmware upgrade or program re-download.
In practice, most PLCs and HMIs are not good at this natively — PLC memory is small, HMI historians are often a rolling buffer, and 'who changed the setpoint' is frequently answered only by 'someone with the operator password, at some point.' This is precisely the gap that a validated data historian or an MES sitting above the control layer is supposed to close: capture the same PLC data with attributable, contemporaneous, immutable recording before it ages out of the controller's own limited buffer.
09Change control on PLC programs
A PLC program is GxP-relevant configuration, and every edit — a new interlock, a changed timer value, a modified alarm limit, even a comment-only cleanup that touches a rung — should go through the same change-control discipline as any other validated system change: documented request, impact assessment (does this touch a CPP, a safety interlock, a batch-record data point?), review and approval, testing proportionate to risk, and an updated, checksummed program backup with version history.
- Maintain an as-built vs as-designed comparison — field modifications made under time pressure during a breakdown are the most common source of undocumented drift.
- Version and checksum every program backup; store it under document control, not just on the programmer's laptop.
- Require a documented reason and approver for any online edit made while the process is running (forcing an output, changing a timer preset live) — these are exactly the changes that later show up as unexplained deviations.
- Re-run the relevant OQ test cases after any change that touches an interlock, alarm setpoint or control-loop tuning parameter.
- Restrict online/download access to the PLC by role — a floor operator's HMI login should not be able to modify ladder logic.
The most common finding is not a missing change-control SOP — most sites have one — it's evidence that the SOP wasn't actually followed for a specific, dated logic change that the investigator can trace to a process anomaly.
10Alarm handling at the PLC/HMI layer
PLCs and the HMIs above them are usually where alarms originate — a value crossing a high/low limit, an interlock tripping, a communications fault. ISA-18.2 defines the discipline for making that stream useful rather than overwhelming: alarm rationalization (every alarm has a documented cause, consequence and operator response, and exists because it requires action — not just because a tag could be flagged), alarm shelving with time-limited, logged suppression instead of silent acknowledgement, and alarm flood prevention so a single upset doesn't bury the operator under hundreds of chattering, low-value alarms exactly when they need to think clearly.
In a regulated context, alarms that indicate a CPP excursion or an equipment state that could affect product quality need a defined path from 'alarm fired' to 'documented response' — ideally captured automatically rather than relying on an operator's memory of what they did and why, hours later during batch record review.
| Alarm class | Example | Response discipline |
|---|---|---|
| Safety | E-stop, guard interlock, over-pressure | Hard-wired or safety-PLC logic; independent of the process PLC where risk-justified. |
| Process/quality | Temperature excursion, pressure out of range, weight out of tolerance | Documented cause/response; often should trigger a deviation if unacknowledged past a time limit. |
| Diagnostic | Communications loss, sensor fault | Maintenance response; should not be presented to the operator with the same urgency as a safety alarm. |
11Common failure modes inspectors actually cite
The recurring pattern across PLC/HMI findings is the same one described throughout this page: control-layer flexibility without control-layer discipline.
- Uncontrolled setpoint changes — an operator or engineer adjusts a temperature, speed or timer setpoint from the HMI with no change-control record, no reason code, and no link to the batch that was running at the time. The process data looks fine in isolation; the missing context is what an investigator flags.
- No audit trail on the HMI — password-protected screens that log 'who' but not 'what changed, from what value, to what value, when, and why' fail the Part 11 audit-trail test even though they look like access control is in place.
- Orphan tags — PLC registers or HMI tags that exist in the program but aren't documented in the current tag map, often left over from a decommissioned feature or a contractor's undocumented addition. They're invisible until someone asks 'what does this actually do' during an investigation and nobody can answer confidently.
- Shared/generic logins on the HMI, defeating individual accountability for setpoint or recipe changes.
- Firmware/program version drift between what's installed on the floor and what's on file as the validated baseline, discovered only when a fault-finding session pulls the live program and compares it to the archived one.
- Safety interlocks bypassed via an HMI 'maintenance mode' or forced I/O left engaged after the maintenance window closed, with no automatic timeout or reminder.
- Alarm setpoints changed without re-qualification, silently shifting what the process considers 'in control.'
12How an MES consumes PLC data without becoming the control system
The correct integration pattern is one-directional and evidentiary: the MES subscribes to PLC/SCADA tags to capture what happened, attaches that data to the work order/batch step it belongs to, and — where the process calls for operator or QA action — surfaces it as a workflow step (confirm, sign, investigate). It does not write setpoints, force outputs, or override interlocks. The PLC remains sole owner of real-time control; the MES remains sole owner of the record, the recipe parameters as approved, the exception workflow and the genealogy.
- Read-only subscription to defined, documented tags via OPC-UA or MQTT, mapped to named process parameters on the batch/work-order record.
- Time-stamped, attributable landing of every value change relevant to a CQA/CPP, closing the audit-trail gap the raw PLC/HMI often leaves open.
- Deviation/CAPA triggers when a subscribed value breaches a defined limit, rather than relying on an operator noticing and manually logging it.
- Recipe parameters flow one way — from the approved, version-controlled MES recipe down to the PLC as a set of validated parameters at batch start — never back up as an uncontrolled runtime edit.
- Any operator action that changes a live process value still happens at the PLC/HMI where the interlocks live; the MES's job is to make sure that action is captured, contextualised and, where required, signed off.
Frequently asked questions
Q.Is a PLC the same thing as a DCS?+
No. A PLC is a discrete controller running a fixed logic program, historically strongest for machine/skid/line control; a DCS is a distributed network of controllers with a unified engineering environment, historically strongest for large continuous processes with thousands of loops. The line has blurred as modern PLCs/PACs scale up, but the design centre and typical use case remain different.
Q.Where does SCADA fit relative to a PLC?+
SCADA is the supervisory layer above the PLC (ISA-95 Level 2): it polls or subscribes to PLC tags, presents operator screens, historises trends and raises alarms across possibly many PLCs/RTUs on a site or wide area. SCADA is a view and a data pipe — it isn't the QMS and shouldn't be treated as the system of record for GxP decisions.
Q.Can MES logic live inside a PLC program to save an integration?+
It can be made to work technically, but it's a design mistake in a regulated environment: ladder/ST logic has no native e-signature, document-version or user-account model, is validated on the automation team's cadence rather than QA's, and is invisible to the business-rule owner. Keep the interlock in the PLC; keep the business rule (approval, release, genealogy) in the MES.
Q.What GAMP 5 category does a typical process PLC fall into?+
Most process-control PLCs with site-written application logic (ladder/ST/SFC, HMI screens, alarms, recipe parameters) are GAMP 5 Category 4 — configured products — requiring URS through IQ/OQ/PQ. A fixed-function device with only vendor firmware and no custom logic is more often Category 3.
Q.Does 21 CFR Part 11 apply to a PLC?+
It applies whenever the PLC, its HMI or its historian functions as the system of record for a GxP electronic record or requires an electronic signature — for example if a critical process parameter is only captured at the HMI trend. That triggers requirements for attributable, contemporaneous, secure audit trails and identity-based access control, which many out-of-the-box HMIs don't provide without additional configuration or a layer above them.
Q.What is an 'orphan tag' and why does it matter?+
An orphan tag is a PLC or HMI data point that exists in the running program but isn't documented in the current tag map — often left behind by a decommissioned feature or an undocumented contractor change. It matters because during an investigation, nobody can quickly and confidently say what the tag does, whether it's GxP-relevant, or whether it's still wired to anything real.
Q.Should an MES ever write setpoints back to a PLC?+
Approved recipe parameters can flow from a validated, version-controlled MES recipe down to the PLC at batch start as part of a controlled recipe download — that's a documented, one-way, validated transfer. What shouldn't happen is an MES making ad hoc runtime writes to live PLC registers outside that controlled mechanism, because that blurs who owns real-time control and complicates both validation and incident investigation.
Q.Why do ladder logic programs need change control if they're 'just automation'?+
Because a PLC program is GxP-relevant configuration: a changed interlock, timer or alarm setpoint can directly affect a critical process parameter or a safety function. Undocumented field edits made during a breakdown are one of the most common sources of unexplained process drift found during investigations.
Primary sources
- IEC 61131-3 — Programmable controllers, Part 3: Programming languages
- ISA-95 / IEC 62264 — Enterprise-Control System Integration
- ISA-88 / IEC 61512 — Batch Control
- ISA-18.2 — Management of Alarm Systems for the Process Industries
- GAMP 5 (2nd ed.) — A Risk-Based Approach to Compliant GxP Computerized Systems
- 21 CFR Part 11 — Electronic Records; Electronic Signatures
- FDA — Data Integrity and Compliance With Drug CGMP: Questions and Answers
- OPC Foundation — OPC-UA specification overview
Further reading
- ISA-95The level model that separates PLC (L1) from MES (L3).
- MESConsumes PLC data; must never issue direct actuator commands.
- GAMP 5Software category framework used to scope PLC validation.
- IQ/OQ/PQThe validation lifecycle a PLC-controlled system runs through.
- 21 CFR Part 11Applies when a PLC or HMI is the system of record.
- Audit TrailWhat most stand-alone HMIs are missing on setpoint changes.
- Change ControlThe discipline that has to wrap every PLC program edit.
- CAPAWhere a repeated PLC/HMI-driven deviation escalates.
- SPCTurns PLC-acquired process data into a control chart.
- Alarm RationalizationISA-18.2 discipline for the alarms a PLC/DCS raises.
- Alarm Flood PreventionWhat happens when alarm handling on the control layer isn't rationalised.
- DeviationWhat an uncontrolled PLC setpoint change should trigger.
Want to see how PLC could fit into your own records and workflows? Explore the related V5 pages or talk to our team about what applies to your operation.
