Home > Power Circuits > Design of temperature detection circuit implemented by single chip microcomputer

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:

t51.png

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

 

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.

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号