Learn PLCs free
Programming Examples15 min read2,948 words

PLC Programming Languages: IEC 61131-3 Examples (2026)

Compare Structured Text, Ladder Diagram, Function Block Diagram and SFC structuring with one matched example, vendor limits and the Edition 4 change to legacy IL.

PPI
PLC Programming IO Editorial Team
Sourced guidance with documented review and correction standards

IEC 61131-3:2025 Edition 4 specifies one textual language—Structured Text (ST)—and two graphical languages: Ladder Diagram (LD) and Function Block Diagram (FBD). It also defines Sequential Function Chart (SFC) graphical and equivalent textual elements for structuring programs and function blocks. Instruction List (IL) is not included in that current suite, although vendor tools can retain legacy mnemonic languages.

For the system-level model behind these representations—field I/O, scan scheduling, program organization, software selection and commissioning boundaries—start with the PLC programming guide.

That is more precise than the familiar “five PLC languages” shortcut:

Current IEC 61131-3:2025 description Practical role
Structured Text (ST) Textual control logic, calculations, arrays and algorithms
Ladder Diagram (LD) Graphical Boolean, interlock and sequence logic
Function Block Diagram (FBD) Graphical signal flow and stateful block networks
Sequential Function Chart (SFC) elements Organize programs/function blocks into steps, transitions and actions
Instruction List (IL) Legacy vendor maintenance context; not in the Edition 4 suite

Primary standard record—reviewed July 25, 2026: the IEC lists IEC 61131-3:2025, Edition 4, published May 22, 2025. The IEC page expressly describes ST, LD and FBD, then separately describes SFC elements. The examples below are original teaching material, not excerpts from the paid standard.

Industrial training cell showing one machine-control requirement represented as ladder, function blocks, structured text, a sequence chart and a legacy mnemonic listing.
One control requirement can be represented in several ways. Language choice should improve review and maintenance—not change the required behavior.

Which PLC Language Should You Learn First?

Start with Ladder Diagram if your immediate goal is discrete machine troubleshooting or maintenance. Add Structured Text next because it expresses calculations, loops, arrays and reusable algorithms more clearly. Learn Function Block Diagram for signal-processing and process-control work. Learn SFC when a machine or batch is easiest to reason about as named states and transitions.

Use this decision table:

Requirement Strong starting representation Why
Start/stop, permissives, interlocks LD The condition path is visible during online diagnosis
Scaling, formulas, arrays, recipes ST Text handles expressions and indexed data compactly
PID, analog conditioning, signal chains FBD Connections make data flow visible
Fill, mix, drain or multi-stage machine cycle SFC elements or an explicit state machine States, transitions and recovery paths are first-class
Existing mnemonic/list routine Legacy IL or vendor mnemonic for maintenance only Preserve behavior until a tested migration is justified

This is a starting point, not a universal ranking. The final choice depends on the exact CPU, engineering software, safety environment, team and lifecycle.

A Matched Motor Example

The requirement:

  • Start latches a run request.
  • Stop removes the request.
  • An overload fault prevents and stops running.
  • Stop/fault must dominate Start.
  • The output follows the validated run request.

Define:

Variable Type Meaning
StartPB BOOL TRUE while the start command is present
StopPB BOOL TRUE while stop is requested
OverloadFault BOOL TRUE while the overload is faulted
RunCmd BOOL Internal latched run state
MotorOut BOOL Output request to the motor-control interface

Ladder Diagram

|----[/ StopPB ]----[/ OverloadFault ]----+----[ StartPB ]----( RunCmd )----|
|                                         |                                 |
|                                         +----[ RunCmd ]--------------------|

|----[ RunCmd ]--------------------------------------------( MotorOut )-------|

The visual branch shows the seal-in path. Stop and overload conditions surround both branches, so either removes the latch.

Structured Text

RunCmd := (StartPB OR RunCmd)
          AND NOT StopPB
          AND NOT OverloadFault;

MotorOut := RunCmd;

The same Boolean expression is compact and easy to diff. It must still be assigned to the correct task and tested scan by scan.

Function Block Diagram

StartPB ----\
             OR ----\
RunCmd -----/        \
                      AND ---- RunCmd
NOT StopPB ----------/
NOT OverloadFault ---/

RunCmd ---------------------- MotorOut

In an actual FBD editor, use explicit NOT/OR/AND elements or the platform's documented equivalents. Feedback from RunCmd creates the latch.

SFC structuring

For a larger sequence, represent the motor command as states:

[STOPPED]
   |
   | StartPB AND NOT StopPB AND NOT OverloadFault
   v
[RUNNING]  action: RunCmd := TRUE
   |
   | StopPB OR OverloadFault
   v
[STOPPED]  action: RunCmd := FALSE

SFC is useful when this motor is one step in a machine cycle. For a two-state latch alone, LD or ST is usually simpler.

Legacy Instruction List

A vendor's old mnemonic language might resemble:

LD      StartPB
OR      RunCmd
ANDN    StopPB
ANDN    OverloadFault
ST      RunCmd

This is conceptual legacy syntax, not a portable program. Mnemonics, operand order and Boolean behavior differ by vendor. Do not create new code from this sample without the exact legacy manual.

Test the requirement, not the drawing style

Run the same tests in every representation:

Test Start Stop Fault Expected RunCmd
Cold start 0 0 0 0
Start pulse 1 0 0 1
Start released 0 0 0 1
Stop 0 1 0 0
Start and Stop together 1 1 0 0
Start with overload 1 0 1 0
Overload while running 0 0 1 0
Fault clears 0 0 0 0 until a new Start

If two language versions do not pass the same table, they are not equivalent.

The same guarded motor-control requirement represented in Ladder Diagram, Structured Text, Function Block Diagram, and sequential-state form
Editorial illustration: different representations are equivalent only when they preserve the same state, priority, and test behavior on the target controller.

Ladder Diagram (LD)

Ladder Diagram presents logic as rungs between rails. Contacts evaluate conditions; coils or output elements write a result. Modern implementations can also contain timers, counters, arithmetic, comparisons and function blocks.

Best fit

  • machine permissives and interlocks;
  • start/stop and mode-selection logic;
  • discrete sequences;
  • logic maintained by electrical/controls technicians; and
  • online troubleshooting where a visible condition path helps.

Strengths

  • Boolean cause and effect is easy to inspect online.
  • Relay-control experience transfers naturally.
  • Contacts and coils expose permissive and interlock structure.
  • Small routines can be reviewed without mentally parsing a long expression.

Failure modes

  • very wide or deeply nested rungs;
  • multiple writes to one output;
  • hidden state spread across latch/unlatch instructions;
  • calculations broken into many temporary tags; and
  • using normal ladder logic as though it were a certified safety function.
Ladder Diagram motor-control concept showing start, stop, permissive, seal-in branch, output command, feedback, and a separate safety boundary
Editorial training illustration: ladder makes Boolean paths visible, but ordinary control logic does not become a validated safety function.

Review checklist

  1. Can the rung be read left to right without scrolling?
  2. Does Stop/fault dominate Start?
  3. Is one tag written in multiple locations?
  4. Is the first-scan state defined?
  5. Are forces, bypasses and simulation bits visibly controlled?
  6. Does the online display reflect the exact task/instance being executed?

Structured Text (ST)

Structured Text is the current IEC suite's textual language. It supports assignments, expressions, conditionals, selection and iteration, plus calls to functions and stateful function blocks.

Best fit

  • engineering-unit calculations and scaling;
  • arrays, loops and structured data;
  • recipes and data transformations;
  • reusable algorithms;
  • state machines; and
  • logic that benefits from source-control diffs.

Example: clamp an analog command

ScaledPercent := DINT_TO_REAL(RawInput) * 100.0 / 27648.0;

IF ScaledPercent < 0.0 THEN
    ScaledPercent := 0.0;
ELSIF ScaledPercent > 100.0 THEN
    ScaledPercent := 100.0;
END_IF;

The conversion before multiplication preserves fractional intent. The raw full-scale value is only an example; use the actual module configuration.

Structured Text data flow through scaling, range limits, conditional branches, bounded array processing, reusable functions, and analog output
Editorial illustration: ST is compact for typed data transformations, but execution bounds, conversions, and platform-specific calls still require review.

Failure modes

  • long loops that threaten task deadlines;
  • implicit numeric conversions;
  • array-index errors;
  • state changes hidden inside functions with unclear side effects;
  • large monolithic routines; and
  • code that is syntactically portable but relies on vendor libraries.

Review checklist

  1. Are every minimum, maximum and array bound defined?
  2. Are type conversions explicit?
  3. Is loop execution bounded?
  4. Are timers/function blocks instantiated and called every required scan?
  5. Can a technician diagnose the current state online?
  6. Are platform-specific functions isolated behind a clear interface?

Function Block Diagram (FBD)

FBD represents a network of functions and stateful function blocks connected by data paths. It is especially effective when the signal path is the explanation.

Best fit

  • analog signal conditioning;
  • PID and other control-loop structures;
  • instrumentation logic;
  • timers/counters connected as a functional network; and
  • reusable equipment or process modules.

Function vs function block

A function normally returns a result without retaining instance state. A function block has an instance and can retain internal state between calls. A MAX calculation and a TON timer therefore have different lifecycle behavior even when both appear as rectangles.

Function Block Diagram signal chain connecting sensor scaling, filtering, limits, stateful control, alarm branch, actuator output, and process feedback
Editorial illustration: FBD is strongest when the signal path explains the logic and every stateful block has a deliberate instance and reset lifecycle.

Failure modes

  • crossing lines and unreadable “spaghetti” networks;
  • unclear execution order where order matters;
  • reusing one stateful instance in two places;
  • constants with no engineering-unit label; and
  • accepting default PID/timer parameters without a test record.

Review checklist

  1. Does data flow consistently across the sheet?
  2. Is each stateful block instance unique?
  3. Are signal units and valid ranges visible?
  4. Is execution order documented when the editor does not make it obvious?
  5. Are enable, reset, saturation and bad-quality paths tested?

Sequential Function Chart (SFC)

Edition 4 describes SFC as graphical and equivalent textual elements for structuring the internal organization of programs and function blocks. In practice, engineers use steps, transitions and actions to express sequences.

Best fit

  • fill/mix/drain cycles;
  • packaging and material-handling stages;
  • startup and shutdown sequences;
  • batch phases;
  • parallel branches that must resynchronize; and
  • equipment state models with explicit recovery.

Minimal tank sequence

[IDLE]
  Start AND permissives
       |
       v
[FILL]  Open inlet
  HighLevel
       |
       v
[MIX]   Run agitator
  MixTimer.Q
       |
       v
[DRAIN] Open outlet
  LowLevel
       |
       v
[COMPLETE]
  Reset
       |
       +------> [IDLE]

Add explicit transitions for Stop, fault, timeout and recovery. A chart that shows only the happy path is incomplete.

Failure modes

  • two transitions true simultaneously without defined priority;
  • no maximum time in a step;
  • outputs left active after abort;
  • re-entry that skips initialization;
  • parallel branches that never converge; and
  • state stored in both the SFC and unrelated latch bits.

Review checklist

  1. Is every step entry and exit condition testable?
  2. Does every active action turn off on abort?
  3. Is there a timeout and diagnostic for stalled transitions?
  4. Are restart and power-cycle behaviors defined?
  5. Can every parallel branch reach a safe convergence?

Instruction List (IL): Legacy Maintenance Context

Instruction List was a compact mnemonic representation used in many older PLC systems. IEC 61131-3:2025 does not list IL in its current language suite.

That does not automatically remove IL from installed equipment or vendor tools. When maintaining it:

  1. identify the exact controller, firmware and editor version;
  2. export and preserve the original project;
  3. obtain the vendor mnemonic/instruction manual;
  4. document accumulator and status-bit behavior;
  5. build an input/output equivalence test;
  6. migrate one bounded routine at a time; and
  7. retain a rollback path until the converted program passes on the target.

Do not claim that an ST translation is equivalent because it “looks the same.” Verify edge handling, numeric width, overflow, jumps, subroutine state and scan order.

Are PLC Languages Portable Between Vendors?

Concepts transfer better than projects.

The standard helps align:

  • language structures;
  • elementary data types;
  • POU concepts;
  • variable declarations;
  • common functions/function blocks; and
  • configuration ideas.

Actual portability is reduced by:

  • proprietary instructions and libraries;
  • I/O and hardware configuration;
  • task scheduling;
  • data-layout and conversion rules;
  • retain/persistent behavior;
  • communication objects;
  • motion and safety systems;
  • file formats; and
  • firmware/version dependencies.

Even PLCopen XML exchange should be treated as a migration aid, not proof of a lossless conversion.

One neutral PLC requirement and acceptance test adapted across four unbranded platforms with different hardware, data, library, address, and instruction conventions
Editorial illustration: requirements and behavior tests transfer more reliably than native projects, libraries, hardware configuration, or vendor-specific syntax.

Vendor Support Checklist

Avoid a brand-wide “yes/no” matrix. Language support is specific to a CPU family, engineering-software edition and release.

For each target, record:

Question Evidence to capture
Which languages can create a Program POU? Current programming manual/help
Which languages can create Functions/Function Blocks? POU creation dialog and manual
Is SFC included in this software edition? Licence/edition comparison
Is IL/mnemonic view legacy-only? Migration and compatibility notes
Can online monitoring show every representation? Tested screenshot/version
Which safety languages/elements are certified? Safety manual and certificate scope
Can projects exchange XML? Exact schema/export/import limits

Apply that checklist separately to TIA Portal/STEP 7, Studio 5000, CODESYS, TwinCAT, GX Works, Sysmac Studio, EcoStruxure Machine Expert, Automation Builder or any other platform. A “CODESYS-based” product can still restrict languages and libraries at the target/device layer.

Selecting a Language for a Real Project

Score the candidates against the application:

  1. Behavior fit: Boolean/interlock, data/algorithm, signal-flow or state sequence.
  2. Target support: exact controller, firmware, editor and licence.
  3. Maintenance audience: who diagnoses it at 02:00?
  4. Online visibility: can they see the active condition/state?
  5. Testability: can the behavior be exercised automatically?
  6. Version control: can changes be reviewed meaningfully?
  7. Reuse: is the logic a tested block or copied network?
  8. Safety boundary: is a certified toolchain and validated library required?
  9. Lifecycle: can the organization maintain the chosen representation for the plant's lifetime?

The smallest number of languages that clearly expresses the system is usually easier to maintain than using every available editor.

A Practical Multi-Language Architecture

A medium machine might use:

  • LD for field permissives, mode handling and output arbitration;
  • ST inside reusable blocks for calculations and data handling;
  • FBD for a few analog loops; and
  • SFC elements or an explicit state machine for the overall sequence.

Define boundaries:

Field inputs
   ↓
Input validation and permissives (LD)
   ↓
Equipment modules / calculations (ST or FBD)
   ↓
Sequence coordinator (SFC or explicit state machine)
   ↓
Output arbitration and diagnostics (LD)
   ↓
Field outputs

No lower layer should bypass an output safety/permissive boundary merely because another language makes it convenient.

PLC Languages and Functional Safety

Programming-language choice alone does not create a safety function. Safety depends on the complete certified and validated system:

  • hazard/risk assessment;
  • required PL or SIL;
  • safety-rated input, logic and output hardware;
  • certified engineering tool and firmware combination;
  • approved instructions/libraries;
  • response-time calculation;
  • validation tests;
  • configuration control; and
  • competent lifecycle management.

Use the safety manual for the selected platform. A standard LD or ST program on a normal PLC is not a safety program just because it contains an EStop tag.

Can Python Replace PLC Languages?

Python is useful around a PLC—for data collection, test automation, engineering utilities, analytics and gateways. Standard CPython on a general-purpose operating system should not be assumed to meet a cyclic control deadline or safety integrity requirement.

A defensible split is:

  • PLC runtime: deterministic machine/process control;
  • Python or other general software: orchestration, analysis, reporting and test tooling; and
  • defined interface: authenticated, bounded, failure-tested data exchange.

Some industrial platforms integrate general-purpose languages or extensions. Use their documented execution class and isolation rules; do not infer real-time behavior from the language name.

Learning Plan

Week 1: Ladder Diagram

  • contacts, coils and Boolean logic;
  • seal-in circuit;
  • Stop/fault dominance;
  • TON and CTU;
  • online monitoring and multiple-write checks.

Week 2: Structured Text

  • variables and explicit types;
  • IF/CASE;
  • bounded loops;
  • arrays and structures;
  • function and function-block calls.

Week 3: Function Block Diagram

  • signal flow;
  • stateless functions vs stateful blocks;
  • analog scaling;
  • timer network;
  • simple control loop with limits.

Week 4: Sequence Modeling

  • state/step definition;
  • transitions;
  • abort and timeout;
  • restart after fault/power loss;
  • matched implementation and tests.

At each stage, rebuild the same motor and tank requirements. Repetition across representations teaches the transferable behavior.

FAQ

How many PLC programming languages are in IEC 61131-3?

IEC 61131-3:2025 Edition 4 describes a suite consisting of ST, LD and FBD, plus SFC elements for program/function-block structuring. “Five languages” refers to older treatments that included IL and counted SFC as a language. Use the edition number when answering.

Was Instruction List removed?

IL is not listed in the Edition 4 suite. Installed vendor systems can still support legacy mnemonic code, so removal from the current IEC publication is not the same as removal from every PLC.

Is SFC a programming language?

The Edition 4 IEC product description calls SFC an additional set of graphical and equivalent textual elements for structuring programs and function blocks. In everyday engineering it is often grouped with PLC languages, but that is not the standard's precise current wording.

Which language is most common?

There is no authoritative global dataset that supports one precise market-share number across industries and regions. LD is commonly encountered in discrete machinery; ST and FBD are common where data/algorithm and process signal flow dominate. Choose for the target and maintenance team.

Which language is fastest?

Do not select by a generic language-speed claim. Compiler, runtime, task period, algorithm, libraries and target CPU determine execution. Measure the compiled project under representative worst-case load.

Should beginners learn Ladder or Structured Text?

Learn Ladder first for visual Boolean reasoning, then ST for calculations and structured software. Rebuild the same requirements in both and compare test results.

Can I mix languages in one project?

Many platforms permit different POUs in different languages. Verify the exact target, define interfaces and keep one clear owner for state/output decisions.

Are IEC programs portable?

Partly. Language concepts and some exchange formats transfer, but vendor instructions, libraries, tasks, hardware, communications and safety configuration often require manual migration and retesting.

Primary Sources and Review Method

This page was reviewed on July 25, 2026. Claims about the current language suite use the IEC publication record; implementation guidance is deliberately framed as a verification checklist because vendor support changes by product and version.

Practise the Same Logic in Multiple Dialects

Our related PLC Simulation Software lets learners practise control patterns across a maintained set of vendor-oriented learning dialects. Its versioned product facts document the current dialect list, lesson allowance, free-account policy, and limitations.

Disclosure and limit: plcprogramming.io and PLC Simulation Software share the same publisher. The product teaches transferable control logic and vendor-style notation; it is not a vendor compiler, firmware or safety simulator. Rebuild and validate production code in the exact target toolchain.

Continue learning:

#PLCLanguages#IEC61131-3#LadderLogic#FunctionBlocks#StructuredText
Share this article:

Related Articles