Rust as Alternative to ICE-61131
This article was first released in SPS_MAGAZIN in German.
The programming of systems and machines is traditionally done with PLCs based on the IEC61131 standard, which originated in the 1990s. However, software development has changed dramatically over the last 30 years, which is also reflected in the programming languages. This article explores the questions of why it is worth reconsidering classic PLC programming and why the Rust language, of all things, should serve as the basic building block.
Why is PLC programming used for system programming at all? A core requirement is the real-time requirement for the control programme. The runtime system, the programming and the integrated development environment (IDE) must provide sufficient support for this. This includes a real-time capable runtime system that can be configured in the IDE. There are also model-driven programming approaches with ladder diagram or sequential function chart to create simpler code for specialised problems. Communication with the I/Os via field bus is also necessary. This must also be easily configurable through the programming system. Furthermore, it must be possible to integrate the PLC into a heterogeneous IT and OT landscape, so the integration and communication of non-real-time critical software must also be easily possible.
Figure 1: Code example with compile error of the borrow system – Image: Institut für Steuerungstechnik der Werkzeugmaschinen und Fertigungseinrichtungen (ISW)
What is Rust?
Rust is a compiled language without garbage collection, which makes it suitable for real-time programming. This is because garbage collection automatically manages memory in the background, which can lead to latency fluctuations and negatively affect real-time. The special thing about Rust is the memory management. Without a garbage collector, manual memory management is necessary, which is a major cause of bugs and security vulnerabilities in C/C++. Rust relies on an ownership and borrowing system, whereby the lifespan of memory and memory references can already be checked at compile time. This makes the compiler a powerful tool for software development. In the code example shown, the transfer of the vector v to the print_vec function indicates ownership of the function. The following push call therefore results in a borrow of move value. In addition to memory safety, the repertoire of Rust also includes concurrency checks at compile time and error handling checks, which increases software stability. The number of runtime errors in Rust programs is lower compared to C/C++ because the compiler catches many errors and forces the programmer to use clean solutions. In addition, Rust offers the advantages of modern programming languages, such as build systems, package managers, easy test integration and IDE integration.
Is Rust worthwhile?
The classic IEC61131-3 languages are also affected by insecure memory management when memory references are used, thus providing a target for potential runtime errors and security vulnerabilities. These challenges can be met by standards such as Misra or by software development processes such as those used in the automotive industry. However, the hurdle for deployment is significantly higher than if the programming language itself already provided memory security. The introduction of Rust into Linux kernel 6.1 shows the potential that is seen in the language. Microsoft is also in the process of integrating Rust into the Windows kernel. Experiences with Rust confirm this impression: it is actually possible to write stable software faster than with C/C++. It seems to be particularly worthwhile in automation technology. However, one disadvantage must be mentioned: getting started with Rust is a major hurdle. The concepts must first be understood and internalised before they can be used effectively and the compiler is satisfied.
What does the PLC programming look like?
For an architecture for the use of Rust in the PLC, a real-time-capable runtime system and a field bus connection are required first. The runtime system abstracts the creation and configuration of cyclic or event-based real-time tasks, so that the user does not have to take care of their administration themselves. The field bus connection is linked to the runtime system, so that the field buses can be started here by means of configuration data. The field bus configuration is carried out in a separate tool that can be integrated into the engineering. With the field bus configuration, the access methods for the process data can be automatically generated at compile time with the help of the macro functionality of Rust. The control programme can then be implemented on this basis. Care is taken to ensure a clear separation of real-time and non-real-time components. This has the advantage that non-critical code does not waste real-time resources and the critical code is reduced in size. However, data structures are needed to exchange data between the two parts without blocking the real-time part. These are provided in a library that also contains other typical models such as state machines. Both the real-time and non-real-time parts can incorporate any libraries available for the respective operating system. This offers a high added value, since a wide range of libraries can be used. However, additional validations must be carried out for the real-time part, e.g. to ensure that memory allocations are not made or that there are no unbound loop passes. This can be done by static code analysis or by analyses during the compilation process.
Outlook
The interest in Rust in control technology is also evident in projects such as an OPC UA server and client or an Ethercat master implemented entirely in Rust. In order to evaluate the potential of Rust and test its practical suitability, the presented architecture is being analysed and implemented at the ISW of the University of Stuttgart. The experience gained so far shows that Rust has the potential to be the PLC programming language of the future.
Explore Rust for Next-Generation PLCs
If you’re looking to build safer, more reliable, and high-performance control software, Rust offers a compelling alternative to traditional IEC61131 PLC programming.
With memory safety, concurrency checks, and modern tooling, Rust enables you to develop real-time applications with fewer runtime errors and greater stability.
Whether you’re working on EtherCAT masters, OPC UA servers, or custom automation solutions, our architecture and experiments demonstrate how Rust can be applied in industrial control systems.
Contact us to learn how Rust can enhance your PLC projects, pilot a Rust-based runtime, or collaborate on real-time automation research.