Learn PLC: What Is a Programmable Logic Controller and Why It Rules Factories?
What Is a Programmable Logic Controller?
A Programmable Logic Controller (PLC) is a ruggedized industrial computer designed to control manufacturing processes. Unlike a desktop PC, a PLC is built to survive harsh factory environments: extreme temperatures, dust, vibration, and electrical noise.
A PLC reads inputs from sensors and switches, executes a user-written program, and drives outputs such as motors, valves, and indicator lights. The entire process repeats continuously in a deterministic loop, making PLCs the backbone of modern industrial automation.
Key characteristics that distinguish a PLC from a general-purpose computer:
- Deterministic execution: the program runs in a fixed, predictable cycle time, guaranteeing response within milliseconds
- Rugged construction: designed for -20 to 60 degrees Celsius, high humidity, and vibration
- Real-time I/O: direct connection to sensors and actuators with millisecond response
- High reliability: mean time between failures measured in decades, not years
- Hot-swappable modules: replace faulty I/O cards without powering down the entire system
- Wide operating voltage: tolerant of industrial power fluctuations and brownouts
PLCs range from micro-controllers with 10 I/O points for a single machine to large rack-mounted systems with thousands of I/O points controlling an entire production line. Regardless of size, the fundamental operating principle is the same: read inputs, execute the program, update outputs, and repeat.
A PLC is not a general-purpose computer. It does not run a desktop operating system, does not connect to the internet by default, and does not execute arbitrary applications. It runs one program, written by the automation engineer, dedicated entirely to controlling the machine or process it was installed for. This single-purpose design is what makes PLCs so reliable.
PLC vs PC-Based Control
Some modern systems use industrial PCs (IPCs) with soft-PLC software like Beckhoff TwinCAT. These systems run PLC programs on a Windows or Linux computer with a real-time kernel. While IPCs offer more processing power and flexibility, traditional PLCs remain dominant in the field because of their simplicity, proven reliability, and the fact that maintenance technicians can troubleshoot them without IT knowledge.
From Relays to PLCs: The Story
Before PLCs existed, factories used hardwired relay panels to control machines. A simple motor start-stop circuit might require dozens of physical relays, timers, and miles of wiring. Changing the logic meant rewiring the entire panel, a process that could take days or weeks.
In 1968, General Motors issued a specification for an electronic replacement for relay panels. The result was the first PLC, the Modicon 084, developed by Dick Morley and his team. The key innovation was replacing physical relay wiring with a software program that could be changed without touching a single wire.
The evolution of PLC technology across the decades:
- 1970s: first commercial PLCs replace relay panels, programming via dedicated terminals
- 1980s: communication networks appear, PLCs begin talking to each other
- 1990s: IEC 61131-3 standard unifies programming languages across manufacturers
- 2000s: Ethernet-based protocols and web servers integrated into PLCs
- 2010s-present: cloud connectivity, edge computing, and integration with IT systems
The transition from relays to PLCs reduced panel wiring by up to 80 percent, cut commissioning time from weeks to days, and made logic changes possible with a laptop instead of a soldering iron. Today, relay panels are found only in the simplest circuits or in legacy installations awaiting modernization.
The IEC 61131-3 standard, first published in 1993, was a turning point. Before this standard, every manufacturer used proprietary programming languages and tools. After the standard, five common languages were defined:
- Ladder Diagram (LD): graphical, resembles electrical relay schematics
- Structured Text (ST): text-based, resembles Pascal or C
- Function Block Diagram (FBD): graphical, connects function blocks with signal lines
- Instruction List (IL): text-based, resembles assembly language (now deprecated)
- Sequential Function Chart (SFC): graphical, models sequential processes as steps and transitions
This meant that an engineer trained on one platform could quickly adapt to another. In this series, we focus on Ladder Diagram and Structured Text, as they are the two most widely used languages in industry today.
How a PLC Works: The Scan Cycle
Every PLC operates on a continuous loop called the scan cycle. Understanding this cycle is fundamental to writing correct PLC programs. The scan cycle has three main phases:
Phase 1 - Input Scan: The PLC reads the current state of all physical inputs (sensors, switches, pushbuttons) and stores them in an input image table in memory. During program execution, the PLC works with this snapshot, not the live inputs.
Phase 2 - Program Execution: The CPU processes the user program from top to bottom, evaluating logic and computing outputs. All results are written to an output image table in memory, not directly to physical outputs.
Phase 3 - Output Update: The PLC transfers the output image table to the physical output modules, turning real-world devices on or off simultaneously.
A typical scan cycle completes in 1 to 50 milliseconds, depending on program size and CPU speed. For a packaging machine running at 200 packages per minute, a 10ms scan cycle means the PLC evaluates the program 100 times per second.
The scan cycle also includes housekeeping tasks:
- Communication processing: responding to HMI requests, exchanging data with other PLCs
- Self-diagnostics: checking memory integrity, monitoring CPU temperature
- Watchdog timer management: detecting if the scan takes too long, which indicates a program error or infinite loop
Understanding the scan cycle explains important PLC behaviors. An input that changes and returns within a single scan may never be seen by the program. Two outputs assigned in the same scan will appear to change simultaneously in the real world. These are not bugs; they are consequences of the scan-based execution model.
Scan Time and Performance
Scan time is a critical performance metric. Factors that affect scan time include:
- Program size: more instructions take more time to execute
- Number of I/O modules: more modules require more time for input and output scans
- Communication load: more HMI screens and network traffic increase housekeeping time
- Instruction complexity: floating-point math takes longer than simple boolean logic
If the scan time exceeds the watchdog timer setting (typically 100-500ms), the PLC enters a fault state and stops all outputs. This is a safety feature that prevents the PLC from running with stale data.
Where PLCs Are Used in the Factory
PLCs are found in virtually every industrial setting. Here are some common applications:
- Conveyor systems: controlling belt speed, routing products to different lanes, tracking items using photoeyes and encoders
- Filling machines: precisely controlling liquid volumes using flow meters and valves, ensuring every bottle receives the correct amount
- Packaging lines: coordinating multiple stations for wrapping, sealing, labeling, and palletizing finished products
- Water treatment: monitoring pH levels, controlling chemical dosing pumps, managing filtration cycles and backwash sequences
- HVAC systems: regulating temperature, humidity, and air pressure in clean rooms and production areas
- Power generation: managing turbine speed, generator synchronization, and load distribution across the grid
In a typical bottling plant, a single PLC might control the entire filling line: detecting empty bottles via proximity sensors, positioning them under fill nozzles, controlling the fill volume, capping, and labeling. The same PLC monitors safety interlocks and reports production counts to the factory management system.
In food processing, PLCs manage pasteurization temperatures, conveyor speeds for cooling tunnels, and batch mixing sequences where ingredients must be added in precise order and timing. The deterministic scan cycle guarantees that time-critical operations execute reliably every cycle, whether the plant has been running for one hour or one month.
Beyond discrete manufacturing, PLCs are increasingly found in building automation, infrastructure management, and even agriculture. Greenhouse climate controllers, irrigation systems, and grain elevator controls all use PLCs. The common thread is always the same: reading sensors, making decisions, and controlling actuators in real time.
The scale of PLC deployment in a modern factory can be significant. A large automotive assembly plant may have over 100 PLCs coordinating welding robots, conveyor transfers, paint booth controls, and quality inspection stations. Each PLC handles its local area, and all communicate over an industrial network to synchronize the overall production flow.
Major PLC Manufacturers
The PLC market is dominated by several key manufacturers, each with their own programming environments and communication protocols:
| Manufacturer | Popular Series | Software | Strength |
|---|---|---|---|
| Siemens | S7-1200, S7-1500 | TIA Portal | Dominant in Europe and Middle East |
| Allen-Bradley | CompactLogix, ControlLogix | Studio 5000 | Dominant in North America |
| Schneider Electric | Modicon M340, M580 | EcoStruxure | Strong in process industries |
| Mitsubishi | MELSEC iQ-R, FX5 | GX Works3 | Dominant in Asia |
| Omron | NX/NJ Series | Sysmac Studio | Strong in motion control |
| Beckhoff | CX Series | TwinCAT 3 | PC-based control, EtherCAT |
All major manufacturers support the IEC 61131-3 standard, which means the Structured Text code you learn in this series will transfer across platforms with minimal changes. The concepts of ladder logic, timers, counters, and function blocks are universal across every manufacturer and every industry.
Choosing a PLC platform depends on the region, the industry, and the existing installed base. A factory in Saudi Arabia with Siemens equipment will naturally standardize on S7-1500 controllers. A plant in the United States with Allen-Bradley infrastructure will continue with ControlLogix. The programming concepts taught in this series remain identical regardless of the platform you choose, because the IEC 61131-3 standard ensures a common foundation.
For learning and experimentation, CODESYS provides a free soft-PLC development environment that supports all five IEC 61131-3 languages and can simulate a complete PLC on your personal computer. Many of the code examples in this series are written in CODESYS-compatible Structured Text.
Summary
A PLC is a purpose-built industrial computer that reads sensors, executes a program in a deterministic scan cycle, and drives outputs to control machinery. PLCs replaced hardwired relay panels starting in the late 1960s, and the IEC 61131-3 standard now provides a common set of programming languages across all major manufacturers. PLCs are found in every type of factory, from bottling plants and food processing to water treatment and power generation. In the following lessons, we will explore PLC hardware, then move into programming with Ladder Logic and Structured Text to build real industrial control applications.