38.2 Temperature Calculation
This section describes the steps involved in calculating the die
temperature, TMEAS:
- Obtain the ADC count value of the measured analog voltage: The analog output voltage, VMEAS, is converted to a digital count value by the Analog-to-Digital Converter (ADC) and is referred to as ADCMEAS.
- Obtain the Gain value from the DIA table. This parameter is TSLR1 for the low range setting or TSHR1 for the high range setting of the temperature indicator module. Refer to the DIA table in the “Memory Organization” chapter for more details.
- Obtain the Offset value from the DIA table. This parameter is TSLR3 for the low range setting or TSHR3 for the high range setting of the temperature indicator module. Refer to the DIA table in the “Memory Organization” chapter for more details.
The following equation provides an estimate for the die temperature based on the above parameters:
ADCMEAS = ADC reading at temperature being estimated
Gain = Gain value stored in the DIA table
Offset = Offset value stored in the DIA table
Note: It is recommended to take the average
of ten measurements of ADCMEAS to reduce noise and improve accuracy.
Temperature Calculation (C)
// offset is int16_t data type // gain is int16_t data type // ADC_MEAS is uint16_t data type // Temp_in_C is int24_t data type ADC_MEAS = ((ADRESH << 8) + ADRESL); // Store the ADC Result Temp_in_C = (int24_t)(ADC_MEAS) * gain; // Multiply the ADC Result by // Gain and store the result // in a signed variable Temp_in_C = Temp_in_C / 256; // Divide (ADC Result * Gain) by 256 Temp_in_C = Temp_in_C + offset; // Add (Offset) to the result Temp_in_C = Temp_in_C / 10; // Divide the result by 10 and store // the calculated temperature
Important: If the application requires more precise temperature measurement,
additional calibrations steps will be necessary. For these applications, two-point or
three-point calibration is recommended. For additional information on two-point
calibration method, refer to the following Microchip application note, available at the
corporate website (www.microchip.com):
- AN2798, “Using the PIC16F/PIC18F Ground Referenced Temperature Indicator Module”