2
\$\begingroup\$

Here's the schematics of my NTC - ADC circuit,

NTC NTC-ADC AREF

ADC 10bits, ADCVCC 2.56V

Vin = 5V

Someone can explain me how i get RT, the value of resistance of NTC from ADC value? thanks.

I'm using the voltage divider formula:

Vout = ADCVCC * ADC_value / 1024
BETA = 3950
R25 = 4700
RT = 10K / (Vin - Vout - 1)
T = (1 / (1/298.16 + 1/BETA * ln(RT/R25 )) - 273.15

But I got wrong results:

the range of my temperatures are:

adc = 1    -> T = 344 °C;
adc = 1023 -> T = 8

How I have to set up the ADC in AVR? with internal voltage reference or not?

do i have wrong formula?

I need to read "exact" temperature in range of -10°C to +30°C more or less.

I've tried already with SH equation with coefficent A,B,C but i've got worst results!!!

I think I've don't understand the schematics of NTC - ADC circuits...

And set up my ATMega with wrong parameters.

Someone can try to explain me how to convert my ADC value to Resistence of thermistor with this schematics?

Thanks in advice for help.

[EDIT]

My setup for AVR ADC:

ADMUX |= (1<<REFS0) | (1<<REFS1);
ADCSRA |= (1<<ADEN) |(1<<ADSC) |(1<<ADIE);
ADCSRA |= (1 << ADPS2) | (1 << ADPS1) | (1 << ADPS0);

and the formula used to get Resistance from ADC value: Vin = 5V Vref = 2,56V (AREF)

Vout = adc_val * (Vref / 1024.0))
RT   = 10k / (Vin / Vout - 1.0)

This code match the schematics? Is it correct my ADC set up with those schematics? thanks in advice.

\$\endgroup\$
  • 1
    \$\begingroup\$ First assumption to clear..the resistance of the NTC get's lower as it warms up So when cold NTC is at high resistance . When hot the resistance goes lower. The voltage at the thermistor will drop as temperature rises ... Is this what you want? I haven't run the calculation but your results show that you can't get the range you want... does the Beta and R25 match your NTC? They are different depending on the model numbers... And was the opamp there in case level shifting and scaling are needed? \$\endgroup\$ – Spoon Oct 19 '13 at 23:37
  • \$\begingroup\$ My Beta and R25 values are correct. I've taken from datasheet. I've set up ADC with internal voltage reference 2.56 V (AREF) so in AVR-C Code is: ADMUX |= (1<<REFS0) | (1<<REFS1); and the adc value, is transformed with voltage divider formula: Vref=2.56V Vin=5V Vout=(adc_val * (Vref / 1024.0)) RT= 10k / (Vin / Vout - 1.0) [I've edit my question with more info] \$\endgroup\$ – Raffaello Oct 20 '13 at 9:52
1
\$\begingroup\$

Someone can try to explain me how to convert my ADC value to Resistence of thermistor with this schematics?

Firstly, the op-amp circuit is doing very little other than adding a small error. If it had gain, you could argue it had a benefit.

Secondly, this circuit benefits from using the supply voltage as its analogue reference because then you remove another error term that being the variable difference between supply voltage on R1 and the reference voltage of the ADC.

So then, the value of the ADC represents the ratio \$\dfrac{thermistor \space resistance}{thermistor\space resistance + 10k\Omega}\$

Can you take it from here?

\$\endgroup\$
  • \$\begingroup\$ I suppose the op-amp circuit is thought as a "noise filter" to take better results. But I'm not sure. I don't know the decision for that... :) for equation you suggest, i've edit my question with more info. but is the voltage divider formula right? Vin/Vout = R1/(R1+R2) \$\endgroup\$ – Raffaello Oct 20 '13 at 10:06
  • \$\begingroup\$ if R1 is the thermistor and R2 is the resistor feeding it from the supply that's the formula for the voltage across the thermistor relative to the supply but, if your ADC uses supply as its reference then the formula is the ADC value divided by 1024. \$\endgroup\$ – Andy aka Oct 20 '13 at 12:42
2
\$\begingroup\$

I ran your code in Python and got 285 for adc_val = 1 and -84 for adc_val = 1023. With an adc_val of 318, I get 25.9. RT at that point is 4504. So it looks like your equations should be right. Are you sure it is being implemented correctly in terms of types? It has to be all floating point. If something is being cast to an integer or something, you could get some strange results.

>>> BETA = 3950
>>> R25 = 4700
>>> Vin = 5
>>> Vref = 5
>>> adc_val = 1
>>> Vout = adc_val * (Vref / 1024.0)
>>> RT   = 10000 / (Vin / Vout - 1.0)
>>> T = (1 / (1/298.16 + 1/BETA * log(RT/R25 ))) - 273.15
>>> T
285.3553121325664
>>> adc_val = 1023
>>> Vout = adc_val * (Vref / 1024.0)
>>> RT   = 10000 / (Vin / Vout - 1.0)
>>> T = (1 / (1/298.16 + 1/BETA * log(RT/R25 ))) - 273.15
>>> T
-84.45667531777428
>>> adc_val = 318
>>> Vout = adc_val * (Vref / 1024.0)
>>> RT   = 10000 / (Vin / Vout - 1.0)
>>> RT
4504.249291784702
>>> T = (1 / (1/298.16 + 1/BETA * log(RT/R25 ))) - 273.15
>>> T
25.970525623383708
\$\endgroup\$
  • \$\begingroup\$ Well, I figured out at that time that there were some errors in the prototype (device). When I had that intuition (i am not electronic eng) because I noticed some strange behavior of hardware responses. The results were less precision that was acceptable for the business because it was a prototype. Anyway: once again ideal and real mismatch! :D :D :D (btw thanks) \$\endgroup\$ – Raffaello Oct 4 '17 at 21:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.