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.
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.
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.
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
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
- Popular Resources
- Popular amplifiers
- A review of deep learning applications in traffic safety analysis
- Multimodal perception parameterized decision making for autonomous driving
- Computer Vision Applications in Autonomous Vehicles: Methods, Challenges, and Future Directions
- Evaluating Roadside Perception for Autonomous Vehicles: Insights from Field Testing
- Molex leverages SAP solutions to drive smart supply chain collaboration
- Pickering Launches New Future-Proof PXIe Single-Slot Controller for High-Performance Test and Measurement Applications
- CGD and Qorvo to jointly revolutionize motor control solutions
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- Nidec Intelligent Motion is the first to launch an electric clutch ECU for two-wheeled vehicles
- Bosch and Tsinghua University renew cooperation agreement on artificial intelligence research to jointly promote the development of artificial intelligence in the industrial field
- GigaDevice unveils new MCU products, deeply unlocking industrial application scenarios with diversified products and solutions
- Advantech: Investing in Edge AI Innovation to Drive an Intelligent Future
- CGD and QORVO will revolutionize motor control solutions
- 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
- Tuya Sandwich Wi-Fi & BLE SoC NANO Main Control Board WBRU+ Unboxing
- Why use WDM-PON in 5G fronthaul
- 【Iprober 520 Current Probe】Evaluation Report (II) Basic Performance Test
- MicroPython Hands-on (28) - Yeelight for the Internet of Things
- Basic operations and precautions for exporting Gerber files from PCB design (Part 1)
- Allegro cannot be installed due to VC2005. Is there any way to fix this?
- Has anyone used Sensortile Box? Please help~
- The serial clock SCL and serial data SDA of the PROM are connected to the master MCU and then to the SC of the clock IC...
- Cost-cutting design cannot be delayed
- A negotiation on salary and shares