PLC & Logic Control
How PLCs work, ladder logic, timers, structured text, wiring, sequences, worked programs and troubleshooting, with examples on Allen-Bradley, Siemens and other common platforms.
A programmable logic controller (PLC) is a rugged industrial computer that reads inputs (switches, sensors), runs a program and drives outputs (motors, valves, lamps) in a repeating scan. This guide takes you from how a PLC works, through ladder logic, timers, structured text, wiring and sequences, to worked programs and PLC troubleshooting, with the communications side covered in the Industrial Communication guide. Examples use the platforms you are most likely to meet: Allen-Bradley (Rockwell) and Siemens in the most detail, with notes for Mitsubishi, Omron, IDEC, Unitronics, AutomationDirect and CODESYS. Networking, protocols, cabling and communication troubleshooting have their own guide: Industrial Communication, and drives and motors on Motion Control.
Start here: what do you need?
| I need to… | Go to |
|---|---|
| understand the scan, the hardware and how PLC memory is organized | How PLCs Work |
| write or read ladder logic: motor start/stop, latches, interlocks | Ladder Logic in Practice |
| use timers, counters, compare, math and data types | Timers, Counters and Data |
| program in Structured Text, function blocks or SFC | Structured Text and the Other IEC Languages |
| wire inputs and outputs: sinking, sourcing, analog loops, relay and transistor outputs | I/O Wiring and Signals |
| build a sequence or state machine (tank, pick and place, traffic light) | Sequences and State Machines |
| start a motor, run a drive over the network or tune a PID loop | Motors, Drives and PID Control |
| see complete programs: conveyor sorter, tank control, batching, packing | Worked Examples |
| set up serial or Ethernet communications, Modbus or an IP address | Connecting PLCs, Drives and HMIs |
| find out why a link does not work: sniffers, adapters, Wireshark | Sniffers, Analyzers and Serial Tools |
| fault-find a machine, back up, commission or understand safety | PLC Troubleshooting, Safety and Documentation |
A suggested order
If you are new to PLCs, read the pages in this order. Each builds on the one before, and the previous and next links at the top and bottom of every page follow it. If you already program, jump to the page you need.
- How PLCs Work: Hardware and modules, memory and tags, the scan cycle, and a comparison of the common platforms.
- Ladder Logic in Practice: Contacts and coils, seal-in and interlock circuits, one-shots and latches, with the same rung shown on several platforms.
- Timers, Counters and Data: Timer and counter types, data types, math and compare, scaling, and the number mistakes that bite.
- Structured Text and the Other IEC Languages: Structured Text, function block, SFC and instruction list, with one example written several ways.
- I/O Wiring and Signals: Sinking and sourcing, relay and transistor outputs, analog signals, noise, grounding and surge protection.
- Sequences and State Machines: Step sequencing and state machines, with a traffic light, a tank filler and a pick-and-place cycle.
- Motors, Drives and PID Control: Motor starter circuits, variable frequency drive control, and PID set-up and tuning.
- Worked Examples: Four complete programs: a conveyor sorter, tank level control, a batching sequence and a bottle-packing line.
- PLC Troubleshooting, Safety and Documentation: Fault finding, forcing I/O, backups and version control, commissioning, lockout and safety standards.
The platforms used in this guide
The ideas are the same on every PLC; the names and the menus differ. Addresses, instruction names and software menus in this guide are typical examples: check the manual for your model and firmware.
| Platform | Software | Typical addressing | Notes |
|---|---|---|---|
| Allen-Bradley (Rockwell): ControlLogix, CompactLogix, Micro800 | Studio 5000 Logix Designer; Connected Components Workbench (Micro800) | Tags: Motor_Run, Local:1:I.Data.0 | Ladder, ST, FBD, SFC; EtherNet/IP native; dominant in North America |
| Siemens: S7-1200, S7-1500 | TIA Portal | %I0.0, %Q0.0, %M0.0, DB tags | Ladder (LAD), SCL (ST), FBD, GRAPH; PROFINET native; dominant in Europe |
| Mitsubishi: iQ-F (FX5), iQ-R | GX Works3 | X0 (inputs) and Y0 (outputs) in octal, M, D | Compact, widespread in Asia and in machine builders |
| Omron: CP1, NX/NJ | CX-Programmer, Sysmac Studio | 0.00 inputs, 100.00 outputs; or tags | Strong in packaging and motion; EtherCAT on NX/NJ |
| IDEC: FC6A | WindLDR | I0, Q0, M0, D0 | Low-cost micro PLCs |
| Unitronics: Vision, UniStream | Unilogic, VisiLogic | I 0, O 0, MB, MI | PLC with built-in HMI in one unit |
| AutomationDirect: Click, Productivity | Click Programming, Productivity Suite | X001, Y001, C1, DS1 | Inexpensive and popular with small machine builders and learners |
| CODESYS-based (Wago, Beckhoff, many others) | CODESYS and vendor variants | Tags (IEC 61131-3 style) | One IEC 61131-3 environment on hundreds of brands |
Quick reference
| Topic | Formula or rule | Page |
|---|---|---|
| Scan time | about input scan + program execution + output scan + communications | How PLCs Work |
| Analog scaling | EU = EUmin + (raw − rawmin) ÷ (rawmax − rawmin) × (EUmax − EUmin) | I/O Wiring and Signals |
| 4–20 mA to percent | % = (mA − 4) ÷ 16 × 100 | I/O Wiring and Signals |
| Siemens raw range | 0 to 27 648 counts for 4–20 mA or 0–10 V | I/O Wiring and Signals |
| Timer on-delay | output on when the enable has been on for the preset (T#5s in Siemens, .PRE in ms in Logix) | Timers, Counters and Data |
| Motor start/stop latch | Run = (Start OR Run) AND NOT Stop | Ladder Logic in Practice |
| PID output | u = Kp e + Ki ∫e dt + Kd de/dt | Motors, Drives and PID Control |
| VFD frequency to speed | rpm = 120 × f ÷ poles (synchronous speed) | Motors, Drives and PID Control |
| Modbus RTU character time | bits per character ÷ baud; frame gap at least 3.5 characters | Modbus RTU, ASCII and TCP |
| Modbus CRC-16 | polynomial A001 (hex), start FFFF, sent low byte first | Modbus RTU, ASCII and TCP |
| RS-485 bus check | about 60 Ω between A and B with two 120 Ω terminators | Sniffers, Analyzers and Serial Tools |
Choosing a language
| Language | Best for | Weak at |
|---|---|---|
| Ladder diagram (LD) | Discrete logic, interlocks, motor control, readable by electricians | Math, loops, text and complex data |
| Function block diagram (FBD) | Signal flow, analog processing, PID and drives | Sequences |
| Structured Text (ST) | Calculations, loops, arrays, strings, communications | Quick visual fault-finding for maintenance staff |
| Sequential Function Chart (SFC) | Step-by-step processes and batch sequences | Fine-grained logic inside a step |
| Instruction List (IL) | Old programs (deprecated in IEC 61131-3 third edition) | Almost everything new |
Most real programs mix languages: ladder for the machine’s interlocks, structured text for calculations and function blocks for the loops. Choose what the person who will fix it at 3 a.m. can read.
Calculators
- Modbus Frame and CRC Calculator: Build Modbus RTU requests, decode captured frames, check a CRC-16 and see the frame timing.
- 4–20 mA / 0–10 V Analog Scaling Tool: Convert a raw analog signal to engineering units and back.
- Motor Torque and Inertia Matching Calculator: Size a motor and check the inertia ratio.
Safety
- A standard PLC is not a safety device. Emergency stops, guard interlocks and light curtains must act through hard-wired or certified safety hardware. See PLC Troubleshooting, Safety and Documentation.
- Lock out before you touch anything. Isolate and verify the circuit is dead; discharge drive capacitors; release stored pneumatic and hydraulic energy.
- Never force or bypass a safety input or output.
- Test with the machine safe. Disconnect or uncouple loads for the first test of a new program, and keep the area clear.
- Follow the local rules (NFPA 79, NFPA 70E, IEC 60204-1, machine-specific standards) and your site’s procedures. This guide is for learning and is not a substitute for them.
FAQ
Which PLC should I learn first?
Learn the ideas first: they carry over. In North America start with Allen-Bradley Micro800 (free software) or an AutomationDirect Click (free software, low cost); in Europe and elsewhere, a Siemens S7-1200 with TIA Portal (a trial is available) or a CODESYS-based controller. Free simulators exist for several platforms.
What is the difference between a PLC and a microcontroller?
A PLC is built for the plant: isolated 24 V inputs and outputs, a rugged enclosure, a predictable scan, industrial networks, and tools for maintenance staff. A microcontroller (Arduino, ESP32) is cheaper and more flexible but needs extra hardware and care to survive industrial conditions. See Embedded Systems.
Do I need to know ladder logic?
Yes, for most plant work. It is the language electricians and technicians read, and most existing programs use it. Learn structured text as well for calculations.
Where do protocols like Modbus and EtherNet/IP fit?
They are how a PLC talks to drives, HMIs, remote I/O and other PLCs. The theory is on Industrial Communication; the hands-on set-up, cabling, security and troubleshooting are in the same guide, for example Connecting PLCs, Drives and HMIs and Sniffers, Analyzers and Serial Tools.
Can I practice without hardware?
Yes. Most vendors offer simulators (Siemens PLCSIM, Rockwell Emulate and Factory I/O-style simulators), CODESYS has a soft PLC, and low-cost hardware like a Click or Micro800 starter kit costs less than a textbook.
References
- IEC 61131-3, Programmable controllers: Programming languages.
- Petruzella, F., Programmable Logic Controllers, 5th ed., McGraw-Hill.
- Bolton, W., Programmable Logic Controllers, 6th ed., Newnes.
- Rockwell Automation, Logix 5000 Controllers General Instructions Reference Manual (1756-RM003); Siemens, S7-1200 System Manual and S7-1500 Function Manuals.
- Modbus Organization, MODBUS Application Protocol Specification V1.1b3; NFPA 79; IEC 60204-1; ISO 13849-1.
Last reviewed: October 2026. Instruction names, addresses and menu paths are typical: check the manual for your controller and software version, and follow the safety rules of your site.
