Academic Journal of Science and Technology ISSN: 2771-3032 | Vol. 4, No. 1, 2022 20 Development of Upper Computer Software Based on OPC UA Technology Lei Tang, Jun Zhao Sichuan University of Science & Engineering, Yibin 644000, P. R. China Abstract: An intelligent manufacturing system is mainly used in experimental teaching. In order to solve the problem that the upper computer software of the system cannot intuitively display the status of field equipment and the data returned, a set of upper computer software of intelligent manufacturing system based on OPC UA technology is developed through Qt design. The software realizes OPC UA client function, and takes KEPServerEX as OPC UA server to control the intelligent manufacturing system. At the same time, the software can collect the status data of field devices and display them on the interface intuitively. Keywords: OPC UA technology, Qt, PLC, Intelligent manufacturing. 1. Introduction With the development of information technology, the world has ushered in a new round of industrial revolution. Meanwhile, intelligent manufacturing has received extensive attention. Intelligent manufacturing systems always contain multiple brands of equipment, and the data exchange between them needs a standard to achieve. OPC technology is such an industrial standard. At present, there are many ways to implement OPC technology. [1] realized the development of OPC server on Qt platform by using OPC development kit, and established Simulink project as OPC client to conduct simulation experiments, realizing information interaction between clients. [2] completed the design of OPC client based on C # language, and used KEPServerEX as OPC server to realize the data acquisition and control of the conveyor belt. [3] built OPC communication by combining Qt and KEPServerEX, and realized the monitoring of wheel hub assembly line. Aiming at an intelligent manufacturing system, this paper uses a method of "Qt+Open62541+KEPServerEX" to develop the upper computer software with OPC UA client function. KEPServerEX V6 is used as the OPC UA server, which can save the time of server development. OPC UA client is developed in Qt using open62541(an open-source implementation of OPC UA) and embedded in the upper computer software interface. Qt is a C++GUI application development framework developed by Qt Company. Qt supports cross-platform which means that programs are written independently of the operating system and the hardware environment. Qt establishes a signal and slot mechanism, which not only can realize human-computer interaction but also can easily transfer any parameter. Compared with other development methods, the method used in this paper has the advantages of short development cycle and strong scalability. 2. Technical Overview 2.1. OPC UA Figure 1. The Architecture of OPC UA For a long time, different manufacturers have used different industrial network standards, which are difficult to be compatible and unified. OPC UA is the globally recognized technological foundation of the future industrial network, which has been widely recognized by academia and industry in the past decade [4]. OPC UA (OPC Unified Architecture) represents the OPC unified architecture [5], which is developed and maintained by the OPC Foundation. It integrates all functions of OPC Classic specification (classic architecture), and is the inheritance and upgrade of OPC. Compared with traditional OPC, OPC UA has the advantages of platform independence (independent of hardware platform and operating system), more security (data encryption function), etc. OPC UA adopts C/S mode, and the specific 21 structure is shown in Figure 1. It can be seen from the figure that the interaction process between the server and the client is as follows: the client sends a service request to the OPC UA communication stack through the underlying communication entity, and then calls the request/response service through the OPC UA server interface. After executing the specified task on one or more nodes in the address space, a response is returned to the client. The client sends the release request to the OPC UA communication stack through the underlying communication entity. Then the request is sent to the subscription through the OPC UA server interface. When the monitoring item specified by the subscription detects data changes or events/alerts, the monitoring item generates a notification and sends it to the subscription. Finally, the subscription sends it to the client. 2.2. PLC PLC (Programmable Logic Controller) is a kind of microcomputer specially designed for industrial applications. It is widely used in various industrial systems because of its convenient use, stability, reliability, easy maintenance and other characteristics. The S7-1200 series PLC of Siemens is used in this paper. This series has compact design, strong scalability, low cost and powerful instruction set, which can provide a perfect solution for small automation systems. The S7-1200 series PLC integrated Profinet/Ethernet port supports OPC communication. 2.3. KEPServerEX KEPServerEX is a data acquisition service software widely used in industrial control. It provides hundreds of device drivers, client drivers and advanced plug-ins, and supports connecting thousands of devices and other data sources [7]. Support client application access through OPC, special protocols (Splunk, etc.), and IT protocols (REST, SNMP, etc.). In addition to being used as a server, KEPServerEX has also built its own OPC Client (OPC Quick Client). With this simple client, we can test the function of obtaining data from OPC Server and modify value of the data. Figure 2. Intelligent Manufacturing System 3. Intelligent Manufacturing System An intelligent manufacturing system consists of eight units: automated warehouse and stacker unit, AGV carrier robot unit, automatic conveying unit, CCD visual shape and color detection unit, industrial robot loading and unloading unit, visual detection and sorting unit, serial robot assembly unit, and parallel robot processing unit. Figure 2 shows the structure of the system. As shown in the figure, the warehouse PLC controls the operation of automatic warehouse and stacker unit through digital I/O and analog I/O. AGV Control PLC controls the operation of AGV carrier robot unit. The other six units are controlled by the converter line PLC. Three PLCs can exchange data in the same industrial Internet. The upper computer software is connected to PLC through OPC UA technology. 4. Development of Upper Computer Software 4.1. Configure Server KEPServerEX is used as OPC UA server in the system. In KEPServerEX, you need to create a "channel", that is, the driver for the project link, which is determined by the protocol used by the device. For example, Siemens S7-1200 uses "Siemens TCP/IP Ethernet". Then you need to specify the model corresponding to the equipment, which is the PLC model used by the system. Then specify a fixed IP address as the unique ID to access the device. LinkType indicates the type of upper computer to be connected, including OP, PG and PC. After adding the equipment, you can import the PLC variables to be accessed. In KEPServerEX, a Tag corresponds to the address of a data variable. Each PLC variable has a unique addressing address, such as the address "DB10. B0.0". DB10 represents the PLC data block with the number of 10, B represents the data type of Boolean, and 0.0 represents the first bit of the byte with the offset of 0. According to the variable address configured in the PLC programming software (TIA Portal), add the corresponding tag in KEPServerEX to form a data channel with the PLC. 4.2. Client Development The client development mainly includes two steps: OPC UA client development and Human Machine Interaction development. The development of OPC UA client in this paper is based on the open-source implementation of Open62541 of OPC UA. Open62541 is developed using C language (C99). It not only implements the OPC UA specification[8], but also provides the implementation interface of OPC UA server and client, which is very friendly to the development of OPC UA client. Open62541 has very complete and powerful functions, and its internal OPC UA data type and function implementation are completely defined. When building OPC UA client, Open62541 provides several main functions as follows. (1) UA_ Client_ connect. Connect the OPC UA server, which is used to connect the client to the specified OPC UA server and return whether the connection is successful. Open62541 provides two connection methods for selection. One is to connect to the server directly, and the other is to provide the username and password.The two methods can be selected according to the application scenario and server settings. (2) UA_Client_readValueAttribute. Read the value attribute of the node. This function passes the specified UA_ NodeId reads the variable value and returns whether the reading is successful. UA_ NodeId indicates the node ID to be read. It can be initialized by the functions such as UA_NODEID_STRING and UA_NODEID_NUMERIC. (3) UA_Client_writeValueAttribute. Write the value attribute of the node. It is used to request OPC UA server to modify the value of a node to write PLC variables. This function needs to specify UA_ NodeId, and the modified variable value. (4) UA_Client_Subscriptions. create.Create Subscriptions 22 for the node. Subscriptions are used to report back notifications. Subscriptions in OPC UA are asynchronous. That is to say the client sends several Publish-Requests to the server. The server returns Publish-Responses with notifications only when a notification has been generated. The client doesn’t wait for the responses and continues normal operations. (5) UA_Client_MonitoredItems_createDataChange. Create MonitoredItems for Events and set the Callback function. When the MonitoredItem properties of an event changed, the server returns a notification message to the client. The Callback function is called when the client receives the notification message. In the Callback Function we can customize the behavior of the client when the event occurs. The OPC UA client can be built using the API(Application Programming Interface) provided by Open62541. The implementation steps are as follows. (1) Custom opc_client class and include the header file of open62541.And then instantiate the UA_ Client class. connects to the server using the UA_Client_connect function. If the connection fails, start the timer to set reconnection and record the times of connections. When the times of reconnections exceeds ten, the reconnection is stopped. (2) Create NodeIds( NodeIds refer to a namespace with an additional identifier value). After connecting to the OPC UA server, we need to create a variable node to access the PLC data collected by the server. The related functions provided by open62541 can be used to create NodeIds. For instance, UA_ NODEID_ STRING (2, "channel1. conveyorPLC. SEN11"), the first parameter represents namespaceIndex and the second parameter is Item ID, which can be queried in OPC Quick Client. (3) Create Subscriptions and Monitored Items using API. After creating Monitored Items, when the data of the monitored Items has changed, the program will call a Callback Function to notify the change of data. So developers can define a Callback Function to complete the corresponding function. In this work, we mainly emit a signal in the Callback Function, and use Qt's signal slot mechanism to bind the signal with the slot function to refresh the interface. So that we can intuitively see the real-time status of the field equipment on the software interface. The development of Human Machine Interaction interface is mainly completed by Qt Designer. Qt Designer can complete the development of Human Machine Interaction by simply dragging widgets, modifying parameters and writing slot functions. It greatly reduces the amount of code and shortens the development cycle. Figure 3. The interface of client 5. Application As shown in Figure 3, the software is successfully deployed in the intelligent manufacturing system. On the interface, we can visually see the status of all conveyor belts and the real- time position of the workpiece. In addition, the software will display the inspection results (including color, material, qualification, etc.) of the workpiece in the table on the interface and write them into the historical database. 6. Conclusion This paper develops an upper Computer software based on Qt for an intelligent manufacturing system. The software is based on OPC UA technology to control and collect data of field devices. And the software uses the variable subscription API provided by open62541 to visually display the status changes of the workpiece on the conveyor belt. In addition, the method of OPC UA development used in this study effectively reduces the development difficulty and greatly shortens the development cycle. Acknowledgment This work is supported by The Innovation Fund of Postgraduate, Sichuan University of Science & Engineering (Y2021085). References [1] Li Bangteng, Liang Wei, Ma Ping. Development and Simulation Application of OPC Server Based on Qt P- latform[J]. Computer Measurement & Control, 2017, 25(11): 154-158.DOI:10.16526/j.cnki.11-4762/tp.2017.11.039. [2] GAO Shi ping, ZHAO Jian- feng, CAO Jin- jiang. Design and Application of OPC Clients Based on C# [J]. Journal of Nanjing Institute of Technology( Natural Science Edition), 2020,18(03):28-31.DOI:10.13960/j.issn.1672- 2558.2020.03.006. [3] TANG Ya-Ling, GUO Jian, ZHANG Xue-Feng, CH-U Yue- Zhong. Monitoring System of Wheel Hub Asse-mbly Line Based on OPC Technology [J]. Computer S-ystems & Applicatio-ns,2021,30(03):103-109. DOI:10.15888/j.cnki.csa.007832. [4] Guidelines for the Construction of National Intellig-ent Manufacturing Standard System (2018 Edition) [J]. Machinery Industry Standardization & Quality,2018(12):7-14. [5] Wang Tong, Dai Minlu, Lei Guoping. Overview of OPC UA System Framework [J]. Fujian Quality Management, 2019. [6] Zhao Yan-hui, Nie Ya-jie, Wang Yong-li, Li Hai-pi-ng. Research on OPC UA Technolo-gy [J]. Chemical Defence On Ships, 2010(2):5. [7] HU Qing-long. Design and Implementation of Rem-ote Centralized Control System for Filter Press Based o-n KEPServerEX Software [J]. Techniques of Automation and Applications, 2021,40(12):32-35. [8] Sun Yuanfeng. Design and Implementation of OPC UA Server Based on SECS/GEM Protocol [D]. Zhejiang Gongshang University, 2022.5. DOI:10.27462/d.cnki.ghzhc.2022.000633.