News:

PROTON pic BASIC Compilers for PIC, PIC24, dsPIC33

Main Menu

Calibration over several points

Started by TimB, Dec 30, 2021, 09:41 AM

Previous topic - Next topic

TimB

Hi all

I'm looking to improve my calibration routines. Currently I use zero and span using floats.
Zero is the off set so will be say -0.0097
Span is the multiplier say 1.0096

But I want multi point. The options as I see it is a formula like a polynomial to apply to the figure.

Or to make on the fly calculation based on interpolating the span at each point.

For instance span at 0 would be 1.0
Span at 100 might be 1.009
Span at 150 might be 1.0093
Span at 200 might be 1.0078

Knowing my temp and then interpolating the span between the recorded points I can apply it.

However that will lead to a zigzag straight line. Is there another way to do it where a bezier curve is generated.

Maths is not my strong point..

Any help appreciated.

Tim

charliecoutas

I don't know if this might help Tim, but I've just discovered, with help from you guys, that Excel (and others) can generate the formula for a curve automatically. Get Excel to plot the curve you want then click the + sign over the top left corner of the plot. You want Trendline, select which option suits. There are people far better qualified in this forum to help further...

Charlie

JonW

I am looking at the same Tim for Calibration of RF kit and multipoint zero and span has many advantages if the calibration is highly non linear and you can live with the error.  Here is a link to a site that has heap of good information/advantages/disadvantages of calibration methods

Calibration Techniques

Click the top left Calibration to get the full article

TimB

Thanks.

The link to that article seems very handy.

I will need to read and digest ..


Tim

John Drew

#4
Hi Tim,
Using the polynomial approach can be a simple solution. Complex curves can be calculated but it's more likely you will need to go to third or even fourth order for the trend line to match. This can mean accuracy  problems for 32 bit variables and also slow down the calculations.

I've also used your segmenting approach using a table and then calculating the offset between two table values. Can be quite a reasonable approach. Works a bit faster than the polynomial approach but steps are not as smooth. Depends on how many points in your table.

32 bits is the limiting factor which is why a 16 bit PIC with 64 bit maths is much better with polynomials.
John

TimB

Thanks John


In reality the digressions from the initially calculated will be small. For example

At 0.0oc a meter will read 0.0
At 250oc a meter will read 250.0
But at 150 the meter might read 149.8

So probably just interpolating will be fine. If the readings are further out then I probably need to resolve the issues at a deeper level.

I might look at some of the other options still though.

Tim

david

Quote from: charliecoutas on Dec 30, 2021, 10:18 AMI don't know if this might help Tim, but I've just discovered, with help from you guys, that Excel (and others) can generate the formula for a curve automatically. Get Excel to plot the curve you want then click the + sign over the top left corner of the plot. You want Trendline, select which option suits. There are people far better qualified in this forum to help further...

Charlie

Hi Charlie and All,
Note that the built-in curve fit function in Excel only goes to 6th order which for many applications is more than adequate but I recently tried to do a battery discharge curve and a 6th order fit still gave large errors.  To go beyond this limit take a look at the LINEST function in Excel.  I ended up with an 8th order polynomial but I don't know what the top limit is.  The LINEST function is also very fast compared to the built-in option but you will only be aware of this at high orders.
I only learned this a few weeks back after putting out a plea for help to an old friend.

Cheers,
David