Temperature sensors — piecewise linear function

Dear reader,

A0..A5 (slope), B0..B5 (y intercept) and T0..T4 (end of range) are the coefficients documented in chapter 6.26.

I've wondered how to interpret them exactly. Assuming that the function should be near-continuosly and guessing a bit around, I came to the equation 

corrected = measured_°C * 1024 / Ax + Bx / 32 ; Tx values also to be interpreted as °C.

From the beginning I've expected the Bx to be falling, if the Ax rise. But both, A and B, rise. Is there somewhere the exact documentation on that?

Kind regards, Jochen

Parents Reply Children
  • I was curious about this, so after some trial-and-error I think the answer is that the raw temperature measure (adc?) converts to a temperature like this:

    Temp_in_C = (raw - B[i] ) * A[i] / 32768;

    But since the peripheral reports Deg C in 0.25 increments

    Temp_in_C_x4 = (raw - B[i] ) * A[i] / 8192;

    Indeed the thresholds T[i] seem to be in Deg C, but this makes it a bit chicken and egg to know which set of coefficients to use, but it can be worked out.

    And yes, normally you wouldn't need to do this because the temperature peripheral applies this for you.  In fact we don't even get the raw value.

    ...Unless you put in 8192 for all the A coefs and 0 for the B.  Then you could theoretically get the raw values, if maybe you want to calibrate the temperature sensor yourself.

    Or you could multiply all the A coefs by 9/5 and from B subtract 4*32*A/8192 (or something like that!) to get Fahrenheit in quarter steps.

    Or instead multiply the A coefs by 10/4 to get DegC in tenths of a degree.

    All at your own risk, who knows what the bit width is they have on the multiplier.  The raw values look like signed 12 bits to me, and the A coefs you gave fit in 11 bits.

    Note: the inverse of the formula is : 

    raw = Temp_in_C * 32768 / A[i] + B[i];

    which is the formula that I found to produce a piecewise continuous curve of raw values versus Degrees C with your coefficients..  The row of coefficients used is the one with the smallest T[i] that is above the DegC being evaluated. 

    Also note: This is still just a guess.  It's just a believable formula that results in a "piecewise continuous" transfer function. 

Related