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.
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
- Keysight Technologies Helps Samsung Electronics Successfully Validate FiRa® 2.0 Safe Distance Measurement Test Case
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- Seizing the Opportunities in the Chinese Application Market: NI's Challenges and Answers
- Tektronix Launches Breakthrough Power Measurement Tools to Accelerate Innovation as Global Electrification Accelerates
- Not all oscilloscopes are created equal: Why ADCs and low noise floor matter
- Enable TekHSI high-speed interface function to accelerate the remote transmission of waveform data
- How to measure the quality of soft start thyristor
- How to use a multimeter to judge whether a soft starter is good or bad
- What are the advantages and disadvantages of non-contact temperature sensors?
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Does the power layer of a four-layer board need to be made into a complete plane?
- [Register to enjoy gifts] element16 sincerely invites you to visit the 2019 Munich Shanghai Electronics Show
- EEWORLD University Hall----Live playback: AM57X platform features and typical applications
- 【ST NUCLEO-H743ZI Review】(1) First experience lighting up the LED
- bluenrg chat example
- Automotive Resistive Bridge Pressure Sensor Interface Reference Design
- 【Share】Complete circuit diagram of the safety barrier at the detection end
- EEWorld is hiring! Fuzhou (work from home)/Beijing (work in a busy business district)
- What address is the uboot of Ti am335x loaded into memory when running?
- One of the reasons why you cannot enter the main function