Hot water controller based on PIC microcontroller

Publisher:以泉换泉Latest update time:2011-12-30 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

introduction

The hot water controllers on the current market basically use bimetallic temperature control, which has low temperature control accuracy, poor reliability and single function. With the development of microelectronics technology, the functions of single-chip microprocessors are increasingly enhanced, the price is low, and they are widely used in various aspects. The application of single-chip microcomputers in hot water controllers has the advantages of simple design, high reliability and easy function expansion.

The hot water controller mainly controls the water temperature and meets the individual needs of different users. Therefore, a more complete controller should have the following functions:

Measurement and display of water temperature;

Measurement and display of water volume;

User setting functions (such as water temperature setting, timer setting, etc.);

Control function of electric heating tube;

Some function keys (such as timed automatic water addition, constant temperature control, manual water addition, manual heating, etc.).

Safety measures (leakage detection, safety failure protection, temperature limit protection, etc.).


Figure 1 Overall layout


2 (a) Basic temperature water temperature measurement circuit


Figure 2 (b) Basic display circuit diagram


Figure 2(c) Water gate heating tube control circuit

Hardware circuit design

According to the functional requirements of the hot water controller and combined with the resource analysis of the PIC16C5X series of microcontrollers, the mainstream model PIC16C57 in this series is used as the control core of the circuit system. The overall layout of the electric hot water controller is shown in Figure 1.

The basic hardware circuit diagram is shown in Figure 2(a)~(c). In this system, RA0~RA3 are used for seven-segment code display, RB6 controls the water gate switch, RB7 controls the electric heating tube, RC3~RC5 are used for key design and reading water volume, RC0~RC2 are used to communicate with DS1820 to measure water temperature, RB0~RB1 scans the seven-segment code, RB2~RB5 LED indicator display, RC6 leakage detection, and RC7 controls the speaker for alarm and indication.

Water temperature measurement circuit

The temperature measuring element uses DALLAS's single-wire digital temperature sensor DS1820. DS1820 provides nine-bit temperature readings, with a measurement range of -55℃~125℃. It uses a unique 1-WIRE bus protocol, and only requires one line to achieve two-way communication with the MCU. It has the characteristics of simple connection, high precision, and high reliability. When working, it is powered by the bus, and the microcontroller sends a command code to read the temperature value.

Keyboard and water measurement circuit

Since in this system, only four levels of water value are required to be displayed, the water level sensor uses a switch type sensor. When the water level reaches a certain level, the level of that level will be lowered. The interface circuit is similar to pressing a button. Therefore, in the circuit design, the water level level signal and the button are connected to the I/O port of the microcontroller through a 74HC148 priority encoder. The button has a higher priority than the water level signal, and the high-level water level signal has a higher priority than the low-level signal to ensure that the button can be responded to first.

Display circuit

The temperature is displayed in two-digit seven-segment code, with a display range of 0℃~99℃. The water volume is displayed in one-digit seven-segment code, showing 1, 2, 3, 4, four water levels. The temperature and water volume are scanned and displayed in a cycle. Four LEDs are used to set the current button function.

Water temperature and water volume control circuit

The single chip microcomputer controls the relay through photoelectric coupling to cut off or connect the power supply of the heating tube and close or open the water valve, thereby achieving control of the water temperature and water volume.

Leakage detection and alarm circuit

Since the water heater works in a humid environment, it needs to have leakage detection and alarm functions. The leakage detection is performed by shaping the output of the leakage detection coil and inputting it into the RC6 port. The circuit schematic is shown in Figure 3(a). When the leakage current exceeds a certain threshold, the comparator outputs a low level, otherwise it maintains a high level, and then generates a waveform as shown in Figure 3(b) through a monostable trigger circuit. The low level holding time t can be adjusted and set by the monostable trigger. In this system, t is 10ms. Since PIC16C57 has no interrupt function, the program must query the RC6 port at regular intervals (less than 10ms) to detect whether there is leakage. Once RC6 is detected to be low, the heating tube current is cut off after confirmation, and an alarm is issued at the same time. The alarm circuit also alarms when the sensor fails or overheats.

PIC16C57 itself has a watchdog timer, which can automatically perform power-off protection and system reset when the system is abnormal.


Figure 3 (a) Circuit schematic



System software design

The system software is written in PIC16C5X simplified instructions. Since PIC16C57 has no interrupt function, the subroutines such as keyboard scanning and leakage detection in this system are implemented through queries, and a 4MHz clock frequency is used to accurately calculate and design the running time of the instructions to ensure the reliability and stability of the software. The main program block diagram of the system is shown in Figure 4. This article discusses the two modules of keyboard display and water temperature measurement.

Keyboard and Display

In this system, there are four function buttons: timed water addition, constant temperature control, manual water addition and manual heating; three seven-segment displays and four LED light indicators.

a) When the timed water adding button is pressed, the timer LED lights up, and the current time is used as the timer timer. Water is automatically added to the set water volume every 24 hours. If the button is pressed for more than 5 seconds, the timer LED goes out, and a "beep" is heard to set the water volume. After that, each time the button is pressed, the water volume display increases by one level, and levels 1 to 4 are displayed in a cycle. If the button is not pressed for more than 5 seconds, a "beep" is heard again, and the water volume setting is completed. The timing function of the system is mainly completed by software. The PIC16C5X has an 8-bit timer/counter RTCC, which is used when performing 24-hour timed water adding. The RTCC and its related circuits are shown in Figure 5.

As shown in Figure 5, the RTCC working state is controlled by the OPTION register, where the RTS bit of the OPTION register is used to select the counting signal source of the RTCC. When RTS is "1", the signal source is the external signal from the RTCC pin, and when RTS is "0", the signal source is the internal clock. The PSA bit of the OPTION register controls the prescaler allocation object. When PSA is "1", it is allocated to RTCC, that is, the external or internal signal is divided by the prescaler and then output to RTCC. The prescaler division ratio is determined by PS0~PS2 in OPTION. The RTE bit of OPTION is used to select the trigger edge of the external counting pulse. When RTE is "1", it is triggered by the falling edge, and when it is "0", it is triggered by the rising edge. The RTCC counter counts in an incremental manner. When the count reaches FFH, it will automatically reset to zero after the next count occurs, and start counting again, and the cycle continues. In the actual design, the OPTION register is "00100111", that is, the signal source of the timer comes from the external signal of the RTCC pin, the prescaler division ratio is 1:256, and the rising edge is triggered. The input frequency of the RTCC pin signal is 1kHz, so it takes 65536ms for the RTCC to count to FFH. The general registers F0EH and F0FH are used as timing temporary storage.

When setting the timed water adding function, initialize RTCC, OPTION, F0EH, F0FH, start timing, query the RTCC value every 256ms, each time RTCC cycles, F0EH-F0FH increases by 1, when it increases to 1318, the 24-hour timing is up, the register is reset, and water is added automatically.

b) Press the thermostat control button, the thermostat LED will light up, indicating that the thermostat control is in progress. Press it again and the LED will go out, cancelling the thermostat control. Similar to the water volume setting, long press to set the temperature.

c) When the manual heating button is pressed, the heating LED lights up and the temperature is heated to 65°C. If the water level is less than level 1, add water to level 1 first and press the button again to cancel heating.

d) When the manual water adding button is pressed, water is added to the set water volume. Long press to set the water volume. During the manual water adding process, press again to cancel the water adding.

Under normal circumstances, two seven-segment codes display the current water temperature, and the other displays the current water level.

Water temperature measurement

Temperature reading is completed by communicating with DS1820. The communication function of DS1820 is completed in time-sharing, and it has a strict concept of time slots. Therefore, the system must perform various operations on DS1820 according to the protocol. The operation protocol is: initialize DS1820 (send reset pulse → send ROM function command → send memory operation command → process data). The operation timing diagrams are shown in Figures 6 and 7.

The operation commands required in this program are as follows:

SKIPROM command (CCH): After this command is executed, it means that the subsequent memory operation commands will be targeted at all online DS1820s. Since there is only one DS1820 in this system, it can be operated after this command is issued.

CONVERT command code [44H]: Start the online DS1280 to perform temperature A/D conversion.

READSCRATCHPAD command code [BEH]: Read the temperature value of the temperature register.

The overall flow chart of DS1820 operation is shown in Figure 8.

Other functional programs

Other functional programs such as leakage detection, data processing, timing counting, etc. are all designed comprehensively according to the program running time and will not be described in detail here.


Figure 6 Read and write timing diagram


Figure 7 Initialization sequence


Figure 8 DS1820 operation flow chart

Conclusion

The single-chip microcomputer controller for electric water heaters has the advantages of novelty, low price, safety and practicality, and has been successfully applied to domestic electric water heaters. Some of the methods in this article are also applicable to the computer control design of household appliances such as refrigerators and air conditioners.

Reference address:Hot water controller based on PIC microcontroller

Previous article:Some Problems in Online Programming and Debugging of PIC Microcontroller
Next article:Intelligent low resistance measuring instrument based on PIC microcontroller

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号