IEC 61131-3 is the international standard for PLC programming. It defines 5 programming languages, data types, and program organization — making it possible to write PLC logic that works across Rockwell, Siemens, Schneider, Mitsubishi, and every other major vendor.
What is IEC 61131-3?
IEC 61131-3 is the third part of the IEC 61131 family of standards for programmable logic controllers (PLCs). Published by the International Electrotechnical Commission (IEC), it specifies:
- 5 programming languages — visual and text-based
- Common data types — BOOL, INT, REAL, TIME, STRING, etc.
- Program organization — Programs, Function Blocks, Functions
- Execution model — scan cycles, tasks, triggers
Think of it as the "JavaScript of PLCs" — a universal standard that runs on any hardware, though each vendor adds proprietary extensions.
The 5 IEC 61131-3 Languages
Unlike traditional programming where you pick one language, PLC programmers use multiple languages in the same project — each optimized for different tasks.
1. Ladder Diagram (LD)
Visual language mimicking electrical relay logic. Most popular for discrete on/off control.
|----[ StartButton ]----[ NOT StopButton ]----( Motor )----||
When StartButton is pressed AND StopButton is NOT pressed, energize Motor.
Best for: Simple logic, safety interlocks, sequential control
2. Function Block Diagram (FBD)
Visual language showing data flow through interconnected blocks. Great for complex logic.
[TempSensor] ──→ PID ──→ [HeaterOutput] [Setpoint] ──┘
A PID controller taking temperature sensor input and setpoint, outputting heater control signal.
Best for: Analog control, math operations, PID loops
3. Sequential Function Chart (SFC)
Visual language for state machines and sequential processes. Represents steps and transitions.
┌─────────┐
│ START │ (initial step)
└────┬────┘
│ [Button pressed]
┌────▼────┐
│ FILL │ (open valve)
└────┬────┘
│ [Level >= 100]
┌────▼────┐
│ HEAT │ (enable heater)
└─────────┘Best for: Multi-step batch processes, state machines
4. Structured Text (ST)
Text-based language similar to Pascal or C. High-level programming with loops, conditionals, functions.
IF Temperature > Setpoint THEN
HeaterOutput := 0; (* Turn off heater *)
ELSIF Temperature < (Setpoint - 5) THEN
HeaterOutput := 100; (* Full power *)
ELSE
HeaterOutput := 50; (* Half power *)
END_IF;Best for: Complex algorithms, data manipulation, loops, calculations
5. Instruction List (IL)
Text-based assembly-like language. Low-level, rarely used in modern systems.
LD StartButton AND StopButton ST Motor
Best for: Legacy systems, low-level optimization (mostly deprecated)
Common Data Types
IEC 61131-3 defines standard data types that work across all vendors:
| Type | Description | Example |
|---|---|---|
| BOOL | Boolean (true/false) | Motor := TRUE; |
| INT | 16-bit integer (-32768 to 32767) | Count := 42; |
| DINT | 32-bit integer | Position := 100000; |
| REAL | 32-bit floating point | Temp := 98.6; |
| TIME | Duration | Delay := T#5s; |
| STRING | Text (up to 255 chars) | Name := 'Plaxio'; |
Program Organization Units (POUs)
IEC 61131-3 structures code into three types of POUs:
1. Programs
Top-level containers. A PLC project has one or more Programs. Each Program runs in a Task (cyclic, periodic, or event-driven).
2. Function Blocks (FB)
Reusable code with internal state (memory). Examples: TON (timer), CTU (counter), PID controller.
MyTimer : TON; (* Declare a timer instance *) MyTimer(IN := StartButton, PT := T#5s); Motor := MyTimer.Q; (* Motor turns on after 5 seconds *)
3. Functions
Stateless operations that return a single value. Examples: ADD, MUL, MAX, SQRT.
Result := ADD(10, 20); (* Result = 30 *) MaxValue := MAX(Temp1, Temp2, Temp3);
Real-World Example: Conveyor Control
Let's build a simple conveyor belt controller using multiple IEC 61131-3 languages in one project.
Ladder Diagram (Start/Stop Logic)
|----[ StartButton ]----[ NOT EStop ]----[ NOT MotorRunning ]----( StartRelay )----|| |----[ StopButton ]-----------------------------------------------------( StopRelay )-----|| |----[ StartRelay ]----[ NOT StopRelay ]-----------------------------( MotorRunning )----||
Structured Text (Speed Control)
IF MotorRunning THEN
IF ItemCount < 10 THEN
ConveyorSpeed := 50; (* Slow speed *)
ELSIF ItemCount < 50 THEN
ConveyorSpeed := 75; (* Medium speed *)
ELSE
ConveyorSpeed := 100; (* Full speed *)
END_IF;
ELSE
ConveyorSpeed := 0; (* Stopped *)
END_IF;Function Block (Item Counter)
ItemCounter : CTU; (* Count-up counter *) ItemCounter(CU := PhotoEye, RESET := ResetButton, PV := 999); ItemCount := ItemCounter.CV; (* Current count value *)
This example shows how different languages work together — LD for simple start/stop, ST for complex logic, FB for reusable counters.
Why IEC 61131-3 Matters
1. Vendor Portability
Write code once, export to multiple vendors. A Ladder Diagram program can be exported to Rockwell L5X, Siemens SimaticML, Schneider XEF, and PLCopen XML.
2. Skill Transferability
Learn IEC 61131-3, and you can program any PLC. No need to relearn for every vendor.
3. Future-Proofing
The standard is maintained and updated by the IEC. New PLC vendors must support it to be competitive.
Common IEC 61131-3 Function Blocks
Every IEC 61131-3 compliant PLC includes these standard function blocks:
Timers
- TON (Timer On-Delay): Output turns ON after a delay
- TOF (Timer Off-Delay): Output turns OFF after a delay
- TP (Pulse Timer): Generates a fixed-duration pulse
Counters
- CTU (Count Up): Increments on rising edge
- CTD (Count Down): Decrements on rising edge
- CTUD (Count Up/Down): Bidirectional counter
Bistable
- SR (Set-Reset): Set dominant latch
- RS (Reset-Set): Reset dominant latch
Edge Detection
- R_TRIG: Rising edge detector
- F_TRIG: Falling edge detector
Getting Started with IEC 61131-3
The best way to learn is by doing. Here's your roadmap:
- Start with Ladder Diagram — easiest to visualize
- Practice with standard function blocks — TON, CTU, SR
- Add Structured Text for complex logic
- Try Function Block Diagram for analog control
- Use SFC for multi-step processes
Learn IEC 61131-3 with Plaxio
Plaxio is a free IEC 61131-3 compliant IDE with:
- Full support for LD, FBD, SFC, and ST
- All standard function blocks (TON, CTU, PID, etc.)
- Real-time simulation with live tag monitoring
- Export to Rockwell, Siemens, Schneider, PLCopen XML
- AI-assisted code generation
Summary
- IEC 61131-3 is the universal PLC programming standard.
- 5 languages: LD, FBD, SFC, ST, IL (use multiple in one project).
- Common data types: BOOL, INT, REAL, TIME, STRING.
- Standard function blocks: TON, CTU, SR, PID — work on all vendors.
- Vendor-neutral: Write once, export to Rockwell, Siemens, Schneider, etc.