Mehmet Fide

LC60: Again On-Chip Temperature Calibration

Discussion created by Mehmet Fide on Mar 27, 2008
Latest reply on Jan 6, 2012 by Darius Styra
Hi,
 
I want to calibrate internal temperature sensor at single point by using floating-point math.
 
Temperature(in C) = 25.0 - ((Vtemp - Vtemp_offset) / m);
 
According to the formula above, I'm recalculating Vtemp_offset value at a known temperature(not always 25C) by using default hot or cold slope values. To do this, I'm calling CalcTempOffset function below with a accurately measured ambient temperature value. After calculating Vtemp_offset value at calibration state, I'm always using this calculated value and default slope values to measure actual temperature with ReadInternalTemperature function bottom.
 
 
Code:
unsigned char CalcTempOffset(signed char temperature){  unsigned int adc_temp, adc_ref;  signed int off;  double Vtemp, m;   DisableInterrupts;    SPMSC1_BGBE = 1; // Bandgap buffer enable.    adc_temp = ReadADCChannel12(26); // Vtemperature     adc_ref = ReadADCChannel12(27);  // Vref = 1.2V      SPMSC1_BGBE = 0; // Bandgap buffer disabled.  EnableInterrupts;    Vtemp = (double)adc_temp*12000/adc_ref; //read temperature sensor voltage    m = 17.075;  if(temperature > 25) m = 17.69;        // hot slope   else if(temperature < 25) m = 16.46;  // cold slope      Vtemp_offset = (Vtemp + (m*(temperature-25)) + 0.5);}

 
Code:
void ReadInternalTemperature(signed char* temperature){  unsigned int adc_temp, adc_ref;  double Vtemp, m;    *temperature = 25; // default value  if(!CheckTempOffsetValid()) return;   DisableInterrupts;    SPMSC1_BGBE = 1; // Bandgap buffer enable.      adc_temp = ReadADCChannel12(26); // Vtemperature     adc_ref = ReadADCChannel12(27);  // Vref = 1.2V      SPMSC1_BGBE = 0; // Bandgap buffer disabled.  EnableInterrupts;    Vtemp = (double)adc_temp*12000/adc_ref;    m = 17.075;  if(Vtemp > Vtemp_offset) m = 16.46;  // cold slope   else if(Vtemp < Vtemp_offset) m = 17.69; // hot slope *temperature = (double)25.0 - ((Vtemp - Vtemp_offset)/m) + 0.5; }

 
The MCU is powered via battery, so the Vdd can vary (1.8V-3.5V) after my calibration.
For example, when ambient temperature is 19 C degree, Vdd is 3.2V, I'm calibrating the MCU by calling CalcTempOffset(19) to determine Vtemp_offset value. After determining this value once, I'm always using ReadInternalTemperature function to measure actual temperature at different Vdd.
I just expect 5 C degree accuracy over VDD and -40 / +85C. But the functions above can't qualify for this.
Do you have a better solution for single point calibration?
Do you think my implementation is applicable?
The datasheet says that 4.5Cdegree error is possible with single point calibration, but I couldn't realize it.
 
10x,
BP.


Message Edited by BasePointer on 2008-03-27 03:33 PM

Outcomes