PLCnext Technology - PLC versus embedded controller

Industrial automation is traditionally a PLC domain since they are simple and robust. However, in modern factories there is an increasing demand for flexibility and a higher need for connectivity & networking leading to more complex integrated systems. Is it possible to combine PLCs and embedded controllers? In this article we will explore the possibilities.

Process Control with PLCs

In its simplest form, a control process has three main parts: the sensor, the controller, and the actuator. The sensor sends information or a reference signal from the process to the controller that implements a feedback or closed-loop control system and uses actuators to drive the process. Sensors can measure any type of parameter from a process. Examples of actuators in a mechanical system are motors, drives, and pumps, but also include pinions, pulleys, and chains.

This directly maps on the processing model of a PLC which runs as a continuous loop where all inputs are read, processing takes place and outputs are being generated. The frequency of the loop is identical to the (highest) sampling frequency. Lower sampling frequencies can be supported by splitting the loop into parts where some parts are executed every loop and other parts e.g. only every alternative loop. If the total processing takes (too) long this might enforce a lower overall loop frequency or splitting the loop as mentioned before. In a simplistic approach there is no concept of a system heartbeat and the loop just runs as fast as it can. In general power optimizations are not relevant for PLC applications hence sleep and wake-up situations are not present.

This continuous loop paradigm is a direct inheritance from the way a PLC was conceived. PLC is an acronym for ‘programmable logic controller’. At the beginning of the electronic revolution (1960s-1970s), controlling devices were designed with discrete electronic components in a fixed topology. Changing project specifications meant redesigning and reengineering the whole control logic, with physical components shuffled and moved around. With PLCs, the design efforts for the control algorithm are confined almost entirely into the software.

PLCs have specific advantages that make them attractive for manufacturing applications. They are modular, simple and robust and suppliers ensure availability of replacement parts for years. Very often production lines have to run for many years and uptime is a very important criterion. However the most important feature of a PLC is that it is hard real-time. A real-time system guarantees that all inputs, outputs, and computations process within a specific time constraint, often referred to as a deadline. A PLC considers missing a deadline to be a total failure. For specific operations hard real-time guarantees are essential.

Limitations of the PLC

PLCs restrict memory, software, and peripheral capability if compared to a personal computer (PC). Motion control (e.g., automation and robotics) can have many inputs and outputs, requiring extra PLC control modules or outside electronics. Production lines are becoming more complex with e.g. the introduction of machine vision and more complex robotics which increase the control complexity. Also in modern factories (industry 4.0) the requirements are shifting towards flexible production lines and a high degree of connectivity. These are areas where PLCs have their challenges.

With flexibility and connectivity complexity enters the equation. Computationally intensive and/or time-critical processes running simultaneously might cause a PLC to become overloaded. Carefully splitting the control loop into higher and lower sampling frequencies will solve many issues but may require extensive testing and tuning effort. Alternatively, to keep less time-critical tasks from affecting those with a deadline, machines can use multiple computing platforms. Typically, these incorporate one or more motion controllers, and one or more supervisory processors that support the operator interface for programming, machine operation, data collection, and maintenance functions. However, using multiple PLCs is costly.

Embedded Controllers

An embedded controller can work in a different paradigm using the concept of interrupt or event-driven processing. Conceptually the controller is continuously in a waiting mode until an event happens which is subsequently handled and might lead to changes in output signals. After the handling has completed the controller goes to waiting mode again. An event can be interpreted as an input signal changing value. Not all changed input signals need to be treated as events, some can be ignored until the change in value becomes relevant. In case sensors do not support the generation of events or the controller does not have (sufficient) interrupts the input signals can be polled based on a timer interrupt. It is easy to give every input its own optimal sampling frequency but it is impossible to provide hard real time guarantees since the regular and timer interrupts may come in bursts.

In embedded controllers real-time is translated into being “as fast as possible”. For many applications there are no strict deadlines so this concept of soft real-time is good enough.

The event driven paradigm naturally supports power optimization since the waiting mode can be used to bring the controller to a sleep mode.

Whereas hard deadlines are not always relevant it is often critical that specific actions are taken in a strict order. Also it is important that an event may lead to a different set of actions depending on the situation or the state the controller is in. This is generally modeled as a state machine. State machines can define very complex controllers but the challenge is to determine whether they behave correctly in all possible circumstances.

Building reliable control applications

Building reliable control applications is the target of Dezyne. Dezyne is set of model-driven software engineering tools (software design tools) that enable software engineers to create, explore and formally verify component based designs for embedded and technical software systems. Based on a powerful, open modelling language, Dezyne gives software engineers the ability to construct software components that implement any kind of behaviour within an application. Graphical views of models enable engineers to easily navigate, communicate and document their architectures and designs. Advanced simulation features provide engineers with the means to fully explore and validate their designs, no code compilation and execution is necessary. Automated formal verification discovers hidden defects that are otherwise practically impossible to find. Efficient code generation instantly turns verified models into executable code.

Dezyne is targeted at modeling event-driven systems so it fits very well with embedded controllers. Its component based approach makes it scalable from small to very large systems and also is the answer to the problem of complexity an engineer often faces.

Having the best of both worlds

In a situation that has some hard real-time constraints the application of PLCs seems the best choice and in a situation with many soft real-time constraints and high complexity the application of embedded controllers seems the best choice. The obvious question is whether we can combine both approaches and how best to achieve that.

There is one aspect which provides a seemingly natural direction. Hard real-time requirements are mostly local in nature: They occur inside a machine or are associated with a tightly linked trigger and response definition. E.g. an emergency stop must immediately stop a motor. However, such a response cannot be expected for a whole factory; it is e.g. critical that an emergency stop for the whole factory brings all machines to a stop in a controlled fashion but not necessarily immediately.\[1]

So an optimal setup is an hybrid approach: PLCs are applied at the lowest level of control supporting all the hard real-time requirements and embedded controllers are used at higher levels of control integrating the systems to an overall control system.

\[1] If that would be required pulling the power is probably the fastest way.

How to support a hybrid approach in software

We have seen that Dezyne fits best with Embedded Controllers. However, there is no fundamental obstacle to use it in combination with PLCs. As already indicated the principle difference in both approaches is the difference between a situation of continuous signal sampling and a situation of interrupt driven behaviour. The easiest way to bridge this is to do continuous sampling as in a PLC loop and check if any signal has changed value: if so treat this as an event and feed it into the Dezyne generated system, if not then all outputs also remain the same.

If the PLC supports any of the languages generated by Dezyne (C, C++, C#, Java, Javascript, Python) this can all be integrated into the PLC code and run on the PLC. A PLC can also work together with an embedded controller by a memory mapped interface where all input and output signals are buffered in a shared section of memory. A PLC can support this e.g. through a PowerLink real-time ethernet connection. Another approach is through the general communication protocol OPC UA supported by most types of PLC. Some brands of PLC are more open to external interfacing than others; this may refer to mixing brands of PLCs or combining PLCs with embedded controllers. So a working solution will be different for different types of PLC.

PLCnext Technology Demonstrator

Currently Verum is developing a demonstrator with a PLC from the PLCnext family of Phoenix contact. We will experiment with multiple ways of integration of the event driven control software in the PLC. If you want to know more about this project please contact us.

PLCnext Technology from Phoenix Contact is a unique, open ecosystem for modern automation that is capable of meeting all the challenges of the IoT world.

The combination of open control platform, modular engineering software, and systemic cloud integration enables simple adaptation to changing demands and the efficient utilization of existing and future software services. With the PLCnext Store, Phoenix Contact provides the PLCnext Community with an open exchange platform for their software functions.