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.

1 Read inputsCopy field inputsinto the input image2 Run programSolve the logic once,top to bottom3 Write outputsCopy the output imageto the output modules4 HousekeepingCommunications,diagnostics, clockrepeats continuously: one pass is one scanTypical scan: a few milliseconds for small programs, longer as the program and I/O grow.
The scan cycle: read the inputs, run the program, write the outputs, handle communications, and repeat.

Start here: what do you need?

I need to…Go to
understand the scan, the hardware and how PLC memory is organizedHow PLCs Work
write or read ladder logic: motor start/stop, latches, interlocksLadder Logic in Practice
use timers, counters, compare, math and data typesTimers, Counters and Data
program in Structured Text, function blocks or SFCStructured Text and the Other IEC Languages
wire inputs and outputs: sinking, sourcing, analog loops, relay and transistor outputsI/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 loopMotors, Drives and PID Control
see complete programs: conveyor sorter, tank control, batching, packingWorked Examples
set up serial or Ethernet communications, Modbus or an IP addressConnecting PLCs, Drives and HMIs
find out why a link does not work: sniffers, adapters, WiresharkSniffers, Analyzers and Serial Tools
fault-find a machine, back up, commission or understand safetyPLC 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.

  1. How PLCs Work: Hardware and modules, memory and tags, the scan cycle, and a comparison of the common platforms.
  2. Ladder Logic in Practice: Contacts and coils, seal-in and interlock circuits, one-shots and latches, with the same rung shown on several platforms.
  3. Timers, Counters and Data: Timer and counter types, data types, math and compare, scaling, and the number mistakes that bite.
  4. Structured Text and the Other IEC Languages: Structured Text, function block, SFC and instruction list, with one example written several ways.
  5. I/O Wiring and Signals: Sinking and sourcing, relay and transistor outputs, analog signals, noise, grounding and surge protection.
  6. Sequences and State Machines: Step sequencing and state machines, with a traffic light, a tank filler and a pick-and-place cycle.
  7. Motors, Drives and PID Control: Motor starter circuits, variable frequency drive control, and PID set-up and tuning.
  8. Worked Examples: Four complete programs: a conveyor sorter, tank level control, a batching sequence and a bottle-packing line.
  9. 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.

PlatformSoftwareTypical addressingNotes
Allen-Bradley (Rockwell): ControlLogix, CompactLogix, Micro800Studio 5000 Logix Designer; Connected Components Workbench (Micro800)Tags: Motor_Run, Local:1:I.Data.0Ladder, ST, FBD, SFC; EtherNet/IP native; dominant in North America
Siemens: S7-1200, S7-1500TIA Portal%I0.0, %Q0.0, %M0.0, DB tagsLadder (LAD), SCL (ST), FBD, GRAPH; PROFINET native; dominant in Europe
Mitsubishi: iQ-F (FX5), iQ-RGX Works3X0 (inputs) and Y0 (outputs) in octal, M, DCompact, widespread in Asia and in machine builders
Omron: CP1, NX/NJCX-Programmer, Sysmac Studio0.00 inputs, 100.00 outputs; or tagsStrong in packaging and motion; EtherCAT on NX/NJ
IDEC: FC6AWindLDRI0, Q0, M0, D0Low-cost micro PLCs
Unitronics: Vision, UniStreamUnilogic, VisiLogicI 0, O 0, MB, MIPLC with built-in HMI in one unit
AutomationDirect: Click, ProductivityClick Programming, Productivity SuiteX001, Y001, C1, DS1Inexpensive and popular with small machine builders and learners
CODESYS-based (Wago, Beckhoff, many others)CODESYS and vendor variantsTags (IEC 61131-3 style)One IEC 61131-3 environment on hundreds of brands

Quick reference

TopicFormula or rulePage
Scan timeabout input scan + program execution + output scan + communicationsHow PLCs Work
Analog scalingEU = EUmin + (raw − rawmin) ÷ (rawmax − rawmin) × (EUmax − EUmin)I/O Wiring and Signals
4–20 mA to percent% = (mA − 4) ÷ 16 × 100I/O Wiring and Signals
Siemens raw range0 to 27 648 counts for 4–20 mA or 0–10 VI/O Wiring and Signals
Timer on-delayoutput 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 latchRun = (Start OR Run) AND NOT StopLadder Logic in Practice
PID outputu = Kp e + Ki ∫e dt + Kd de/dtMotors, Drives and PID Control
VFD frequency to speedrpm = 120 × f ÷ poles (synchronous speed)Motors, Drives and PID Control
Modbus RTU character timebits per character ÷ baud; frame gap at least 3.5 charactersModbus RTU, ASCII and TCP
Modbus CRC-16polynomial A001 (hex), start FFFF, sent low byte firstModbus RTU, ASCII and TCP
RS-485 bus checkabout 60 Ω between A and B with two 120 Ω terminatorsSniffers, Analyzers and Serial Tools

Choosing a language

LanguageBest forWeak at
Ladder diagram (LD)Discrete logic, interlocks, motor control, readable by electriciansMath, loops, text and complex data
Function block diagram (FBD)Signal flow, analog processing, PID and drivesSequences
Structured Text (ST)Calculations, loops, arrays, strings, communicationsQuick visual fault-finding for maintenance staff
Sequential Function Chart (SFC)Step-by-step processes and batch sequencesFine-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

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.