IEC 61131-3
IEC 61131-3 is the third part of the international standard IEC 61131 for programmable logic controllers. It was first published in December 1993 by the IEC; the current edition was published in May 2025.
Part 3 of IEC 61131 deals with basic software architecture and programming languages of the control program within PLC. It defines three graphical and two textual programming language standards:
- Ladder diagram, graphical
- Function block diagram, graphical
- Structured text, textual
- Instruction list, textual deprecated. Per IEC 61131-3-2025, chapter 7.2 Instruction List is no longer included in Edition 4. Thus, IL is no longer part of IEC 61131-3.
- Sequential function chart, has elements to organize programs for sequential and parallel control processing, graphical.
Data types
Elementary Data Types (basic)
- Bit Strings – groups of on/off values
- * BOOL - 1 bit
- * BYTE – 8 bit
- * WORD – 16 bit
- * DWORD – 32 bit
- * LWORD – 64 bit
- INTEGER – whole numbers
- * SINT – signed short integer
- * INT – signed integer
- * DINT – signed double integer
- * LINT – signed long integer
- * USINT – Unsigned short integer
- * UINT – Unsigned integer
- * UDINT – Unsigned double integer
- * ULINT – Unsigned long integer
- REAL – floating point IEC 60559
- * REAL –
- * LREAL –
Elementary Data Types (Date and Time)
- Duration
- * TIME –. Literals in the form of T#5m90s15ms
- * LTIME –. Literals extend to nanoseconds in the form of T#5m90s15ms542us15ns
- Date
- * DATE – calendar date
- * LDATE – calendar date
- Time of day
- * TIME_OF_DAY / TOD – clock time
- * LTIME_OF_DAY / LTOD – clock time
- Date and time of Day
- * DATE_AND_TIME / DT – time and date
- * LDATE_AND_TIME / LDT – time and date
Elementary Data Types (Character / Character string)
| Escape sequence | Produces |
| $$ | $ |
| $' | ' |
| $L | linefeed |
| $N | newline |
| $P | page |
| $R | return |
| $T | tab |
| $xx | hex value |
- Existing
- * CHAR – Single-byte character
- * WCHAR – Double-byte character
- * STRING – Variable-length single-byte character string. Literals specified with single quote, 'This is a STRING Literal'
- * WSTRING – Variable-length double-byte character string. Literals specified with a double quote, "This is a WSTRING Literal"
- New in version 4 of the standard
- * UCHAR – Single character encoded according to UTF-8
- * USTRING - Variable-length character string in which each character is encoded according to UTF-8
Generic Data Types
Only available for the input / output/ in-out variables of system-defined Program Organization Units- ANY
- ANY_DERIVED
- ANY_ELEMENTARY
- * ANY_MAGNITUDE
- ** ANY_NUM
- *** ANY_REAL: LREAL, REAL
- *** ANY_INT
- **** ANY_UNSIGNED: ULINT, UDINT, UINT, USINT
- **** ANY_SIGNED: LINT, DINT, INT, SINT
- ** ANY_DURATION: TIME, LTIME
- * ANY_BIT: LWORD, DWORD, WORD, BYTE, BOOL
- * ANY_CHARS
- ** ANY_STRING: STRING, WSTRING
- ** ANY_CHAR: CHAR, WCHAR
- * ANY_DATE: DATE_AND_TIME, DATE_AND_TIME, DATE, TIME_OF_DAY, LTIME_OF_DAY
User-defined Data Types
- Enumerated data type
- Enumerated data type with named value
- Subrange data type – puts limits on value i.e., INT for current
- Array data type – multiple values stored in the same variable.
- Structured data type – composite of several variables and types.
- Directly derived data type – type derived from one of the above types to give new name and initial value as a type.
- References – a kind of strongly typed pointer. Arithmetic operation of the value of this type is prohibited.
Variables
Variable attributes: RETAIN, CONSTANT, ATConfiguration
- Resource – Like a CPU
- Tasks – Can be multiple per CPU.
- Programs – Can be executed once, on a timer, on an event.
Program organization unit (POU)
- Functions
- * Standard: ADD, SQRT, SIN, COS, GT, MIN, MAX, AND, OR, etc.
- * Custom
- Function Blocks
- * Standard:
- * Custom – Libraries of functions can be supplied by a vendor or third party.
- Programs
Configuration, resources, tasks
- Configuration – processing resources, memory for IO, execution rates, number of tasks.
Object oriented programming (OOP)
- The 3rd revision of the standard describes how to implement OOP within the application programming