Design of tap water flow monitoring terminal based on GPRS

Publisher:bluepionLatest update time:2010-07-11 Source: 今日电子Keywords:GPRS Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

System overall composition

The structure of the remote monitoring system for tap water flow is shown in Figure 1. The system consists of three parts: several monitoring terminals, wireless data transmission network and monitoring center. Among them, the monitoring terminal is installed at the monitoring point of each water supply zone, and the monitored flow data is transmitted to the monitoring center located in the tap water company through the GPRS network in a timely manner. The center analyzes the data of each zone, thereby realizing the scientific management of water supply in each zone. The water supply zone mentioned here is not the general water supply system zone (parallel zone or series zone), but the flow meter is installed on the water supply network to divide the entire water supply system into several water supply areas. Each area is used as a monitoring point to quantify the total amount of tap water flowing into the management area and the actual sales water volume, so as to understand and grasp the water demand, supply and sales difference, leakage, uncharged water volume and other conditions in each area.

System structure diagram

Figure 1 System structure diagram

Among them, the monitoring terminal should realize the following functions:

(1) Collect flow information on site, including instantaneous flow, forward total, reverse total, flow percentage, difference total, flow velocity and other information.

(2) It has remote communication function. It can upload the collected traffic information to the monitoring center through GPRS network at regular intervals.

(3) The monitoring terminal can complete time calibration according to the instructions of the monitoring center.

(4) Recording of power outage and power restoration time. Monitor the power supply of the flow meter. Once a power outage occurs, immediately record the power outage time and report it to the monitoring center, then enter sleep mode. When the power is restored, record the call time and also upload it to the center.

(5) Historical data record. It has a certain non-volatile data storage area, which can save power failure/re-power-on time and historical data locally.

(6) Online software upgrade. The monitoring terminal has a reserved upgrade interface, which can upgrade the software according to user needs without changing the hardware design to meet the needs of different users.

Hardware design of monitoring terminal

The monitoring terminal consists of a single-chip microcomputer, a GPRS DTU (including a SIM card, an antenna, etc.), a power supply circuit, a real-time clock, a Flash memory, and a data acquisition device, as shown in Figure 2. The dotted box is the part that needs to be implemented with hardware.

Hardware composition of monitoring terminal

Figure 2 Hardware composition of the monitoring terminal

1 PIC16F877A microcontroller

As the monitoring terminal is set up in an unattended and harsh environment, it is required to have strong anti-interference ability and reliable performance. Therefore, PIC16F877A from Microchip's PIC microcontroller is used.

The PIC16F877A microcontroller has 8K*14 Flash program memory and 368B RAM data memory; it adopts Harvard structure, with data line and instruction line separated, so data and instruction can be fetched at the same time, with high execution efficiency and fast speed.

2 GPRS DTU

The wireless communication module uses the ZSD2110 GPRS DTU of Chengdu Zhongshan Technology Co., Ltd. ZSD2110 is a terminal device that uses GPRS for wireless data transmission, supports many complex network protocols such as PPP, TCP, UDP, ICMP, supports transparent data transmission and user-free control of transmission mode, and supports various communication modes such as point-to-point, point-to-multipoint, between devices, and between devices and centers.

3 Serial communication interface

As can be seen from Figure 2, the microcontroller collects data and communicates with the DTU through a serial interface, while the PIC16F877A has only one USART interface. The principle of time-division multiplexing is adopted here, and a 4-bit bus switch chip FST3125 is used to switch between the flow meter and the DTU. Usually, it is connected to the flow meter to collect data. When the upload time is up, it disconnects from the flow meter, connects to the DTU, and uploads data (completes time calibration when necessary).

4 DS1302 Real-time Clock

The real-time clock is used to provide a time reference for system sampling, timed uploading, and recording power-off/power-on time operations, and is an indispensable part of this system. This design uses the DS1302 real-time clock chip.

DS1302 uses a 32.768kHz external crystal oscillator. The oscillator circuit does not require any external resistors or capacitors, and the design is simple. It should be noted that in the selection of crystal oscillators, only 32.768kHz crystal oscillators with a load capacitance of 6pF can be used, otherwise the crystal oscillator may not start oscillating and DS1302 may not time.

5 SPI Flash Memory

Serial Flash is used as an external memory to record historical data and power-off/power-on time. Compared with previous parallel memory or ferroelectric memory, serial memory has great advantages. Parallel memory has large storage capacity and fast read and write speed, but poor anti-interference ability; ferroelectric memory uses a serial interface, has strong anti-interference ability, and is also very flexible. It can read and write single byte (no need to erase, data can be directly rewritten), but its storage density is small, unit cost is high, and read and write speed is slow. The M25P16 memory used in this system combines the advantages of both. It not only has large storage capacity and fast read and write speed, but also has strong anti-interference ability and occupies less MCU pin resources.

6 Power supply circuit and power failure detection

All devices on the entire circuit board operate at 5V.

In addition to normal power supply, in order to ensure that the power outage time can be recorded in time in case of sudden power outage, so as to report to the monitoring center, a backup power supply and a power outage detection circuit are also required. The main power supply of this system is UPS, which can ensure that it can still work when the AC power is cut off. In addition, a power supply is directly connected from the 220V AC as the input of the power failure detection circuit, which is isolated by an optical coupler and connected to the RB0 pin of the microcontroller. When the power is cut off, the RB0 external interrupt of the microcontroller is triggered to realize power-off protection, and the current DS1302 time is read and saved in the Flash memory, and uploaded to the monitoring center through the DTU, and then the microcontroller enters a low-power working state. When the power is restored, the power restoration time should also be recorded and uploaded.

Software Design of Monitoring Terminal

In the software design of the monitoring terminal, modular design is adopted, and the program is divided into multiple modules according to the function and designed separately. This design method not only makes the program structure clear, but also facilitates the expansion of new functions and program transplantation in the future, and also facilitates the location of software faults during the debugging process.

The software is implemented in C language using PICC compiler under MPLAB IDE8.10 environment. The main program flow is shown in Figure 3. After the monitoring terminal is powered on, it is initialized first, and then enters a loop to call each subroutine according to the conditions. The initialization includes the direction setting of each I/O port, SPI initialization, interrupt flag setting, etc. When writing data to Flash, it is necessary to first determine whether the entire Flash is full, so it must be erased before writing new data.

Main program flow chart

Figure 3 Main program flow chart

In this system, the microcontroller needs to handle multiple tasks, and some of the tasks are random, so the MCU adopts a combination of query and interrupt work. Among them, the timing report adopts the query method, as shown in Figure 3, while the power-off detection and incoming call wake-up are completed through the RB0 level change interrupt of the PIC microcontroller. However, in the interrupt service program, only the power-off/power-on flag is simply set, and no other complex operations are performed. The corresponding power-off/power-on service is executed after the power-off/power-on flag is detected in the main program. This is because the PIC16F877A microcontroller has only 8 layers of hardware stack, and stack overflow is very likely to occur when calling a subroutine in an interrupt. In order to ensure the reliable operation of the program, the operations such as reading the time of DS1302 and entering sleep mode are all executed in the main program, so that the interrupt service program is as short as possible and the reliability of system operation is improved.

2010/7/3 17:14:48

Keywords:GPRS Reference address:Design of tap water flow monitoring terminal based on GPRS

Previous article:Development of engine bus data simulator based on SAE J1939 protocol
Next article:Design of groundwater level monitoring system based on LM3S615

Recommended ReadingLatest update time:2024-11-16 17:54

Design and implementation of vehicle terminal application of GPS_GPRS positioning and directional navigation system
1. Introduction At present, with the improvement of people's living standards, there are more and more means of transportation, and security services are becoming more and more important. In particular, vehicle-mounted monitoring systems are receiving more and more attention from the industry. This pap
[Automotive Electronics]
Design and implementation of vehicle terminal application of GPS_GPRS positioning and directional navigation system
Application and comparison of GSM&GPRS in wireless meter reading system
Wireless meter reading system refers to a system that uses embedded systems and wireless network technologies to automatically read and process user meter data, and transmits the user's water, electricity and gas meter usage information to the management enterprise for comprehensive processing. It is developed on the b
[Microcontroller]
Application and comparison of GSM&GPRS in wireless meter reading system
Latest Industrial Control 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号