Offline
Newbie
Karma: 0
Posts: 34
|
 |
« on: November 01, 2012, 02:33:15 pm » |
Hi I have a 50K thermistor ( this one), which I cannot get to work correctly. My set up is the following: 5V -- T -- A -- 10K -- GND Where T is the thermistor, A is the analog PIN. The problem is that I got weird temperatures like 100 celsius degrees, even if I am sure that the SH equation is correct, since I read the same values as in the datasheet table. Any idea about that? Thanks
|
|
|
|
|
Logged
|
|
|
|
|
California
Online
Edison Member
Karma: 51
Posts: 2185
|
 |
« Reply #1 on: November 01, 2012, 03:01:32 pm » |
Have you tried manually measuring the resistance of the thermistor and verifying the temperature from the datasheet?
|
|
|
|
|
Logged
|
|
|
|
|
Netherlands
Online
Tesla Member
Karma: 101
Posts: 9553
In theory there is no difference between theory and practice, however in practice there are many...
|
 |
« Reply #2 on: November 01, 2012, 03:53:58 pm » |
Can you post your code? and/or the SH equation? Such a table is work for - http://arduino.cc/playground/Main/MultiMap - Think 11 - 15 entries should be enough to get an acceptable approximation although I do not know your requirements
|
|
|
|
|
Logged
|
|
|
|
|
the land of sun+snow
Offline
Edison Member
Karma: 91
Posts: 2240
|
 |
« Reply #3 on: November 01, 2012, 03:58:04 pm » |
Since you have a 50K@room_temp thermistor, is it possible your curve is expecting to see R = 50K rather than 10K?
|
|
|
|
|
Logged
|
Something different - Kitchen-Sink Arduino-compatible boards
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 34
|
 |
« Reply #4 on: November 02, 2012, 03:06:59 am » |
My code is: #include <math.h> #define READING_PIN 5 #define SERIESRESISTOR 10000
double R1 = 10000.0; //resistance put in parallel double V_IN = 5.0;
double A = 9.6564E-04; double B = 2.1069E-04; double C = 8.5826E-8; double K = 9.5; // mW/dec C – dissipation factor
double SteinhartHart(double R) { // calculate temperature double logR = log(R); double logR3 = logR * logR * logR;
return 1.0 / (A + B * logR + C * logR3); }
void setup() { Serial.begin(9600); }
void loop() { double adc_raw = analogRead(READING_PIN);
double V = (adc_raw / 1024) * V_IN; Serial.print("V ="); Serial.print(V);
//calculate resistance double R_th = (R1 * V ) / (V_IN - V); Serial.print("V R_th = "); Serial.print(R_th);
double kelvin = SteinhartHart(R_th) - V * V / (K * R_th); double celsius = kelvin - 273.15; Serial.print(" Ohm - T = "); Serial.print(celsius); Serial.println("C"); delay(1000); }
For the map function, I think that is not the problem. I can correctly map my resistance value to temperature values, but is my resistance value which is wrong, not its mapping. I also tried with 5 10KOhm resistors in series, but this hasn't work either.
|
|
|
|
|
Logged
|
|
|
|
|
Germany
Offline
Edison Member
Karma: 28
Posts: 1589
|
 |
« Reply #5 on: November 02, 2012, 03:32:39 am » |
According to your datasheet the Thermistor has 50k @25°C , which should result in V =0.83, if I understand your ascii wiring scheme correctly.
At lower temperatures you get a higher resistance, e.g. 100k @10°C, which would result in V = 0.45. Higher temperatures provide a higher voltage, e.g. 10k @62.5°C yields V =2.50
Is that in line with your first debug output, [edit:]and what you read with a voltage meter between A5 and GND ? If no, check your wiring (or correct my understanding) If yes, check the maths.
|
|
|
|
« Last Edit: November 02, 2012, 04:02:21 am by michael_x »
|
Logged
|
|
|
|
|
Dallas, TX
Offline
Sr. Member
Karma: 10
Posts: 318
|
 |
« Reply #6 on: November 02, 2012, 09:25:01 am » |
Your equation for Rth assumes a set up like so: 5V -- 10K -- A -- T -- GND
|
|
|
|
|
Logged
|
|
|
|
|
Germany
Offline
Edison Member
Karma: 28
Posts: 1589
|
 |
« Reply #7 on: November 02, 2012, 09:35:08 am » |
That deserves a karma brownie, PapaG.
And it provides a much bigger voltage swing that way.
|
|
|
|
|
Logged
|
|
|
|
|
Dallas, TX
Offline
Sr. Member
Karma: 10
Posts: 318
|
 |
« Reply #8 on: November 02, 2012, 09:40:05 am » |
Thank you, michael_x, my first!
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Edison Member
Karma: 114
Posts: 2205
|
 |
« Reply #9 on: November 02, 2012, 03:43:05 pm » |
I got weird temperatures like 100 celsius degrees Did you get the right V? Did you get the right Rth? Did you get the right T?
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 34
|
 |
« Reply #10 on: November 03, 2012, 02:17:10 am » |
Using PapaG help, I got it working! Thanks!
|
|
|
|
|
Logged
|
|
|
|
|
Anaheim CA.
Offline
Edison Member
Karma: 34
Posts: 2404
Experienced old Whitebeard with a Full head of Hair...
|
 |
« Reply #11 on: November 03, 2012, 03:27:38 am » |
@ dhenry... did you read the whole post... you know, from the first posting??
Bob
|
|
|
|
|
Logged
|
“The solution of every problem is another problem.” -Johann Wolfgang von Goethe
|
|
|
|
Offline
Edison Member
Karma: 114
Posts: 2205
|
 |
« Reply #12 on: November 03, 2012, 05:32:30 am » |
You can also rewrite your Rth calculation to fit your setup:
Rth = (Vin - V) * R1 / V.
|
|
|
|
|
Logged
|
|
|
|
|
Dallas, TX
Offline
Sr. Member
Karma: 10
Posts: 318
|
 |
« Reply #13 on: November 03, 2012, 10:46:46 am » |
Using PapaG help, I got it working! Thanks!
You're welcome, erbedo. You can try an experiment if you're curious. If you select 50K for your series resistor instead of 10K, you'll notice that the voltage vs. temperature curve is far more linear over the range 0-100 Celsius. So much so that, if your interest is a thermometer for measuring the temperature of your environment, you might not even need the Steinhart-Hart function. If you wire your circuit the way you had it originally, and use the right equation, you get a response curve that is fairly linear in the temperature range above 40 degrees Celsius but as michael_x commented, you don't get much of a voltage variation so your resolution is less. If you substitute the 50K resistor again, you get a fairly linear curve at room temperatures but again, not much resolution. So, you see, there are a few trade-offs you can consider in your design.
|
|
|
|
|
Logged
|
|
|
|
|
|