# OPC-UA Agent for Legacy Programmable Logic Controllers +
## 1 Introduction  
With the advances of industrial Internet-of-Things (IoT) in recent years, open platform communications (OPC) unified architecture (UA) is attracting attention as a communication technology for automatic monitoring and control between machines. OPC-UA is a communication standard for the exchanging of control and management data between distributed entities in industrial automation systems [1]. It is standardized by IEC 62541 [2] and specifies reliable, secure, and interoperable communication between various automation devices such as programmable logic controllers (PLCs), human-machine interfaces (HMIs), and supervisory control and data acquisition (SCADA) systems. OPC-UA offers numerous advantages [3, 4]. Its functionality is platform-independent and scalable. It supports comprehensive information modeling and allows for the design of service architecture with complex hierarchical data structures [5]. Moreover, OPC-UA provides enhanced security for session encryption and authentication. To use OPC-UA in specific applications, each application domain has an associated companion specification [6]. The OPC-UA for IEC 61131-3 specification presents an information model for PLCs and defines function blocks for using OPC-UA services in PLC programs [7, 8]. The information model describes the configuration, resources, tasks, and programs of an IEC 61131-3-based software in terms of OPC-UA objects, variables, and methods, and enables the PLC to be monitored and used by OPC-UA clients. PLCs may also need the OPC-UA client functionality to perform data exchanges horizontally withother PLCs and/or vertically with higher-level machines such as SCADA and HMIs. The specification of an OPC-UA client for IEC 61131-3 defines function blocks as those used for connecting to an external OPC-UA server, accessing data either synchronously using read services or asynchronously using a subscription, and calling methods on remote servers. Despite the advantages of OPC-UA, there are legacy PLCs with a significant installation base that cannot benefit from the technology [3; 9; 10; 11; 12]. This is because they do not support TCP/IP or lack the built-in computational functions required by IEC 61131-3 due to limited hardware or software capabilities. Typically, programs in legacy controllers are written in instruction lists (ILs) or ladder diagrams (LDs) that only support numeric types and do not support string or complex structure types. Even if the PLC has the necessary computing resources, including the OPC-UA, functionality in the PLC can have catastrophic computational side effects. Since PLCs perform real-time control functions, interference by the additional functions must be thoroughly investigated to ensure that the timing constraints of the control functions are satisfied [13; 14]. Therefore, the approach of having a dedicated agent running OPC-UA on a separate machine could be a viable solution for these legacy systems. This paper proposes the design of an OPC-UA agent to enable information service and client functionalities in legacy PLCs. The agent runs on a separate machine connected to the PLC using a dedicated link, and maintains shared memory for certain variables in the PLC. Based on the periodically synchronized variables, the agent services the OPC-UA information model and executes client function blocks on behalf of the PLC. One important design feature is that, using synchronized variables, the agent implements simplified remote procedure calls (RPC) of IEC 61131-3-based function blocks. This allows the standard OPC-UA client API to be used in existing PLCs that do not support strings or complex user-defined structures. To validate the proposed design, we implement an agent prototype and demonstrate the successful monitoring and control of an industrial robot controller via OPC-UA. Through experiments, we evaluate the performance of UA functions in terms of the latency of the read service as the number of items increases. The remainder of the paper is organized as follows.