
IEC 61131-3 Programming Languages: A Practical Overview
Introduction
IEC 61131-3 is the globally recognized standard that defines programming languages and key software concepts for programmable logic controllers (PLCs). For electrical engineers and technicians working with industrial electrical components—contactors, motor starters, drives, sensors, safety devices, and the PLC hardware tying them together—IEC 61131-3 matters because it influences how control strategies are implemented, maintained, and transferred between projects and platforms.
This practical overview explains the IEC 61131-3 programming languages, where each fits best, and how to choose a language based on real-world tasks like interlocking motors, sequencing actuators, diagnosing faults, and integrating field I/O. While PLC vendors add proprietary tools and extensions, IEC 61131-3 provides the common vocabulary that makes multi-site maintenance and training far easier.
IEC 61131-3 in practice: what the standard covers
IEC 61131 is a multi-part standard for PLCs. IEC 61131-3 focuses on programming languages and software model. In practical terms, it standardizes:
- Languages used to express control logic (the “how”)
- Program organization units (POUs):
- Programs: top-level execution units
- Function Blocks (FBs): reusable components with internal state (memory)
- Functions (FCs): reusable components without internal state (pure logic/compute)
- Data types (e.g., BOOL, INT, DINT, REAL, TIME, DATE_AND_TIME) and derived types (structures, arrays)
- Execution concepts such as tasks, cyclic execution, and event-driven behavior (implementation depends on platform, but the model is consistent)
- Variables and scoping (local, global, retained/persistent where supported)
A key practical takeaway: IEC 61131-3 encourages modular, reusable design through FBs—ideal for standardizing repeated equipment such as pump skids, conveyors, valve manifolds, and VFD-controlled motors across a plant.
The IEC 61131-3 languages: strengths, best uses, and pitfalls
IEC 61131-3 defines five languages commonly encountered in PLC engineering:
Ladder Diagram (LD)
LD resembles electrical relay logic and is widely used for discrete control and interlocking. It maps naturally to how electricians and technicians think about circuits: contacts, coils, and rungs.
Best for:
- Motor starter logic (seal-in circuits, permissives, overload trips)
- Safety-related permissive logic (when implemented in appropriate safety PLC environments and validated per safety standards)
- Simple discrete I/O diagnostics and “what is stopping the machine” troubleshooting
Practical tips:
- Use named boolean signals for clarity (e.g.,
MTR1_PermissiveOK,EStopOK,OL_Trip) - Avoid overly long rungs; break complex logic into intermediate bits or FBs
- Be explicit about edge detection when needed (start pushbutton vs. maintained command)
Common pitfalls:
- Complex arithmetic and data manipulation becomes hard to read in LD
- Excessive parallel branches can reduce maintainability
Function Block Diagram (FBD)
FBD is a graphical “block wiring” language, well-suited for combining standard function blocks (timers, counters, PID, scaling) with process I/O.
Best for:
- Analog signal conditioning (scaling, filtering, limit checking)
- Control loops (PID function blocks provided by many vendors)
- Modular equipment control using reusable FBs (valve blocks, drive control blocks)
Practical tips:
- Build a standard FB library for common components:
- VFD start/stop with permissives and fault reset
- Valve open/close with limit switch validation and timeout alarm
- Analog input scaling with sensor fault detection (e.g., 4–20 mA under/over-range)
- Keep networks small; group blocks into logical “signal chains” (Acquire → Condition → Control → Output)
Common pitfalls:
- Large sheets become visually cluttered—use hierarchical FBs to encapsulate complexity
Structured Text (ST)
ST is a high-level textual language resembling Pascal. It excels at algorithms, loops, array handling, and state machines—areas where graphical languages can become unwieldy.
Best for:
- Recipe handling and parameter sets
- Data processing (arrays, maps, device lists)
- Sequencing and state machines for complex machines
- Communications handling (where supported by the platform)
Practical tips:
- Prefer CASE-based state machines for sequences:
- Clear transitions
- Easy to add steps and diagnostics
- Use enumerated types (vendor support varies) or constants to label states
- Keep safety interlocks outside complex code paths; make permissives explicit and testable
Common pitfalls:
- Technicians less familiar with text code may find troubleshooting harder without good comments and variable naming
- Be mindful of scan-cycle behavior (e.g., loops executing fully every cycle)
Sequential Function Chart (SFC)
SFC models control as steps and transitions—excellent for batch operations and multi-step sequences (start-up, changeover, shutdown).
Best for:
- Automated sequences: conveyor start-up chains, CIP skids, batch mixing
- Coordinating multiple actuators with clear progression logic
- Capturing “what step are we in?” for HMI and troubleshooting
Practical tips:
- Expose the active step and transition conditions to the HMI for diagnostics
- Implement timeouts and fault branches for steps (e.g., valve failed to open within X seconds)
- Combine SFC with ST/LD inside actions for the detailed logic
Common pitfalls:
- Poorly defined transition conditions can cause “stuck steps”
- Be consistent about whether actions are continuous (while step active) or one-shot (on step entry)
Instruction List (IL) (legacy)
IL is a low-level, assembly-like language. It is deprecated in newer editions of IEC 61131-3 and many environments no longer support it. You may still encounter IL in legacy PLCs and older projects.
Practical guidance:
- Plan migration to LD, ST, or FB-based implementations where feasible
- If maintaining IL, document heavily and isolate IL segments to minimize risk
Choosing the right language for common industrial tasks
Most real PLC projects use multiple IEC 61131-3 languages together. The best choice depends on the task and the skills of the maintenance team.
Typical selection guide
- Discrete interlocks, permissives, E-stop chains (non-safety PLC logic for standard stops): LD
- Analog scaling, drive references, PID blocks: FBD
- Complex sequencing, recipes, data handling: ST or SFC (often SFC + ST actions)
- Reusable equipment modules (motors, valves, alarms): FBs implemented in LD/FBD/ST depending on complexity
A practical example: VFD-controlled motor module
A robust motor control FB commonly includes:
- Inputs:
- Start/Stop command (Auto/Manual sources)
- Permissives (guard closed, pressure OK, upstream running)
- Fault reset
- Feedbacks (Run status, Fault, Ready)
- Outputs:
- Start command to VFD
- Reset command
- Status bits for HMI (Running, Stopped, Faulted, Inhibit reason)
- Internal behavior:
- Start latch logic with permissive validation
- Start timeout alarm (commanded to run but not running within X seconds)
- Fault handling and reset sequence
Implementation approach:
- Use LD for the permissive chain and latch (easy to troubleshoot)
- Use ST for alarm timers, counters, and structured diagnostics
- Expose “first-out” permissive blocking as a list or code to speed commissioning
Commissioning and maintenance considerations
When your control logic touches industrial electrical components, practical maintainability is as important as elegance:
- Signal naming: align with panel drawings and I/O lists (e.g.,
DI_101_MTR1_OLvs. ambiguousI0.3) - Cross-references: ensure the PLC environment supports where-used searches for coils/variables
- Online monitoring: LD and SFC often provide more intuitive online status visualization
- Standardized alarm handling: implement consistent alarm bits, timestamps (where supported), and reset logic
IEC 61131-3 best practices for modular, reusable PLC software
IEC 61131-3 shines when you treat PLC code like an engineered system, not a one-off ladder file.
Build with Function Blocks and clear interfaces
- Create FBs that represent physical assets:
FB_MotorStarterFB_VFDFB_ValveDOFB_AI_Scale
- Define clean I/O interfaces:
- Group related inputs/outputs using structures (if supported)
- Keep “commands” separate from “status” to avoid feedback loops
Use consistent timing and scan-cycle assumptions
Timers in IEC 61131-3 (e.g., TON, TOF, TP) are standardized conceptually, but behavior can vary slightly by vendor (especially around retentive behavior and time base). Validate:
- Minimum timer resolution and task cycle time
- Whether timers reset on task stop or mode changes
- How retentive memory is handled across power cycles (vendor-dependent)
Document for technicians
A practical program is one a technician can troubleshoot at 2 a.m.:
- Comment permissive logic with plain-language reasons (“Blocked: suction pressure low”)
- Provide HMI-friendly diagnostic bits:
Inhibit_EStopInhibit_GuardOpenInhibit_OverloadTrip
- Standardize “first fault” capture where possible (latched fault code)
Conclusion
IEC 61131-3 provides the foundation for PLC programming across much of industrial automation, defining common languages and software structures that help teams build maintainable, portable control systems. In day-to-day electrical engineering work, the most practical approach is rarely “pick one language”—it’s selecting the right tool for each layer: LD for clear interlocks, FBD for signal flow and control blocks, ST for algorithms and diagnostics, and SFC for step-based sequencing.
By structuring your projects around reusable function blocks, consistent naming, and technician-friendly diagnostics, you’ll reduce commissioning time, simplify troubleshooting, and create control software that scales cleanly across machines and sites—all while staying aligned with the real-world intent of IEC 61131-3.