IEC 61131-3 programming languages reference (LD, FBD, ST, IL, SFC), PLCopen standards, program organization units, data types. Use when discussing PLC programming standards or cross-platform compatibility.

GitHub
Install command
npx skhub add claude-dev-suite/iec61131
Markdown
SKILL.md

IEC 61131-3 Programming Languages Reference

Overview

IEC 61131-3 defines 5 programming languages for PLCs, all interchangeable:

LanguageTypeBest ForStatus
LD (Ladder Diagram)GraphicalDiscrete logic, motor interlocksActive
FBD (Function Block Diagram)GraphicalContinuous control, PID, analogActive (DCS primary)
ST (Structured Text)TextualComplex calculations, algorithmsActive (most expressive)
IL (Instruction List)TextualLow-level, assembly-likeDeprecated (3rd ed. 2013)
SFC (Sequential Function Chart)GraphicalSequences, batch, state machinesActive

Program Organization Units (POUs)

PROGRAM

Top-level executable, associated with a task (scan cycle).

FUNCTION_BLOCK (FB)

Reusable block with persistent internal state (memory between calls). Used for motors, PID, timers, counters.

FUNCTION_BLOCK MotorControl
VAR_INPUT
    StartCmd : BOOL;
    StopCmd  : BOOL;
    FbkRun   : BOOL;
    Interlock: BOOL;
END_VAR
VAR_OUTPUT
    StartOut : BOOL;
    Running  : BOOL;
    Fault    : BOOL;
END_VAR
VAR
    MonTimer : TON;
    State    : INT;
END_VAR

FUNCTION (FC)

Stateless, no memory. Always returns same output for same input.

Data Types

Elementary

BOOL, BYTE, WORD, DWORD, LWORD, SINT, INT, DINT, LINT, USINT, UINT, UDINT, ULINT, REAL, LREAL, TIME, DATE, TIME_OF_DAY, DATE_AND_TIME, STRING, WSTRING

Derived (User-Defined)

TYPE MotorData :
STRUCT
    Running  : BOOL;
    Fault    : BOOL;
    Speed    : REAL;
    Runtime  : TIME;
END_STRUCT
END_TYPE

Variable Scopes

ScopeKeywordDescription
LocalVARInternal to POU
InputVAR_INPUTRead-only input parameter
OutputVAR_OUTPUTOutput parameter
In/OutVAR_IN_OUTBidirectional parameter
GlobalVAR_GLOBALAccessible by all POUs
ExternalVAR_EXTERNALReference to global
TempVAR_TEMPNo persistence
ConfigVAR_CONFIGSet at download
ConstantCONSTANTNamed constant

Language Details

ST (Structured Text) - Most Relevant for Code Generation

IF Motor.FbkRunning AND NOT Motor.Fault THEN
    Motor.Status := RUNNING;
    Motor.Runtime := Motor.Runtime + T#1s;
ELSIF Motor.Fault THEN
    Motor.Status := FAULTED;
    Motor.AlarmActive := TRUE;
END_IF;

CASE State OF
    0: (* IDLE *)
        IF StartCmd AND NOT Interlock THEN State := 1; END_IF;
    1: (* STARTING *)
        StartOut := TRUE;
        MonTimer(IN:=TRUE, PT:=T#10s);
        IF FbkRun THEN State := 2; END_IF;
        IF MonTimer.Q THEN State := 99; END_IF;
    2: (* RUNNING *)
        IF StopCmd THEN State := 3; END_IF;
    3: (* STOPPING *)
        StartOut := FALSE;
    99: (* FAULT *)
        StartOut := FALSE;
        Fault := TRUE;
END_CASE;

SFC (Sequential Function Chart)

Elements: Steps, Transitions, Actions

  • Steps contain actions (in any language)
  • Transitions are boolean conditions
  • Action qualifiers: N (non-stored), S (set), R (reset), L (time limited), D (delayed), P (pulse)
  • Parallel branches (simultaneous), Alternative branches (selective)

FBD (Function Block Diagram)

Signal flow left-to-right. Blocks represent functions. Wires connect outputs to inputs. Primary language in DCS (PCS 7 CFC, DeltaV Control Studio, ABB Freelance).

LD (Ladder Diagram)

Based on relay logic. Contacts (NO/NC), coils, timers, counters. Left/right power rails. Rungs top-to-bottom.

PLCopen Standards

TCTopicDescription
TC1StandardsIEC 61131-3 compliance testing
TC2Motion ControlMC_MoveAbsolute, MC_Stop, MC_Home, etc.
TC3Software EngineeringCoding guidelines
TC4CommunicationsOPC UA mapping
TC5SafetyIEC 61508 extensions
TC6XML ExchangeVendor-neutral program interchange format

PLCopen XML Format (TC6)

<project xmlns="http://www.plcopen.org/xml/tc6_0201">
  <types>
    <pous>
      <pou name="MotorControl" pouType="functionBlock">
        <interface>
          <inputVars>
            <variable name="Start"><type><BOOL/></type></variable>
          </inputVars>
          <outputVars>
            <variable name="Running"><type><BOOL/></type></variable>
          </outputVars>
        </interface>
        <body>
          <ST><xhtml><!-- Structured Text --></xhtml></ST>
        </body>
      </pou>
    </pous>
  </types>
</project>

Supported by: CODESYS, ABB AC500, Schneider, Beckhoff, B&R. NOT supported by: ABB Freelance (uses PRT), Emerson DeltaV (uses FHX), Siemens (uses SimaticML).

Other Exchange Formats

FormatStandardUsed By
PLCopen XMLIEC 61131-10CODESYS, Schneider, Beckhoff
SimaticMLSiemens proprietaryTIA Portal
AutomationMLIEC 62714Siemens PCS 7 V9+, multi-vendor
FHXEmerson proprietaryDeltaV
PRT/CSVABB proprietaryFreelance
DEXPIISO 15926P&ID exchange
Discovery
Tags

No tags published for this skill.

Version
Latest version metadata

Version

v2026.09.24

Published

Sep 24, 2026

Category

Uncategorized

License

MIT

Source path

skills/industrial/iec61131

Default branch

main

Latest commit

9496306

Tree SHA

fe4e2f1