Electronics > Beginners

K Thermocouple conversion by polynomial conversion formula

<< < (2/2)

Vindhyachal.takniki:
The code is only for getting best mathematical accuracy & demonstration by using polynomial function.

Later i will shift code to look up table. But I want to try code on polynomial also, just to use & experiment



So wanted to know if the method used is correctly used or somewhere i have done any mistake like converting cold junction temperature to voltage or any other.



This is just for fun/hobby. Made a loop on arduinio Leonardo to see what is max time it take to convert with fixed cold junction temperature 0C & varying  thermocouple voltage from -5.891 to 54.886 with 0.01 step, all done in code only.

Max time to convert I get is 3776us even with this float intensive operation

Code is O3 optimized.

mikerj:
Are you using the usual thermocouple arrangement i.e. a single welded junction connected to a terminal block that forms the reference/cold junction?  If so then the cold junction temperature does not determine which set of coefficients you should be using, and the cold junction temperature wouldn't cover such a huge range (it will usually be close to ambient). 

The cold junction temperature will need to be measured using some kind of absolute temperature sensor (e.g. RTD, thermistor, bandgap) which is why I asked about the accuracy you expect from this.

ejeffrey:
I agree with a 10th order polynomial being useless and also suggest using float64 for any high order polynomial interpolation.

However there is one more thing about polynomial fitting.  You should rescale you x axis variable to be small, typically between -1 and +1 to make the most of your numerical precision.  The higher order fit the more important this is.  Remember, Tc^10 is Enormous when Tc =50 and you are adding that to the linear term.

Kleinstein:
The POW() function in the pure form is very inefficient and may add some numerical error. So it may be better to rewrite the way the polynomnals are calculated. An efficient way is calculating a polynominal is like
y = a_0 + x*(a_1 + x* (a_2 + ..... )).

The compiler may optimize this, but not sure.

There is rarely need for such high degree polynomials. TC are usually not that accurate anyway.

Dave:
Flash is cheap, you can just put the whole ITS-90 table in there and use it as a look-up table. The whole thing (with single-precision values) will take about 6,4kB flash. I've done exactly this in a multichannel thermometer that I've developed at work.

Doing high order polynomial approximation will be slow as wet wick on a microcontroller and you'll need to do conversions in both directions to calculate the hot junction temperature.

Navigation

[0] Message Index

[*] Previous page

There was an error while thanking
Thanking...
Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod