Share this

Design of a Liquid Level Control Simulation Experiment Platform Based on OPC Technology

2026-04-06 05:15:04 · · #1

Abstract: This paper introduces the design process of a liquid level control simulation experimental platform based on KingSCADA and VB6.0. This scheme utilizes KingSCADA's user-friendly interface and data acquisition capabilities, combined with the convenience of VB programming, and establishes data communication between KingSCADA and VB using a reliable OPC interface. The server-side interface is developed using KingSCADA, and the control algorithm is written in the VB client environment, ultimately achieving precise control of the water tank level. Experimental results show that this method is simple and reliable, and can be widely applied to teaching and experimental platform construction.  

Keywords: Simulation experiment; KingSCADA; VB6.0 ; OPC interface

0 Introduction

Using PLC and configuration software as units, various industrial control systems ranging from simple to complex can be formed [1] . PLC can realize complex logic programming and simple algorithm programming, but for advanced control algorithms, such as fuzzy control algorithms, matrix operations are involved [2] . Due to the complexity of the algorithm itself, the programming function of PLC alone can no longer meet the requirements. Although the programming language of configuration software is simple, most of them are script languages, which still have many inconveniences in processing algorithms. Therefore, the idea of ​​writing the algorithm into VB (Visual Basic) program is proposed. With the help of VB's fast calculation function and rich function library, the algorithm can be easily written, and the output value is fed back to the configuration software through a reliable OPC interface [3] , and finally the control of the controlled object is realized.

Based on the above ideas, this paper designs and develops a liquid level control simulation experimental platform using KingSCADA and VB. This platform is simple and reliable. A traditional PID control algorithm was written in the VB environment to achieve simulation control of the liquid level in a dual-tank system. Furthermore, other advanced algorithms can be developed on this platform, avoiding the tediousness of online programming and testing.

1. OPC communication between KingSCADA and VB

1.1 OPC Communication Principle

The commonly used interfaces for communication between KingSCADA and VB are DDE and OPC. However, in actual use, users have found that using DDE to transmit real-time information between devices and control systems is not an ideal method because it has many limitations in terms of transmission performance and reliability. In addition, DDE is not suitable for high-speed data acquisition of large amounts of data, and DDE has never provided a reliable mechanism for data exchange between different computers. The emergence of OPC has effectively solved such problems [4] .

OPC is a standardized interface for industrial equipment servers. OPCServer enables simple, standardized data exchange between devices and various OPC-enabled configuration software. Previously, to access data from field devices, each application software developer needed to write dedicated interface functions. Due to the wide variety of field devices and continuous product upgrades, this often placed a heavy workload on users and software developers. This often failed to meet actual needs, and system integrators and developers required a plug-and-play device driver that was efficient, reliable, open, and interoperable. OPC uses OLE/COM/DCOM mechanisms as the application-level communication standard, employing a client/server model. It places the task of developing the access interface on hardware manufacturers or third-party vendors, providing it to users as an OPC server. This resolves the conflict between software and hardware vendors, completes system integration, and improves system openness and interoperability. The implementation of OPC technology consists of two parts: the OPC server and the OPC client application. The basic structure of OPCServer is shown in Figure 1. Furthermore, it is superior to the DDE interface in terms of transmission speed and reliability; therefore, this paper uses the OPC interface to complete data communication between VB and KingSCADA.

Figure 1 Basic structure diagram of OPC Server

1.2 OPC Programming

To facilitate user access to KingSCADA's real-time data using the KingSCADA OPC Server functionality, Beijing Yacon provides a dynamic link library (DLL) named kingvewcliend.dll for KingSCADA OPC users. This DLL contains a rich set of library functions, including StartCliend, ReadTag, and WriteTag. In a VB environment, this solution uses this DLL to achieve dynamic data exchange with the KingSCADA data dictionary, ultimately transmitting the data collected by the lower-level machine to KingSCADA in real-time via the OPC interface.

The specific implementation process involves using the StartCliend function to connect the VB project and the KingSCADA project. The user calls the AddTag function to add the items to be collected to the collection list (as shown in Figure 2). This operation is mandatory; otherwise, item collection cannot proceed. After the user calls this function, it returns the item's position in the collection list (TagID) and the item's data type (TagDataType). The user then collects items based on the returned information. After adding the items to the collection list, the user can read and write items using the ReadTag and WriteTag functions.

Figure 2 Partial Project List

Write data to KingSCADA

For i = 1 To TagNo-5 Step 1

If i = 1 Then

Data = YeWei_Xia

End If

………………………………

xuhao = Val(i)

Select Case Typ(xuhao - 1)

Case 11

bVal = Val(Data)

Case 3

lVal = Val(Data)

Case 4

fVal = Val(Data)

Case 8

sVal = Data

Case Else

MsgBox "Invalid data type, cannot write data.", 64, "Error"

Exit Sub

End Select

ret = WriteTag(i, bVal, lVal, fVal, sVal)

Next i

1.3 PID Programming

In the VB environment, a liquid level control program was written. To ensure the control accuracy of the entire system, cascade control was adopted, with the lower tank level as the primary control object and the upper tank level as the secondary control object. A PID control algorithm was used (the calculation law is shown in Equation 1), with a PID controller in the outer loop and a PI controller in the inner loop.

2. Design of the configuration screen

Beijing Yacon's KingSCADA software boasts a user-friendly graphical interface, rich driver and network capabilities, a simple programming style, a purely Chinese interface, and easy exchange with other applications. This system utilizes KingSCADA's powerful configuration functions to establish a server-side interface for a dual-tank water system, including a main screen, PID control screen, historical trend screen, alarm screen, and report screen. A connection is established between the KingSCADA data dictionary variables and the VB client via the OPC protocol to achieve real-time monitoring of VB variables. The main screen is shown in Figure 3.

Figure 3. KingSCADA main screen

3. System Testing and Result Analysis

After editing the configuration screen in the KingSCADA environment, a connection is established with the VB client via the OPC protocol. The operation interface in the VB client is shown in Figure 4. The liquid level control program is compiled and executed, and an OPC connection is established by clicking the "Connect to Server" button. The "Add Project" button is then clicked to establish a connection between the KingSCADA data dictionary and the VB variables, ultimately enabling real-time monitoring of the liquid level and other variables on the VB client. Figure 5 shows the liquid level curve of the lower tank monitored by the KingSCADA server. The curve demonstrates that the platform has good real-time data communication performance and high accuracy.

  1. 4. Conclusion

After editing the configuration screen in the KingSCADA environment, a connection is established with the VB client via the OPC protocol. The operation interface in the VB client is shown in Figure 4. The liquid level control program is compiled and executed, and an OPC connection is established by clicking the "Connect to Server" button. The "Add Project" button is then clicked to establish a connection between the KingSCADA data dictionary and the VB variables, ultimately enabling real-time monitoring of the liquid level and other variables on the VB client. Figure 5 shows the liquid level curve of the lower tank monitored by the KingSCADA server. The curve demonstrates that the platform has good real-time data communication performance and high accuracy.

4. Conclusion

This paper designs a liquid level control simulation experimental platform based on the OPC interface. A server-side interface is built using KingSCADA, and a liquid level PID control algorithm is written in the VB client. The two are connected via the OPC interface. Experimental results show that the experimental platform has good real-time data communication performance and can be widely used in teaching. Furthermore, this method can effectively compensate for the limitation of PLCs in implementing complex algorithm programming, making PLC control methods more flexible and possessing certain practical value.

References:

[1] Shao Xinhua, Jin Yuanyu, Lü Xuefang. Real-time monitoring system based on configuration software and VB [J]. Control Engineering. 2003, 10(5): 439-440, 459

[2] Li Weijiang, Ma Yongwen. Intelligent control of papermaking wastewater treatment by combining MCGS with VB language. Industrial Control Computer. 2009, 22(3):22-23

[3] Yu Haisheng, Pan Songfeng, Ding Junhang, et al. Computer Control Technology [M]. Beijing: China Machine Press. 2007.

[4] Duan Kaichuang et al. Extension of KingSCADA functions by DDE and OPC [J]. Industrial Control Computer. 2008, 21(12): 11-12

[5] Ma Longbo, Zheng Jianying. Real-time monitoring system for intelligent instruments based on KingSCADA and VB [J]. Automation Instrumentation. 2008, 29(8): 32-34

Read next

CATDOLL Laura Hybrid Silicone Head

The hybrid silicone head is crafted using a soft silicone base combined with a reinforced scalp section, allowing durab...

Articles 2026-02-22