# Thermistor Look Up Table

## Recommended Posts

Hello

I have 10, 49.12k thermistors that I need to get the temperature from.

I am having no luck using the Steinhart equation, can't even get it to work in Excell. So I'm thinking a look up table.

I have the resistance values from the manufacturer, for example, at 20 deg C, min R = 60.57k, std R = 64.34k and max R = 62.36k.

I only need to span from 10 to 30 deg C.

So once I get the analog voltage in, convert to resistance how would I match that to a look up table?

I haven't played with arrays yet so I'm a total noob here.

Any help is always welcomed.

Thanks

RJ

##### Share on other sites

OK, this is actually a non-standard lookup table because the thing you are looking up (resistance) is not linear. However, the setup is the same:

First, create a variable array with the lookup values starting with 10 and going to 30. Lets say you have it in 0.1 degree increments, so you'd have 200 values. I'll just show a few:

`global therm49k = {23.43, 24.83, 25.92, ... }`

If you actually have 200 values, it might be easier to write it as:

```global therm49k
therm49k = {23.43, 22.83, 21.92, ... }
therm49k = {14.29, ...}
etc.```

doing 10 values in each.

If this was a forward lookup table (meaning you were looking up the resistance for a given temperature, once you have that, you would just need to take your input value and scale it so its a number between 0 and, in my example, 200, where 0 = 10 deg C and 200 = 30 deg C. To do this, take the reading, subtract 10 (the zero point), then divide the result by 20 (the total range). Finally do floor() on the whole result. That is the index into the array, so to get the resistance:

`therm49k[floor((tempReading - 10) / 20)]`

However, you have a backward lookup table, meaning instead of being able to use the array index, you have to actually search the array for the appropriate value, then get the index and calculate the temp from it. Fortunately, this isn't much harder, but kind of requires multiple lines of script, so is best put in a sequence function. I'll assume resistance is going down as temperature goes up and thus the values go down as you go through the array:

```function therm(resistanceReading)
private index = search(therm49k &lt; resistanceReading)
if (index == -1)
index = numrows(therm49k) - 1
endif
return(index / numrows(therm49k) * 20 + 10)```

So, the first line simply creates a sequence function that you can call using therm(23.48) and will return the temperature. The second line searches the therm49k array for the first value that is less than the resistance reading. We can't use == because it will never be exactly equal to the value in the lookup table. The next three lines look to see if the value is found, and if not, it uses the last value in the table. The last line returns the index scaled for temperature assuming the first value in the array corresponds to 10 degrees and the last corresponds to 30. The "20" again is the range (30-10).

##### Share on other sites

Whoa!

I actually understand what you are doing in your example.

Thanks, until I hit the next brick wall.

RJ