introduction
At present, there are many kinds of coal mine monitoring systems in China. The main targets of monitoring are gas, carbon monoxide and temperature. Mine roof monitoring has the characteristics of many measuring points and large span. Therefore, the domestic mine roof monitoring equipment is mainly independent monitoring instruments, which is time-consuming and laborious, and can not complete the online multi-point monitoring of coal mine roadway roof.
Aiming at the deficiency of mine roof monitoring, this paper designs the roof monitoring system by using Mobus RTU protocol and RS485 bus, realizes the mine roof network monitoring, and improves the automation level of mine roof monitoring to a certain extent.
1、 Introduction to Modbus Protocol
Modbus network is a kind of master-slave network, which allows one master to communicate with one or more slaves. The communication adopts command / response mode. The command frame is sent by the host, and the slave responds to the host in the form of response frame. Each slave has a unique address, and the host communicates with the slave through the slave address. Modbus protocol has two transmission modes: ASCII mode and RTU mode. In ASCII mode messages, every 8 bit byte is sent as two ASCII characters; In the message of RTU mode, every 8 bit byte contains two L6 characters of 4 bits. In RTU mode, 1 byte of information is sent as an 8-bit character, while in ASCII mode, it is sent as two ASCII characters. Therefore, at the same baud rate, RTU mode can transmit more data and higher character density than ASCII mode. As far as the monitoring system is concerned, it has many monitoring points and a large amount of data transmission. Therefore, the system selects RTU mode as the system data communication mode, and the message structure is shown in Table 1.
start
Address domain
End of CRC verification in function domain and data domain
T1-t2-t3-t4 8-bit 8-bit n 8-bit 16 bit t1-t2-t3-t4
For the host, the message sending should start with a pause interval of at least 3.5 characters, as shown in t1-t2-t3-t4 of Table 1. When the slave receives the first byte, it determines whether to send it to its own. After the last transmitted character, another pause of at least 3.5 characters marks the end of a frame message. At this time, the slave performs CRC verification on the address, function code and data segment of the received message. If the verification result is consistent with the CRC verification contained in the message, it indicates that the communication is normal. Otherwise, an error code is returned, indicating that there is an error in the frame communication, and the host is notified to resend the command frame. At the same time, the whole message frame must be sent in a continuous character stream, and the interval between two characters in the frame is less than 1.5 characters.
2、 Network structure
The mine roof monitoring system is composed of one host and 30 slaves, and its network structure is shown in Figure 1. The physical layer between master and slave is RS-485 bus. The host can send query and control commands to any slave on the bus. Modbus RTU communication protocol is adopted between master and slave.
3、 Hardware design
The slave hardware block diagram is shown in Figure 2, which is mainly composed of AT89C52 single chip microcomputer, data acquisition, LCD display, communication and power supply module. The roof subsidence sensor is connected with the single chip microcomputer through the A / D module. The single chip microcomputer compares and judges the collected data with the roof safety early warning threshold, and whether there is an audible and visual alarm according to the comparison result. The communication baud rate, transmission format and slave ID can be set through the keyboard. In addition to replacing the slave data acquisition module with a mass storage module, the host hardware is basically similar to the slave structure.
The schematic diagram of communication hardware is shown in Figure 3. The single chip microcomputer TXD and RXD exchange data with RS485 bus through RO and Di of MAX485; Pass P1 6 and P1 7 controls the de and / re of MAX485 to control data reception and transmission.
4、 System software design
The host communication program is shown in Figure 4 and the slave communication program is shown in Figure 5. The host and slave receive and send in interrupt mode. The host first carries out the bus communication fault test. If the test is correct, it will send a message to the extension according to the format of RTU protocol frame. After receiving the message from the slave, first judge whether the address in the message is consistent with the local machine. If so, continue the following processing, otherwise discard the message and continue to execute other applications. The slave performs CRC verification after the address verification is correct. If the verification is wrong, it generates an error code 80h and returns, and requests the host to resend the message; If the verification is correct, continue to judge whether the function code in the message can be executed. If yes, execute this function and return the processing result. Otherwise, the error code 81h is returned to notify the host that the function code is invalid.
After the host sends the message, wait for the message returned from the slave. After receiving the message frame returned from the slave, the host first performs CRC verification. If the verification is wrong, it sends a command request to the slave. If the verification is correct, judge the function code and deal with it accordingly. The processing methods include error processing and normal processing. Error handling is that the host makes corresponding handling according to different error codes; Normal processing is that the host further processes the received data.
5、 In RTU protocol mode, the pause time interval between the front and back frames must be greater than or equal to 3.5 characters, and the maximum time interval between two characters in the frame must be less than or equal to 1.5 characters. The monitoring system uses a timer of AT89C52 to calculate the starting character time. The timer is set to 0.5 character time, and two variables are set as character time counters. In the timer interrupt program, the two variables A and B are accumulated continuously, and whether they reach 7 and 3 is judged, and the frame end flag is set in the timer interrupt service program. If a is greater than 3 or B is less than 7, it indicates that the frame reception is incomplete, and the error code 82H is sent.
6、 Test results
In the laboratory, the Modbus debugging software is used to test the performance of the host and extension respectively, and the test baud rate is 9600. The test results of the host reading extension (function code 03h) are shown in Figure 6. Finally, the system has been tested in the laboratory and industrial field. The test results show that the performance indexes of the system meet the design requirements.
7、 Conclusion
The field test shows that the mine roof monitoring system adopts Modbus RTU protocol to reliably realize the data communication between the monitoring extension and the switchboard and the on-line monitoring of 30 roof monitoring points, which meets the actual operation requirements of the underground work site of the coal mine. At present, most of the domestic coal mine monitoring systems use the standard Modbus RTU protocol, which makes the monitoring extension very convenient to connect with the domestic monitoring system, so it has a good application prospect.