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

  • PS: the decimal values of Ax, Bx and Tx as taken from the documentation:

    # a0= 806 [0x00000326] b0=-17 [0xffffffef] t0=-30 [0xffffffe2]
    # a1= 840 [0x00000348] b1=-66 [0xffffffbe] t1=  0 [0x00000000]
    # a2= 938 [0x000003aa] b2=-66 [0xffffffbe] t2= 25 [0x00000019]
    # a3=1038 [0x0000040e] b3= 18 [0x00000012] t3= 60 [0x0000003c]
    # a4=1213 [0x000004bd] b4=292 [0x00000124] t4= 80 [0x00000050]

  • Hi

    What temperature sensor is this? I think this question is better suited to the temperature sensor manufacturers instead of us, as we don't have intricate knowledge of every type of sensor on the market.

    Best regards,

    Simon

  • The internal temperature sensor of the nRF52833. Perhaps I should have repeated this in my post — it is in the labels on the right side, too.

  • Hi

    Ok, I don't think you need to use this equation to use the internal temperature sensor, please check out the temperature peripheral example we have that shows how to use the internal temperature sensor. I don't think it's necessary to implement this equation at all.

    Best regards,

    Simon

  • 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