中国科技论文在线 http://www.paper.edu.cn

OPC Server Software Design in DCS

Tundong Liu, Gangquan Cai, Xiafu Peng Automation Dept. Xiamen University, Xiamen, China 361005 [email protected]

Abstract—In order to meet the application of OPC for the introduction about OPC technology and OPC server process control, a set of OPC server interface software is interface software in this paper, OPC application on fertilizer designed with OPC specification in this paper. This software plant in the gas furnace Distributed Control System is organizes the device data as OPC standard data for other presented later. equipments which also support the OPC standard, and it successfully solves the communication between different II. OPC TECHNOLOGY INTRODUCTION equipment manufacturers. The software is applied in the Distributed Control System (DCS), so as to realize the data A. COM Technology exchange between the management configuration software and OPC technology is mainly based on Microsoft's COM the control device, which enhance the compatibility and technology. COM is a component tool that widely used, interoperability of the system. provides a wealth of integrated services for software designing [5]. COM uses binary canonical form, and can Keywords—OPC Technology, COM, Interface establish components to communicate with each other. As I. PREFACE long as in accordance with the norms of COM, any software functions will be implemented very well with high-level For a long time, many different hardware manufacturers program language. DCOM is COM’s seamless expansion in usually use different communication mechanism, which easily the distributed computing, realizes the transparency of the leads to "information island" phenomenon. In order to integrate network. the data of different equipments in a system, software developers have to invest considerable time and effort to B. OPC Technical Specifications construct the underlying software, and delay the development There are three kinds of OPC specification: (1) OPC Data cycle. To this end, the industrial control field needs an open Access specification; (2) OPC Alarm and Event norms; (3) standard to conduct a data access mechanism and management OPC Historical Data Access specification. The OPC Data that enable communication between various types of Access Specification is mainly applied in this paper. equipment more flexible [1]. The OPC Data Access Specification is based on the logic In 1990s, some of the world's leading suppliers of of the object model of OPC, the model includes three types: hardware or software develop a set of OPC specifications with OPC server object, OPC group object and OPC item object. Microsoft. OPC is an industry standard, which is based on OPC server object: It is at the most top-level of the logic Microsoft's OLE (now ActiveX), COM and DCOM model, and maintains information on the server and acts as a technology, includes a set of interfaces, properties and container of OPC group object, each OPC server object can methods for the process control and manufacturing contain many group objects. automation systems [2]. OPC group object: It provides the mechanism that In August 1996, the version of OPC 1.0 specification contains and manages many item objects. A group object can published by the OPC Task Force was passed. In 1998, OPC provide a way to allow customers to "subscribe" list, so Foundation organizations launched OPC 2.0 version [3], and customers can be notified when changes are happened in the amended some errors in the last version, added a few interface project. and adjusted the means of data communication, making OPC item object: it represent a connection which connects programs to run more stable and reliable. with data source, including the value, quality, timestamp, the OPC technology is to bring the advantages of separating 3 basic attributes. All the OPC item operation is controlled by software development and hardware development completely, the OPC group object that contains related items. leaves access interface task to the hardware manufacturer or third-party manufacturers, and offers OPC server for users. III. OPC SERVER INTERFACE DESIGN OF THE SOFTWARE OPC technology will be widely applied to control filed [4]. A. OPC Server Overall Structure Many well-known international hardware manufacturers added OPC interface in their own products. On the basis of The overall framework of OPC server is shown in Figure 1.

Supported by Science and technology plan projects (2008H0060) of Fujian, China 转载 中国科技论文在线 http://www.paper.edu.cn

While watching do OPC client // Always loop, //and stop when //removing surveillance server begin if actived then

groups // Whether the I/O DLL //group object is active items begin … //update the

Field //group object di if changed then // to judge whether //the content changes Figure 1. The overall framework of OPC server begin … //update this group by the In this chart, OPC clients exchange data with OPC server //new datas,notify the through the interface. The basic steps for the connection //connection terminals, between OPC server and client are as follows (with , omitting the definition of variables) //and update the datas //of client. • To initialize COM library. End; • OPC Server create object. End; • Access to the interface OPC Server. End; QueryInterface(IID_IOPCServer,(void**)(&m_pServer)); • AddItem () function can be used for adding a new • Add Group. item, it should have the following functions: Confirm the validity of the item just added; Items will • Select a data access mechanism. effectively be joined into the group object but • Add item. different groups can have the same items. In addition, OPC server uses the I/O DLL to read/write When a new item is added, it is needed to define a data devices, and send data to the client by asynchronous item record. For example: communication or point-to-point connection. It should be Type noted that reading/writing operation is very time-consuming, Item=record so OPC server generally uses multi-threading technology to sItemName :string; //Itemname solve it. sDescr :string; //Description B. OPC Interface software design hwnd :Thandle; //Handle The OPC specification assumes that every interface must vType :TvarType; //type have its function, but there is no specific about how to achieve Quality :WORD; //Quality its function. Thus in the actual development process, Ft :TfileTime; //timestamp designers can use different algorithms to implement software Value :OleVariant; //value interface functions. End; • When the system startups, the OnRegister () is to The AddItem() function is to assign a value to a variable. register OPC server. When the system is terminated, For example: the OnUnRegister () is to cancel OPC server. After the success of the implementation these functions return Test. sItemName:=’TAG1’; TRUE, or FALSE otherwise. Test. sDescr:=’ sDescr tag1’; • According to the OPC specification, adding a group Test. vType:=varInteger; must use AddGruop () interface. AddGroup () function Test.Quality:=OPC_QUALITY_BAD; should be designed by the following features: GetSystemTimeAsFileTime(test1.Ft); Test.Value:=num; Check new group name, and ensure that this OPC Server //num is the data transmited object can’t have two identical group name; Create a new OPC //from field device Group object, and create a thread to scan the data of the OPC group object. Test.hwnd:= CreateItem(PChar(Test.sItemName), Test.Value, Test.Quality, True) ; Thread-specific scanning process is as follows. //Create different handle by

中国科技论文在线 http://www.paper.edu.cn

// CreateItem to identify Using the callback function successfully realizes the //different data item setting for the operating parameters, process parameters, technical parameters from the clients. IV. OPC TECHNOLOGY USED IN DCS OF CHEMICAL After field testing, the OPC server interface software FERTILIZER PLANT works well in the distributed control system, helping A. Demand Analysis realization of the data exchange between different systems in A chemical fertilizer plant in Shandong, China, uses gas the upper monitor software and enhancing the plant furnace DCS system [6], and its PC software was designed distributed control system-wide compatibility and through Delphi[7]. The software monitors 10 gas furnace and interoperability. more than 600 field data at the same time, and the synthetic V. CONCLUSION ammonia control system uses HOLLiAS DCS system, designed by Hollysys Company in Beijing, so as to realize the A large chemical fertilizer plant builds a integrated distributed control system data sharing and management. A automation system consists of three parts: basic automation set of software is designed to encapsulate field data into the system, large-scale real-time database and relational database OPC standard format for client interface of synthetic ammonia system, the enterprise resource management system.For basic control system, so as to realize all the equipment data automation system, it is the key to success that data if can be management and information sharing. uploaded to the real-time database reliably and real-time. B. OPC Server software application A example about Foxboro I/AS system for implementation of communication between DCS and real-time database by Field devices communicate with the OPC server by means of OPC method is as follows: following ZF2002 master-slave communication protocol: the baud rate of the communication ports is set to 9600bps, each Realize route. Foxboro I/AS system itself provides OPC communication is startuped by the host command, the slave communication protocol to read/write online data in DCS. immediately implement new task of communication after OPC Server software is installed on polymerizing-kettle to receiving new orders. communicate between Foxboro I/AS and DCS by its API.As the same, Real-time database on the Ethernet also can connect The preparation of software code is from Delphi. with OPC Server and acquire online data of field devices. Communication is completed with the help of Microsoft's MSComm component. The component realizes the serial Hardware and software configuration on polymerizing- communication between OPC server and field devices. We kettle. There are a polymerizing-kettle and two Ethercards, the would set a timer so that OPC server can read the data of field OS is Windows 2000+sp4.Besides, polymerizing-kettle devices every one second, then encapsulate what have just should have enough Ethernet interfaces to visit the network read into OPC data items and send them to other clients. data. At the same time, when the client modifies the settings of In order to meet the requirements for communication a parameter, it is required that OPC server can inform the field between different equipments, an OPC server interface devices what parameter has been changed. In specific software is designed with OPC specification in this paper. technologies, we can get it by the callback function: OPC is a kind of brand new technology, but in the near future, OPC technology and standards will be applied to more fields WriteCallback(hTagHandle:THandle;pNewValue: with the development of the technology, and inject new PVARIANT; pDeviceError :PDWORD);stdcall; vitality for modern industrial control software. Var num_get; begin REFERENCES If (hTagHandle=opcitem.m_hHWND) then

//obtain handle that data item has been [1] Longhua Ma.Research and Application of OPC Data Access //changed,and judge which data item Specifications.Control and Instruments in Chemical Industry //to belong 2002,29(1):43-45 begin [2] Haijiang He.Chemical DCS Network Based on OPC Protocol Control and Instruments in Chemical Industry 2003,30(6):33-35 num_get:= pNewValue^; [3] OPC Foundation, OLE for Process Control Data Access Standard. //get new Version 2.0 //value by num_get [4] Xianhui Yang.OPC Technology & its Influence on the Openness of … //transmite date changed Control Systems Industrial Control Computer .2001,14(9):31-33. //to field devices [5] Jianmin Shao.COM technology .Journal of Harbin University of Civil : end ; Engineering and Architecture. 2000, 33 131-134. [6] Tundong Liu.An intelligent predictive control algorithm in the gas end; furnace control .Control and Instruments In Chemical Industry. 2003,30(3):16-20. [7] Feisi IT R & D Center. Delphi7 components and distributed application development.Beijing:Publishing House OF Electronics industry,2003.