IMDHMIControls LibraryShop main store

Selection guide

Which IEC 61131-3 PLC language to use for each control task

PLC programming Published 8 min read

Short answer

Match each control task to the IEC 61131-3 language whose form shows its dominant data path: ladder for discrete interlocks, structured text for calculations and data handling, function block diagram for connected signal functions, SFC for phased sequences. Instruction List is deprecated, so new code uses the other four, and the controller's supported languages set the final limit.

On this page
  1. The selection rule: the data path decides
  2. The five languages at a glance
  3. Choosing task by task
  4. Ladder for discrete interlocks
  5. Structured text for math and data handling
  6. Function block diagram for connected signal functions
  7. SFC for phased sequences
  8. Instruction List: maintain it, do not extend it
  9. Mixing languages in one program
  10. Worked example: splitting a 36-function batching skid across four languages
  11. Proving the choice at commissioning
  12. Questions asked

Match the language to the dominant data path of the task, and the choice makes itself: ladder for discrete interlocks, structured text for math and data handling, function block diagram for connected signal functions, and SFC for phased sequences. IEC 61131-3 defines those four plus Instruction List, which the standard deprecates, so no new code starts there. One gate comes before any of this: language support belongs to the PLC model and manufacturer, so confirm what the controller compiles before a language becomes a project standard. Below are the rule, the task-by-task table, and one worked split of a small machine program across four languages.

The selection rule: the data path decides #

Every control function moves a value from a field input, through a decision, to an output command. That path takes one of four shapes: a chain of discrete conditions ending in one command, a calculation that turns numbers into a decision, a signal transformed block by block on its way to an output, or a phase that must finish before the next begins. Choose the language per function, then let the counts settle the project standard, as the worked example below does.

Team skill is the tiebreaker, because the program has to stay diagnosable by whoever is on shift, not just by its author. And before anything settles, check the controller itself: language availability varies by PLC model and manufacturer, and the gap is wide enough that moving platforms reopens the question — the difference in IEC 61131-3 language support between an S7-300 and a Q series shows how far apart two installed platforms can be.

The five languages at a glance #

The standard defines five languages: two textual ones (Structured Text and Instruction List), two graphical ones (Ladder Diagram and Function Block Diagram), and the Sequential Function Chart that structures work written in the others.

Language Identifier Form Strongest at Weakest at
Ladder Diagram LD Rungs of contacts and coils between two rails Discrete interlocks, permissives, output control Dense math and data handling
Function Block Diagram FBD Blocks wired into signal paths Connected signal functions and analog chains Long Boolean chains, which rungs show better
Structured Text ST Textual statements with Pascal-like syntax Calculations, comparisons, arrays, data moves Glance-level tracing of a Boolean path
Sequential Function Chart SFC Steps with actions and guarded transitions Phased sequences and machine state The detail inside each action
Instruction List IL Low-level mnemonic text Keeping existing IL programs running Any new code; deprecated in the standard

Availability is decided per controller and per programming tool, so treat this table as the shortlist the platform then filters.

Choosing task by task #

Dominant data path Write it in Why Do not force it into
Discrete conditions ending in one output LD The rung shows the whole path at a glance ST, where the Boolean chain hides in text
A formula: scaling, totalizing, filtering ST One statement carries the arithmetic LD, where one formula becomes many rungs
Arrays, recipes, buffers, message formatting ST Indexing and moves are native statements SFC actions, which bury data handling
A signal transformed block by block FBD The wiring shows the signal route LD, which fragments a chain across rungs
Operating phases with entry conditions SFC Steps and transitions expose the state LD, which needs hand-built state bits
An existing IL routine that still runs IL, unchanged Its execution order is proven New IL, which the standard deprecates

Ladder for discrete interlocks #

Contacts and coils map one-to-one onto relays, timers and field wiring, which is why a rung reads like the circuit it replaced. Use it wherever the job is permissives, seal-ins, interlocks and output commands: the state of every condition sits on one horizontal path, an electrician can follow it, and forcing an input shows its effect immediately. The pattern holds at any scale, from a two-sensor pump latch to structuring dock door conveyor interlocks in Studio 5000.

One boundary belongs here: a language choice never turns a standard CPU into a safety controller. Interlocks that carry a safety function belong in the safety-rated hardware the risk assessment calls for, and the standard program only mirrors their status.

Structured text for math and data handling #

Scaling, totalizing, filtering, recipe handling and the comparisons that feed decisions are statements, not rungs. One assignment carries a formula that ladder would spread across branches of math boxes, and nested conditions stay nested instead of becoming interleaved coils. The syntax reads like Pascal or C, so engineers from those languages orient quickly, though each platform keeps its own details. Ported math lands here naturally, as when porting a PLC-5 filter routine to ControlLogix structured text.

Confirm how the platform's integer math behaves before trusting a division: integer division truncates on some controllers and quietly changes results, and why Do-more MATH truncates your integer division result is the habit to build.

Function block diagram for connected signal functions #

When the work is a signal being conditioned, limited, scaled and controlled on its way to an output, FBD shows the route the way an instrument loop drawing does. Block outputs feed block inputs, so a troubleshooter walks the value from its origin to the actuator across one diagram. Use it for analog chains and closed-loop control function libraries; when the logic is mostly Boolean with one or two analog steps, ladder does the same job with less layout effort.

SFC for phased sequences #

A step holds actions, and a transition holds the condition that ends the step and opens the next one. That structure is the choice whenever the machine runs defined phases — charge, mix, hold, transfer — because the chart shows which step is active and what the next transition is still waiting for, which is most of sequence troubleshooting. The actions inside the steps are written in ladder, structured text or FBD, so SFC organizes the sequence rather than replacing the logic inside it. Where the platform offers no SFC, ladder state bits reproduce it with more housekeeping and more places to be wrong.

Instruction List: maintain it, do not extend it #

The standard deprecates IL, and its mnemonic line-by-line form offers nothing the other four languages do not show better. Leave working IL routines running and documented. When one has to change, migrate it into structured text preserving its execution order, and prove the translation against the original behavior before the new routine goes live.

Mixing languages in one program #

The major platforms compile a program whose sections are written in different languages and call one another, and a mixed program is the normal outcome of choosing per function. Two disciplines keep it healthy: each physical output has exactly one owning section, so competing logic cannot write contradictory states; and interfaces are explicit named variables, tested like field signals, because a mixed program hides its mistakes at the seams. Expect platform behavior at those seams — the case of a CODESYS TON that works in structured text but not ladder is why interface tests are part of commissioning.

Worked example: splitting a 36-function batching skid across four languages #

The question behind this article named no machine, so the case is a typical one: a small batching skid with dosing pumps and valves, an agitator, a heater, analog flow and temperature loops, recipe selection and a batch record. Its function list — illustrative, but the kind of list a machine survey produces — breaks down as follows:

  • 18 discrete functions: valve and pump permissives, agitator and heater interlocks, alarm contacts, output commands.
  • 6 calculation functions: flow totalizing, temperature scaling and filtering, dose-target arithmetic.
  • 4 data-handling functions: recipe selection, batch record buffer, log formatting, operator entry checks.
  • 8 connected analog functions: the signal-conditioning chains feeding each analog output.
  • 5 operating phases that order the work.

The rule, in words: assign every function to the language whose form matches its dominant data path, count per language, and accept a single-language standard only if that language is the natural form for every function on the list.

The arithmetic:

  • Ladder: 18 discrete functions.
  • Structured text: 6 calculation functions + 4 data-handling functions = 10.
  • Function block diagram: 8 connected analog functions.
  • Total: 18 + 10 + 8 = 36 functions.
  • Outside ladder: 10 + 8 = 18, and 18 / 36 = 0.50, so half the program is not interlock logic.
  • The 5 phases are structure, not extra functions: one SFC chart calls the sections.

Decision: a ladder-only standard would flatten 18 of 36 functions — 50 percent — into rungs, far past the working threshold, which is to give non-ladder functions their own sections once they pass a quarter of the list. Structured text only, at 10 / 36 = 0.28 of functions, would bury every interlock in text. So the skid gets four sections: a 5-step SFC chart at the top, a ladder section owning every output coil, a structured-text section returning computed values the ladder reads, and FBD chains feeding the analog outputs. New IL code: zero.

Proving the choice at commissioning #

Each language is verified by tracing its own path. Ladder: force an input and watch rung states to the coil. Structured text: watch the variables each branch reads. FBD: read every block input and output along the chain. SFC: confirm the active step and prove each transition fires on its condition, not on timing luck. Build the smallest complete path first — one input to one decision to one output — before parallel functions multiply the combinations, and confirm a second engineer can find which instruction commands a given actuator without a walkthrough.

Questions asked

Is ladder logic still the default for new PLC programs?

For discrete control, yes. Ladder remains the default section for interlocks and output control because technicians trace a rung like an electrical circuit, and it dominates the installed base you will be asked to maintain. It stops being the default the moment calculations, data handling or phase sequences dominate the task list; those sections belong in structured text, function block diagram or SFC, called from the ladder that owns the outputs.

Can one PLC program mix several IEC 61131-3 languages?

Yes, and that is normal practice on the major platforms: each section is written in the language that fits it and calls the others. A benefit beyond readability is modular testing, because a structured-text routine can be checked with test values before the ladder that calls it exists. Keep one owner per output and pass data through named interfaces, and a later conversion of any single section to another language touches no field wiring.

Why is Instruction List deprecated, and what do I do with existing IL code?

The standard deprecated IL because its low-level mnemonic form duplicates what structured text expresses with clearer structure, while being harder to review and easier to get wrong in silence. Leave working IL routines running and documented. When one must change, migrate the routine into structured text preserving its execution order, and prove the translation against the original behavior before the new code goes live.

Which language should a new controls engineer learn first?

Ladder first, structured text second. Ladder makes you productive on the discrete control and interlock logic that fills most plants and panels, and it is the form maintenance staff will ask you about. Structured text is the second tool, because every program eventually needs scaling, totalizing or data handling that ladder expresses poorly. Function block diagram and SFC come next, learned against the platform your plant actually runs.

Does using SFC mean the phases no longer need ladder or structured text?

No. SFC organizes the sequence; it does not replace the logic inside it. Each step's actions and each transition's condition are still written in ladder, structured text or function block diagram, so the chart tells you what runs when while the actions tell you how. That split is the point: the chart exposes state for troubleshooting, and the action logic stays in the language that fits the work it does.

Keep reading

  • Selection guide

    S7-300 vs Q series IEC 61131-3 language support

    Both platforms meet IEC 61131-3 once you buy the right toolchain: S7-GRAPH gives the S7-300 sequential function chart with function block calls from steps, and GX Works3 gives the Q series the SFC nesting that IEC Developer V5.0 lacked. With languages equal, integrated motion decides: one QD77MS16 module synchronizes 16 axes over SSCNET III/H at a 0.222 ms cycle, while the S7-300's 4-axis FM 357-2 is discontinued. Choose Q with GX Works3 for new multi-axis machines; stay with Siemens only inside an installed S7-300 base.

    PLC programming

  • How-to

    Program startup, flasher and digital-use analog inputs on an M172

    Declare a BOOL, set it TRUE in an ST program assigned to the Init Task, compute the flasher as x1Sec := TO_BOOL((sysTimer/1000) MOD 2) in cyclic code, and convert each of AI5-AI8 with TO_BOOL before ladder accepts it as a contact. The object not found error means the example names were never declared.

    PLC programming

  • Troubleshooting

    When a CODESYS TON works in structured text but not ladder

    The structured text routine counts because its four statements run in sequence inside one scan; the ladder version fails when the reset network clears Timer.Q before the addition samples it, or an unconditional reset restarts the timer every cycle. Put the call, the Q test, the addition and the reset of the same TON instance in one ladder network, left to right in that order, and it counts exactly one B per interval.

    PLC programming