2564 views|0 replies

1148

Posts

0

Resources
The OP
 

Application of Embedded MODEM in Railway Rainfall Monitoring System [Copy link]

Introduction Rainfall monitoring by the railway department is an important part of railway safety. Floods caused by excessive rainfall will affect the railway roadbed and cause train accidents. Therefore, in order to ensure the safety of the lifeline of transportation, the rainfall along the railway should be fed back to the railway management department in a timely manner. In the past, rainfall monitoring was done by manually recording the data of rainfall monitoring instruments at each station and then summarizing them for the railway management department. Obviously, the information transmission was not timely, and there were human factors, making it difficult to file. The development of microcomputers and the improvement of computer communication technology have made it possible to collect various information automatically and in real time. The author successfully used microcomputers and single-chip microcomputers to form a master-slave microcomputer network, and formed a distributed rainfall monitoring system for railway rainfall monitoring. The system automatically collects the data collected by the single-chip microcomputer rainfall monitor from the MODEM to the system main computer, making the remote communication of hundreds of kilometers both economical and reliable, greatly improving the disaster resistance of the railway department. The MODEM used by the detector is the embedded MODEM MMD-24(Z)A of Fansheng Electronic Communication Factory . The PC end uses the Star Jaguar 2 external MODEM .


1. System structure design The rainfall monitoring system is a master-slave microcomputer network composed of microcomputers and single-chip microcomputers. Rainfall monitors with single-chip microcomputers as the core are distributed at various railway stations. The functions of the instrument include collecting rainfall, storing rainfall information, rainfall alarm, printing rainfall curves on site, and communication. The management department uses a personal computer as the system host. The structure of the rainfall monitoring system is shown in Figure 1. It can be seen from Figure 1 that the system host directly establishes communication with the single-chip microcomputer. Since each station is far away from the system host, the single-chip microcomputer plus MODEM method and telephone line are used to realize the remote control of the single-chip microcomputer without adding external connection and other hardware facilities. The system host can perform various settings and data collection on the single-chip microcomputer rainfall monitors of each station. The single-chip microcomputer rainfall monitor can also automatically send the current rainfall data to the system host according to the rainfall situation, so that the rainfall situation on site can be provided in time.


2. Single-chip rain gauge monitor and its remote communication The rain gauge monitors at each station use 8051 series single-chip microcomputer as CPU , supplemented by customized LCD display, SRAM , thermal plotter, rain gauge sensor, etc. Its principle block diagram is shown in Figure 2. In the figure, W87E58 is MCU , which is compatible with MCS-51 single-chip microcomputer and has 32KB on-chip EEPROM . Single-chip remote communication is provided by ST

16C450 connected to MODEM . ST16C450 is a universal asynchronous receiver transmitter with 10 registers inside, including MODEM control register and MODEM status register. MCU controls MODEM and understands the working status of MODEM through the operation of these two registers , so as to smoothly carry out data communication .16CBefore 450 can communicate, it must first be initialized, that is, the baud rate, communication data format, whether to use interrupts, etc.16CAfter 450 is initialized, it can communicate by program query or interruption. The use of MODEM mainly includes the following four operations: Initialize MODEM ; Dial; Answer incoming calls; Hang up the line to return MODEM to AT command state. MODEM control is completed by Hayes AT command set, and the program can directly send (starting with AT characters and then adding commands and parameters) to MODEM . However, AT commands cannot complete file transfer between systems. Sending or receiving files must be completed by communication software according to the pre-defined communication protocol. MODEM initialization command string "AT&FS0=3" , "&F" resets MODEM , "S0=3" means the answering bell rings 3 times. The rainfall monitor MODEM initialization subroutine is as follows: MSTR : MOV R4 , #0 MST0 : MOV DPTR , #P3FE ; MODEM status register address MST1 : MOVX A , @DPTR ANL A , #30H CJNE A , #30H , MST1 MOV DPTR , #P3FD ; communication line status register MST2 : MOVX A , @DPTR JNB ACC.5 , MST2 MOV DPTR , #MTAB MOV A , R4 MOVC A , @A+DPTR JZ MST3 MOV DPTR , #P



















3F3 ; Data transmission holding register MOVX @DPTR , A INC R4 SJMP MST0 MST3 : RET MTAB : DB 41H , 54H , 26H , 53H, 30H , 3DH , 33H DB 0DH , 0 ; AT&FS0=3 After the subroutine is executed, the MODEM responds "OK" , indicating that the initialization is completed. The MODEM dialing command string is "ATDTxxxxx" , xxxxx is the telephone number; when the dialing is successful, the MODEM will respond with a string starting with the "CONNECT" character. After the microcontroller is connected to the system host, the data is exchanged according to the data string communication specified by the communication protocol. After the data communication is completed, the program sends the hang-up line command string "+++ATH0" , and the MODEM automatically disconnects the line, thus completing 1 communication.








3. Communication between the system host and the rainfall monitor The system host software is compiled with VB5.0 and runs in Windows 95 environment. The entire software consists of modules such as communication, daily report, monthly report, annual report, setting, curve chart, alarm, etc. The operating platform is shown in Figure 3. The host can connect to the rainfall monitors at 30 sites. The program uses the MSComm control to control by sending AT commands to the MODEM connected to the serial port. The host communication status is divided into two categories: active communication and passive communication. They are introduced below. 1. Active communication When the host transmits the alarm setting value to the site rainfall monitor and collects the rainfall data of the day or the day before yesterday, it is called active communication. The telephone icon represents the rainfall monitor at each site. Once selected, the program sends the "ATDTxxxxx" dialing command, and the rainfall monitor MDOEM is connected in automatic answering mode. After the MODEM is successfully connected, the host will receive the "CONNECT 4800" message. At this time, the host can send commands and data strings to the site. If the station receives the correct data, it can know whether the host wants to set parameters or collect rainfall data for the day or the day before according to the command code (specified by the communication protocol). If it is collecting rainfall data, the station rainfall monitor transmits the rainfall data to the host; after the host receives the correct rainfall data from the station, it sends the "+++ATH0" offline hang-up command to the MODEM to end this communication. The data string sent by the master station includes information such as the station number, communication code, current date and time, warning value and checksum. @K and @J are used as start and end marks. The following is the main source code for active communication: Private Sub Active communication (sending code) Dim i,j,ss,FsStr,ret Set to allow communication False For i=0 T0 29 ' Work area number If work area is selected ( i ) Then display the information " Dial to " + work area name ( i) + "..." FsStr="ATDT" + phone number ( i ) + vbCr ' Dial AT command ret = Send AT command ( FsStr,"CONNECT" , 60000 ) ' Send dial command, time limit 60s If ret=" Normal "Then FsStr=Format(i,"00") + Send code ' Send string combination FsStr=FsStr+Format(Now,"yymmddhhmmss") FsStr=FsStr+ set value FsStr=FsStr+ calculate cumulative sum ( FsStr ) FsStr="@K"+FsStr+"@J" ret= Send AT command ( FsStr,"@J" , 5000 ) ' Send data, wait for the end of the receiving string @J If InStr ( receiving string, "@KCUO@J")Then ' Receive the return from the lower computer is " error " display " return error ." information processing Else process the receiving string ' the lower computer receives correctly End If display " hang up ..." Information processing ret = send AT command ( "+++" , "OK" , 3000 ) ' Hang up, wait for OK , time limit 3S ret = send AT command ( "ATH0"+vbCrLf


































, "OK" , 3000 ) End If End If Next i End Sub 2. Passive communication When the site detects that the rainfall exceeds the warning value, it will actively dial the host, which is passive communication for the host. Usually, the host MODEM is also in automatic answering state and can receive site calls at any time. After receiving the correct data string, the host program records the data in the corresponding file, lights up the alarm indicator of the site on the operating platform to remind the user, and sends the " correct reception " message to the site. After receiving the correct information from the host, the site sends the "+++ATH0" offline hang-up command to the MODEM to end this communication. The data string sent by the site includes the site number, communication code, various rainfall data, alarm data and checksum information. Use @K and @J as the start and end marks. The main source code of the passive communication part is as follows: Private Sub MSComm1_OnComm() Dim strSh,Shc Shc=MSComm1.InBufferCount ' Get the number of received characters If Shc>0 Then strSh=MSComm1,Input ' Get the current receiving string receiving string = receiving string +strSh If InStr( receiving string, "RING")Then ' If the phone rings, display the " Receiving data ..." message ' Display the received data information receiving string ="" End If If InStr( receiving string, "@J")Then ' End of receiving the receiving string answer @J process the receiving string ' Process the receiving string End If End If End Sub






















Conclusion This system has been successfully applied in the railway sector. It has the advantages of good real-time performance, long information transmission distance, high reliability, simple circuit, and low investment. It can be promoted to other departments that require information collection and remote communication, such as temperature and wind speed collection in the meteorological department, water level and rainfall monitoring in the hydrological department, and power grid monitoring in the power department.

This post is from Automotive Electronics

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list