Current location - Education and Training Encyclopedia - Graduation thesis - A paper on temperature control system of single chip microcomputer
A paper on temperature control system of single chip microcomputer
Abstract: This paper introduces a temperature measurement and control device based on MSP430 single chip microcomputer. The device can measure the temperature and adjust the ambient temperature according to the set value, so as to achieve the purpose of temperature control. The control algorithm is based on digital PID algorithm.

Introduction to 0

Temperature is one of the main controlled parameters in industrial control, especially in metallurgy, chemical industry, building materials, food, machinery, petroleum and other industries. With the rapid development of electronic technology and microcomputer, microcomputer measurement and control technology has been rapidly developed and widely used [1]. Single chip microcomputer has the advantages of strong processing ability, fast running speed and low power consumption. When applied to temperature measurement and control, it has the advantages of simple and convenient control, wide measuring range and high precision.

In this paper, a temperature measurement and control device based on MSP430 single chip microcomputer is designed, which can measure the ambient temperature, give the adjustment amount according to the given temperature, control the actuator, and realize the purpose of adjusting the ambient temperature.

1 overall scheme design

The temperature control system of single chip microcomputer is based on MSP430 single chip microcomputer. The hardware part of the whole system includes temperature detection system, signal amplification system, A/D conversion, single chip microcomputer, I/O equipment, control execution system and so on.

The control block diagram of single chip microcomputer temperature control system is as follows:

After the temperature sensor converts the temperature information into an analog voltage signal, it amplifies the voltage signal to a range that can be processed by the single chip microcomputer, and after low-pass filtering, it filters out the interference signal and sends it to the single chip microcomputer. In order to further improve the measurement accuracy, the single chip microcomputer samples the signal and then digitally filters it. The microcontroller compares the detected temperature information with the set value. If they are inconsistent, the digital regulating program designs the control quantity according to the PID control algorithm according to the difference between the set value and the measured value, and the trigger program controls the execution unit according to the control quantity. If the detected value is higher than the set value, start the refrigeration system to reduce the ambient temperature; If the detected value is lower than the set value, the heating system is started to increase the ambient temperature, thereby controlling the temperature.

2 Temperature signal detection

In this system, the detection accuracy is not very high, only at room temperature, so high-precision thermistor is selected as the temperature sensor. Thermistor has the characteristics of high sensitivity, strong stability and high exchange accuracy. It can make the amplifier circuit extremely simple and avoid the trouble of replacing compensation.

Thermistors have negative temperature resistance characteristics. As the temperature rises, the resistance decreases, and its resistance-temperature characteristic curve is exponential, which is very nonlinear. For this design, the temperature requirement is not high, and the resistance value of thermistor is basically linear with the ambient temperature at room temperature [2], so the temperature value can be converted into voltage value simply by resistor voltage division.

When a constant current is applied to the thermistor, the voltage across the resistor can be obtained. According to the temperature parameter T0 and the characteristic coefficient k related to the thermistor characteristics, the following formula can be obtained.

T=T0-kV(t) ( 1)

Where t is that measure temperature.

According to the above formula, the relationship between resistance and temperature can be transformed into the relationship between voltage and temperature. Because the electrical signal of thermistor is generally millivolt, it must be amplified to convert the electrical signal measured by thermistor into 0 ~ 3.6 before it can be used in single chip microcomputer.

The diagram below shows the schematic diagram of the amplifier circuit. The voltage stabilizing value of the voltage stabilizing tube is1.5v..

Because the sensor outputs a weak analog signal, when there is environmental interference in the signal, the interference signal is also amplified, which affects the detection accuracy. It is necessary to process the analog signal with filter circuit to improve the anti-interference ability of the signal. This system adopts Butterworth second-order active low-pass filter circuit. Select the cutoff frequency of Butterworth second-order active low-pass filter circuit.

FH= 10 kHz.

3 control system design

3.0 Software design

The temperature controller of single chip microcomputer controls the temperature range from 100℃ to 400℃. In a given control period, the temperature is raised and lowered by changing the on-off time of heating and refrigeration equipment, so as to achieve the purpose of adjusting the temperature.

In the software design, the control period TC is 200(T 1×C) and the on-time is Pn ×T 1×C, where Pn is the output control quantity, the Pn value is between 0 and 200, T 1 is the timer timing time, and c is a constant. It can be seen from the above two formulas that the control period TC can be changed by changing the timing time of T 1 or the constant c, and the maximum temperature controlled by the temperature controller is 400℃, which is calculated when the given temperature exceeds 400℃.

Fig. 3 is a flow chart of sampling interrupt.

The digital-to-analog conversion part adopts the 12-bit A/D converter of single chip microcomputer, which can realize digital-to-analog conversion and control at the same time, without special conversion chip, making the system process faster and more accurate, and simplifying the circuit. The sampling period is 500μ s. When the data of 16 points are collected, the flag "nADCFlag = 1" is set to inform the main program that the data of 16 points have been collected, and the main program reads the data from the global buffer.

In order to further reduce the influence of random signals on the system accuracy, after A/D conversion, the sampled values are digitally filtered by the average method. Every 16 sampling points on average. Then, the calculated average value is displayed as measurement data. At the same time, the deviation between the temperature sampling value and the given value is controlled according to PID algorithm, and the control quantity is obtained. After the whole sampling process is completed, the sampling interrupt can be shielded, and at the same time, T 1 Timing [3] can be started to enter the control process.

The temperature value and the measured value of thermistor basically change linearly in the whole temperature sampling interval, so there is no need to linearly correct the measured data in the program. The T 1 timer interrupt of MSP430 is used as the control interrupt, and the temperature sampling process and the control output process adopt an interlocking structure, that is, T 1 does not time when temperature sampling, temperature value processing and operation are carried out, and then T 1 timing is started when the whole sampling process is completed, and the sampling interrupt is shielded. T 1 enters the control process from the timing, and the whole control process is not sampled until the timing of 200(T 1×C) arrives, and a new control cycle should be started. Mask T 1 interrupt at the beginning of sampling.

Fig. 4 is a flowchart of T 1 timing interrupt.

In the figure, m represents the count value of the timer control period, and n represents the control quantity calculated by the regulator. First, it is judged whether the control period TC has ended. If the control period TC has ended (that is, M=0), the T 1 timer will be blocked and a new round of temperature sampling will be conducted. If the control period TC has not ended (i.e., m ≠ 0), it is started to judge whether the on-time has ended. If the on-time has ended (i.e. N=0), the output control signal is set low, the constant c value is re-assigned, the timer is started, and the interrupt service program is exited at the same time; If the conduction time is not over (i.e. N ≠0), set the output control signal to high, continue conduction during control execution, redistribute the constant c value, start the timer, and exit the interrupt service program at the same time.

3. 1 digital PID

The control algorithm in this paper adopts digital PID control, and the expression of digital PID algorithm is as follows:

Where KP is the proportional coefficient; KI=KPT/TI is the integral coefficient; T is the sampling period and TI is the integration time coefficient; KD=KPTD/T is the differential coefficient, and TD is the differential time coefficient. U(k) is the kth output of the regulator, and e(k) is the kth given and feedback deviation.

For PID regulator, when the deviation value is large, the output value will be large, which may lead to system instability, so in actual operation, it is necessary to limit the output of the regulator [4], that is, when | u | >;; Umax, let u=umax or u=-umax, or as the case may be.

3.2 Temperature adjustment

PI controller adjusts the deviation between the given temperature value and the measured value, gives the adjustment amount, and then outputs PWM wave through single chip microcomputer to adjust the phase angle of thyristor trigger phase, so as to control the turn-off and turn-on time of actuator, and achieve the purpose of raising or lowering the temperature. Then, the whole system carries out further control correction by detecting the temperature after the previous control, and finally realizes the expected temperature monitoring purpose.

4 conclusion

This design uses the characteristics of low power consumption and strong processing ability of single chip microcomputer, and uses single chip microcomputer as the main controller to monitor the indoor environment temperature. It has simple structure and high reliability, and has certain practical value and development prospect.

refer to

Zhao Lijuan, Shao Xin. Design and implementation of temperature monitoring system based on single chip microcomputer. Mechanical Manufacturing, April 2006 (1)

[2] Zhang Kaisheng, Guo Guofa. Design of MCS-5 1 single chip microcomputer temperature control system. Microcomputer Information, 2005, (7)

[3] Shen Jianhua, Yang Yanqin, Zhai Xiaoshu .. Principle and application of MSP430 series 16-bit ultra-low power single chip microcomputer. Tsinghua University Publishing House, 2004, 148- 155.

Lai Shouhong. Microcomputer control technology. Beijing: Machinery Industry Press, 1994:90-95.