Ladder Logic Programming — Symbols, Scan Cycle, Basic Programs & Best Practices - ELECTRICAL ENCYCLOPEDIA

Ladder Logic Programming — Symbols, Scan Cycle, Basic Programs & Best Practices

Ladder Logic (LD) is the most widely used programming language for Programmable Logic Controllers (PLCs). It uses a graphical notation that resembles electrical relay circuit diagrams — making it intuitive for electricians and control engineers who already understand relay logic. Ladder Logic is one of five languages defined in the IEC 61131-3 international standard for PLC programming.

What is Ladder Logic?

Ladder Logic is a graphical programming language where instructions are arranged between two vertical lines (power rails) in horizontal rows called rungs. Each rung represents one logical operation — just like one line in a relay control circuit.

The program reads left-to-right, top-to-bottom. Conditions (inputs) are placed on the left side of a rung, and actions (outputs) on the right side. If all conditions in a rung evaluate to TRUE, the output is energized.

IF (conditions are TRUE) → THEN (energize output)

This mirrors how a physical relay circuit works: current flows from left rail through contacts (conditions) to the coil (output) on the right rail.

Why Ladder Diagram?

Before PLCs existed (pre-1970s), industrial control was done with hardwired relay panels — hundreds of relays, timers, and contactors wired together. When PLCs replaced these panels, engineers needed a programming method that:

  • Looked familiar to electricians maintaining the systems
  • Could be understood without computer science background
  • Mapped directly to physical I/O wiring
  • Allowed troubleshooting with the same logic as relay circuits

Ladder Logic achieved all four — which is why it remains the dominant PLC language 50+ years later, especially for discrete (on/off) manufacturing and machine control.

Ladder Logic Symbols

Symbol Name Function Relay Equivalent
—| |— Normally Open (NO) Contact TRUE when input is ON Push button (NO)
—|/|— Normally Closed (NC) Contact TRUE when input is OFF E-stop (NC)
—( )— Output Coil Energizes when rung is TRUE Relay coil / contactor
—(S)— Set (Latch) Coil Turns ON and stays ON Latching relay (set)
—(R)— Reset (Unlatch) Coil Turns OFF and stays OFF Latching relay (reset)
—[TON]— Timer On-Delay Output ON after preset time Time-delay relay
—[CTU]— Counter Up Counts input transitions Mechanical counter

Program Structure — Rungs, Rails & Scan Cycle

Program elements:

  • Left power rail — represents +V supply (always energized)
  • Right power rail — represents return/common
  • Rungs — horizontal lines between rails, each containing one logic operation
  • Contacts — placed on the left side (conditions/inputs)
  • Coils — placed on the right side (outputs/actions)

Series = AND logic: Contacts in series — ALL must be TRUE for output to energize.

Parallel = OR logic: Contacts in parallel (branching) — ANY one TRUE energizes output.

The PLC Scan Cycle:

  • Step 1 — Input scan: Read all physical inputs into input memory table
  • Step 2 — Program execution: Execute ladder rungs top-to-bottom, left-to-right
  • Step 3 — Output update: Write output memory table to physical outputs
  • Step 4 — Housekeeping: Communication, diagnostics, watchdog timer
  • Repeat: Typical scan time = 1–20 ms depending on program size
Scan Time = Input Scan + Program Execution + Output Update + Overhead
Typical: 5–10 ms for 1000 rungs

Basic Ladder Programs

Program 1: Simple Motor Start/Stop (3-wire control)

The most fundamental industrial circuit — START button (NO), STOP button (NC), with self-holding contact:

  • Rung 1: [START (NO)] OR [MOTOR_AUX (NO)] AND [STOP (NC)] AND [OVERLOAD (NC)] → (MOTOR)
  • When START is pressed, MOTOR energizes
  • MOTOR_AUX contact seals in (self-holding) — motor stays running after START is released
  • STOP (NC) or OVERLOAD (NC) breaks the circuit → motor stops

Program 2: Forward/Reverse with Interlocking

  • Rung 1: [FWD_BTN] AND [/REV_RUNNING] AND [STOP (NC)] → (FWD_CONTACTOR)
  • Rung 2: [REV_BTN] AND [/FWD_RUNNING] AND [STOP (NC)] → (REV_CONTACTOR)
  • The /REV_RUNNING contact in Rung 1 prevents forward if reverse is active (and vice versa)
  • This software interlock works alongside the electrical interlock in the power circuit

Program 3: Sequence Control (Conveyor → Drill → Clamp)

  • Rung 1: [START] AND [PART_SENSOR] → (CONVEYOR)
  • Rung 2: [POSITION_SENSOR] → (CLAMP) — part in position, clamp it
  • Rung 3: [CLAMP_CONFIRMED] → TON (T1, 2s) — wait for clamp to seat
  • Rung 4: [T1.DN] → (DRILL_DOWN) — timer done, start drilling
  • Rung 5: [DRILL_DEPTH_SENSOR] → (DRILL_UP) AND (R CLAMP) — retract drill, release clamp

Timers and Counters

Timer Types:

Type Behavior Use Case
TON (On-Delay) Output ON after input stays TRUE for preset time Star-delta transition delay, debouncing
TOF (Off-Delay) Output stays ON for preset time after input goes FALSE Cooling fan run-on after motor stops
TP (Pulse) Output ON for fixed duration regardless of input Alarm hooter pulse, one-shot signal
RTO (Retentive) Accumulates time across multiple activations Total machine run-hours, maintenance timers

Counter Types:

  • CTU (Count Up) — increments on each rising edge, output when count ≥ preset
  • CTD (Count Down) — decrements from preset, output when count = 0
  • CTUD (Up/Down) — bidirectional counting

Example: Count 10 parts on a conveyor, then activate a packing station:

  • Rung 1: [PART_SENSOR] → CTU (C1, Preset=10)
  • Rung 2: [C1.DN] → (PACK_STATION) AND (RES C1) — done counting, activate packer and reset

Ladder vs FBD vs Structured Text

Aspect Ladder (LD) Function Block (FBD) Structured Text (ST)
Best for Discrete logic, interlocks Analog processing, PID Math, data manipulation
Readability Easy for electricians Easy for control engineers Easy for programmers
Debugging Excellent (live animation) Good (signal flow) Harder (text-based)
Complex math Poor (clumsy) Moderate Excellent
Industry share ~70% (dominant) ~15% ~10%

Modern PLC software (Siemens TIA Portal, Allen-Bradley Studio 5000, Codesys) supports all five IEC 61131-3 languages. Most industrial programs use Ladder for discrete logic and Structured Text for calculations — mixed within the same project.

Best Practices

  • One output per rung — never use the same coil address in multiple rungs (last rung wins)
  • Use descriptive tag names — CONVEYOR_MOTOR_FWD not Q0.1
  • Comment every rung — describe the function, not the code
  • Emergency stop first — always check E-stop in the first rung or as a master condition
  • Avoid complex nesting — if logic needs more than 3-4 branches, use intermediate flags
  • Test with simulation — all PLC software includes offline simulation mode
  • Document I/O mapping — maintain a spreadsheet of physical address ↔ tag name ↔ terminal number

FAQs

Is Ladder Logic still used in industry?

Yes — Ladder Logic accounts for approximately 70% of all PLC programming worldwide. It dominates in discrete manufacturing, packaging, material handling, and machine building. Its visual resemblance to relay circuits makes it accessible to maintenance electricians who need to troubleshoot on the factory floor.

Can Ladder Logic handle analog signals?

Yes, but it's clumsy for complex analog processing. Modern PLCs use Ladder for discrete logic (start/stop, interlocks) and switch to Function Block Diagram or Structured Text for PID loops, scaling, and mathematical calculations — all within the same program.

What is a self-holding contact in Ladder Logic?

A self-holding (or seal-in) contact is an auxiliary NO contact of the output coil placed in parallel with the START button. Once the output energizes, this contact maintains the circuit even after the START button is released. The STOP button (NC) breaks the seal-in circuit to de-energize the output.

What is the difference between Ladder Logic and relay logic?

Relay logic uses physical hardware (relay coils, contacts, wires) that cannot be easily modified. Ladder Logic is software that executes in a PLC — changes require only reprogramming, not rewiring. Ladder Logic also adds capabilities impossible with relays: timers, counters, math operations, communication, and data logging.

How do I learn Ladder Logic programming?

Start with a free PLC simulator (Codesys, Do-More Designer, or Siemens TIA Portal trial). Practice the basic circuits: motor start/stop, forward/reverse, traffic light sequence, conveyor counting. Then connect to a real PLC training kit for hands-on I/O wiring experience.

Related Articles

No comments:

Post a Comment