Technical Article

PLC Programming: Overview of IEC 61131-3 in Industrial Automation Systems

March 25, 2021 by Anish Devasia

IEC 61131 has become the standard for programming and configuring industrial automation systems. Learn about this standard and some of its key features and functions.

The International Electrotechnical Commission (IEC) is the international body that sets global standards for electrical, electronic, and other related technologies. 

Various region-specific technology certification bodies derive their standards from IEC. IEC 61131 is the standard for programmable controllers.

It has ten parts covering general information, equipment requirement, user guidelines, communication protocols, safety, fuzzy control programming, and many other aspects regarding programmable controllers.

 

IEC 61131 Part 3: Protocol Overview

The third part of IEC 61131 defines the programming languages used for programmable controllers. It was published in December 1993 by IEC, and the current edition (third edition) was released in 2013. 

 

Video used courtesy of Panasonic

 

What are the Five Programming Languages Defined in the IEC 61131 Standard?

This set of standards defines the basic architecture of specific programming languages and allowed programming in 5 different programming language standards. Of the five languages, three are graphical, and two are textual programming standards. They are listed below:

Before IEC 61131-3, different vendors had various programming languages, and interoperability was non-existent. An engineer who knew how to program with one vendor's software had to learn the new programming of another vendor to work with the PLC. The different software life-cycle stages are specification, design, implementation, testing, installation, and maintenance, which were heterogeneous for different vendors. 

 

plc

Allen Bradley CompactLogix PLC. Image used courtesy of Rockwell Automation

 

IEC 61131-3 defined a minimum set of structures, the basic programming elements, and syntactic and semantic rules for programming languages used for programmable controllers. The advantages of IEC 61131-3 are:

  • Improved interoperability of programming languages
  • Higher programming efficiency
  • Reduced errors
  • Improved reusability
  • Modularization
  • Implementation of modern software techniques
  • Increased user efficiency

This made IEC 61131-3 widely accepted by users and vendors globally and has become the standard for programming and configuring industrial control devices. The standards are also evolving according to the needs of the industry and inefficiencies in earlier editions. A noted enhancement in the subsequent editions is the addition and improvement of support for Object-Oriented Programming (OOP), including classes, methods, interfaces, and namespaces. 

 

Features of IEC 61131-3 Programming Languages 

IEC 61131-3 defines the basic structure and elements of all programming languages for programming controllers. This allows PLCs to be programmed using multiple languages. Note that software used to program PLCs from one vendor cannot typically be used to program PLCs from another vendor. 

This is due to the differences in addressing schemes, task scan rates, array sizes, string lengths, and file formats. Users can utilize the five programming languages to program PLCs. The features of IEC 61131-3 that aid this are mentioned below. 

 

Standard Data Types 

IEC defined a standard set of data types with uniformity across all the programming software compliant with IEC 61131-3. The standard has defined how to interpret the contents of the variable. Only one type of operation is allowed for a particular data type. For example, mathematical operations can be done only on numerical data types and not on bit patterns.

 

Derived Data Types 

High-level, PC-oriented programming languages offer derived data types that users can define according to their needs. This gives more flexibility and versatility to programming languages. IEC 61131-3 supports derived data types like Fields and structures that allow for efficient organization and grouping of data. This allows for the use of data in a secure manner. 

 

Program Organization Units (POU)

Functions and function blocks are the most common POUs for programming. Recurrent tasks can be bundled as functions or function blocks that can be called when they are required.

This division of sub-tasks of the whole program makes programming and verifying written programs easier. It will be legible and coherent, opposed to the mess when such POUs are not available while programming.

 

Ladder logic on PLC

Specialized software tools in test and commissioning of PLC-based automatic control.

 

Data Encapsulation 

The third edition of IEC 61131-3 supports object-oriented programming. This is enabled by the capability of data encapsulation. It is the practice of bundling data with the functions that use the data. Classes are the most common use case of data encapsulation, widely used in high-level object-oriented computer languages.

With this, all the POUs have only local data and cannot be manipulated by other parts of the program. This avoids overwriting data errors.

 

Data-Exchange Interfaces 

It's necessary to have POUs and data encapsulation to have a robust programming language and define the data-exchange interfaces. The data types and the scope of each data type in different POUs must be well-defined. IEC 61131-3 has standardized the data exchange interfaces for programming languages for logic controllers.

 

Symbolic Functions & Function Blocks

Using the IEC 61131-3 standards, programs can be written in a way that is address and module independent. This enables writing functions and function blocks that are independent of target systems. The logic takes precedence over the specific implementation. This allows users to write reusable programs that can be appropriated for various systems.

 

Standard Syntax and Semantics

Syntaxes and semantics make up a high-level computer language. IEC 61131-3 has standardized them for all programmable controller languages. The commands and instructions would be the same across various programming languages.

This reduces the training required by engineers if they have to work with PLCs from multiple vendors. This additional feature enhances the reusability of the programs.

 

Language Extensions 

IEC 61131-3 has no intention of reducing the development of new PLC languages but only to standardize the languages. The standard allows proprietary function blocks to be programmed in non-IEC 61131-3 languages such as C++.

There are PLC vendors and dedicated software vendors that write reusable programs in higher-level PC-oriented languages. These are then ported to use with a specific device. PLC vendors can also enhance and provide extensions to the programming languages that are IEC 61131-3 compliant.

All these features help with using multiple languages for the same PLC according to the comfort of the user. It also helped create organizations like PLCopen, that work towards unification standards from different vendors. 

Users and engineers can purchase IEC 61131-3 compliant programming software from many providers according to the organization's needs and customizations. This standard helped unify, to an extent, the heterogeneous and fragmented programming landscape for PLCs.