Design of temperature detection circuit implemented by single chip microcomputer
Source: InternetPublisher:spectrum Keywords: Microcontroller temperature detection power supply and other power supply circuits Updated: 2021/01/20
This article provides a low-cost temperature detection circuit that utilizes the redundant I/O ports of a microcontroller. The circuit is very simple and easy to implement, and is suitable for almost all types of microcontrollers. Its circuit is shown in the figure below:
In the picture:
P1.0, P1.1 and P1.2 are the three I/O pins of the microcontroller;
RK is a 100k precision resistor;
RT is 100K - thermistor with 1% accuracy;
R1 is an ordinary resistor of 100Ω;
C1 is a 0.1μ ceramic capacitor.
Its working principle is:
1. First set P1.0, P1.1, and P1.2 to low level output to discharge C1 until it is completely discharged.
2. Set P1.1 and P1.2 to input status, set P1.0 to high level output, charge C1 through the RK resistor, clear the internal timer of the microcontroller and start timing, detect the status of P1.2 port, when When the P1.2 port detects a high level, that is, when the voltage on C1 reaches the gate voltage of the high-level input of the microcontroller, the microcontroller timer records the time T1 from the start of charging to the P1.2 port transitioning to a high level.
3. Set P1.0, P1.1, and P1.2 to low-level output to discharge C1 until it is discharged.
4. Then set P1.0 and P1.2 to the input state, set P1.1 to high level output, charge C1 through the RT resistor, clear the internal timer of the microcontroller and start timing, and detect the status of the P1.2 port. When the P1.2 port detects a high level, the microcontroller timer records the time T2 from the start of charging to the P1.2 port transitioning to a high level.
5. From the voltage formula of the capacitor
![Design of temperature detection circuit implemented by single chip microcomputer](http://www.eeworld.com.cn/circuit/upload/a1dffc61b1d853d7a0a6caab6c286e56/1fac628b3b13a303ec840bdfbee9f9d8.jpg)
It can be obtained: T1/RK=T2/RT, that is, RT=T2×RK/T1. The resistance value of the thermistor RT is calculated by the microcontroller. And the temperature value can be obtained through the look-up table method.
As can be seen from the above, the error of the temperature measurement circuit comes from the following aspects: the timer accuracy of the microcontroller, the accuracy of the RK resistor, the accuracy of the thermistor RT, and the output voltage value of the microcontroller, the gate embedded voltage value and capacitance accuracy. Therefore, if the accuracy of the thermistor and precision resistor is appropriately selected and the operating frequency of the microcontroller is high enough, better temperature measurement accuracy can be obtained.
When the microcontroller uses a 4M operating frequency and RK and RT are resistors with 1% accuracy, the temperature error can be less than 1°C.
If P1.2 has the function of external rising edge interrupt, the program can be simpler and the effect will be better.
- How about the boost converter TPS61299?
- Build a simple buck-boost regulator and test it on a breadboard
- Fabrication of multi-cell lithium battery charging circuit
- What kind of circuit is a voltage regulator circuit?
- Basic connection circuit of signal and power supply composed of ISOll3
- Single-power supply circuit for ISO122P/ISO124
- Transformerless AC-DC constant current LED driver circuit
- A novel and practical DC low voltage stabilized power supply
- CNC regulated power supply production
- LM317T voltage regulation adjustable circuit diagram explanation
- Mobile phone fast charging may become standard
- Teach you a reliable new method to implement overvoltage protection for electronic signal inputs
- Analysis on solving various electromagnetic interference problems of electronic equipment
- PCF8591 hardware interface (circuit diagram pin diagram)
- Analysis of internal reset circuit diagram of microcontroller
- SPI interface and microcontroller interface principle circuit diagram
- Dual audio decoding electronic circuit
- Microcontroller measurement circuit
- IR2130 combined with microcontroller and SLE4520 for three-phase frequency conversion system diagram
- Optoelectronic interface circuit between single-channel DA chip DAC0832 and microcontroller