LUT – Maximum error of linear interpolation approximation

resolutionthermistor

I'm currently using an LUT (Look-Up Table) stored in a microcontroller, to read the temperature from an NTC sensor. I'd like to achieve a precision which is known, it doesn't matter if it is not so high.

The first step in which I'm stuck is to know well the error introduced by evaluating an interpolation of two values in a LUT.

What I thought: If the LUT have 1°C steps, the maximum error using the intermediate value as discriminant, is 0.5°C. And (what I thought) the only final solution to this is that I can print on a display the value interpolated (i.e. 24.8°C) instead of the LUT (i.e. 25°C), but both have 0.5°C of error. The case of 24.8 +- 0.5°C it doesn't seems so meaningful. Maybe 24.5°C could be a better solution.

The second thought is that interpolating using two points separated by 1°C, are bringing an error which can be smaller than 0.5°C, since it is related to the ratio of second derivative of the curve and a factor of 1/8 times the step of the function (here 1°C) (https://en.wikipedia.org/wiki/Linear_interpolation#Linear_interpolation_as_approximation). But I'm not sure at all of what I am reading: supposing that I have the Steinhart-Hart equation, I do not have the second order derivative. Am I right? Any suggestion? Is this analysis necessary to make a correct estiamtion of the error?

Best Answer

The curve is smooth and monotonic, hence the maximum error is 0.5 degrees C.

The derivative of the function will give you the slope, higher order derivatives are necessary to find the maximum error. You could fit a cubic spline (matching the slopes on either side of the area of interest) to the data points and evaluate the maximum error analytically, but frankly it would be a much better approach to simply evaluate at a much finer resolution than your desired accuracy, just as @Scott suggested in his comment

Suppose you don't care about anything finer than 0.1°. You can easily evaluate over the entire range to 0.01 or 0.001 degrees C on a PC in seconds. The maximum error in those calculations will be +/- 0.005 or +/-0.0005 degrees C respectively, since the curve is smooth and monotonic at any resolution.

Doing an simple brute-force exhaustive search will provide confidence on the maximum error. Unless your range is very narrow, or your ADC very fine resolution, you'll probably run into resolution errors with a typical thermistor long before you have unacceptable linearization errors.