IEC 61499 and open source solutions for control system development

Why IEC 61499 is needed

In this article, I will try to share the results obtained by the team of MAI Department 307 in the process of cooperation with Kaspersky Lab in the development of secure control systems for industrial control systems, IoT and smart home.

Traditionally, the world of embedded programming is divided into PLC programming, using IEC 61131 programming environments and C/C++ development for microcontrollers and embedded devices. The IEC 61131 standard includes 5 programming languages ​​ST, FBD, IL, LD, SFC and allows you to abstract from the features of the hardware implementation of the device and data transfer protocols. This significantly reduces development time and reduces the number of errors.

It should be noted solutions that are often used in the development of prototype systems:

However, these tools are more focused on rapid prototyping and make it difficult to move from prototype to solution later on.

Programming in IEC 61131, for example, in a structured text language, allows you to quickly describe the control algorithm in terms of input / output variables and operations on them. When developing this standard, a separate programmable controller was considered as a computing module. It is possible to describe the interaction of several controllers within a single control system, but it may not be very convenient. A stone that is sometimes thrown into the IEC 61131 garden is the sharpening only for control systems. Python, java script or even C++ are used in various areas, while ST or FBD is only used in industrial automation.

IEC 61499 has been proposed as an extension of the IEC 61131 standard for distributed control systems consisting of multiple controllers. The basic building block of IEC 61499 is a functional block similar to the FBD language.

Fig.1.  Function block in IEC 61499.
Fig.1. Function block in IEC 61499.

A function block in IEC 61499 has data inputs, data outputs, and in addition to IEC 61131, event inputs and outputs (marked in red). At the moment of arrival of the input event (REQ), the input variables are read, the logic of the function block is triggered. The function block logic performs calculations, assigns output variables, and fires output events (CNF). A function block can have dedicated events for initialization (INIT) and confirmation of initialization (INIT0). The IEC 61499 program is a graph whose nodes contain functional blocks interconnected by data and events. The use of events provides an explicit way to control the flow of execution in a distributed system.

There are nice runtime implementations for IEC 61499 Eclipse 4diac forte and development environments Eclipse 4diac IDE. They are available under the open license EPL. The development environment can run on Linux, Windows or Mac. The runtime runs on any posix compatible OS and even on microcontrollers. To develop a secure solution, it seems promising to launch the IEC 61499 4diac forte execution environment on Kaspersky OS.

Starting with “Hello world”

An example of a minimal “Hello world” program in the 4diac development environment is as follows:

Fig.2.  Minimal program in 4diac environment.
Fig.2. Minimal program in 4diac environment.

What’s inside a function block

The development environment allows you to describe the program as a set of related function blocks and in fact works only with descriptions of function block interfaces. There is an option to pre-made function blocks from the library or create your own. For example, you can create a function block in the IDE with the following description to get the current time:

Fig.3.  Function block interface E_TIMESTAMP
Fig.3. Function block interface E_TIMESTAMP

The runtime only parses the function block interface. Inside the runtime, xml is used to describe the functional block:

Fig.4.  Example function block declaration E_TIMESTAMP
Fig.4. Example function block declaration E_TIMESTAMP

The runtime contains a kernel for working with events and a library of function block implementations. When an application is loaded, instances of the
functional blocks and starts the exchange of messages between them. For a new function block, the IDE can generate a C++ class stub. For example, for E_TIMESTAMP the source code for forte looks like this:

Fig.5.  Class that implements the logic of the function block E_TIMESTAMP
Fig.5. Class that implements the logic of the function block E_TIMESTAMP

The main logic of the function block is implemented in the virtual method void executeEvent(int pa_nEIID); It is this method that the developer must implement if he creates his own functional block.

The 4diac standard library has function blocks for working with I / O, specific blocks for control systems, such as PID and communication blocks for various protocols. 4diac includes support for common industrial protocols Modbus TCP, Modbus RTU, MQTT, OPC UA and others out of the box.

Fig.6.  Possible system architecture with 4diac
Fig.6. Possible system architecture with 4diac

For me, the following became extremely attractive when working with 4diac:

  • wide possibilities of extending functionality in C++

  • well-thought-out strict structure of function block interfaces, based on the IEC 61499 industry standard

  • the ability to reuse components between projects as component interfaces are standardized

The runtime is written in classic C++, which allows you to add the desired fieldbus protocol, work with I / O, or run on an unsupported platform. For example, we have successfully added DBUS, CAN and work with custom peripherals and even video stream processing.

When downloading a project to the controller, the function block descriptions and information
their relationships are passed to the forte runtime. To download a function block to a device:

  • set device configuration

  • assign a function block to a device

  • download project to device

An example of an interface for configuring devices and networks is shown below:

Rice.  7. Determining the device configuration of the system
Rice. 7. Determining the device configuration of the system

To download the project to the device in 4diac IDE, you need to execute the deploy command.

Fig.8.  Downloading a project to a device
Fig.8. Downloading a project to a device

Installing the Development Environment and Building the Runtime Environment

You can download and install the Eclipse 4diac IDE development environment from site eclipse. For the IDE to work, you must first install java.

You can download the Eclipse 4diac forte source code from the eclipse repository:

git clone

To build under Windows, you can run the commands:

cd org.eclipse.4diac.forte
mkdir build
cd build

The executable file will be here build\src\Debug\forte.exe

To build under Linux or another posix compatible operating system, you can run the commands:

cd org.eclipse.4diac.forte

The executable will be placed in the build\posix\src\forte directory

After starting for execution, forte tries to read the project to run from the forte.fboot file (which may not exist) and waits for the project to be loaded from the development environment. The following message is usually given:

INFO: T#18446743746374136594: FORTE is up and running
INFO: T#18446743746374744094: Using provided bootfile location set in CMake: forte.fboot
INFO: T#18446743746375534594: Boot file forte.fboot could not be opened. Skipping...

In the development environment, you can view the input and output values ​​of function blocks while the program is running, using the watch command, which can be called by the right mouse button.

As I mentioned earlier, the forte runtime can be built for various operating systems, such as Windows, Linux, Freertos. Recently, students of Department 307 of the Moscow Aviation Institute launched forte on Kaspersky OS CE (I will talk in more detail about the porting process and the project forte4kos in the next article).

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *