-
Notifications
You must be signed in to change notification settings - Fork 50
CalibrationExampleDerivation
On the calibration page, I used several examples, containing several values that it might not be obvious how to find. This page is to explain how I found those numbers.
Note that these examples used simple values on purpose, to keep the math fairly simple; in practice, the numbers may be a bit more annoying to work with.
Also, the method used here (polynomial interpolation) might not always be very effective in practice, especially for higher-order polynomials, as it basically assumes perfect values both for measurement and reality - in practice, measurements for both sides may be noisy, and in those cases you may need to use other methods for good results.
Throughout this page, I'll use Tm
for measured temperature, and Tr
for real (or reference) temperature (probably as measured by a reference thermometer).
The symbols a, b and c refer to the factors in the polynomial Tr = a + b * Tm + c * Tm^2
, where ^ is exponentiation (so x^2 means xx, x^3 means xx*x, and so on) and the operator precedence is first ^ then * then + and finally =.
--
There were three examples used, one with a constant offset, one linear, and one curved.
The constant offset one is pretty obvious - simply measure the offset across the range, notice that it's the same all over, and use that offset.
This means that a is the offset, b is 1, and c is 0. Since b defaults to 1 and the rest to 0, you can give tempered just the offset value and skip the rest: -c 5
.
--
The linear one is fairly simple; to be honest I got this one by picking a and b and then calculating the Tr values at Tm = 0 and 100, but it can be done the other way around like this:
Say you've measured Tr at Tm = 0 and 100, and got Tr = 5 and 95 respectively.
Since you have two measurements, you have data for two unknowns (a and b), so you can use the first-order polynomial Tr = a + b * Tm
to find a and b by plugging in the values for Tr and Tm like this:
(eq 1) 5 = a + b * 0
(eq 2) 95 = a + b * 100
You can get a
very easily from (eq 1) by noticing that b * 0
is always 0, which makes it simplify to 5 = a
, which means that a is 5.
Then we plug a = 5 into (eq 2) and simplify it:
95 = 5 + b * 100
95 - 5 = b * 100 = 90
b = 90 / 100 = 0.9
This leaves us with a = 5 and b = 0.9, so that the option to tempered is -c 5:0.9
.
--
The curve example is similar to the linear one, just complicated slightly by having more information, leading to more unknowns, and thus more algebra.
Say you've measured Tr at Tm = 0, 50 and 100, and got Tr = 0, 60 and 100 respectively.
Since you have three measurements, you have data for three unknowns, so you can use the second-order polynomial Tr = a + b * Tm + c * Tm^2
to find a, b and c by plugging in the values for Tr and Tm like this:
(eq 1) 0 = a + b * 0 + c * 0^2
(eq 2) 60 = a + b * 50 + c * 50^2
(eq 3) 100 = a + b * 100 + c * 100^2
From (eq 1) we can easily see that a = 0, because b * 0 and c * 0 are always zero. Plug that into (eq 2) and (eq 3), and we get these equations:
(eq 4) 60 = 0 + b * 50 + c * 50 * 50
(eq 5) 100 = 0 + b * 100 + c * 100 * 100
Then we can simplify (eq 4) further like this:
60 = 0 + b * 50 + c * 50 * 50 = 50 * ( b + c * 50 )
60 / 50 = b + c * 50
6 / 5 - c * 50 = b
And plug that into (eq 5) and simplify further, like this:
100 = 0 + ( 6 / 5 - c * 50 ) * 100 + c * 100 * 100
100 = 100 * ( 6 / 5 - c * 50 + c * 100 )
100 / 100 = 6 / 5 - c * 50 + c * 100 = 6 / 5 + c * 50
1 - 6 / 5 = c * 50 = 5 / 5 - 6 / 5 = -1 / 5 = -0.2
c = -0.2 / 50 = -0.004
Then plug this result ( c = -0.004 ) into the simplified form of (eq 4) like this:
6 / 5 - (-0.004) * 50 = b = 1.4
Leaving us with the result a = 0, b = 1.4, c = -0.004 to plug in as an option to tempered, giving us -c 0:1.4:-0.004
.