What is a PLC (Programmable Logic Controller)?
A PLC (Programmable Logic Controller) is an industrial computer designed to control machines and production lines, ruggedised to run 24/7 through dust, vibration, electrical noise and a wide temperature range. It reads inputs from the field, makes decisions according to the user program and drives the outputs.
How does a PLC work: the scan cycle
A PLC program repeats continuously in a loop. One scan cycle consists of:
- Read inputs: all input states are copied into an image memory.
- Execute the program: the logic runs from top to bottom against that copy.
- Write outputs: the calculated outputs are transferred to the physical outputs.
- Communication and diagnostics: network traffic and internal checks are handled.
Programs are written in the languages of IEC 61131-3: Ladder Diagram (LD), Function Block Diagram (FBD), Structured Text (ST) and Sequential Function Chart (SFC). Instruction List (IL) was deprecated in the third edition of the standard.
Worked example: worst-case response time
If an input changes just after the PLC has read its inputs, it is not seen until the next scan, and the output is written at the end of that scan. The worst-case response time is therefore roughly:
Response ≈ Input filter delay + 2 × Scan time + Output delay
With a 10 ms scan, a 3 ms input filter and a 10 ms relay output: 3 + 2 × 10 + 10 = 33 ms. On a fast filling machine this delay can overshoot the target weight because flow continues; in such applications the decision is made in a device closer to the measurement, or the delay is compensated for.
Common mistakes
- Word order of 32-bit values: Modbus registers are 16-bit, so a value like 125430 is carried in two registers (high word = 1, low word = 59894, because 1 × 65536 + 59894 = 125430). If the PLC reads the words swapped, the value shows as 59894 × 65536 + 1 = 3,925,213,185.
- Wrong analog scaling: forgetting to subtract 4 mA as zero on a 4-20 mA input shifts every reading. See 4-20 mA Current Loop.
- Not detecting a broken wire: current below 4 mA should be treated as a fault.
- Not measuring scan time: as the program grows, the scan gets longer and fast signals can be missed.
Sensor integration
Modern PLCs read not only on/off signals but also smart sensor data over protocols such as Modbus or Profinet. The GDT Digital Transmitter sends loadcell weight directly to the PLC over Modbus RTU/TCP. Amazeng ZMA Data Acquisition Cards act as an interface (gateway) that lets PLCs read analog signals with high precision. We discuss moving from PLC-based panels to Linux-based interfaces in PLC to Linux Panel Transition.
Related Terms
- What is Modbus RTU and Modbus TCP?How Modbus RTU and Modbus TCP work: RS-485 framing, function codes, CRC, the MBAP header, port 502 and the most common mistakes in the field.
- What is Profinet?What Profinet is: IO Controller and IO Device roles, RT and IRT communication, the GSDML file, differences from Profibus and common commissioning mistakes.
- What is 4-20mA Current Loop?How a 4-20mA current loop works: scaling formula, loop resistance budget, live-zero fault detection and how it compares with 0-10V signals.
- Basic Device Definitions: Sensor, Transducer, Transmitter, ActuatorSensor vs transducer vs transmitter vs actuator: their roles in the measurement and control loop, a 4-20 mA scaling example and commonly confused terms.
- What are Embedded Systems?What is an embedded system? MCU vs MPU, bare-metal vs RTOS vs embedded Linux, a real-time timing budget example and the role in industrial devices.