Development of heat meter based on HOLTEK single chip microcomputer
[Copy link]
With the reform of China's welfare system, the heating system has also changed accordingly. The original heating charges had problems such as inaccurate estimation of the heat energy used and unreasonable charges. For this reason, the Ministry of Construction of the People's Republic of China implemented a pilot reform of the heating system in some cities and implemented metered charges for heat energy, which requires accurate measurement of the heat energy used. This scheme provides a design scheme for a hot water heating heat meter based on the HT46R64 microcontroller. 1. Composition principle of heat meter The flow measurement principle block diagram of a general heat meter is shown in Figure 1. It mainly consists of three parts: an integrator, a flow meter, and a temperature sensor. The flow meter is used to measure the volume of hot water flowing through the heating equipment. The two temperature sensors are used to measure the inlet water temperature and the return water temperature. The integrator is the core of the heat meter. It can calculate the consumed heat energy based on the hot water volume flow and the inlet and return water temperature difference data provided by the flow meter. The calculation formula is as follows: Q=CV(twater supply-twater return) Among them, Q is the consumed heat energy, in kWh; C is the specific heat capacity of water (C=0.001167kWh/L.℃); V is the volume of hot water flowing through the heating equipment, in liters (L); tsupplywater and treturnwater are the temperatures of the hot water flowing through the water inlet and return outlet of the heating equipment, in ℃. From the calculation formula of heat energy consumption, it can be seen that as long as the temperature difference between the inlet and return water of the heating equipment and the volume of hot water flowing through the heating equipment are measured, the consumed heat energy can be calculated. Therefore, the factors causing measurement errors are: ( 1) Flow meter accuracy; ( 2) Accuracy of temperature measurement; ( 3) Pairing error of two temperature sensors; ( 4) The calculation accuracy of the integrator. The error caused by the flow meter can be solved by selecting a flow meter with higher accuracy, and the calculation accuracy can be solved by using a suitable MCU and a perfect algorithm. For temperature measurement, the country has corresponding standards. The temperature measurement error is generally not greater than ±0.3℃, and the pairing error of two temperature sensors should not be greater than ±0.1℃, so it needs to be solved as a priority. In addition, since heat meters are usually installed outdoors and used for a long time, the power consumption, anti-electromagnetic interference and reliability factors of the heat meter need to be considered, so they are considered as key conditions when selecting the microcontroller. 2. Introduction to MCU and development tools 2.1 Single chip microcomputer: The HT46R64 is an 8 -bit high performance RISC microcontroller designed specifically for products that require A/D conversion and LCD display. This model provides customers with a mask version of the HT46C64 . The HT46C64 has exactly the same pins and functions as the HT46R64 , allowing customers to minimize production costs during mass production. The main features of this MCU are as follows: - Operating voltage:
fSYS =4MHz : 2.2V ~ 5.5V fSYS =8MHz : 3.3V ~ 5.5V - 24 bidirectional input / output ports
- 2 external interrupt inputs
- One 8- bit and one 16- bit timer / counter with PFD ( Programmable Frequency Divider ) function
- 33 × 3 or 32 × 4 segment LCD driver (SEG0~SEG15 can be set as logic output by mask option )
- 4K × 15 program memory
- 192 × 8 data memory
- With PFD function, it can be used for sound generation
- A real-time clock (RTC)
- An 8-bit real-time clock prescaler
- Watchdog Timer
- Buzzer output
- Built-in crystal, RC and 32768Hz crystal oscillator circuit
- HALT and wake-up functions to reduce power consumption
- 8- layer hardware stack
- 8- channel 10 -bit resolution A/D converter
- 4- channel 8 -bit PWM output, sharing pins with 4 input / output ports
- Bit operation instructions
- Table lookup instruction, table content word length 15 bits
- When the system frequency is 8MHz , the instruction cycle is 0.5μs
- 63 instructions
- Instruction execution time is 1 or 2 instruction cycles
- 56-pin SSOP, 100-pin QFP package
- Industrial specifications: temperature range from -40 to 85°C
2.2 Development Tools: The HT46 series emulator CICE46C00CCEA produced by Shengyong Semiconductor (Shenzhen) Co., Ltd. has the advantage of low cost. The market price of a set of development tools is only 1,300 yuan. This emulator has unparalleled advantages over other manufacturers. The emulator itself comes with a burner, which solves the needs of customers in the early stage of development at one time and reduces the investment in development costs. Moreover, Holtek 's self-developed integrated development environment HT-IDE3000 fully supports the Chinese language environment and comes with C compilation (completely free), which is a great boon for development engineers who are accustomed to programming in C language. In addition, Holtek 's innovative COTPWRITER00A full series of mass-produced burners are priced at only 500 yuan in the market. The burner uses a serial port to communicate with the computer, supports offline burning, and is very convenient to use. 3. Hardware circuit composition and implementation principle 3.1 Hardware Composition According to the above analysis, the author designed a heat meter based on Holtek single chip microcomputer, and its composition block diagram is shown in Figure 2. The system is mainly composed of MCU, flow meter, temperature sensor, LCD display, circuit control, EEPROM memory and clock circuit. The MCU uses the Holtek microprocessor HT46R64, which is the core of the system and is used to complete all control and calculation functions. The temperature sensor and the internal A/D converter of the single-chip microcomputer form a temperature acquisition circuit, which can measure the temperature of the inlet and return water of the heating equipment. The single-chip microcomputer has a 10-bit A/D converter, which can maximize the measurement accuracy. The flow meter is used to measure the volume of hot water flowing through the heating equipment. Every time a certain volume of hot water flows through, the reed switch inside the flow meter is closed once. This signal is connected to the external interrupt input terminal of the MCU. Every time the reed switch is closed, an interrupt is requested to the MCU. The MCU uses this signal to accumulate the volume of hot water flowing through the heating equipment to calculate the heat energy. When necessary, the water temperature, the consumed heat energy and system information can also be displayed through the LCD display. The EEPROM memory is used to store system information and consumed heat energy. The clock circuit is used to provide system time for the entire system. The keyboard can be used to perform various operations, such as checking water temperature, consumed heat energy and system information. The power control circuit mainly cuts off the power supply of the corresponding circuit when display and temperature measurement are not needed to reduce system power consumption. The system setting is to set the system's time information such as year, month, day, hour and minute every time the power is turned on. In addition, when the system fails, it can also apply for an interrupt to the MCU so that the MCU can write the time, heat energy value and fault information at that time into the EEPROM for query. The EEPROM uses HOLTEK's HT24LC04. In terms of power control, we use Holtek's power management chips HT7033, 7044, and 7130 to ensure the stability of the system. 3.2 System working process The workflow diagram of the system is shown in Figure 3. Each time the power is turned on, the system information is generally set first, and then the MCU enters the sleep state and waits for various interrupts to be processed. Before the MCU enters the sleep state, the power of the temperature sensor, A/D converter and display needs to be turned off to reduce the system power consumption. After processing the interrupt, the MCU enters the sleep state again to wait for the next interrupt. The water meter interrupt indicates that there is a certain volume of hot water flowing into the heating equipment, and the heat consumption needs to be calculated once. The keyboard interrupt indicates that various displays should be processed, and the fault interrupt indicates that a part of the system has a fault. At this time, the MCU should write the fault type and relevant information at this time into the EEPROM. 4. Notes 4.1 Temperature measurement error and sensor pairing error It can be seen from the heat consumption calculation formula that both temperature measurement error and sensor pairing error will cause measurement error. In view of this situation, on the one hand, a temperature sensor with good performance must be selected during design; on the other hand, the characteristics of the temperature sensor should be linear and the temperature characteristic curves of the two sensors should be consistent. However, the temperature sensor characteristics are often not linear at 0℃~100℃, and the characteristic curves of each sensor are not exactly the same. Therefore, in addition to using platinum resistance with relatively good performance as a temperature sensor, each heat meter must be calibrated by hardware or software. Since hardware calibration will increase the cost, software calibration is often used. The specific approach is to divide the entire temperature measurement range into several sections according to the allowable measurement error, and measure the error of each calibration point during calibration and store it in EEPROM. In actual work, the water temperature is measured first, and then the correction value is found from the error by looking up the table to correct the measured temperature. If the measured water temperature is not exactly at the calibration point, it can be corrected by interpolation estimation. This treatment can not only solve the temperature measurement error, but also solve the sensor pairing error. 4.2 Power consumption and electromagnetic interference resistance Since the heat meter is unattended for a long time and can only be powered by batteries, the system power consumption should be very low and the anti-electromagnetic interference performance should be good during design. In order to reduce the power consumption of the system, all devices except the display are designed to use 3.3V low-power devices. For example, the HT46R64 as the control core has the characteristics of low power consumption and fast operation speed. Its working current is only 1.5mA (3.3V@32kHz), and it is only 3uA after entering the sleep state and can be awakened from the sleep state by interruption. In addition, since the data bus and address bus of the HT46R64 are buried inside the chip, it has good anti-electromagnetic interference performance. 5 Conclusion The heat meter designed in this paper has the characteristics of simple structure and accurate measurement. It can be used for heating measurement in public places such as residences, office buildings, and shopping malls. We are currently working on upgrading the solution. The next solution to be launched will support remote meter reading, and the reserved interface will be able to realize centralized meter reading with three meters. For more information, please visit the website of Shanghai Qiji Electronics Co., Ltd. ( www.chipgem.com.cn).
|