Software implementation of computer monitoring system simulation development platform (i)

Source: Internet
Author: User
Tags manual integer

The computer monitoring system is a whole which is composed of the monitoring and control computer and the detection device, the executing agency and the object being monitored and controlled. In this system, the computer is directly involved in the detection, supervision and control of the monitored objects [1]. The detection is mainly through the sensor and the corresponding input module to obtain the monitored object's state data, the main supervision is the analysis of state data to provide operators with manual operation of the reference, control is manual or according to a certain strategy automatically to the monitored objects to perform the corresponding operation. Therefore, the detection and control module is a computer monitoring system directly associated with the monitored objects of the indispensable input and output (I/O) module, learning and research these modules on the computer Monitoring system of auxiliary development, testing and teaching are of great significance.

I/O module is generally configured with serial communication interface, this paper uses software to simulate a 2-channel analog input and 2-channel digital (also known as switching) output of the module based on RS-232 interface (analog input/digital output module, referred to as ai/do-m), The main control program for the simulation module is developed, and the rs-232/rs-232 converter is developed, which can connect two different communication protocols with different baud rate master or controlled machine, and can intercept the communication protocol between them, and develop the RS-232/RJ-45 protocol converter Software, The serial communication protocol can be converted to TCP protocol, and the software can work in the client mode, and can work in the server mode, with the aid of this Protocol converter, the traditional monitoring system based on RS-232 interface can be converted to the internet-based monitoring system, and then the remote test Universal Serial Device Testing tool can automatically generate a variety of check code and add a variety of end code, can act as a master control machine to test the controlled machine, can also act as a controlled machine to test the master, and can record test results and communication protocols. On the basis of these simulation modules and the protocol converters, can be in the university's computer room 0 cost (only need serial connection line and network cable) to build a variety of forms of computer monitoring and control system simulation development platform, and it can be integrated testing, so as to save a lot of teaching equipment funding and related project development costs of expenditure.

The main technology of 1 serial communication

Communication is the key to the realization of computer monitoring system. The basic technology of serial communication mainly includes data processing technology, calibration technology and serial port operation technology, the serial port data receiving technology is the key technology. With these technologies, you can automatically generate data packets in a specified format, validate packets, and send and receive data through the serial interface very easily.

1.1 Data processing Technology

Visual Basic 2008 provides a rich string-handling function that uses a 16-string representation of data to better observe the data, such as 0xFF is an invisible character, which is more clear if it is displayed "FF." The Bytestohexchars function implements the conversion of a byte sequence to a 16 binary string, in which a byte is converted to a standard two 16-character by the Bytetotwohexchars function (its definition is simpler, slightly), and then the characters are added.

Public Function BytesToHexChars(ByRef byteArray As Byte()) As String

Dim I As Integer

Dim strData As String = ""

For I = 0 To byteArray.Length - 1

  strData &= ByteToTwoHexChars(byteArray(I))

Next I

Return strData

End Function

When a byte sequence is sent, it is also necessary to convert the 16-string into a byte sequence, which can be achieved by Hexcharstobytes, whose rationale is to call the Twohexcharstobyte function (defined slightly) to convert two 16 characters to one byte.

Public Function HexCharsToBytes(ByVal strVal As String) As Byte()

Dim I As Integer

Dim nLength As Integer

Dim bTmp() As Byte

If strVal = "" Then Return Nothing

strVal = Trim(strVal)           '删除尾部空格

nLength = Len(strVal) 2 - 1   '求得字节长度

ReDim bTmp(nLength)             '可变数组保存字节序列

For I = 0 To nLength

 '每两个16进制字符转换为一个字节,存入可变数组

 bTmp(I) = TwoHexCharsToByte((Mid(strVal, I * 2 + 1, 2)))

Next I

Return bTmp

End Function

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.