Design of TM card water meter control system based on P87LPC764 single chip microcomputer

Publisher:幸福之星Latest update time:2012-01-07 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

1 Introduction

With the rapid development of social science and technology, resource shortage is becoming increasingly serious, especially water resources, which are closely related to human survival. With the rapid development of my country's information industry, it has become possible to realize the electronic, information and networking of tap water fee management. The intelligentization of water meter system can greatly improve the work efficiency of water supply management departments, save costs, improve water supply facilities, and improve the quality of drinking water for residents. This paper takes a smart card water meter control system as the research object, which combines control technology, computer technology and other technologies. It is a cross-disciplinary electronic information system.

2 Overall structure of smart water meter control system

The intelligent water meter control system specifically realizes the functions of automatic water flow measurement, TM card reading and writing, valve control, display and alarm, etc. The control system circuit consists of a low-power single-chip microcomputer, a flow meter, an E2PROM storage circuit, a TM card reading and writing circuit, an LCD display control circuit, a valve control detection circuit, a voltage detection circuit, etc. The structural principle is shown in Figure 1.

Figure 1. Schematic diagram of smart water meter control system

When the user inserts the TM card containing the purchased water volume and other information into the card holder on the water meter, the control valve opens the water supply channel under the control of the electronic control system. Every time the user uses a measurement unit (10 liters), the metering circuit sends a set of metering pulse sequences. If the pulse sequence is determined to be valid by the electronic control system, one measurement unit can be subtracted from the purchased water volume. When the remaining water volume reaches the alarm value, the LCD Chinese characters display "Please purchase water"; when the water volume is zero, the control valve automatically closes and the water channel is cut off. At this time, the user must re-use the card to purchase water. Under normal circumstances, the control valve is in the on state, and the control valve changes from the on state to the off state only when a special event occurs.

3 Hardware Design of Smart Water Meter Control System

The TM card water meter control system consists of a low-power single-chip microcomputer, a flow measurement circuit, an E2PROM storage circuit, a TM card read-write circuit, an LCD display control circuit, a valve control detection circuit, a voltage detection circuit, a real-time clock circuit, etc.

1. Single chip microcomputer

The microcontroller as the core component of the TM card water meter control system adopts the P87LPC764 single-chip microcomputer in the PHILIPS 51LPC series. This single-chip microcomputer has fast running speed, flexible programming, low power consumption, and comes with 4K bytes of OTP program memory, 128 bytes of RAM, and 32 bytes of user code area that can be used to store sequence codes and set parameters. It also has rich I/O functions and strong interrupt capabilities, which can well meet the requirements of high integration, low cost, and low power consumption of the TM card water meter control system.

2. E2 PROM storage circuit

In the smart card water meter control system, the storage of information is very important. Therefore, in this control system, the memory uses a 2K capacity serial CMOS E 2 PROM--CAT24WC02, which is a low voltage (1.8 ~ 6V), low power consumption, long life (one million programming and erasing cycles) device, using I 2 C bus data transmission protocol, easy to use. It is used to store information such as total water purchase, total water consumption, last water purchase, card number, water meter status, etc. The interface circuit is shown in Figure 2.

Figure 2 I 2 C device interface circuit

3. TM card reading and writing circuit

The carrier of information, TM card, adopts single bus protocol communication, and all read and write operations are completed through a signal line (bus) and a ground line, so the read and write circuit is extremely simple. I will not elaborate on it in detail.

4. LCD display control circuit

The LCD driver uses HT1621, which is a 128-point, memory-mapped and multifunctional LCD driver. Its unique software configuration features make it suitable for a variety of LCD applications. There are only 4 or 5 pins used to connect the main controller and HT1621. In this design, resistors and PNP transistors are used to control the power supply of HT1621 to reduce power consumption and extend the service life of the LCD. The LCD is usually in the off state. When a TM card is inserted and a valid card is confirmed or there are other conditions, the LCD turns on and displays information such as the current water purchase, water used, available water, valve status, etc.

5. Water metering circuit

The base meter of the water meter adopts a single-flow rotor-type cold water meter that complies with the ISO4064B standard. The technical parameters are shown in Table 1. The counting mechanism and the measuring mechanism of the meter are driven by magnetic coupling, and a reed switch is used to measure the water volume and send a signal. A pulse is generated every time 10 liters of water flows through. The meter is equipped with a magnetic protection device, which has a strong ability to resist external magnetic interference. The water volume metering pulse is input into the single-chip microcomputer through an anti-shake circuit composed of capacitors and resistors. For each input pulse, the corresponding water volume is subtracted from the memory.

Table 1 Technical parameters of single-flow rotary vane cold water meter

Nominal diameter

Measurement level

Overload flow

Common traffic

Demarcation flow

Minimum flow

15mm

B

3m 3 /h

1.5m 3 /h

120 1/h

30 1/h

6. Valve control detection circuit

Valve control is a very sensitive part of the water meter control system. Poor reliability of valve opening and closing will cause great problems to the water supply department. Therefore, we designed an electric ceramic valve with ingenious structure, reliable closing and DC2.6-3.6V control to effectively solve the problem of unreliable valve closing. As shown in Figure 3, the forward and reverse control circuit of the electric valve, when the forward end inputs a high level and the reverse end inputs a low level, the valve opens; otherwise, the valve closes. When the microcontroller P1.6 port inputs a low level and the P1.7 port inputs a high level, the transistors Q3, Q5, and Q6 are turned on, and Q2, Q4, and Q7 are turned off. Therefore, the forward end (ON) outputs a high level and the reverse end (OFF) outputs a low level, opening the valve. When it is fully opened, the microcontroller P1.5 port inputs a detection signal and the action stops. Conversely, the transistors Q2, Q4, and Q7 are turned on, and Q3, Q5, and Q6 are turned off. The forward end outputs a low level and the reverse end outputs a high level, closing the valve. The microcontroller P1.6 port also inputs a fully closed detection signal.

Figure 3 Control circuit of electric valve

7. Power supply voltage detection circuit

In order to improve the reliability and safety of water meter operation, hierarchical power supply voltage real-time detection is adopted, and the voltage real-time detection chip uses RH5VL28 and RH5VL30. When the power supply voltage is normal, the Vout pin of the chip is high level; when the power supply voltage is less than 3.0V, the Vout pin of RH5VL30 outputs a low level. After the single-chip microcomputer detects the signal, it controls the LCD display module to display undervoltage and closes the valve to warn the user to replace the battery; when the power supply voltage is less than 2.8V, the Vout pin of RH5VL28 outputs a low level. After the single-chip microcomputer detects the signal, it completely closes the valve until the user replaces the battery.

8. Power supply and real-time clock circuit

The power consumption of a microcontroller system is often proportional to the power supply voltage. Therefore, in a battery-powered system, the lowest power supply voltage should be selected as much as possible while meeting performance requirements. To this end, we use the ER14505 DC3.6V/2.0Ah disposable lithium-thionyl chloride battery from Wuhan Lixing Company as the system power supply to fully utilize the low voltage and low power consumption characteristics of the microcontroller and peripheral devices.

In the actual application of TM card water meters, users may not use them for a long time due to some reasons. Therefore, after a long period of micro-current discharge (equivalent to self-discharge during storage), the internal resistance of the battery will increase, and the instantaneous driving ability of the battery will decrease, which is very likely to affect the action of the electronically controlled valve or produce undervoltage, affecting the stability of the system. But at the same time, the battery may still have enough capacity to use. If the battery is replaced for this reason, the cost of using the water meter will increase. To solve this problem, we added a clock circuit to the control system. Every month, the clock chip (PCF8563) generates an interrupt. After the microcontroller receives it, it controls the valve to open and close, so that the battery can generate a relatively large current discharge at a fixed time, reduce the internal resistance of the battery, improve the performance of the battery, and thus improve the stability, reliability and maintenance-freeness of the entire system.

4. Software Design of Intelligent Water Meter Control System

If the hardware circuit is the foundation of the control system, then the control software is the soul of the entire system. The quality of the control software design directly affects the performance of the system. In this system, considering the size of the internal program memory of the P87LPC764 microcontroller, the running speed, the readability and maintainability of the program, etc., 51 assembly language is used and the modular method is used for compilation.

The software of the TM card water meter control system mainly consists of the main program, interrupt service program, subprogram, etc. The main program mainly includes the initialization, self-test, and power-off state of the single-chip microcomputer and interface chip; the interrupt service program includes water metering interrupt, card insertion interrupt, magnetic interference input interrupt, undervoltage interrupt, and monthly alarm interrupt; the subprogram mainly includes LCD display, memory reading and writing, and delay program. The entire water meter control system is usually in the power-off state. When there is an external interrupt signal, it wakes up from sleep and executes the program. Figure 4 is the main program flow of the control system. The P87LPC764 single-chip microcomputer has a strong interrupt function, a four-priority interrupt structure, and can support up to 11 interrupt sources. In this control system, considering that the single-chip microcomputer is usually in power-off mode, the interrupt type used by the system should have the ability to wake up the P87LPC764 single-chip microcomputer. To this end, the interrupts used in the control system all adopt the very simple KBI interrupt with wake-up function in P87LPC764, and set the priority for each interrupt source, such as the water metering interrupt priority is set to the highest.

Figure 4 Control system main program flow chart

5. System anti-interference design

1. In order to prevent users from using electromagnetic interference to steal water, an additional measure to prevent artificial electromagnetic interference is added. That is, a reed switch is placed side by side with the metering signal-transmitting reed switch, but its trigger switch value is slightly higher than that of the signal-transmitting reed switch. Therefore, when the user uses electromagnetic interference, as long as the magnetic force exceeds a certain limit, the anti-electromagnetic interference reed switch is closed, and the single-chip computer detects this signal and can perform corresponding operations, effectively preventing artificial electromagnetic interference.

2. Connect a decoupling capacitor, a 10μF electrolytic capacitor and a 0.1μF capacitor, between the power supply and ground of the circuit board to eliminate power supply interference. In the smart water meter system where the power supply quality is not very high, a relatively good effect has been achieved.

3. The circuit board is a highly integrated collection of devices, signal lines, and power lines in the circuit system. The quality of the circuit board design has a great influence on the anti-interference ability, so the design of the printed circuit board must comply with the anti-interference design principles.

The author's innovation points :

This paper mainly introduces the design of TM card water meter control system, which has reliable operation, accurate measurement, strong anti-interference ability and low energy consumption. The charging management system has a friendly interface, data security, is simple and easy to use, and greatly improves work efficiency.

References :

[1] Hu Haigang. Low power consumption design of PHILIPS 51LPC series microcontroller[J]. Mechanical and Electrical Engineering, 2002, 19(2): 18-20.

[2] Hu Tao. Application and optimization design of IC card prepaid water meter[J]. Water Supply and Drainage, 2002(2):76-79.

[3] Wang Yuner, Qiu Deyu, Jiang Qingjun. Design and implementation of water meter and fee management system based on IC card [J]. Computer Engineering and Science, 2001, 23(2):105-107.

[4] Li Xiangming, Jing Junkai, Sun Jun, Liu Minglan. Research and development of IC card type intelligent water meter based on MSP430F413[J]. Microcomputer Information, 2007, 6-2: 87-88

Reference address:Design of TM card water meter control system based on P87LPC764 single chip microcomputer

Previous article:Directly drive LCD using MCU I/O port
Next article:Design of speech recognition system based on SPCE061A

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
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号