Small water heater PID heating control system and program based on single-chip microcomputer

By adopting a small water heater PID heating control system based on a single chip computer in the household electric heater control system, combined with the fuzzy PID control algorithm, the problem of low temperature control accuracy in the existing technology is solved, and temperature adjustment with high accuracy, stability and energy-saving effects is achieved.

CN119902470APending Publication Date: 2025-04-29NANTONG INST OF TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510067607.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-16
Publication Date
2025-04-29

AI Technical Summary

Technical Problem

The existing household electric heater control system has low accuracy in temperature control, frequent opening and stopping, and large power, resulting in a large temperature fluctuation range.

Method used

It adopts a small water heater PID heating control system based on a microcontroller, integrates the STM32F103ZET6 microcontroller, DS18B20 temperature sensor and SSD1306 OLED module, and combines the fuzzy PID control algorithm to monitor the water temperature in real time and make precise adjustments.

Benefits of technology

It significantly improves the accuracy and stability of temperature control, reduces the fluctuation range of water temperature, and achieves obvious energy-saving effects.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119902470A_ABST
    Figure CN119902470A_ABST
Patent Text Reader

Abstract

The invention provides a small water heater PID heating control system and program based on a single-chip microcomputer, and relates to the technical field of PID heating control, the system comprises a main control module, a temperature module, a key module, an OLED module, a relay module, a communication interface module and a heating rod module; the crystal oscillator circuit adopts a 8MHz external crystal oscillator as an external high-speed clock, is matched with two capacitors as an oscillation starting circuit and is provided with a resistor to play a role in protecting the crystal oscillator, and the reset circuit is used for resetting the single-chip microcomputer at a low level, the voltage on the capacitors is 0 when the single-chip microcomputer is powered on, a reset pin is pulled down, after the capacitors are fully charged, the point position of the reset pin is high, starting-up resetting is carried out, and a key is pressed down. A reset pin is pulled down, and the circuit is reset. The system can realize high-precision control of the small water heater, and is good in stability and remarkable in energy-saving effect.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of PID heating control, and in particular to a PID heating control system and a program for a small water heater based on a single chip microcomputer. Background Art

[0002] The household electric heater control system is an integrated system used to adjust and control the working state of household electric heaters. It detects the actual temperature through sensors, and the controller receives the signal and applies the control algorithm (such as PID control), and then sends instructions to the actuator to adjust the heating power, thereby maintaining the water temperature or room temperature within a preset range to meet the user's heating or hot water needs. It is easy to operate, safe and reliable, energy-saving and efficient.

[0003] Generally, a household electric heater control system usually sets a temperature value when controlling the heater. When the heating temperature is lower than the set value, the heater starts working, and when the heating temperature is higher than the set value, the heater stops heating. Due to its frequent start and stop and high power, its temperature control accuracy is low, mostly within a few degrees.

[0004] Therefore, we made improvements to this and proposed a small water heater PID heating control system and program based on a single-chip microcomputer. Summary of the invention

[0005] The purpose of the present invention is to address the problems raised by the current background technology.

[0006] In order to achieve the above-mentioned purpose of the invention, the present invention provides a small water heater PID heating control system and program based on a single-chip microcomputer to improve the above-mentioned problems.

[0007] The specific application is as follows:

[0008] A small water heater PID heating control system based on a single chip microcomputer includes the following modules:

[0009] Main control module: It consists of STM32F103ZET6 microcontroller, external crystal oscillator circuit, reset circuit, power supply circuit and BOOT selection circuit;

[0010] Temperature module: Use DS18B20 temperature sensor, and a 4.7kΩ pull-up resistor needs to be connected to the DQ pin of this sensor;

[0011] Button module: It consists of three buttons, two of which are connected to ground and the other is connected to 3.3V;

[0012] OLED module: The OLED bare screen driver chip SSD1306 consists of 30 pins in total. C1 and C2 are connected to two capacitors as required, VBAT is connected to VDD, and BS is the mode selection.

[0013] Relay module: consists of a relay body, a resistor, a PNP transistor, a diode and a light-emitting diode;

[0014] Communication interface module: This module uses CH340G as a USB to TTL chip, which can be used for serial port. It consists of 1 NPN transistor and 1 PNP transistor, a crystal oscillator, and auxiliary circuits.

[0015] Heating rod module: The heating rod adopts a power of 15W.

[0016] As the preferred technical solution of the present application, the crystal oscillator circuit adopts an 8MHz external crystal oscillator as an external high-speed clock, is equipped with two capacitors as a starting circuit, and is connected in parallel with a resistor to protect the crystal oscillator.

[0017] As the preferred technical solution of the present application, the reset circuit is a single-chip microcomputer reset with a low level. When powered on, the voltage on the capacitor is 0, the reset pin is pulled low, and after the capacitor is fully charged, the reset pin point is high, and the power is turned on and reset. After the button is pressed, the reset pin is pulled low to reset the circuit.

[0018] As the preferred technical solution of the present application, the power supply circuit is powered by USB, and the 5V voltage is converted to 3.3V through the AMS117-3.3 linear regulator. A tantalum capacitor is connected to the output end to power the microcontroller.

[0019] As the preferred technical solution of the present application, the temperature module is mainly composed of a 64-bit ROM and a memory. The 64-bit ROM stores a unique serial number, and the memory is composed of a high-speed RAM and an EEPROM.

[0020] A PID heating control program for a small water heater based on a single-chip microcomputer includes a fuzzy PID design process. Two parameters are passed in, one is the address of the global PID structure and the sampling temperature. Then the sampling temperature will be quantified, the membership of E and Ec will be calculated, and then the fuzzification will be solved through the rule table and the centroid method. Finally, the gain output is adjusted. The following steps are taken:

[0021] (1)PID structure:

[0022]

[0023]

[0024] (2) Quantitative data collection:

[0025]

[0026] (3) Membership calculation:

[0027]

[0028]

[0029]

[0030] (4) Defuzzification and gain output:

[0031]

[0032] / / ec's index in the rule base, membership

[0033] uint8_t indexEC[2] = {0,0};

[0034] float msEC[2] = {0,0};

[0035] / / pid increment value

[0036] float pidvalue[3];

[0037] / / Quantization

[0038] LinearQuantization(pid,qValue);

[0039] / / Calculate the membership and index of e

[0040] CalcMembership(msE,qValue[0],indexE);

[0041] / / Calculate the membership and index of ec

[0042] CalcMembership(msEC,qValue[1],indexEC);

[0043] / / Use the centroid method to calculate the pid increment value

[0044] pidvalue[0]=msE[0]*(msEC[0]*ruleKp[indexE[0]][indexEC[0]]+msEC[1]*ruleKp[in dexE[0]][indexEC[1]])

[0045] +msE[1]*(msEC[0]*ruleKp[indexE[1]][indexEC[0]]+msEC[1]*ruleKp[indexE[1]][indexEC[1]]);

[0046] pidvalue[1]=msE[0]*(msEC[0]*ruleKi[indexE[0]][indexEC[0]]+msEC[1]*ruleKi[in dexE[0]][indexEC[1]])

[0047] +msE[1]*(msEC[0]*ruleKi[indexE[1]][indexEC[0]]+msEC[1]*ruleKi[indexE[1]][in dexEC[1]]);

[0048] pidvalue[2]=msE[0]*(msEC[0]*ruleKd[indexE[0]][indexEC[0]]+msEC[1]*ruleKd[in dexE[0]][indexEC[1]])

[0049] +msE[1]*(msEC[0]*ruleKd[indexE[1]][indexEC[0]]+msEC[1]*ruleKd[indexE[1]][indexEC[1]]);

[0050] / / pid gain

[0051] pid->dKp=pid->qKp*pidvalue[0];

[0052] pid->dKi=pid->qKi*pidvalue[1];

[0053] pid->dKd=pid->qKd*pidvalue[2];

[0054] }.

[0055] As the preferred technical solution of the present application, in the PID structure, Sv is the set value, Av is the current value, err is the current error, last_err is the last error, err_sum is the historical error, dKp, dKi, dKd are the increments after each fuzzy PID calculation, and qKp, qKi, qKd are gains.

[0056] As the preferred technical solution of the present application, in the quantization of data collection, first, the PID structure address and the address where the data is stored after quantization are passed in, the setting range is 0-50 degrees, the error estimation range is 50, and the quantization value is divided by 50 and then multiplied by 6 and 3 to be between positive and negative 6 and positive and negative 3. After that, the printing function required for testing is performed, which will facilitate quick detection of errors.

[0057] As a preferred technical solution of the present application, in the membership calculation, the triangle membership function is implemented by segmentation, and then the membership of the fuzzy subset and the index of the rule table are returned.

[0058] As the preferred technical solution of the present application, in the defuzzification and gain output, after defuzzification, the PID gain is obtained, and the obtained result is superimposed on the Kp of the position PID to perform a fuzzy PID calculation.

[0059] Compared with the prior art, the present invention has the following beneficial effects:

[0060] In the scheme of this application:

[0061] 1. In order to solve the problem that the heater in the prior art starts working and stops heating when the heating temperature is higher than the set value, and the temperature control accuracy is low due to its frequent start and stop and high power, and most of the temperature control accuracy is more than a few degrees, this system integrates advanced PID control algorithms, which can monitor the water temperature in real time and accurately adjust it according to the preset target temperature. This control method not only significantly improves the stability of the system and ensures that the water temperature fluctuation range is extremely small, but also brings obvious energy-saving effects. Since the PID algorithm can quickly respond to water temperature changes and make corresponding adjustments, the system can minimize unnecessary energy consumption while ensuring hot water supply. In general, the PID heating control system for small water heaters based on single-chip microcomputers has become an ideal choice for the design of modern small water heaters with its high-precision control, good stability and significant energy-saving effects;

[0062] 2. The PID heating control system and program of the small water heater based on the single chip microcomputer not only has high-precision control, good stability and significant energy-saving effect, but also has certain scalability, which provides great convenience for the addition of subsequent functions. The modular structure of the system design makes it easy to integrate new functional modules into the existing control system without large-scale reconstruction of the entire system. This scalability is not limited to the hardware level. The software part also supports flexible programming and debugging. Developers can easily add advanced functions such as remote control, fault diagnosis, and intelligent scheduling according to actual needs. BRIEF DESCRIPTION OF THE DRAWINGS

[0063] Figure 1 The USB to serial port circuit diagram in the PID heating control system of a small water heater based on a single chip provided in this application;

[0064] Figure 2 The relay circuit diagram of the PID heating control system for a small water heater based on a single chip microcomputer provided in this application;

[0065] Figure 3This is the OLED driving circuit diagram in the small water heater PID heating control system based on a single chip microcomputer provided in this application;

[0066] Figure 4 The system assembly circuit diagram of the small water heater PID heating control system based on a single chip microcomputer provided in this application;

[0067] Figure 5 The fuzzy PID flow chart in the PID heating control program of a small water heater based on a single chip provided in this application;

[0068] Figure 6 This is a temperature collection flow chart for the PID heating control program of a small water heater based on a single-chip microcomputer provided in this application. DETAILED DESCRIPTION

[0069] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.

[0070] As described in the background art, the heater starts working and stops heating when the heating temperature is higher than the set value. Due to its frequent starts and stops and high power, its temperature control accuracy is low, mostly above a few degrees.

[0071] In order to solve this technical problem, the present invention provides a small water heater PID heating control system based on a single chip microcomputer, which applies the technical field of PID heating control.

[0072] In order to enable those skilled in the art to better understand the solutions of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings.

[0073] It should be noted that, in the absence of conflict, the embodiments of the present invention and the features and technical solutions in the embodiments may be combined with each other.

[0074] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.

[0075] Example 1, please refer to Figure 1-4 , a small water heater PID heating control system based on single chip microcomputer, including the following modules:

[0076] Main control module: It consists of STM32F103ZET6 microcontroller, external crystal oscillator circuit, reset circuit, power supply circuit and BOOT selection circuit;

[0077] Temperature module: DS18B20 is used. A 4.7kΩ pull-up resistor needs to be connected to the DQ pin of this sensor.

[0078] Button module: It consists of three buttons, two of which are connected to ground and the other is connected to 3.3V;

[0079] OLED Module: Reference Figure 3 , OLED bare screen driver chip SSD1306 consists of 30 pins in total. c1 and c2 are connected to two capacitors as required, VBAT is connected to VDD, BS is mode selection, this design will use IIC mode, so BS0 and BS2 are pulled low here, BS1 is pulled high, CS# is chip select, it is pulled low here, RES# is the reset circuit, its function is to realize power-on reset, D / C# is data or command mode, which determines the data on D[7:0]. In IIC mode, this pin needs to be connected to VSS, R / W# is the read / write control pin, high level read, low level write, E / RD# needs to be connected to VSS in serial port mode, D[7:0] is the data line, IREF is the current output reference pin, a resistor should be connected between the pins, VCOMH is connected to a capacitor, VCC is connected to an input voltage, VLSS is the analog ground pin, connected to VSS;

[0080] Relay Module: Reference Figure 1 , consists of a relay body, a resistor, a PNP transistor, a diode and a light-emitting diode. When a high level is input, the transistor is turned on, the light-emitting diode is on, and the relay is energized. Conversely, the relay is disconnected. The diode plays the role of a freewheeling diode in the circuit. Because there is a coil inside the relay, it prevents the coil from having a large self-inductance potential after power on and off, which will damage the circuit. It is connected in parallel in the circuit and reversely connected to the coil, that is, the cathode of the diode is connected to the positive power supply, and the anode of the diode is connected to the negative power supply;

[0081] Communication interface module: Reference Figure 2This module uses CH340G as a USB to TTL chip, which can be used for serial port. It consists of 1 NPN transistor and 1 PNP transistor, a crystal oscillator, and auxiliary circuits. When communicating via serial port, only the D+ and D- of the chip need to be connected to the D+ and D- of USB, and the RXD of the module needs to be connected to the TXD of MCU. The TXD of the module is similar. When downloading the program, DTR# and RTS# are high by default. At this time, Q2 is turned on, Q1 is not turned on, and Boot0 is low. When downloading is enabled, DTR# is high and RTS# is low. At this time, Q1 and Q2 are turned on, and Boot0 is high. At this time, the startup mode is changed to system memory. When the program is written, Boot0 is low, and the startup mode is changed back to starting from FLASH. In general, the program is started from system memory when downloading and started from FLASH when running.

[0082] Heating rod module: The heating rod adopts a power of 15W.

[0083] refer to Figure 4 The crystal oscillator circuit uses an 8MHz external crystal oscillator as an external high-speed clock, with two capacitors as the start-up circuit, and a resistor in parallel to protect the crystal oscillator;

[0084] refer to Figure 4 , the reset circuit is for the microcontroller to reset at a low level. When powered on, the voltage on the capacitor is 0, the reset pin is pulled low, and after the capacitor is fully charged, the reset pin is high, and the power is turned on and reset. After the button is pressed, the reset pin is pulled low to reset the circuit;

[0085] refer to Figure 2 ,The power circuit is powered by USB power, and the 5V voltage is converted to 3.3V through the AMS117-3.3 linear regulator. A tantalum capacitor is connected to the output end to power the microcontroller;

[0086] refer to Figure 3 The temperature module is mainly composed of a 64-bit ROM and a memory. The 64-bit ROM stores a unique serial number, and the memory is composed of a high-speed RAM and an EEPROM.

[0087] Example 2, please refer to Figure 5-Figure 6 , a small water heater PID heating control program based on a single-chip microcomputer, including a fuzzy PID design process, which passes in two parameters, one is the address of the global PID structure and the sampling temperature, then quantizes the sampling temperature, calculates the membership of E and Ec, and then uses the rule table and the centroid method to solve the fuzziness, and finally adjusts the gain output. The process reference Figure 5 , the following steps:

[0088] (1)PID structure:

[0089]

[0090]

[0091] Where Sv is the set value, Av is the current value, err is the current error, last_err is the last error, err_sum is the historical error, dKp, dKi, dKd are the increments after each fuzzy PID calculation, qKp, qKi, qKd are the gains;

[0092] (2) Quantitative data collection:

[0093]

[0094] First, pass in the address of the PID structure and the address where the quantization is stored. Set the range to 0-50 degrees and the error estimation range to 50. Divide by 50 and then multiply by 6 and 3 to divide the quantization value between positive and negative 6 and positive and negative 3. Then, the printing function required for testing is used, which will facilitate quick troubleshooting of errors.

[0095] (3) Membership calculation:

[0096]

[0097]

[0098]

[0099] The triangle membership function is implemented by segmentation, and then the membership of the fuzzy subset and the index of the rule table are returned;

[0100] (4) Defuzzification and gain output:

[0101]

[0102]

[0103]

[0104]

[0105] If the task creation fails, fail will be displayed. If the task creation succeeds, the temperature reading module and the system operation indicator task will be suspended, and then the UI interface of the display module will be displayed. Finally, the task block itself will be deleted and the critical area will be exited.

[0106] In the DS18B20 sensor, the software design process is initialization, temperature conversion and temperature calculation, refer to Figure 6 , design of control system for DS18B20:

[0107] (1) DS18B20 programming:

[0108]

[0109]

[0110] The temperature acquisition program must first send a reset command, then send a skip command and a read register command, and you can get the lower 8 bits and the upper 8 bits, a total of 16 bits of data. Since the last 4 bits of the lower 8 bits are decimals, they need to be taken out, and then the upper 8 bits and the first 4 bits of the lower 8 bits are taken out and spliced ​​together, and finally added together to get the complete data;

[0111] (2) DS18B20 task design

[0112]

[0113]

[0114]

[0115] 9. Design of button module:

[0116]

[0117]

[0118]

[0119] 10. Task design of button module:

[0120]

[0121]

[0122]

[0123]

[0124]

[0125] After obtaining the key value, the key event group information will be sent, and the event bit will be obtained in the event receiving task, and other tasks can be controlled by suspending / waking up the key.

[0126] In the present invention, unless otherwise clearly specified and limited, the terms "installed", "connected", "connected", "fixed" and the like should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral one; it can be a mechanical connection, an electrical connection, or communication with each other; it can be a direct connection, or an indirect connection through an intermediate medium, it can be the internal connection of two elements or the interaction relationship between two elements, unless otherwise clearly defined. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.

[0127] Obviously, the embodiments described above are only some embodiments of the present invention, rather than all embodiments. The preferred embodiments of the present invention are given in the accompanying drawings, but they do not limit the patent scope of the present invention. The present invention can be implemented in many different forms. On the contrary, the purpose of providing these embodiments is to make the understanding of the disclosure of the present invention more thorough and comprehensive. Although the present invention has been described in detail with reference to the aforementioned embodiments, for those skilled in the art, it is still possible to modify the technical solutions recorded in the aforementioned specific embodiments, or to perform equivalent replacements for some of the technical features therein. Any equivalent structure made using the contents of the specification and drawings of the present invention, directly or indirectly used in other related technical fields, is also within the scope of patent protection of the present invention.

Claims

1. A small water heater PID heating control system based on a single chip microcomputer, characterized in that: Includes the following modules: Main control module: It consists of STM32F103ZET6 microcontroller, external crystal oscillator circuit, reset circuit, power supply circuit and BOOT selection circuit; Temperature module: Use DS18B20 temperature sensor, and a 4.7kΩ pull-up resistor needs to be connected to the DQ pin of this sensor; Button module: It consists of three buttons, two of which are connected to ground and the other is connected to 3.3V; OLED module: The OLED bare screen driver chip SSD1306 consists of 30 pins in total. C1 and C2 are connected to two capacitors as required, VBAT is connected to VDD, and BS is the mode selection. Relay module: consists of a relay body, a resistor, a PNP transistor, a diode and a light-emitting diode; Communication interface module: This module uses CH340G as a USB to TTL chip, which can be used for serial port. It consists of 1 NPN transistor and 1 PNP transistor, a crystal oscillator, and auxiliary circuits. Heating rod module: The heating rod adopts a power of 15W.

2. According to the single chip microcomputer-based small water heater PID heating control system of claim 1, it is characterized in that: The crystal oscillator circuit uses an 8MHz external crystal oscillator as an external high-speed clock, with two capacitors as the start-up circuit, and a resistor in parallel to protect the crystal oscillator.

3. A small water heater PID heating control system based on a single chip microcomputer according to claim 2, characterized in that: The reset circuit resets the microcontroller at a low level. When powered on, the voltage on the capacitor is 0, and the reset pin is pulled low. After the capacitor is fully charged, the reset pin is high, and the power is turned on and reset. After the button is pressed, the reset pin is pulled low to reset the circuit.

4. A small water heater PID heating control system based on a single chip microcomputer according to claim 3, characterized in that: The power circuit is powered by USB power, and the 5V voltage is converted to 3.3V through the AMS117-3.3 linear regulator. A tantalum capacitor is connected to the output end to power the microcontroller.

5. A small water heater PID heating control system based on a single chip microcomputer according to claim 4, characterized in that: The temperature module is mainly composed of a 64-bit ROM and a memory. The 64-bit ROM stores a unique serial number, and the memory is composed of a high-speed RAM and an EEPROM.

6. A PID heating control program for a small water heater based on a single chip microcomputer, using a PID heating control system for a small water heater based on a single chip microcomputer as claimed in claim 5, characterized in that: Including the fuzzy PID design process, two parameters are passed in, one is the address of the global PID structure and the sampling temperature, then the sampling temperature will be quantified, the membership of E and Ec will be calculated, and then the fuzzification will be solved through the rule table and the centroid method, and finally the gain output will be adjusted. The following steps: (1) PID structure; (2) Quantitatively collect data; (3) Membership calculation (4) Fuzzy and gain output.

7. A PID heating control program for a small water heater based on a single chip microcomputer according to claim 6, characterized in that: In the PID structure, Sv is the set value, Av is the current value, err is the current error, last_err is the last error, err_sum is the historical error, dKp, dKi, dKd are the increments after each fuzzy PID calculation, and qKp, qKi, qKd are the gains.

8. A PID heating control program for a small water heater based on a single chip microcomputer according to claim 7, characterized in that: In the quantitative data collection, first, the PID structure address and the address where the data is stored after quantification are passed in. The range is set to 0-50 degrees, the error estimation range is 50, and the quantized value is divided between positive and negative 6 and positive and negative 3 by dividing by 50 and then multiplying by 6 and 3. Then the printing function required for testing is used, which will facilitate quick troubleshooting of errors.

9. A PID heating control program for a small water heater based on a single chip microcomputer according to claim 8, characterized in that: In the membership calculation, the triangle membership function is implemented by segmentation, and then the membership of the fuzzy subset and the index of the rule table are returned.

10. A PID heating control program for a small water heater based on a single chip microcomputer according to claim 9, characterized in that: In the defuzzification and gain output, after defuzzification, the PID gain is obtained, and the result is superimposed on the Kp of the position PID to perform a fuzzy PID calculation.