Implementation of a machine tool retrofit system

Abstract. Small and medium-sized companies increasingly turning their attention towards the fourth industrial revolution. In order to increase their own long-term competitiveness, there is a growing desire to make production smarter, more efficient, safer and more sustainable through new technologies. Often, however, existing plants cannot be easily replaced by modern equipment. The reasons for this can be high investment costs, excessive downtimes or the unavailability of an equivalent machine. An alternative solution to the purchase of new equipment is the modernisation or expansion of existing systems, also called retrofitting. Thus, this paper deals with the retrofit process of a machine tool, whereby the software architecture of the control unit is the primary concern of this work.


Introduction
Since the introduction of the fourth industrial revolution, the shape of the industry is changing and individual customer requirements become the focus of attention more than ever before. This paradigm shift from conventional production strategies towards fully connected valueadding processes places new demands on small and medium-sized companies (SME). To cope with this, Industry 4.0 (I4.0) enables more individual, flexible, efficient and sustainable production through the intelligent networking of machines and processes with the help of information and communication technologies [1]. Another concept that has recently come to the fore, are systems in which virtual and physical processes merge and interact, known as Cyber-Physical Systems (CPS) [2]. CPS can be seen as a technology for upgrading production for Industry 4.0. and consist of sensors, actuators, embedded systems, control, computing and communication devices that collect data and enable their availability [3]. However, implementing conventional machine tools into a CPS environment is not a trivial task, as these systems often do not provide adequate sensors or communication standards and mostly rely on proprietary system architectures, which inhibits the interconnection with other devices.
With machine tools, raw material is processed into a saleable product. These systems are part of the inventory of every company and impress with large quantities and high resource consumption [4]. They often constitute a high proportion of a company's capital. For this reason, a work life of 20-30 years is common for such machines [5]. Due to the paradigm shift in the course of Industry 4.0, older machine tools may no longer meet the requirements for quality or connection ability. Retrofitting offers an alternative solution to the purchase of a new machine.
Retrofitting can be divided into two categories, namely: traditional and smart retrofitting. Traditional retrofitting is the replacement of components to optimise accuracy, speed, maintainability and ease of use [5]. Upgrading the drive and control elements of an old machine is one way to extend work life. But often, when the machine is about to reach its payback point, the drive and control elements still meet the quality requirements but they do not fit into modern production systems [4]. Therefore, smart retrofitting focuses on adapting existing equipment at a low-cost level. By adding smart sensors inside the old machine tool, relevant data will be generated. Both the historical and real-time data can be used to access status and condition of the system. The data can be, for example, further processed into a cloud service and also provides a decision-making basis for the plant control [5]. It should be noted that, for successful modernisation according to the idea of Industry 4.0, both types of retrofitting are necessary.
An important point that should be considered when retrofitting existing machinery is the control software of Programmable Logic Controllers (PLC). Due to the increasing functionality, higher availability as well as the higher degree of automation through modernisation, the demands on the PLC software are increasing [6]. Therefore, the development costs of the software contribute a not negligible share to the total costs of the retrofit project [7]. Especially when it comes to sustainability, it is important that the software has a modular structure and thus allows it to be extended, easy maintainable or individual modules to be tested at an early stage of development. For the reasons mentioned above, this paper describes both the hardware retrofitting process and the PLC software architecture. Stock and Seliger (2016) [8] describes various ways of realising sustainable manufacturing in Industry 4.0. The authors identify retrofitting as one opportunity for sustainable manufacturing. In a case study, retrofitting is applied to a machine tool. Therefore, the retrofit process is divided into four essential steps: situation analysis, defining of the monitoring strategy, data processing and implementation of the equipment in a CPS. As a result of the case study a milling machine has been extended by an acceleration sensor. Although their approach shows the fundamental steps of the retrofitting process, they leave open the question of how connectivity can be achieved.

Related Works
A first retrofitting approach which is independent of the type and model of equipment is highlighted by the authors of Baker et al (2016) [9]. The authors are mainly concerned with requirements engineering for the technology applied in the modernisation process of subsea equipment used in offshore deepwater operations. To objectively define the requirements, they use a Model-Based Systems Engineering framework, which is basically the application of models to support product development at any stage of development or life cycle. Even though they do not devote to a specific type or model of equipment, their approach is limited subsea equipment. In addition, their work concentrates on the definition of requirements for this particular use case. Arjoni et al. (2017) [10] propose retrofit techniques and focus on keeping the cost factor as low as possible. These developed techniques are demonstrated on three machines forming an academic plant. All three retrofit processes are about establishing intelligent and remote communication, as the scoped machines are outdated and do not allow communication with modern equipment. As a result, the authors present the Raspberry Pi 3 boards as a cost-effective tool in the retrofit process due to their versatility and stable operation. Ehrlich et al. (2015) [11] consider the modernisation of a production line in terms of the potential offered by modern Industry 4.0 technologies. They conclude that the replacement of a whole production line by I4.0 technology at once is not financially feasible and they do not see the retrofit process as a "knee-jerk" action but more as a progressive process. The authors also present a new business model called Retrofitting as a Service. The retrofit process itself is divided into four steps, but the approach is limited to production lines.
Al-Maeeni et al. (2020) [5] show one way in which augmented reality (AR) can be used to increase the ease of use as well as reduce costs and processing times of existing machines and equipment. They use AR as a tool to help the machine operator to do the right thing in the right sequence. In a case study, the authors use a navigation aid displayed on a Google HoloLens to improve orientation on a rotary bending machine due to an unstructured and unclear process flow. With this, they demonstrate a new technology or tool in the context of retrofitting.
In [12] and [13], Lins et al. deal with the topic of retrofitting in the context of Industry 4.0. These papers aim to develop a universal approach to transform industrial equipment into a CPS. In the latter contribution, a retrofitting platform is presented resp. developed, which provides resources for integrating old equipment in I4.0, regardless of the model or type. Inspired by the Reference Architectural Model for Industry 4.0, the developed retrofitting platform consist of three layers: infrastructure, communication and application. Furthermore, requirements, components and technical necessities to assist the implementation of the proposed platform were defined.  [13]. This work is specifically aimed at companies that want to practise retrofitting. In addition to a detailed introduction to the field of retrofit, the authors present a multi-stage retrofit model. The multistage model shows users their current progress in the Industry 4.0 retrofitting as well as the stages and the order in which they need to be passed through. Subsequently, the universal approach is presented, which is split into 10 steps. Although the work of  [14] introduce an approach for retrofitting that can be applied regardless of the model and type of equipment. However, for the implementation of retrofit, it is beneficial to use the work of Lins et al. (2020) [13] as a basis, as this work clearly defines various requirements, components, methods and resources.
Related work on retrofit only show the upgrading process of the hardware, while the software is often left out of the discussion. In addition, the implementation is often not described in detail. The aim of this work is to look at the entire retrofit process from both the hardware and the software side in a case study.

Software Architecture
Software architectures describe a shared understanding of the design of a software application. Typically, an architecture describes how major components of a system interact with each other. The representations of software architectures are usually subjective, as the view of the significant architectural features may change during the life cycle [15].
A widely used architecture of software systems is the multitier architecture in which the software is subdivided into several layers. Each layer has a specific responsibility and contributes with its function to the overall application, whereby it provides and uses services. The basic principle of a multitier architecture is to allow only neighbouring layers to interact with each other. As a result, the system remains modular. This means that a layer can use the services of another layer without having to understand how this layer works [15]. This advantage is particularly useful in the development of standardised processes. However, layered architectures are not suitable for every application. A major disadvantage is that the software cannot be easily adapted to changing requirements. The reason for this is that the business logic is rooted in all layers. In addition, many layers harm the performance of a system. This paper presents and applies a hexagonal architecture, also called Ports and Adapters, which was according to Litvinov (2020) [16] originally introduced by Alistar Cockburn in 2005. The idea is that users, programs, automated tests or batch scripts should drive the application equally. Furthermore, this and other approaches are the consequence of the desire for more flexibility, adaptability, maintainability and testability in software development [16]. The hexagonal architecture consists the three layers: domain, application and framework. Compared to multitier architectures, in here the business logic is strictly separated from other logic elements. Consequently, the hexagonal architecture departs from the conventional multitier models and introduces ports and adapters. Ports define the protocol in which an interaction with the domain layer is allowed. In other words, they specify how the communication with the outside world can be established [17]. Adapters, on the other hand, form the bridges between the outside world and all ports. They convert incoming signals into a protocol-specific form so that the domain layer is capable of interpreting the signals and vice versa [16].  Figure 1 shows the architecture of the developed software. In the middle of the abstract diagram is the domain layer. The domain is the central part of the software and contains the business logic. Summarised, the business logic describes the behaviour and constraints of the application. In addition, the domain layer acts as a supervisor and throws errors if there is incorrect communication with the domain. In the figure shown, the circle elements describe the ports. There is a difference between inner and outer ports. The outer ports are the interfaces between the outside world and the application itself, whereas inner ports are the interfaces to the domain layer. Between the inner and outer ports the application layer is rooted and links the framework to the domain layer. All adapters are embedded in the application layer. The adapters convert the input of the outer ports into a shape that can be understood by the domain. As shown in figure 1, the entire application is surrounded by the framework layer. This outermost layer contains all input and output devices, other applications, external libraries or third-party services.

Use Case
According to the universal approach given by Lins et al. [13], the retrofit procedure begins with the mapping of all existing resources and the definition of new resources. For the implementation of the resources and the achievement of all functionalities, various components have to be added to the system. All available components are divided into three structural layers. The layers are interconnected and each component has access to information and functions of other components [13]. The infrastructure layer covers the support and connection of the components to the industrial equipment. The communication layer is responsible for integration into an industrial network and communication with other network participants. Finally, the application layer enables interaction with other applications within the industrial network. Figure 2 shows the relationship between the added components and the bench drill.
Existing resources. The bench drill used in this case study is an OPTIdrill D17 Pro made by Optimum. It is a hand-operating bench drill with a maximum power of 500W. Between the motor and the spindle, there is a belt drive. By changing the drive ratio of the belt, the spindle speed can be regulated between 500 and 2520 min -1 . An inductive sensor is used to detect the speed. A metallic object is attached to one pulley on the spindle so that a signal is triggered with each full revolution. In addition to the speed, the machine also detects the height of the drilling tool. A potentiometer is mounted on the feed lever, which changes its resistance (and hence the voltage) equivalent to the height of the drilling tool. The machine's digital display contains a HT46R54A 8-bit microcontroller that processes the signals of the speed and drilling tool height as well as visualising them on the display. The machine is also equipped with an emergency stop switch, a switch for the drill chuck protection and a magnetic switch for the belt gearbox. Each of these switches can interrupt the power supply to the motor and consequently stop the machine.
Defining new resources. Following the description of the Lins et al. 2020 [13], the new resources must be defined. In addition to the drilling tool height and the spindle speed, the motor temperature, the room temperature, the motor current and the motor voltage needs to be measured too. The positions of the three safety switches also need to be digitized. Adding an RFID identification enables the assignment of process data to the current job and the user working on it. The data collected shall be stored in a database. For communication with other Industrial Internet of Things (IIoT) devices, the CPS needs to be extended by an interface to an Industry 4.0 network. Furthermore, relevant information must be visualised via a user interface directly on the drilling machine and remotely via a web service. Table 1 shows a list of all resources.

Infrastructure and Communication
Embedded Board. The main component of the infrastructure layer is the embedded board, which receives the signals of all sensors. Such a board requires the support of various connections, buses and interfaces [13]. In this case study, a Revolution Pi Connect+ is used. The Revolution Pi is a programmable logic controller made by Kunbus. The PLC supports several industrial bus systems such as Modbus and RS485 and others like USB. Furthermore, extension modules allow the use of additional communication interfaces. Since the embedded system of the drilling machine does not offer a communication interface, the sensor signals must be captured separately. With the extension modules DIO (Digital In-and Output) and AIO (Analogue In-and Output), the signals of the integrated sensors of the machine tool can be received and processed by the PLC. The DIO module adds 16 individual digital inputs and outputs to the PLC. With the AIO module, up to 6 analogue signals can be captured and up to 2 analogue outputs can be controlled. The DIO module is responsible for monitoring the safety switches, while the AIO module monitors the temperature sensors and the potentiometer. All inputs and outputs on the PLC and the extension modules are read cyclically every 20ms.

Power Monitoring Device.
As the PLC and the expansion modules only work up to a maximum of 24VDC, the additional power monitoring device Sentron PAC3200 from Siemens is used. The Sentron PAC3200 measures the supply voltage (≈230VAC), measures the current at the motor and sends the information to the PLC via the Modbus TCP/IP interface, where the PLC software can compute the power from these two values. However, instead of the primary current of the motor, a secondary current is measured, which is generated by an AX-0500 current transformer. The current transformer has a transmission ratio of 500:1.

Temperature sensor.
A complete representation of the physical machine in the virtual world also includes the monitoring of temperatures. Since the AIO module of the PLC has two inputs especially programmable for resistance temperature detectors (RTD), two PT1000s are used to detect the room and motor temperatures. The AIO module automatically computes a temperature from the analogue signal.
Microcontroller. The PLC with a cycle time of 20ms is not fast enough to capture the signal peaks of the inductive sensor for the rotational speed. For this reason, an Adafruit Feather M0 Bluefruit microcontroller is used. The microcontroller measures the time difference between two signal peaks and sends this value periodically to the PLC via the RS485 bus.
USB RFID Reader. The bench drill is equipped with two USB EM 4100 radio-frequency identification (RFID) readers. One RFID reader is responsible for the user access identification. This means that registered users can only start the machine. Otherwise, relays interrupt the power supply. Another reader is responsible for identifying the current job. By scanning the RFID tag, the system searches for the route card belonging to the current job and displays it on the monitor.
Communication. The integration of a network component is an essential part of retrofitting. The network component is responsible for integrating the industrial equipment into an Industry 4.0 communication network. The PLC attached to the drilling machine still has an unused Ethernet port. A static IP address is set for this port so that other network participants can access the historical and live data via TCP IP protocol.

Application
Database. By using a database component, historical process data can be stored and retrieved. Also, user-specific information for machine access and job details are stored. A SQLite database is used for this purpose. Another advantage of using a database is that the recorded process parameters are linked to the respective job and the machine user. This improves and simplifies the evaluation of the dataset.
Webserver. In general, the purpose of a web service component is to provide quick and easy access to relevant data. The web server is built with the web framework Flask. Flask is suitable for simple applications and supports simple URL routing.
Visualising Component. The visualization component works in cooperation with the webserver. The user interface is accessible via a website. For this purpose, a 10.1-inch capacitive touch Liquid Crystal Display (LCD) is equipped on the drilling machine, which displays relevant information to the user. The user interface only visualizes the process and cannot affect the physical process itself.

Results and Conclusion
In this paper, a traditional drilling machine, commonly encountered in industry, was equipped with modern acquisition and communication technologies (retrofitting). For this purpose, different approaches from the literature were presented and analysed for their suitability. By using a universal approach, the machine tool was upgraded for integration into I4.0 systems. Besides the integration itself, further functionalities were added. Table 1 shows the results of the retrofitting process and compares the before and after state. System is able to identify the positions of the safety switches and provide data to other network participants Furthermore, the architecture of the control software is presented in this paper. The presented software departs from the conventional layered architecture and builds on a hexagonal architecture. Due to the principle of ports & adapters, it is possible to separate the business logic from the rest of the logic. As a result, the domain becomes independent of the rest of the application. Thus, the system can easily be extended by further components. This only requires the creation of an adapter, which communicates with the domain via the defined ports. An additional effect, individual software elements can be tested independently of the entire system.

Future Works
As future work, it is intended to implement an Open Platform Communications Unified Architecture (OPC-UA) component. This will standardise the data transfer and ensure interoperability between the communication participants. On the basis of this paper, a digital twin will be built for a complete representation of the machine in virtual world. In addition, the system will be extended by an AR application.