Hooking up a 10K NTC Thermistor to an LTC2440
hello everybody,
disclaimer: not , electronics expert, knowledge limit please bear me
i'm doing research find limit of cooling solution i'm using. i'd measure temperature stability, not accuracy.
i ordered linear dc570a demoboard in hopes hook 10k ntc thermistor easily.
i wrong. =(
i go interface running using following topic link.
made adjustments , got following sketch
i readings 25c , rawadc value of 16777216 /2
it not go further no matter how connect thermistor.
any other connection tried doesn't give me correct temperature.
i connected dc570a followed:
from ref+ 10k resistor
from 10k resistor 10k thermistor
from 10k resistor in+
from 10k thermistor in -
in- connected straight gnd
could advice on how full range of 10k thermistor?
disclaimer: not , electronics expert, knowledge limit please bear me
i'm doing research find limit of cooling solution i'm using. i'd measure temperature stability, not accuracy.
i ordered linear dc570a demoboard in hopes hook 10k ntc thermistor easily.
i wrong. =(
i go interface running using following topic link.
made adjustments , got following sketch
code: [select]
/*
interface between arduino dm board , linear tech ltc2440 24-bit adc
nov. 12 2010 john beale
ltc2440 <----------> arduino
11: /cs <- digital pin 10 (ss pin)
7: mosi <- digital pin 11 (mosi pin)
12: miso -> digital pin 12 (miso pin)
13: sclk <- digital pin 13 (sck pin)
10: /ext - ground
1: gnd - ground
2: vdd3 - 5v supply
*/
#include <spi.h> // include spi library
// set i/o pins used in addition clock, data in, data out
const byte slaveselectpin = 10; // digital pin 10 /cs
const byte resetpin = 9; // digital pin 9 /reset
const int nsamples = 5; // how many adc readings average together
// spi_clock_div16 gives me 1.0 mhz spi clock, 16 mhz crystal on arduino
void setup() {
serial.begin(115200); // set serial comm pc @ baud rate
pinmode (slaveselectpin, output);
pinmode (resetpin, output);
digitalwrite(slaveselectpin,high); // chip select active low
digitalwrite(resetpin,high); // reset active low
spi.begin(); // initialize spi, covering mosi,miso,sck signals
spi.setbitorder(msbfirst); // data clocked in msb first
spi.setdatamode(spi_mode0); // sclk idle low (cpol=0), mosi read on rising edge (cphi=0)
spi.setclockdivider(spi_clock_div16); // system clock = 16 mhz, chip max = 1 mhz
serial.println("ltc2440 test");
}
#include <math.h>
float vcc = 5.00; // used display purposes, if used
// set measured vcc.
float pad = 10000; // balance/pad resistor value, set to
// measured resistance of pad resistor
float thermr = 10000; // thermistor nominal resistance
float thermistor(long rawadc) {
long resistance;
float temp; // dual-purpose variable save space.
resistance=((16777216 * pad / rawadc) - pad);
temp = log(resistance); // saving log(resistance) not calculate it 4 times later
temp = 1 / (0.000831166375923117 + (0.000256436021065264 * temp) + (0.000000206045827449766 * temp * temp * temp));
temp = temp - 273.15; // convert kelvin celsius
// begin- remove these lines function not display anything
//serial.print("adc: ");
//serial.print(sum);
//serial.print("/1677216"); // print out raw adc number
//serial.print(", vcc: ");
//serial.print(vcc,2);
//serial.print(", pad: ");
//serial.print(pad/1000,3);
//serial.print(" kohms, volts: ");
//serial.print(((sum*vcc)/1677216.0),3);
//serial.print(", resistance: ");
//serial.print(resistance);
//serial.print(" ohms, ");
// end- remove these lines function not display anything
// uncomment line function return fahrenheit instead.
//temp = (temp * 9.0)/ 5.0 + 32.0; // convert fahrenheit
return temp; // return temperature
}
// =============================================================================
// main loop:
// acquire 'nsamples' readings, convert units of volts, , send out on serial port
void loop() {
int i;
long secs;
float mins;
double volts;
long in; // incoming serial 32-bit word
long sum = 0;
float temp;
long rawadc;
for (i=0; i<nsamples; i++) {
in = spiread();
in &= 0x1fffffff; // force high 3 bits zero
in = in>>5; // truncate lowest 5 bits
sum += in;
delay(198); // (msec). total looptime: +2 msec (overhead comms)
}
// volts = in * 2.5 / 8.388607; // 0x7fffff = 8388607
volts = sum * (0.2980232594); // microvolts
volts = volts / nsamples;
rawadc = sum / nsamples;
mins = (float) millis() / 60000; // elapsed time in minutes
temp=thermistor(rawadc); // read adc , convert celsius
serial.print(volts);
serial.print(", ");
serial.print(rawadc);
serial.print(", ");
serial.println(temp,3); // display celsius
} // end main loop
// =================================================================
// spiread() -- read out 4 bytes ltc2440 chip via spi interface
// =================================================================
long spiread(void) {
long result = 0;
long b;
// long result2 = 0;// mosi/sdi pin 7 high => 7 hz, best resolution
digitalwrite(slaveselectpin,low); // take ss pin low select chip
delaymicroseconds(1); // not needed, need 25 nsec delay
b = spi.transfer(0xff); // b3
result = b<<8;
b = spi.transfer(0xff); // b2
result |= b;
result = result<<8;
b = spi.transfer(0xff); // b1
result |= b;
result = result<<8;
b = spi.transfer(0xff); // b0
result |= b;
// take ss pin high de-select chip:
digitalwrite(slaveselectpin,high);
return(result);
}
i readings 25c , rawadc value of 16777216 /2
it not go further no matter how connect thermistor.
any other connection tried doesn't give me correct temperature.
i connected dc570a followed:
from ref+ 10k resistor
from 10k resistor 10k thermistor
from 10k resistor in+
from 10k thermistor in -
in- connected straight gnd
could advice on how full range of 10k thermistor?
a few things:
1) 99.9% of seasoned engineers cannot 24-bit adc work. requires tremendous amount of know-how , art of engineering (layout in particular).
2) 1 approach usable data out of high resolution adc average. has downside.
3) in case, should @ room temperature close half of full scale , varies temperature.
4) do, onboard adc fine.
1) 99.9% of seasoned engineers cannot 24-bit adc work. requires tremendous amount of know-how , art of engineering (layout in particular).
2) 1 approach usable data out of high resolution adc average. has downside.
3) in case, should @ room temperature close half of full scale , varies temperature.
4) do, onboard adc fine.
Arduino Forum > Using Arduino > Sensors > Hooking up a 10K NTC Thermistor to an LTC2440
arduino
Comments
Post a Comment