Approach to Adapt a Legacy Manufacturing System Into the IoT Paradigm

— Enterprises are adopting the Internet of Things paradigm as a strategy to improve competitiveness. But enterprises also need to rely on their legacy systems, which are of vital importance to them and normally difficult to reconfigure or modify, their mere replacement being usually not affordable. These systems constitute, therefore, barriers to agility and competitiveness, raising the need to develop cost-effective ways for IoT adaptation. An approach for adapting legacy manufacturing systems into the IoT realm is proposed in this research. The methodology is twofold: an adaptation board is firstly designed to provide IoT connectivity, allowing to remotely invoke the “legacy” functionality as services. Then, the board itself can leverage the legacy system by developing additional functionalities inside it, as the update process is usually triggered by the need of new functionality from these systems. An experiment, which consists of adapting to IoT a small distribution line that is controlled by an aged Programmable Logic Controller, is developed to illustrate how straightforward, affordable and cost effective the adaptation approach is, allowing to holistically achieve a new system with more sophisticated functionality.


Motivation
We are currently witnessing an increase regarding the use of IoT systems, which manifests itself in the various aspects of human activity. In fact, the IoT paradigm has been gradually used in a variety of areas, such as surveillance, monitoring, localization, logistics, healthcare, manufacturing, and so on, mostly driven by complex market demands. This trend has in turn allowed the creation of new and innovative products and services. However, many systems exist today, usually mentioned as legacy systems, that are still used and participating in value creation, but which are unable to be integrated in the IoT realm. For instance, in manufacturing, there are many machines and other systems, which may be relatively old and lacking these IoT capabilities, but whose use is still economically advantageous. These systems, although of vital value in many enterprises, affect their competitiveness, as explained below. This is very specifically pointed in a related research [ [1]]: there are systems, namely legacy software systems, which have been working for more than 50 years.
The most important aspect for manufacturing systems is that they need to cope with an increasingly competitive and more global market environment, whose demands have shifted from the mass production paradigm into one which necessitates more personalized products and fast delivery. This requires that these manufacturing systems should remain as agile and adaptable as possible to the changing conditions. Among the trends under Industry 4.0 that may enable this agility is the IoT paradigm. According to [[2]], IoT is considered as one of the key enabling technologies for the fourth industrial revolution that is known as Industry 4.0. The transformations in manufacturing systems, due to this paradigm, have enabled enterprises with the required agility. This is also confirmed in [ [3]], where it is mentioned that the automation of assembling products is considered a key aspect for labor-costs, asserting that to improve manufacturing efficiency and profitability, it is necessary to transform capital intensive assembly-lines into smart systems able to reconfigure rapidly, allowing fast rescaling of the production systems, in response to demand fluctuations. Legacy systems, due to their lack of autonomous responsiveness to disruptive events, would not allow prompt reaction to changing demands. An interesting trend also mentioned in [ [3]] is the economical and social shift towards "manufacturing as a service".
The importance of integrating legacy-manufacturing systems into the IoT realm is emphatically expressed in related research. As described in the next chapter, there is an abundant research focusing on legacy system adaptation to IoT. Most authors deal with this problem in a very broad perspective, either in the form of management architectures, IoT adaptors, gateways, and so on. To our knowledge, no research work is to be found with approaches describing the concrete steps that are necessary to adapt a legacy manufacturing system to the IoT paradigm. This is precisely the aim of our research. Therefore, in this paper, we present an approach that allows the transfiguration of a legacy manufacturing system into a form that allows operating within the IoT paradigm. The proposed methodology allows resetting the characteristics of a legacy system in terms of IoT functionality, typically, easier wireless communication, more autonomous behaviour, the ability to collaborate with other IoT objects, and energy management. By comparing the system's existing (legacy) functionality with the one required for an IoT object, gaps can be identified. Within our approach, these gaps are fulfilled through the development of corresponding service modules that are used to "upgrade" the legacy system. With these services, the transformed system can now operate in the IoT realm. As an illustration, the proposed approach is applied in the control of a distribution line, which is currently controlled by an aged (or legacy) Programmable Logic Controller (PLC). After its transfiguration, the mentioned assembly line is now able to behave as an IoT system. This distribution line, now able to operate in an IoT realm with many other IoT systems, can collaboratively participate in the provision of more complex services.

1.2
The legacy system and the IoT adaptation approach As mentioned before, we present an experiment that consists in the adaptation of a legacy system to the IoT paradigm. This system is a small distribution line, as illustrated in Figure 1. A Programmable Logic Controller (PLC) controls the line, which is very old. A simple local Human-Machine Interface (HMI) has got a button for starting a part transfer process. The PLC programming software no longer runs on the current operating systems. As it is, the system is not able to connect to the Internet and we are not able to reprogram the LADDER program running inside, unless we use a computer with an outdated operating system. From the assumptions highlighted later on, in the related research section, we can consider the distribution line and PLC as a legacy manufacturing system. As illustrated in Figure 1, the system can only be controlled locally through its HMI. Available operations are those that are programmed within the PLC code, which under the context of our experiment, we are not able to modify. Our aim is, on one hand, to adapt the system so that it can provide additional functionality. On the other hand, we intend that both the current and new functionalities can be remotely invoked in the form of services. A remote operator could then invoke these services. Furthermore, other IoT devices may be able to collaborate with this system and, holistically, participate in the execution of more complex services.
Our approach relies on developing a simple, very flexible, efficient and affordable adaptor, named IoT adaptor, as illustrated in Figure 2. The approach we are going to describe can easily be replicated in other situations. This includes the electronic circuit design, the connections to the PLC and distribution line, the firmware that will also hold the web services, and examples of services invocation. Contrasting with related research, as stated in the next section, our aim is to specifically describe the concrete steps to develop the board and undertake IoT adaptation of the legacy manufacturing system.

Literature Review
There are currently many systems, specifically legacy systems, which still participate in value creation and play vital roles inside enterprises. In spite of their lack of flexibility, mainly regarding interoperability with other systems, there are good reasons to keep them, and as an alternative, proceed to their modernization with adequate approaches. To illustrate what we mean in reality, it is important to first discuss the concept of a legacy system.
According to research work from the software engineering area [ [4]], a legacy system can be informally characterised as being difficult to maintain, but remaining itself vital for an organization. According to this research, many of such systems have been in operation for many years, as much as 50 years. Due to their reliance on the use of legacy systems, it is believed that, as stated in [ [1]], one in four companies will lose in competitiveness due to lack of competences in digital business technologies, and, therefore, they will not have the access to new markets, faster time-to-market, streamlined operations and cost savings that digital businesses generate. The research emphasizes the fact that these systems digest up to 90 percent of the IT budget, the main causes of these situations being problematic APIs and "dead" languages. Older APIs do not have built-in RESTful model properties. Many systems have been implemented with languages and paradigms that are no longer taught in universities, notably COBOL [ [1]].
In a manufacturing context, recent research work emphasizes the idea that at shopfloor level operations are frequently controlled by PLCs and computer numerical controlled resources, and that IoT or Cyber Physical System (CPS) virtualization will need to consider these shop-floor aspects for legacy reasons [ [5]]. Furthermore, according to the research in [ [6]], IoT is transforming the way that modern manufacturing systems will be developed and operated, mainly due to the adaptation of the REST architectural paradigm. According to the mentioned research, this imposes a paradigm shift for the automation system and requires effective approaches for handling the complexity in this transition, including the need for legacy manufacturing components to be integrated in the modern IoT manufacturing environment. These are modelled through the Unified Modelling Language (UML) profile design for the IoT, allowing the automation of the IoT-compliant generation process for both new and legacy equipment.
Many of the IoT works found in related research are focused on developing architectures for sensor networks, IoT or CPS. For example, the research described in [[7]] deals with the design of IoT architectures from the perspective of European projects, aimed at obtaining a common framework of IoT architecture design. The research described in [[8]] proposes an IoT architecture that allows for the interaction between mobile clients and smart / legacy systems through wireless gateways. In [ [9]] an IoT architecture is proposed that includes support for legacy systems, focused on easing the task of adaptation. Also legacy integration in the car manufacturing industry is slightly addressed in [ [10]]. The research described in [[11]] deals with the problem of connecting legacy devices to the world of smart services, by the utilization of mediator adapters that provide interoperability between industrial networks (CAN, PROFIBUS, and so on) to other systems. Other work deals with the integration of legacy devices in the SOA-based factory, emphasizing an infrastructure that copes with device heterogeneity, and proposing a gateway, or Service Mediator, to perform the transition of legacy infrastructure [ [12]]. In this research it is assumed that Gateways and Service Mediators for legacy systems are connected to an industrial communication system, e.g. Modbus, PROFIBUS / PROFINET, and CAN, which are commonly used industrial networks.
Other works focus on the study of gateways for the interoperability of IoT nodes, including legacy systems. For instance, an "IPV6 multi-protocol gateway" is proposed in [ [13]] for seamless integration of automatic building management systems into IoT, providing an interface for each legacy system.
There are research works making comprehensive surveys of IoT in the industry context. For instance, the research in [ [14]] provides this kind of survey, identifying key enabled technologies, major industry IoT applications, research trends and challenges, such as wireless sensor networks (WSN), big data analytics, RFID, and so on.
In the approach described in [ [15]], mechatronic components are considered at the lowest level in the system composition hierarchy that tightly integrates mechanics with the electronics and software required to convert the mechanics into a intelligent (smart) object, offering well-defined services to its environment. A software layer, named wrapper, is developed on top of the mechatronic components, allowing integration in an IoT based industrial automation environment. It transforms a mechatronic component in an "industrial automation thing" (named as "IAT" in [15]). The approach is undertaken by a so-called model-to-model transformer, which automatically transforms the legacy mechatronic component into an IAT.
All in all, our study of the related research led us to conclude that there are many authors addressing the adaptation of legacy systems, and specifically manufacturing systems, to the IoT paradigm. The research of legacy to IoT transformation is in general well addressed. However, we found little research describing the concrete steps undertaken during this transformation. Implementation and Testing

Legacy system IOTization
In this section, an approach for adapting a legacy system into the IoT environment is presented. We will describe the concrete steps undertaken during the adaptation of the system. The initial step consists of reformulating the existing "legacy" functionality, with additional requirements that are desired in the system after being adapted into IoT, as illustrated in Figure 3. This is because the desire to replace or upgrade a legacy system is frequently induced by the need for additional functionality. The comparison between these two sets allows us to identify gaps of unsatisfied requirements and proceed to their implementation during the adaptation phase.

Requirements for modelling and implementation
In order to proceed with our experiment, a wireless digital input/output board is assembled in a circuit that will be connected to both the PLC and the distribution line. The PLC unit is very old and, as mentioned before, it no longer allows modification of the LADDER diagram that is encoded and runs in its internal memory. Therefore, this system can be considered as legacy.
Applying the suggested approach of filling the required functionality gaps (as suggested in Figure 3), both existing and required functionality are placed in contrast as shown in Table 1. The first set of requirements are the ones already existing in the legacy system. The latter constitute the newly desired functionality, which ought to work in an IoT way. Requirement 7 provides the doorway for invoking the legacy functionality as remote services.  Table 1. Requirements for the legacy system -IoT adaptation

Req Description
Legacy (already there) 1 A button in a HMI triggers the start operation, which performs a push of a new part from the entry buffer.
2 Each part that enters the system is identified as either A, B or C by the sensors. 3 According to its type, each part A, B or C must be delivered to exits 1, 2 and 3 respectively.
New IoT functionality 4 Remotely, switch on/off the power of the legacy system.

5
Monitor whether the legacy system power is on/off. 6 Count the number of each part transferred from the input buffer into each station.

7
Trigger the local operations through corresponding remote services. As a legacy system, the distribution line required locally the presence of a human to operate the system through its HMI. The new requirements were specifically formulated to allow the system to be operated remotely, without the need for the local human operator. That is also why the new IoT functionality permits the on/off electrical power switch of both the PLC and distribution line, allowing significant savings in energy consumption. Furthermore, the adaptor board can inform whether there is a sudden power cut from the grid. In such situations a backup battery provides power to the IoT adaptor board. The satisfaction of the above requirements resulted in an adaptation of the system as shown in the diagram in Figure 4.

Proof of concept and testing
The distribution line is represented by a reduced scale model, as shown in Figure 5. For the intended purposes, we can rely on a model for our experiment. The line has got a vertical feeder at the right side. A cylinder is used to push a part on the main conveyor. During this process, two digital sensors are used to identify the part number. According to the LADDER program running inside the PLC, each part is distributed to its exit according to the identified type.
The PLC, which is running the LADDER program, and the HMI, are shown in Figure 6. As in any PLC, the sensors of the distribution line are connected to the input lines of the PLC. The actuators, namely the main conveyor and cylinders, are connected to the output lines.
The circuit diagram for the IoT adapter is shown in Figure 7. It comprises an integrated circuit, namely the ESP8266-12e (ESP) microcontroller, which provides Wi-Fi connectivity and several reconfigurable General Purpose Input/Output lines (GP_IO). An example of the use of this device in engineering contexts can be found in [ [16]]. Additional components, like resistor and opto-couplers, are used to interconnect the ESP and both the PLC and distribution line. The adoption of a distinct network protocol, such as Bluetooth or ZigBee, is just a technological aspect we can neglect for the purposes of our experiment.  The corresponding circuit for the ESP-based IoT adapter is shown in Figure 8. Below the circuit lies the battery backup, which provides power to the board when there is a power shortage in the grid. In normal conditions, the battery is charged with energy from the mentioned grid.
The program for the IoT adapter is programmed inside the ESP in C language. The structure of the code for ESP configuration, namely setting pin modes, either input or output, is shown in Figure 9. Figure 10 illustrates the C code for configuring ESP as an Access Point (AP). Setting it as an AP, any laptop or mobile device can connect to the ESP as a client. Additionally, the ESP circuit could be programmed in "station" mode and, therefore, be able to connect to an existing network infrastructure.
An important aspect subjacent to IoT systems is their ability to interconnect with other IoT devices. Similarly, our IoT adapter requires a number of web services, which enable remote operation. That is, by invoking these services, a human operator, or even other IoT systems, can remotely operate the distribution line. According to the requirements previously established during the gaps identification, the corresponding web services are identified in Table 2.   The source code for a developing a web service inside the ESP is illustrated in Figure 11. It comprises the manipulation of the corresponding GP_IO pins, to remotely trigger the push of a new part into the system. The remaining part is composed of HTML code, which is optional, showing the result of the operation in a web browser. Figure 12 illustrates how such services can be invoked by a browser in a mobile device. The web service and HTML corresponds to the service shown in Figure 11.
The test just performed on the new IoT based distribution line shows that the proposed approach is effective. The implementation costs are fairly attractive and the time required to adapt the system was also satisfactorily short. Now that the legacy device can be used through web services, it can interact with other IoT systems inside a manufacturing system. For such interaction, there are several protocols, which fall on the category of Remote Procedure Call, like REST web services [ [17]]. Furthermore, approaches on bridging with industrial networks can be found in [ [11]] and [ [12]].
The ESP8266 microcontroller, used in the adaptation board, uses Wi-Fi for connectivity, but can also be developed with other network protocols like ZigBee as illustrated in [ [18]]. For that purpose, it is necessary to use another microcontroller like the CC2530, as described in [[19]].
This research is only focused on the functional aspects of legacy system IoT adaptation. There are several important quality-of-service factors, including security, which must be considered in the industrial context. For instance, the research in [ [20]] addresses the security aspects when considering traditional SCADA systems in the realm of the Internet of Things.
Therefore, in a functional sense, we can conclude that the process of adapting a legacy manufacturing system into the IoT paradigm, like the approach proposed in this research, constitutes an attractive alternative, especially when the legacy systems in question are expensive, difficult to replace and of vital importance for an enterprise.

Conclusions and Future Work
As expressed in the previous sections, and confirmed by the related research, legacy manufacturing systems will persist for long, given their importance in value creation in companies and the high cost of their replacement. On the other hand, these systems constitute serious barriers to the agility and adaptability of companies. As such, the more affordable alternative lies in their adaptation from legacy into IoTbased manufacturing systems.
We have described an approach to adapt a legacy system to operate in the IoT realm. We have focused on the essential aspect of providing remote interoperability to the legacy system. Other crucial aspects, like security, will be addressed in a further refinement of this approach.
Our IoT adaptation methodological steps has shown potential value as a general approach for turning legacy systems into IoT ones. Based on the experiment performed during this research, the adaptation of the legacy system into IoT was achieved in an affordable way, both in terms of hardware, firmware, and time. Another side effect is that a human is no longer required to locally operate the system anymore and is then free to perform other task.