This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Tiva EK-TM4C129XL temperature sensor ADC wrong values

Other Parts Discussed in Thread: TM4C123GH6PM, TM4C1294KCPDT, EK-TM4C1294XL

I am running the code found in TivaWare\examples\peripherals\adc\temperature.sensor.c with appropriate modifications for e.g. clock configuration and using the conversion formula from the datasheet:

TEMP = 147.5 - ((75 * (VREFP - VREFN) × ADCCODE) / 4096)

Which translates into:

ui32TempValueC = ( (1475 * 4096) - (2250 * pui32ADC0Value[0]) ) / 40960;

Which is different from the Stellaris, where it was 10 bit ADC instead of 12, so a factor of 1024 instead of 4096.

The result I get is between 42-46.Maybe I am wrongly assuming that Vrefp - Vrefn is 3 as it was on the Stellaris?

Please advise.

  • Hello Dennis,

    Are you using the Internal or External Voltage Reference. if it is internal then it would be the same as VDDA supply (which I think would be 3.3V)

    What is the ADCCODE you are getting for the temp conversion?

    Regards

    Amit

  • Changing 3 into 3.6 gives the values I'd expect: 23-26C.

    The ADCCODE values I am getting are mostly about 1840-1870

    As for what voltage reference I am using, I know so little about ADC design that I can't answer your question. All I can say is that I'm working on an out of the box evaluation board.

  • Hello Dennis

    A word of caution: Changing the voltage value is not the right step, even if it gives you the correct value. For an out of box evaluation board you can use the IDE to check the register ADCCTL (offset 0x38) of the ADC module to see if the bit-0 is set or clear.

    Secondly, measure the VDDA pin if it is clear or VREFP:VREFN pin if it is set to get the voltage values

    Lastly, the measurement is of the on-die temperature and this may be higher than the ambient temperature.

    Regards

    Amit

  • I can see the bit is cleared. Incoming voltage is indeed around 3.3. Using that value in the formula gives 34-36C even on a cold board, which seems too high.

  • Hello Dennis,

    Even though the board is cold, it does not mean the device is cold. A device is packaged and the die which is the actual chip inside the package may be warmer than the room.

    To ensure the correctness of reading we have tested the Temp Sense for accuracy by forcing cold air for 30 minutes before making readings.

    Regards

    Amit

  • Thanks, Amit.


    I will leave it without power for the weekend and see what I get next week.

  • Well, a dead cold board still shows 34-36C a few seconds after power-up. I guess I'll just assume it's very uncalibrated.

  • Dennis Begun said:
    still shows 34-36C a few seconds after power-up

    Hi Dennis, internal sensor measure the temperature die, so which temperature are you measuring the first few millisecond is powered up?

     After few second temperature can be the one at steady condition, can you do Hybernate then store a temperature at wake up?

     Temperature must be referred to a reference than power supply but a so large variation can be due to error on measurement, remember all the resistance between case and die then blow a cold air over the chip measure the surface temperature and internal, blow a warm air and do the same, use the thermal resistance and see if internal temperature is the one you can have at drawn power.

    MSP430 at very low cpu duty cycle caan be used to measure air temperature, this one is not a very low power processor so die temperature is forever higher than case.

  • Dennis Begun said:

    for e.g. clock configuration and using the conversion formula from the datasheet:

    TEMP = 147.5 - ((75 * (VREFP - VREFN) × ADCCODE) / 4096)

     Hi Dennis, from where you read that equation?

     Which device are you using?

     For example from datasheet of tm4c123gh6pm page 812:

    V TSENS = 2.7 - ((TEMP + 55) / 75)

    on page 813 there is a graph with relation between voltage and temperature and the formula:

    TEMP = 147.5 - ((75 * (VREFP - VREFN) × ADC CODE ) / 4096)

    but your assertion why assume 2250 stating vref = 3.0V and not Vref*75? where are connected reference sense?

    Dennis Begun said:

    Which translates into:

    ui32TempValueC = ( (1475 * 4096) - (2250 * pui32ADC0Value[0]) ) / 40960;

    For sure temperature sensor code from Tivaware is wrong:

     
            //
            // Use non-calibrated conversion provided in the data sheet.  Make
            // sure you divide last to avoid dropout.
            //
            ui32TempValueC = ((1475 * 1023) - (2250 * pui32ADC0Value[0])) / 10230;
     
            //

    4096, 75*vref 40960

     Your Vref P and N are VCC and GND?

  • Hello Dennis

    The ADC temp sense limits are +/-5C as mentioned in the data sheet's electrical section. As Roberto and myself have mentioned, the on-die temp can be higher than the ambient temperature.

    Regards

    Amit

  • Amit Ashara said:
    The ADC temp sense limits are +/-5C as mentioned in the data sheet's electrical section. As Roberto and myself have mentioned, the on-die temp can be higher than the ambient temperature.

     Amit this is true but please forward error on tivaware code.

     About problem we don't know ambient temperature nor board temp nor processor and total power drawn by processor.

  • Hello Roberto,

    I would need to test this code under a temp chamber to see if the equation is something different from the data sheet or not...

    Second aspect will correct it self once we get the temp chamber testing done.

    Regards

    Amit

  • Amit Ashara said:
    I would need to test this code under a temp chamber to see if the equation is something different from the data sheet or not...

     Hi Amit, I wish pinpoint another problem...

     Starting from Temp sensor:

    V TSENS = 2.7 - ((TEMP + 55) / 75)

    then (Vsens-2.7)*75 = -(Temp+55) change signs:

      202.5 - 75*Vsens = Temp + 55

      202.5 - 55 -75*Vsens = Temp

     so Temp = 147.5 -75*Vsens

     From this point just math is applied but not correct ADC behaviour:

     if ADC span from VrefN to VrefP then zero is at VrefN so ADC range is from N to P

     Vsens -> Vadc so

     Vadc = VrefN + (VrefP-VrefN)*ADC_Code/FullScaleCode

     Again if VrefN is 0 then Vadc simply equaet to

     Vadc = VrefP*ADC_Code/Full scale -> VrefP*ADC_Code/4096

     SO my question why <VrefN> is included in the Vsensor formulae range but not the translation term of range? This can be inaccurate in the case of non zero negative reference.

      If all is correctly evaluated then we can simply calculate the power drawn by uC then read case temperature with a FLIR or a simple non contact thermometer and evaluate die temp from reversing thermal model of chip. At this point which chip is using our poster??

  • If "our poster" is me, then he is using EK-TM4C129XL and the chip is TM4C129KCPDT.

    You asked earlier where the formula I was using was from. It is from the Tiva™ TM4C1294KCPDT Microcontroller data sheet, June 18 2014, page 1066.

  • Hello Roberto,

    I would disagree on the second part of the equation where the Temp is replaced bu the Vsense in the main equation. The VrefN comes into picture when using an external Voltage reference in a manner that there is a non-0 voltage applied to the pad.

    If the source is an internal source then VrefN will be 0 but not the case when an external VrefN is applied.

    Regards

    Amit

  • Hello Roberto, Dennis,

    The mystery of the equation is resolved. it comes from the examples/peripheral part of TivaWare and is not necessarily tied to a particular device, The equation makes sense if the VDDA or VREFP-VREFN = 3.0V but is not correct if the VDDA=3.3V or VREFP-VREFN=3.3V

    Regards

    Amit

  • Dennis Begun said:

    If "our poster" is me, then he is using EK-TM4C129XL and the chip is TM4C129KCPDT.

     Hi Dennis, in first thank for details, I suppose EK-TM4C1294XL but this one was fitted with 1294NCPDT 1M flash 256K ram, KCPDT has 512K flash and 256Kram, is this original or custom mounted on launchpad?

     I am sorry but I just own experimental silicon XM4C1294NCPDT, your code has to be tested on current silicon.

     Just ot complete data please post also silicon date and version, better a picture of chip.

  •      Hi, I 've dificult to work with analogic input...... can someone  send me a exemplo a analogic imput.....may board is a TM4c129XL....I'm using a potenciometro to change the volts ...my email is jefrysp@gmail.com....

         Thank you.......

  • Hello Jefferson,

    Your post is already answered with the correct redirection.

    e2e.ti.com/.../434720

    Regards
    Amit