Using #define for a thermistor lookup table?

Hello! would like to use a lookup table (like a *.h file with #define inside) to lookup thermistor values. Currently, the program I am using uses a formula to calculate temperature, but I would like it to be more accurate. Can I define for resistance values, lets say, 5 ohms apart? Here is my code:

/* some comments up here
   Coding done in Arduino 1.0.1 and Notepad++
   */

#include <math.h>
#include <SD.h> //Starts the SD library

int DATA = 0;
int Rest;
int Temp;
int Rr = 3950; //Resistance at room temp
int Rt = 24; //Room temp (C)
float conv;
float Volt = 0;
const int chipSelect = 4; //sets the C/S pin to 4
int Thermopins[] = {1, 2, 3}; //array of the pins. When it is called, 0 = 1, 1 = 2, etc...
void setup() {
  pinMode(10, OUTPUT); //needed with ethernet sheild, no reason known yet by me
  SD.begin(chipSelect);//turns on the SD card
}

void loop() { //loop and loop and loop and loop...
  for(int x = 0; x < 3; x++) { //create a variable named x, incriment it each time program is run, and run it 3 times.
    DATA = analogRead(Thermopins[x]);
    Volt = DATA / 204.6; //Converts 1023 to 5v
    Rest = 10000*((5/Volt)  - 1); //Wheras 10000 = resisitor value, 5 = volatage, and Volt = the voltage ACROSS the resistor
    //Beware, you are going into CRAZY MATH LAND
	conv = Rest / 10000;
	conv = log(conv);
	conv /= Rr;
	conv += 1.0 / (Rt + 273.15);
	conv = 1.0 / conv;
	conv -= 273.15;
    File dataFile = SD.open("log_file.txt", FILE_WRITE); //open file
    if (dataFile) { //is it there?
    dataFile.print("Current pin: ");
    dataFile.println(x + 1);
    dataFile.print("Raw: ");
    dataFile.print(DATA);
    dataFile.print("  Voltage: ");
    dataFile.print(Volt);
    dataFile.print("  Resistance: ");
    dataFile.print(Rest);
    dataFile.print("  Temperature: ");
    dataFile.print(Temp);
    dataFile.println("");
    dataFile.println("");
    dataFile.close();
    }
    delay(5000);
  }
}

Thanks for all the help, and I the process to be completed in 5 seconds.
email:
waterlubber@rocketmail.com

What is the range of thermistor values to be converted to a temperature ?
How many different thermistor values do you expect to deal with ?

I may deal with two, but the value should remain between 55F and 120F, I know how to convert Celsius to Fahrenheit. The code is just to measure some information on a SD card, and I don't care about space much. (I can run the thing from a 2GB microSD, what will 32KB do to that?!) Thanks for all the help! Also, I would like a 5/10 second interval between recordings. (Maybe 30 second), but the process needs to be completed quickly.

One simple way would be to declare and populate an array of temperature values that map to the raw analogRead results. Put it in progmem if you need to. The largest array you would need would be 1024, where you define the temperature for every possible value the ADC can provide. Since you have a known range of temperatures, you might be able to reduce that somewhat. Equally, you could provide a temperature for every two (or whatever) readings of the ADC to trade memory for granularity.

Edit: English

I don't care about space much.

You will if you are going to hold the lookup table in the Arduino memory, which is why I asked how many different thermistor values you expect to have to deal with.

you might try MultiMap which works quite well for non linear functions - Arduino Playground - MultiMap -

UKHeliBob:

I don't care about space much.

You will if you are going to hold the lookup table in the Arduino memory, which is why I asked how many different thermistor values you expect to have to deal with.

The code itself takes up 18KB, I have 32KB of data space. Thats 14,000 integers, if you catch my drift.
Thats probably incorrect, don't correct me, instead, how do I even use a table for this? I only need about 5 degree accuracy, so I probably need 50-75 different values. How would I have the arduino 'round' the number to the value I need? (I have made a program that calculates resistance) to something like 10,000 ohms from something like 10,004 ohms?
Thanks
waterlubber

Here's the basic idea:

long DATA = 0;
byte temps[]={1,2,3,6,7,9,10,15,21,27};
long NUM_TEMPS = sizeof temps/sizeof temps[0];

void setup() 
{
}

void loop() 
{
int temperature;
DATA = analogRead(0);
temperature=temps[DATA*NUM_TEMPS/1024L];
delay(5000);
}

... how do I even use a table for this? I only need about 5 degree accuracy, so I probably need 50-75 different values. How would I have the arduino 'round' the number to the value I need? (I have made a program that calculates resistance) to something like 10,000 ohms from something like 10,004 ohms?

I don't think #defines would suit your needs. Think of two arrays of intervals: one is for analog readings (ints), the other for the calculated values corresponding to those readings (floats). The maths should ensure that the function is monotonic, so the intervals are in a one-to-one correspondence.

If you have no "holes" each interval can be identified by its upper boundary. So, if the n-th interval is [10000-10010] the value in the n-th position of the array will be 10010.

Then you need a density function: if the intervals were equally spaced you would start your lookup from max-value / number of elements (for example, for analog readings from 0 to 1023 divided into 16 intervals, looking up the value 72 vould involve dividing this value by 64). A density function would assign a higher resolution to a certain portion of the interval space. Obviously, if the upper boundary of the interval is lower than your value you would move to the previous interval, and if it is higher you would mode to the next until you cross the boundary of the right one. Once you have found the right position in the source interval, you'll find the calculated value in the same position of the "parallel" one.