Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.


Log in or register to post/reply in the forum.

how to use a look-up table file?


kirving Aug 14, 2012 07:29 PM

We normally use the Steinhart-Hart equation for reading thermistors, but rather than derive the empirical coefficients from the sensor's resistance-temperature table I'm interested in using that table directly in the logger. Are there CRBasic instructions for this sort of thing? I've seen calFile() and fieldCal(), but am not sure if those are applicable.

A way to do this from scratch might be to store the sensor R-T data in a file in CPU: on the logger, read it into an array on startup, then do a lookup in the array, perhaps using a binary search to find the closest match for a given R value, or probably interpolating between the two nearest values.

I've seen some references to something like this in the forum archives, e.g., for river stage ratings, but did not see the code.

Thanks for any hints about implementing look-up tables.


aps Aug 15, 2012 10:03 AM

The derivation of the Steinhart-Hart equation is not empirical but usually done by solving the equation using three known calibration points. If you search on the internet you can find various spreadsheets or tools to do this for you. One is here:

http://www.capgo.com/Resources/Temperature/Thermistor/ThermistorCalc.html

Generally you will not get better results (only speed of operation) from a lookup table, especially as many of the published R vs T datasets published for thermistors, are often generated using the Steinhart-Hart equation!

If you do want to create a lookup table, the simplest way to do this is to embed the data in the program and to use the Data and Read commands, however you need to watch out for the line length limitation.

Alternatively you could create a separate text file you load on the logger and read the data in, parsing it into an real array using the FileOpen, FileRead and Splitstr commands, reading the data in a loop.


kirving Aug 16, 2012 05:44 PM

Very good points. Turns out I already have a python script to calculate the coefficients, based on a YSI spreadsheet calculator.

But also thanks for the hints on implementing a lookup table, which I'll leave for another time.

Log in or register to post/reply in the forum.