Programmable logic controllers in manufacturing

PLC hardware, the scan cycle, ladder logic with seal-in, timers and counters, IEC 61131-3 languages, response time and signal-detection limits.

Drafted with Aria, reviewed by the AiCanCode.org team. Spotted an error? Use Give Feedback at the bottom of the page.

Why it matters

Behind every conveyor, press, packaging machine, robot cell and FMS there is discrete logic: "if the guard is closed and the part is present, start the clamp; after 2 s, start the spindle". Programmable logic controllers (PLCs) replaced cabinets of hard-wired relays for this job in the 1970s and are still the workhorse of factory automation. A production engineer must be able to read a ladder diagram, understand the scan cycle and judge whether a PLC is fast enough for a signal.

Key ideas

What a PLC is. A microprocessor-based controller with ruggedised hardware, designed to read discrete and analog inputs, execute a stored program of logic, timing, counting, sequencing and arithmetic, and drive outputs — in electrically noisy, hot, vibrating environments, continuously.

Why it replaced relays. Relay logic is changed by rewiring; a PLC by editing the program. PLCs are smaller, more reliable (no mechanical contacts in the logic), cheaper for anything beyond a few relays, provide timers and counters without extra hardware, and give diagnostics and network communication.

Components.

  • Processor (CPU) and memory — executes the program; memory holds the program, the input/output image tables and data (timers, counters, registers).
  • Input modules — discrete (limit switches, push buttons, proximity sensors, photo-eyes) and analog (4–20 mA, 0–10 V from temperature, pressure, level transmitters); they isolate and filter field signals.
  • Output modules — relay, transistor or triac outputs driving solenoid valves, contactors, lamps; analog outputs to drives and valves.
  • Power supply, programming device (PC software or handheld) and, usually, an HMI and network interfaces. PLCs come as compact (fixed I/O) or modular (rack-mounted cards) units.

The scan cycle. A PLC repeats one cycle continuously:

  1. Input scan — read every input into the input image table.
  2. Program scan — execute the program rung by rung, top to bottom, left to right, using the image table.
  3. Output scan — copy the output image table to the physical outputs.
  4. Housekeeping — communications and self-diagnostics. Because inputs are read only once per scan, an input that turns ON and OFF between two input scans can be missed, and the response to an input can take up to about two scans plus the module delays.

Ladder logic. The most common language, drawn like a relay diagram between two vertical power rails.

  • Normally open contact ] [ — true when the input bit is 1. Normally closed contact ]/[ — true when the bit is 0.
  • Contacts in series make AND; in parallel, OR. The coil ( ) at the right energises when the rung is true.
  • Seal-in (latching) circuit: a START push button in parallel with a contact of the motor's own output, in series with a normally closed STOP — the motor stays on after START is released until STOP is pressed. In Boolean form M = (START + M) · STOP′.
  • Timers: on-delay (TON) — output turns ON after the input has been true for the preset time; off-delay (TOF); retentive (RTO).
  • Counters: up (CTU) and down (CTD) counters with preset values, reset by a separate instruction. IEC 61131-3 defines five languages: ladder diagram (LD), function block diagram (FBD), structured text (ST), instruction list (IL, now deprecated) and sequential function chart (SFC).

Safety. Stop and emergency-stop buttons are wired as normally closed field contacts so that a broken wire stops the machine (fail-safe). Emergency-stop circuits must also act through hard-wired safety relays or a safety-rated PLC, not only through ordinary program logic.

Formulas

T_scan = T_in + T_prog + T_out + T_hk

  • Scan time (ms) = input scan + program execution + output update + housekeeping.

T_prog = n_i · t_i

  • n_i number of instructions; t_i average execution time per instruction (ms).

T_resp,max ≈ T_filter + 2 · T_scan + T_outdelay

  • Worst-case response (ms) from a field input change to the output terminal: the input can change just after an input scan, so it waits almost one scan to be read and one more to be solved and written out.

t_on = L / v ≥ T_filter + T_scan

  • For a part of length L (m) passing a sensor at speed v (m/s), the signal must last at least an input filter time plus one scan (s) to be detected reliably.

Worked examples

Example 1 (standard). A PLC program has 4000 instructions at 0.75 µs each. I/O update takes 2 ms and housekeeping 1 ms. The input filter is 10 ms and the output module delay 1 ms. Find the scan time and the worst-case response time.

  1. T_prog = n_i · t_i = 4000 × 0.75 µs = 3000 µs = 3 ms.
  2. T_scan = 3 + 2 + 1 = 6 ms.
  3. T_resp,max ≈ 10 + 2 × 6 + 1 = 23 ms.

Example 2 (GATE level). (a) A rung energises output Y when (A AND B) OR (C AND NOT D). Find Y for A = 1, B = 0, C = 1, D = 0, and for A = 1, B = 0, C = 1, D = 1. (b) Boxes 40 mm long pass a photo-eye on a conveyor. The input filter is 10 ms and the scan time 8 ms. Find the maximum conveyor speed for reliable counting.

  1. (a) Y = A·B + C·D′. First case: A·B = 0; C·D′ = 1 · 1 = 1 → Y = 1.
  2. Second case: A·B = 0; C·D′ = 1 · 0 = 0 → Y = 0.
  3. (b) Required ON time ≥ 10 + 8 = 18 ms = 0.018 s.
  4. t_on = L / v ≥ 0.018 → v ≤ 0.040/0.018 = 2.22 m/s.
  5. Above this speed some boxes would be missed — use a faster scan, an interrupt or a high-speed counter input.

Common mistakes

  • Using a normally closed program contact for a STOP button that is already wired normally closed in the field — the logic inverts and the motor will not start.
  • Assuming the PLC reacts instantly; response can be two scans plus module delays.
  • Forgetting the seal-in contact, so the motor stops as soon as START is released.
  • Writing the same output coil on two rungs — only the last one evaluated wins.
  • Relying only on program logic for an emergency stop.

For GATE PI

Expect MCQs on PLC components, the scan cycle, ladder symbols and IEC 61131-3 languages, and on PLC versus relay logic. Short numericals ask for scan time, worst-case response time, or the maximum speed or minimum pulse width for reliable detection; logic questions ask for the output of a ladder rung or the Boolean expression of a circuit such as the seal-in. Practise converting ladder rungs to Boolean expressions and back.

Quick check

  1. In which order does a PLC execute the scan cycle?
  2. Write the Boolean expression for a start/stop seal-in circuit with motor M.
  3. Contacts in series represent which logic function?
  4. Scan time 12 ms, input filter 5 ms, output delay 2 ms. Estimate the worst-case response.
  5. Why are STOP buttons wired normally closed?

Answers: 1. Input scan, program scan, output scan, housekeeping. 2. M = (START + M)·STOP′. 3. AND. 4. 5 + 2 × 12 + 2 = 31 ms. 5. So that a broken wire or loose terminal stops the machine (fail-safe).

Try answering each one aloud before you open it.

  1. 1.What is a Programmable Logic Controller (PLC) in the context of manufacturing?Concept

    A Programmable Logic Controller (PLC) is an industrial digital computer designed to control manufacturing processes, such as assembly lines or robotic devices. It is used to automate specific processes, machine functions, or even entire production lines. PLCs are highly reliable and can operate in harsh industrial environments.

  2. 2.Explain the basic components of a PLC system.Concept

    A PLC system typically consists of a processor (CPU), input/output (I/O) modules, power supply, and a programming device. The CPU executes control instructions based on the program stored in its memory. I/O modules connect the PLC to sensors and actuators, allowing it to receive inputs and send outputs. The power supply provides the necessary electrical power, and the programming device is used to write and load the control program into the PLC.

  3. 3.How does a PLC differ from a traditional computer?Concept

    PLCs are designed specifically for industrial control applications and are more robust than traditional computers. They can withstand extreme temperatures, vibrations, and electrical noise. Unlike traditional computers, PLCs are optimized for real-time control and can handle multiple inputs and outputs simultaneously. They also have a simpler user interface and are programmed using ladder logic or other specialized languages.

  4. 4.Why are PLCs preferred over relay-based control systems in modern manufacturing?Application

    PLCs are preferred over relay-based systems because they offer greater flexibility, reliability, and ease of programming. They can be easily reprogrammed to accommodate changes in the production process, whereas relay-based systems require physical rewiring. PLCs also provide better diagnostics and troubleshooting capabilities, reducing downtime and maintenance costs.

  5. 5.What happens if a PLC fails during a manufacturing process?Application

    If a PLC fails during a manufacturing process, it can lead to a halt in production, potentially causing significant downtime and financial loss. Most PLC systems are designed with fail-safe mechanisms and redundancy to minimize the impact of a failure. In critical applications, backup PLCs or redundant systems are used to ensure continuous operation.

  6. 6.Explain how ladder logic is used in programming PLCs.Concept

    Ladder logic is a graphical programming language used to develop software for PLCs. It resembles electrical relay logic diagrams and consists of rungs that represent control logic. Each rung contains inputs (conditions) and outputs (actions), and the logic is executed from left to right, top to bottom. Ladder logic is intuitive for engineers familiar with electrical control systems and allows for easy troubleshooting and modification.

  7. 7.In what scenarios would you use a PLC over a microcontroller in manufacturing?Application

    PLCs are used over microcontrollers in scenarios where industrial-grade reliability, robustness, and ease of integration with existing industrial systems are required. They are ideal for complex control tasks involving multiple I/O points, real-time processing, and harsh environmental conditions. Microcontrollers might be used for simpler, less demanding applications where cost is a primary concern.

  8. 8.What are the advantages of using PLCs in a distributed control system (DCS)?Application

    PLCs offer several advantages in a distributed control system, including modularity, scalability, and ease of integration. They can be distributed across different locations within a plant, allowing for localized control and reducing the complexity of wiring. PLCs also provide real-time processing capabilities and can be easily networked to communicate with other control systems, enhancing overall system flexibility and efficiency.

Finished this topic? Mark it so your progress, study plan and readiness keep up.

Stuck on something here?