# IEC 61131-3

First appeared 1993 3.0 / February 2013 None

IEC 61131-3 is the third part (of 8) of the open international standard IEC 61131 for programmable logic controllers, and was first published in December 1993 by the IEC. Part 3 of IEC 61131 deals with programming languages and defines two graphical and two textual PLC programming language standards

## Overview

IEC 61131-3 is the first vendor independent standardized programming language for industrial automation. Established by the International Electrotechnical Commission (IEC) a worldwide standard organization founded in 1906 and recognized worldwide for standards in the controls industry by over 50 countries. The standard is already well established in Europe and is rapidly gaining popularity in North America and Asia as the programming standard for industrial and process control.

The adoption of IEC 61131-3 by the industry is driven by the increasing software complexity of control and automation requirements. The time to create, labor cost, and maintainability of control software has a major impact on control projects which can be improved using the IEC 61131-3 vendor independent programming language standard. Applying a standard programming language has a positive impact on the software life-cycle that includes requirements analysis, design, construction, testing (validation), installation, operation, and maintenance. The impact on maintenance is important since control software maintenance, including upgrades, is generally 2- 4 times the labor of initial programming.

The IEC 61131-3 standard combined with new powerful Freescale chip architectures enables an entire controller to be delivered in an embedded device. Control programs can run distributed and independently rather than concentrated in large controllers. No longer are thousands of lines of control programs required running in one controller for complex automation applications. This increases performance, improves reliability, and simplifies programs.

IEC 61131-3 provides multiple language support within a control program. The control program developer can select the language that is best suited to a particular task, greatly increasing their productivity. Plus with a standardized programming interface that is completely independent of the hardware platform, users can greatly reduce the cost of program maintenance and training across company wide automation applications.

IEC 61131-3 is hardware independent. The ability to transport automation solutions to other platforms is vastly improved over PLC applications offering users and System Integrators a level of reusability never before available. IEC 61131 increases the efficiency and speed of implementing new automation solutions by using readily available control components developed on other projects and by outside developers.

Companies that have chosen to implement IEC 61131-3 find that they reduce human resource costs in training, debugging and maintenance, and improve productivity from the higher reusability.

## Programming languages

Graphical language. Represents a program by a graphical diagram based on the circuit diagrams of relay logic hardware. Ladder logic is used to develop software for programmable logic controllers (PLCs) used in industrial control applications. The name is based on the observation that programs in this language resemble ladders, with two vertical rails and a series of horizontal rungs between them.

### Function block diagram (FBD)

Graphical language. Functional block expresses subprogramm. Each FB has entries and exits. Programm is developed by integrating various FB.

### Structured text (ST)

Textual language. Has Pascal resemblance. Example:

IF Voltage>220 THEN
Current:=Current - 10;
ELSE
Current:=50; Speed:= ON;
END_IF;

### Instruction list (IL)

Textual (deprecated in 3rd edition of the standard), influenced by Assembler. Example:

    LD Voltage (*Load Voltage in accumulator*)
GT 220 (*If >220*)
JMPCN М1 (*Go to label, if ">220" is false*)
LD Current (*Load Current in accumulator*)
SUB 10 (*Substact 10 from accumulator*)
ST Current (*Set Current value from accumulator*)
M1: LD 0 (*Load value "0" in accumulator*)
ST Out (*Set Out value from accumulator*)

### Sequential function chart (SFC)

Graphical, has elements to organize programs for sequential and parallel control processing.

### Continuous Function Chart (CFC)

This language is an extension to the IEC 61131-3 standard, which gives free positioning of graphic elements.

## Data types

• Bit Strings - groups of on/off values
• BIT - 1 bit
• BYTE - 8 bit (1 byte)
• WORD - 16 bit (2 byte)
• DWORD - 32 bit (4 byte)
• LWORD - 64 bit (8 byte)
• INTEGER - whole numbers (Considering byte size 8 bits)
• SINT - signed short (1 byte)
• INT - signed integer (2 byte)
• DINT - double integer (4 byte)
• LINT - long integer (8 byte)
• U - Unsigned - prefix a U to the type to make it an unsigned integer.
• REAL - floating point IEC 60559 (same as IEEE 754-2008)
• REAL - (4 byte)
• LREAL - (8 byte)
• TIME - duration for timers, processes.
• Date and Time of day:
• DATE - calendar date
• TIME_OF_DAY - clock time
• DATE_AND_TIME: time and date
• STRING - character strings surrounded by single quotes. Escaped characters are preceded by a dollar sign.
• WSTRING - holds multi-byte strings.
• Arrays - multiple values stored in the same variable.
• Sub Ranges - puts limits on value i.e., (4-20) for current
• Derived - type derived from one of the above types.
• TYPE - single type
• STRUCT - composite of several variables and types.

## Variables

Variable attributes: RETAIN, CONSTANT, AT

• Global
• Direct (local)
• I/O Mapping - Input, Output, I/O
• External
• Temporary

## Configuration

• Resource - Like a CPU
• Tasks - Can be multiple per CPU.
• Programs - Can be executed once, on a timer, on an event.

## Program organization units (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 - processing resources, memory for IO, execution rates, number of tasks.

## Changes

### New capabilities

• Data types with explicit structure
• Data type with named values
• Basic data types
• References
• Dynamic length arrays
• Initialized variables
• Types convertations - implicit, explicit
• Functions - call rules for functions without results
• Conversion types funtions: numeric, bitmaps, etc
• Functions of combining date and time
• Classes, methods, interfaces
• Object-oriented function blocks (FB)
• Namespaces
• Structured text (ST): continue operator, etc
• Appendix A - formal specification of language elements

### Deleted

• Appendix - Expamles
• Appendix - interaction with IEC-61499

### Deprecated

• Octal literals
• Using the direct address in the body of the IEC programmable organizational units (POU)