Design and implementation of temperature controller based on single chip microcomputer and fuzzy control
[Copy link]
This post was last edited by Hot Ximixiu on 2020-11-16 21:33
Temperature is one of the most basic physical quantities in science and technology. In industrial production and life, it is often an important parameter to characterize the state of objects and processes. Its control has nonlinearity, time lag and uncertainty, and traditional control cannot achieve good control effects. Design a temperature controller with single-chip microcomputer MSP430F149 as the core component of the system, and apply fuzzy control algorithm to it. The temperature control range is 0-100℃ at room temperature. The set temperature value and the measured temperature value are displayed in real time, and the control accuracy can reach ±0.5℃. The system uses constant temperature power supply, the circuit is simple, the cost is low, and the temperature control accuracy is high. It can be widely used in production and life that require constant temperature control.
0 Introduction
Temperature control has broad application prospects in industries and daily life. Many application fields require high-precision constant temperature control. Due to its nonlinearity, time lag and uncertainty, traditional control cannot achieve good control effects. Fuzzy control is a rule-based control that directly uses language-based control rules. The starting point is the control experience of on-site operators or the knowledge of relevant experts. It has strong robustness, and the influence of interference and parameter changes on the control effect is greatly reduced, so it is particularly suitable for precise control of 0-100℃ temperature. The
MSP430 series microcontroller is a 16-bit, ultra-low power hybrid microcontroller with a reduced instruction set. The MSP430F149 microcontroller uses a reduced instruction set (RISC), with rich addressing modes (7 source operand addressing, 4 destination operand addressing), concise 27 core instructions and a large number of analog instructions. A large number of registers and on-chip data memory can participate in a variety of operations, and there are also efficient table lookup processing instructions; it has a high processing speed, and the instruction cycle is 125 ns under 8MHz crystal drive. These features ensure that a highly efficient source program can be compiled. The MSP430F149 microcontroller has different combinations of some peripheral modules such as 10-bit/12-bit ADC, 16-bit Sigma-Delta A/D, direct addressing module (DMA), port 1~6, basic timer, etc. Among them, the watchdog can quickly reset the program when it is out of control; the analog comparator compares the analog voltage, and with the timer, an A/D converter can be designed. The system uses the MSP430F149 microcontroller, which can save hardware circuits such as A/D, reduce its cost, and greatly enhance its reliability.
1 System Design
The system uses the MSP430F149 microcontroller as the control core. The temperature measurement is completed by the platinum resistance constant current conditioning circuit. The output voltage of the conditioning circuit is sent to the microcontroller, and the A/D conversion is realized inside the microcontroller. The sampled data is filtered and scaled, and the temperature value is displayed by a 3-digit digital tube. The input temperature setting value is carried out by a 4-digit independent keyboard circuit. After the setting value is sent to the microcontroller, it is displayed by another 3-digit digital tube. The system design block diagram is shown in Figure 1.
2 Main hardware circuit design
2.1 Platinum resistor temperature measurement conditioning circuit
In this system, the actual temperature value is measured by the constant current working conditioning circuit of the platinum resistor. In order to overcome the nonlinear characteristics of the platinum resistor, a negative feedback nonlinear correction network is added to the signal conditioning circuit. As shown in Figure 2, the platinum resistor uses RT100 with a nominal value of 100Ω as the temperature sensor. A1, A2 and A3 use low temperature drift op amp OP07. Since there is current flowing through the platinum resistor sensor, when the temperature is 0℃, there is a voltage drop on the platinum resistor sensor. This voltage is the bias voltage of the platinum resistor sensor and is part of the output voltage of op amp A1, so that the output of the constant current working conditioning circuit is not actually 0, so it is necessary to zero this bias voltage. R3 in the figure is the zero adjustment resistor. The op amp A3 and resistors R1, R4 and R6 in the figure constitute a negative feedback nonlinear correction network. R5 is used to adjust the gain of op amp A2.
2.2 Temperature control circuit
The system heating wire and fan both adopt the circuit shown in Figure 3. The circuit uses a DC electromagnetic relay driven by a transistor. When P5.4 of the single-chip microcomputer is at a low level, the relay RL1 is energized, and when P5.4 is at a high level, the relay RL1 is released. This control logic can prevent the relay from energizing during power-on reset or single-chip microcomputer controlled reset. The relay is driven by transistor 2N222A, which can provide the required driving current.
3 Fuzzy control rule table and software flow chart
3.1 Establish fuzzy control rule table
Temperature error E and temperature error change rate Ec are used as input variables of the fuzzy controller, and temperature control quantity U is used as the output variable of the fuzzy controller. The basic domains of temperature error E, temperature error change rate Ec and temperature control quantity U (unit: ℃) in the system are [-5, +5], [-2, +2] and [0, 1] respectively. The language value of the input language variable is 7, and the output control quantity is used to control the relay drive circuit. The duty cycle fuzzy control quantity is set to five single-point fuzzy quantities of 0, 1/4, 1/2, 3/4, and 1, and a single-point fuzzy quantity for controlling the fan blowing. The language value of the output language variable is 6. When U=0, the P3.5 port of the single-chip computer is set to a low level to make the fan control circuit work; when U=1, the heating wire control circuit works, and the relay is fully turned off within 1 cycle; when U=2, the heating wire control circuit works, and the relay is connected within 1/4 cycle and turned off within 3/4 cycle; when U=5, the heating wire control circuit works, and the relay is fully connected within 1 cycle. This control system uses trigonometric functions, ascending semi-trapezoidal functions, and descending semi-trapezoidal functions as the membership functions of the input language value, and uses pulse functions as the membership functions of the output language value. The fuzzy control rules are shown in Table 1.
Reasoning from fuzzy rules can derive the input-output relationship of the fuzzy controller language rules, which is a nonlinear relationship surface. When the deviation is large, the change of the control quantity should try to reduce the deviation quickly; when the deviation is small, in addition to eliminating the deviation, the stability of the system should also be considered to prevent the system from overshooting or even causing system oscillation.
|