1. TOP
  2. PLC
  3. IEC61131-3

日本語 English

IEC61131-3

What Is IEC 61131-3?

IEC 61131-3 is an international standard that standardizes the programming languages of PLCs (Programmable Logic Controllers).

Its purpose is to unify the program notation that differed between PLC manufacturers and to improve the reusability and maintainability of programs.

Five Standard Programming Languages

Graphical languages

LD (Ladder Diagram)

A language based on relay circuits.

FBD (Function Block Diagram)

A language that expresses processing by connecting blocks with signal lines.

SFC (Sequential Function Chart)

A language that describes process "steps" and "transition conditions" like a flowchart.

Textual languages

ST (Structured Text)

A high/mid-level language similar to C and Pascal. Complex numeric calculations, data processing (arrays and strings) and
conditional branching (IF statements, FOR loops, etc.) can be written compactly and cleanly.

IL (Instruction List)

So-called mnemonics. A low-level language similar to assembly language.

Choosing Between Them

Programs are basically written by combining LD (ladder) and FBD (FUNs, FBs)
By grouping frequently used processing into modules, it can be reused. Modules (your own FUNs or FBs) can be shared as company-wide assets, and when a bug is found, fixing the module fixes every program that uses it, which also improves quality
ST makes complex numeric calculations, data processing (arrays, string processing), loops (FOR statements) and conditional branching (IF statements) easier to read

Data type

Basic type

Data type
CategorySize
BooleanBOOLTRUE/FALSE
Bit stringBYTE8bit
WORD16bit
DWORD32bit
LWORD64bit
Integer typesSINT8bit
INT16bit
DINT32bit
LINT64bit
USINT8bit
UINT16bit
UDINT32bit
ULINT64bit
Real typesREAL32bit
LREAL64bit
STRINGNumber of characters + NULL

Date type

Data type
CategorySize
Duration typeTIME64bit
Date typeDATE64bit
Time of day typeTIME_OF_DAY64bit
Date and time typeDATE_AND_TIME64bit

Arrays

CategoryExample
INT array with 100 elementsARRAY[0..99] OF INT

Structures

NameData type
mySTRUCTSTRUCT
mem1DINT
mem2INT
mem3STRING

Unions

NameData type
myUNIONUNION
mem1ARRAY[0..3] OF BYTE
mem2ARRAY[0..1] OF WORD
mem3DWORD

Enumerations

NameValue
myENUM
right1
left2
center3

Variable Scope

Local

Variable used only within a POU

Global variable

Variable usable everywhere

Input variable

Variable writable from an external network

Output variable

Variable readable from an external network

In-out variable

Variable readable and writable from an external network

FUNs and FBs

Function (FUN)

Behavior

A function executes when its input turns ON and returns a result. Input and output values do not retain state.

Examples of standard FUNs

  • MOV
  • SHL
  • Decoder
  • etc.

Function Block (FB)

Behavior

Instances (children) are created from the function block definition (parent).
Each instance is handled separately; if you create multiple instances, each behaves independently.
Note that, unlike functions, function blocks are executed every scan.

Examples of standard FBs

  • TON
  • PIDAT
  • SktUDPCreate
  • FileOpen
  • etc.

Compatibility Between Manufacturers

Programs using only contacts and outputs, like relay circuits, do not depend on the manufacturer.
However, the implementation and names of FBs and FUNs differ somewhat between manufacturers.
Below are some of the FUNs and FBs defined by IEC 61131-3

Function

Arithmetic

  • ADD, SUB, MUL, DIV, MOD : addition, subtraction, multiplication, division, modulo
  • ABS : absolute value
  • SQRT : square root
  • SIN, COS, TAN, ASIN, ACOS, ATAN : trigonometric functions
  • EXPT : exponentiation
  • LN, LOG : logarithms

Bit operations

  • AND, OR, XOR, NOT : bitwise logical operations
  • SHL, SHR : bit shift left / right
  • ROR, ROL : bit rotate right / left

Data type conversion

  • INT_TO_UDINT etc. : convert from any data type to another
  • INT_TO_REAL, REAL_TO_INT : conversion between integer and real
  • BCD_TO_INT, INT_TO_BCD : conversion between BCD code and integer

Selection and comparison

  • MOVE : assign a value
  • EQ, NE, GT, GE, LT, LE : comparison operations
  • LIMIT : upper/lower limit of a value
  • MAX, MIN : select the maximum/minimum of several values
  • MUX : multiplexer

String operations

  • LEN : get string length
  • CONCAT : concatenate strings
  • INSERT : insert into a string
  • DELETE : delete from a string
  • REPLACE : replace in a string
  • FIND : search a string

Function block

Timers and counters

  • TON : on-delay timer
  • TOF : off-delay timer
  • TP : pulse timer
  • CTU : up counter
  • CTD : down counter
  • CTUD : up-down counter

Related pages

PLC

systemvar

FUN/FB Comparison by Manufacturer

Compares the functions and function blocks of OMRON NX and KEYENCE KV-X.

Comments