PLC Programming Languages: Ladder, FBD, Structured Text, SFC and IL with One Example in Each
On this page
Most PLCs are programmed in languages defined by IEC 61131-3: two graphical languages (ladder diagram and function block diagram), two textual languages (structured text and instruction list) and a structuring language (sequential function chart). They are not competing choices so much as tools for different jobs: a well-written program often uses several of them.
To compare them fairly, this page uses one example throughout.
The example: filling a tank (illustrative)
A pump fills a tank. It should run when the operator has enabled filling, start when the level falls below the low switch, stop when the level reaches the high switch, and stop immediately if the pump overload trips.
| Tag | Type | Meaning |
|---|---|---|
Fill_Enable |
BOOL input | Operator enables filling |
LSL |
BOOL input | Low level switch (TRUE when level is below low) |
LSH |
BOOL input | High level switch (TRUE when level is at or above high) |
Pump_OL_OK |
BOOL input | Overload healthy (normally closed contact) |
Pump_Run |
BOOL output | Pump contactor |
The logic is a start/stop latch: start on low level, stop on high level, with enable and overload as conditions.
Ladder diagram (LD)
Ladder logic looks like relay circuit drawings: contacts on the left, coils on the right, power flowing from the left rail.
| Fill_Enable Pump_OL_OK LSL LSH Pump_Run |
|----] [-----------] [-------+--] [--+------]/[----------( )---|
| | | |
| | Pump_Run |
| +--] [--+ |
Strengths: easy for electricians and maintenance staff to follow online; excellent for discrete interlocks. Weaknesses: calculations, loops and data handling become clumsy.
Function block diagram (FBD)
FBD connects blocks (AND, OR, timers, PID, custom function blocks) with signal lines. The same logic uses an OR block for the stop conditions and a reset-dominant RS flip-flop, so a stop condition always wins over a start:
Network 1: stop conditions
┌──────┐
LSH ────────────┤ OR │
NOT Fill_Enable ┤ ├──── Stop_Cond
NOT Pump_OL_OK ─┤ │
└──────┘
Network 2: latch (RS = reset dominant)
┌──────┐
LSL ────────────┤ S │
│ RS ├──── Pump_Run
Stop_Cond ──────┤ R1 │
└──────┘
With a set-dominant SR block instead, a low level together with an overload trip would keep the pump running, which is why the choice of bistable matters.
Strengths: natural for continuous control and signal flow (analog scaling, PID, calculations); widely used in process control and DCS. Weaknesses: large sequences become hard to follow.
Structured text (ST)
ST is a high-level textual language similar to Pascal:
IF NOT Fill_Enable OR NOT Pump_OL_OK OR LSH THEN
Pump_Run := FALSE; (* stop conditions have priority *)
ELSIF LSL THEN
Pump_Run := TRUE; (* start on low level *)
END_IF;
Strengths: calculations, loops, arrays, string handling, algorithms and reusable function blocks. Weaknesses: harder for maintenance staff to follow online; badly structured code is difficult to debug.
Sequential function chart (SFC)
SFC structures a sequence as steps and transitions. Each step has actions (written in any other language); a transition condition moves to the next step.
┌──────────────┐
│ S0: Idle │ Pump_Run := FALSE
└──────┬───────┘
┼ Fill_Enable AND LSL AND Pump_OL_OK
┌──────┴───────┐
│ S1: Filling │ Pump_Run := TRUE
└──────┬───────┘
┼ LSH OR NOT Fill_Enable OR NOT Pump_OL_OK
(back to S0)
Strengths: makes sequences visible (batch steps, machine cycles, start-up procedures), shows the active step for fault finding. Weaknesses: overkill for simple logic; parallel branches need careful design.
Instruction list (IL)
IL is a low-level, assembler-like language. It was deprecated in the third edition of IEC 61131-3 (2013) and is not recommended for new programs, but it still appears in older systems:
LD LSL
OR Pump_Run
ANDN LSH
AND Fill_Enable
AND Pump_OL_OK
ST Pump_Run
Choosing a language
| Task | Usually best | Why |
|---|---|---|
| Discrete interlocks, motor and valve control | LD | Readable online by maintenance |
| Analog processing, PID, signal flow | FBD | Shows data flow clearly |
| Calculations, data handling, algorithms | ST | Compact and powerful |
| Machine cycles, batch steps, sequences | SFC (with LD or ST actions) | Makes the sequence visible |
| New code in any area | Not IL | Deprecated |
Many sites set rules in a programming standard, for example “equipment logic in LD, calculations in ST, sequences in SFC”. See PLC Programming Best Practices.
Program organisation units
IEC 61131-3 structures programs into program organisation units (POUs):
| POU | Characteristics | Example |
|---|---|---|
| Function (FC) | Returns a result, no memory between calls | Scaling calculation |
| Function block (FB) | Has internal memory (instance data) | Motor control block with its own timers and state |
| Program (PRG) | Top-level unit called by a task | Area or machine program |
Reusable function blocks for motors, valves and analog inputs are the basis of good, consistent PLC code.
Common building blocks
| Element | Examples |
|---|---|
| Data types | BOOL, INT, DINT, REAL, TIME, STRING, arrays, structures (user-defined types) |
| Timers | TON (on-delay), TOF (off-delay), TP (pulse) |
| Counters | CTU (up), CTD (down), CTUD (up/down) |
| Edge detection | R_TRIG (rising edge), F_TRIG (falling edge) |
| Bistables | SR (set dominant), RS (reset dominant) |
Vendor names for the languages
| Vendor environment | Language names |
|---|---|
| Siemens TIA Portal | LAD (ladder), FBD, SCL (structured text), GRAPH (SFC), STL (statement list, IL-like, on some CPUs) |
| Rockwell Studio 5000 | Ladder diagram, function block diagram, structured text, sequential function chart |
| CODESYS-based systems | All IEC 61131-3 languages, plus CFC (continuous function chart) |
| Mitsubishi, Omron, Schneider | IEC 61131-3 languages, with vendor-specific variations |
Implementations differ in details (data types, instruction sets, addressing), so programs are rarely portable between vendors without rework. See PLC Programming Software.
Frequently asked questions
What are the five PLC programming languages?
Ladder diagram, function block diagram, structured text, instruction list and sequential function chart, as defined by IEC 61131-3. Instruction list was deprecated in 2013.
Is ladder logic still used?
Yes. It remains the most common language for discrete machine logic because maintenance staff can read it easily while the machine runs.
Should I learn ladder logic or structured text?
Both. Ladder logic is essential for maintenance and discrete control; structured text is increasingly important for calculations, data handling and reusable function blocks.
Key takeaways
- IEC 61131-3 defines LD, FBD, ST, SFC and the deprecated IL.
- Choose the language by task: LD for interlocks, FBD for signal flow, ST for calculations, SFC for sequences.
- Build programs from reusable function blocks and consistent data types.
- Vendor implementations differ; portability usually needs rework.
Related tutorials
Before you apply this in a plant: this article is for education. Always check the current edition of the relevant standards, the manufacturer's documentation for your exact product and version, and your site's procedures. Safety-related work needs qualified personnel. See our editorial policy.