From: Bob on
Albert van der Horst wrote:
> In article <hPCdndCdvZmC9CbWnZ2dnUVZ_qednZ2d(a)giganews.com>,
> Bob <SkiBoyBob(a)excite.com> wrote:
>> PeteG wrote:
> <SNIP>
>>> (2) The TI part is 16bit with a 12bit ADC. Good enough for the tc input.
>> If a 12bit on-uP ADC is good enough, then you certainly don't need
>> floating point. But without accuracy and data rate specs, it's
>> impossible to say what you might really need.
>>
>> Integer math cubic splines have worked for me in a variety of
>> approximations. Results to 16 bit or better are usually available with a
>> couple of k of look-up table + code space, a handful of 16x16
>> multiplies, and a few 16 bit adds. There's always a trade-off between
>> table size and execution time. You could view the NIST polynomials as
>> the smallest table (coefficients only - not including the FP lib you'll
>> need) and the longest execution time.
>
> Then there is the classical table interpolation technique.
> As platinum resistors are linear plus slight deviation I guesstimate

The OP is about thermocouples, but the problem is similar.

> a 32 entry table of 16-bit values and 4 point interpolation
> to nearest points would do the job. Easy enough to increase
> to required precision.

Cubic splines *are* 4 point interpolations. The trick to making it fast
is to re-sample the table, and pre-calculate and pre-scale the
differences so that the run-time math is simple:

extract table index by masking and right-shift
extract remainder by masking
y = C[i] * r;
y >>= S1;
y += B[i];
y *= r;
y >>= S2;
y += A[i];

B[], and C[] are scaled to compensate for S1 and S2 (improves accuracy
in the higher terms). I usually do some easy error calculations on a
spreadsheet before writing a desktop test wrapper for the approximation
code. See Jack Crenshaw's "Math Toolkit for Real-time Programming" for
the calculus behind it and details about how to get B[] and C[] (and
higher orders, if necessary). Or pull out your ESP archives where he
wrote about it more than once.

> Floating point is good if you have no time or inclination to
> go beyond copying the text book formula's.
I very much agree.
Bob