Real-time monitoring system of intelligent instruments based on Kingview and VB

Publisher:千变万化Latest update time:2012-12-01 Source: 21IC Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

0 Introduction

With the continuous development of science and technology, computer measurement and control technology is increasingly used in various measurement and control systems at industrial sites. Usually, various measurement and control systems at industrial sites require the host computer to communicate with various intelligent instruments at the industrial site in order to timely understand the operation of the instruments at the site, thereby achieving real-time monitoring of various conditions at the site.

As an excellent upper computer monitoring software, KingView software has been widely used in remote monitoring in many fields. However, the large number of underlying device drivers provided by KingView for data acquisition and control are mainly for boards and modules of larger manufacturers. There are no ready-made drivers for various intelligent instruments developed by smaller manufacturers and boards designed by users themselves. Therefore, when using KingView to communicate with intelligent instruments and boards designed by users themselves, users are often required to develop the underlying drivers themselves, which brings a lot of inconvenience to users. In order to solve the above problems, KingView specifically provides a DDE technology that enables users to easily exchange data between KingView and other applications that support dynamic data exchange.

Visual Basic 6.0 (VB for short) is a simple and easy-to-use visual programming language. Developers can easily use the components it provides to quickly build an application. Therefore, VB has been widely used in various program developments. At the same time, the serial communication control MSComm provided in VB provides an effective way for developers to realize communication between the host computer and various instruments on site. In addition, VB also supports DDE technology, which can be used to easily develop DDE programs in Windows environment.

This paper aims at the existing problems in the communication between Kingview and intelligent instruments, and provides a method for the host computer to communicate with the on-site intelligent instruments based on VB and DDE technology. A set of intelligent instrument monitoring system combining Kingview and VB has been developed, which can better realize the real-time monitoring of the operating status of various intelligent equipment in the industrial field.

1 Basic structure of the system

The structure of the intelligent instrument monitoring system based on Kingview and VB is shown in Figure 1. As shown in Figure 1, the system consists of a host computer, RS2232/485 communication cables and various intelligent instruments on site. The system adopts a one-to-many communication link form, that is, a variety of intelligent instruments on site are connected to the RS2485 bus, and then converted by the RS2232/485 converter and connected to the host computer.

Figure 1 Basic schematic diagram of the system.

2 How the system works

The communication principle between Kingview and field intelligent instruments is shown in Figure 2.

As can be seen from Figure 2, the communication of this system includes two parts: DDE communication between Kingview and VB program; and communication between VB program and field intelligent instruments via RS2232/485.

Figure 2 Communication principle between KingView and field intelligent instruments

2.1 Dynamic data exchange between KingView and VB

Dynamic Data Exchange (DDE) is a complete communication protocol on the Windows platform that enables applications to exchange data and send commands to each other. During the DDE communication between KingView and VB, the party requesting to send data is called the "client" and the party being requested is called the "server". During DDE communication, the two parties need to realize the two-way transmission of data or control commands. Therefore, they are both "clients" and "servers".

2.1.1 KingView settings for DDE communication

The data exchange content between Kingview and VB is agreed upon by three flag names:

① Application name. The names of the two parties in the DDE dialogue.

The program name of the KingView operating system is View.

② Topic. The data domain being discussed. The topic in KingView is defined as tagname.

③ Project. The specific data object being discussed. In the KingView data dictionary, when defining I/O variables, the project name is also defined.

In order to establish a DDE link, you need to create an I/O variable in the data dictionary of KingView and register the three flag names of the server program.

In this system, the application name is VBDDE, the topic name is form1, the project name is INCREA100, and the program exchange method is standard Windows DDE exchange.

2.1.2 VB settings for DDE communication

In VB programming software, DDE connection is mainly realized through the properties and methods of controls. Usually, DDE communication is mainly carried out through controls such as text boxes, labels or picture boxes.

If VB acts as a client, when exchanging data, the LinkTop ic, Link Item, and LinkMode properties of the above controls need to be set as follows:

Control. LinkTopic = server program name | topic name

Control. Link Item = Item Name

Control. LinkMode has four options: 0 means turning off DDE;

1 indicates a hot link; 2 indicates a cold link; 3 indicates a notification link.

Among them, Control represents the name of the text box, label or picture box.

In this system, Control represents the text box Text1, LinkTop ic is set to View|Tagname, LinkItem is set to PLC1. INCREA100, LinkMode is set to 1.

If KingView is used as a customer, you only need to set the LinkMode property of the data form provided in the VB application to 1, and there is no need to add any other programs in VB.

After completing the initial settings of KingView and VB, combined with the communication program written in VB with the intelligent instrument, running the application program as server and customer respectively, the automatic data exchange between KingView and VB can be realized.


2.2 Communication between VB and intelligent instrument

This system combines the MSComm control of VB Professional Edition with VB modular programming to realize the communication between VB and intelligent instruments. The main program modules and some programs are as follows:

① Program initialization module. It mainly completes the serial port settings such as serial port selection, baud rate, frame structure setting, and serial port opening.

② Data transmission module. Manual data collection and automatic data collection are realized by sending control command words manually and automatically. Among them, the automatic data transmission method includes a timer transmission program and a timer time response program; the timer transmission program is used to control the transmission cycle of the control command word, and the timer response program is used to complete the cyclic assignment of the addresses of various intelligent instruments on site and the transmission of the control command word.

Part of the timer response program in the above module is as follows:

Private Sub Timer1 Timer

Timer1. Enabled = False

Text_SEND. Text = "" ∥ Clear the send text box

MSComm.OutBufferCount = 0 ∥ Clear the send buffer data

Dim OutByte (1 To 3) AsByte

IfNotMSComm.PortOpen Then ∥ Ensure the serial port is open

MSComm.PortOpen = True

End If

\'24 cyclic data acquisition of the product calculator

If k = 1 Then

OutByte (1) = &HCA

OutByte(2) = 0

OutByte(3) = 1

End If

If k = 2 Then

OutByte (1) = &HCA

OutByte(2) = 0

OutByte (3) = 2

End If

??

k = k + 1

If k > 24 Then

k = 1

End If

MSComm.InBufferCount = 0 ∥ Clear the receive buffer data

MSComm.OutBufferCount = 0 ∥ Clear the send buffer data

MSComm.Output = OutByte

For j = 1 To 3

OutByte again(j) = OutByte(j)

Next

For i = 1 To 50000000

\'DelayNext

End Sub


③ Data receiving module. The reception of field data is completed through event response. If the serial port receives field data and the content in the data buffer exceeds one byte, the com2EvReceive event will be triggered. The OnComm function is responsible for capturing the com2EvReceive event, writing the field content in the send buffer to the VB text box for display, and performing DDE data exchange with KingView. [page]

The OnComm function response procedure in this module is as follows:

Private Sub Timer1 Timer

Timer1. Enabled = False

Text_SEND. Text = "" ∥ Clear the send text box

MSComm.OutBufferCount = 0 ∥ Clear the send buffer data

Dim OutByte (1 To 3) AsByte

IfNotMSComm.PortOpen Then ∥ Ensure the serial port is open

MSComm.PortOpen = True

End If

\'24 cyclic data acquisition of the product calculator

If k = 1 Then

OutByte (1) = &HCA

OutByte(2) = 0

OutByte(3) = 1

End If

If k = 2 Then

OutByte (1) = &HCA

OutByte(2) = 0

OutByte (3) = 2

End If

k = k + 1

If k > 24 Then

k = 1

End If

MSComm.InBufferCount = 0 ∥ Clear the receive buffer data

MSComm.OutBufferCount = 0 ∥ Clear the send buffer data

MSComm.Output = OutByte

For j = 1 To 3

OutByte again(j) = OutByte(j)

Next

For i = 1 To 50000000

\'DelayNext

End Sub

Private Sub Timer1 Timer

Timer1. Enabled = False

Text_SEND. Text = "" ∥ Clear the send text box

MSComm.OutBufferCount = 0 ∥ Clear the send buffer data

Dim OutByte (1 To 3) AsByte

IfNotMSComm.PortOpen Then ∥ Ensure the serial port is open

MSComm.PortOpen = True

End If

\'24 cyclic data acquisition of the product calculator

If k = 1 Then

OutByte (1) = &HCA

OutByte(2) = 0

OutByte(3) = 1

End If

If k = 2 Then

OutByte (1) = &HCA

OutByte(2) = 0

OutByte (3) = 2

End If

??

k = k + 1

If k > 24 Then

k = 1

End If

MSComm.InBufferCount = 0 ∥ Clear the receive buffer data

MSComm.OutBufferCount = 0 ∥ Clear the send buffer data

MSComm.Output = OutByte

For j = 1 To 3

OutByte again(j) = OutByte(j)

Next

For i = 1 To 50000000

\'DelayNext

End Sub

④ Fault-tolerant module: By adding a data acquisition fault-tolerant module, the real-time and accuracy of data acquisition can be guaranteed, and the reliability of system operation can be improved.

⑤ Database module. It mainly uses Access database to realize the storage, management, analysis and historical data query of computer collected data.

⑥ Other program modules. Mainly used to complete the clearing of the sending and receiving text boxes, etc.

Through the coordinated work of the above modules, serial communication, data analysis and historical data query between VB and intelligent instruments can be better realized.

3 Conclusion

Through serial communication between VB and intelligent instruments and DDE communication between Kingview and VB, and by using the rich graphics and configuration technology of Kingview, the real-time data refresh, various curves and alarm display are well completed. The operation results show that the system has a friendly human-computer interface, good stability and reliability, and has solved the real-time communication problem between Kingview and general intelligent instruments, and realized the real-time monitoring of intelligent instruments by Kingview.

Reference address:Real-time monitoring system of intelligent instruments based on Kingview and VB

Previous article:Linear prediction and its implementation in Matlab
Next article:Displacement measurement encoding and identification based on magnetic sensing technology

Recommended ReadingLatest update time:2024-11-16 15:29

Design of transformerless power supply based on power chip VB409
In small MCU application systems, when AC 220V is used for power supply, a transformer is generally used to process the power supply, reducing the high voltage AC to low voltage before DC processing, or converting AC to high voltage DC before high frequency conversion to obtain the working power supply of the MCU sy
[Power Management]
Design of transformerless power supply based on power chip VB409
Recommended Content
Latest Test Measurement Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号