Conventional method of collecting temperature using an NTC thermistor
This article provides a more conventional method of collecting temperature using an NTC thermistor. First, an NTC thermistor having a resistance value of Rn=10K and a thermal index of B=3950 is used when the rated temperature Tn=25°C. The method of collecting temperature using a thermistor is very simple, as shown in Figure 1. ADC_Temp enters the ADC6 port of the chip, using the AVR 8-bit chip Atmega48. The chip converts the thermistor resistance value by detecting the voltage of the voltage divider circuit to obtain the actual temperature value. As shown below:
The resistance and temperature of the thermistor are as follows:
Programmers can use Excel or other software to obtain the relationship between resistance and temperature by using the above relationship, or directly use the form provided by the seller with the thermistor. In fact, what we need is the relationship between AD value and temperature. From the chip data, it can be understood that the voltage corresponding to the 0-5V AD value is from 0-1023. To make a graph, you can get the following relationship curve:
First, the temperature and AD values should be posted.
In the above table, NTC_fdb represents the AD value corresponding to i degree. PROMEM defines the table data in the flash space.
The actual temperature value can be obtained by the position of the acquired AD value in the table.
Initialization is required before using the ADC.
The subfunctions that read the AD values are as follows:
So how do you use the above subfunctions?
Very simple. Just use the following statement: temp_value=GetNTCTemperature(adc_read(ADC_TEMP));
Figure 1 Schematic diagram of NTC thermistor temperature acquisition circuit
The resistance and temperature of the thermistor are as follows:
Figure 2 Temperature and resistance curve Figure 3 Temperature and AD worthy relationship curve
The above outlines an idea. Here is the post program.First, the temperature and AD values should be posted.
In the above table, NTC_fdb represents the AD value corresponding to i degree. PROMEM defines the table data in the flash space.
The actual temperature value can be obtained by the position of the acquired AD value in the table.
Initialization is required before using the ADC.
The subfunctions that read the AD values are as follows:
So how do you use the above subfunctions?
Very simple. Just use the following statement: temp_value=GetNTCTemperature(adc_read(ADC_TEMP));