Electronics > Beginners

Calibration - How to Mathematically

(1/9) > >>

jboard146:
I'm trying to wrap my head around the math around calibration tables, but don't know where to start. Google and ChatGPT aren't really a help probably due to my search/prompt.

For example if characterized a temperature sensor (it could be any sort of measured values). So i have a list of input and output values, but they are not linear. My real world example is measuring RF power which is a whole other rabbit hole so lets stick to a temperature sensor.

I'm assuming that when you have a calibration table you are trying to fit them into a linear line and not some polynomial function. Then code this into some sort of micro controller etc

I may be totally off here, but i think that is what i want to do.

I'm looking for a good reference book, video, web etc and/or what is this called in mathematics. A generic code example would also be great as well.

calzap:
Would be helpful if you post an example of a calibration table and gave more detail about what you want to calibrate.   The basic mathematical approach to finding a function to approximate tabular data is called curve fitting.   Choice of function to fit can be via doing a plot of the data and deciding what function to use based on the apparent trend.   Even better is if you know the underlying mechanism the data (i.e., table values) represent.  The mechanism may align with a particular function.  A straight line is often not satisfactory.

Mike

TimFox:
One common mathematical function to use in curve fitting is a polynomial, such as
y(x) = a0 + a1x + a2x2 + a3x3
where the as are the calibration constants.
This can work well to interpolate between the measured calibration values, but such a polynomial will always "turn around" outside the range used for the measured data, so it should not be used to extrapolate past that range.

brucehoult:

--- Quote from: jboard146 on February 29, 2024, 06:53:44 pm ---I'm assuming that when you have a calibration table you are trying to fit them into a linear line and not some polynomial function. Then code this into some sort of micro controller etc

--- End quote ---

Linear would be nice, for sure. Over a sufficiently small range any smooth function can be treated as linear.

But if you have to deal with a wide range of conditions and the physics aren't linear -- then you either accept inaccuracy, or you use a more complex function.

If you're lucky then quadratic or cubic might be close enough.  Piecewise cubic lets you match the slope as well as the value at both ends of each segment. But piecwise linear might be good enough.

You might want to approximate the inverse function rather than trying to solve the forward function.

Even a 16 MHz 8 bit AVR can do a lot of maths for each data point if if it only needs to do it 10 or 100 times a second. But these days the term "microcontroller" can include a 300 MHz 32 bit chip with hardware floating point.

Picuino:
You can learn about splines too.
https://en.m.wikipedia.org/wiki/Spline_(mathematics)