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.
Previous article:Some Problems in Online Programming and Debugging of PIC Microcontroller
Next article:Intelligent low resistance measuring instrument based on PIC microcontroller
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- 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
- How does AD import the complete content of a DWG file, or how does AD apply copper in a ring-shaped strip area?
- 5G mobile phones bring huge opportunities to RF front-end
- About the equivalent series resistance problem
- stm32 controls LCD1602 display, but the screen always displays two blank spaces, and the letter p is displayed as the letter r. Can you guys see what the problem is?
- ESP32 Simulator
- EEWORLD University ---- Blockchain Technology and Application
- I can't see any reply for the third time. This time there is one on the 40th floor, but no more on the 41st floor...
- Documentation for adding Bluetooth to MicroPython
- How to convert brd file to ad pcb file
- Class AB amplifier power calculation problem