Achieving high accuracy across temperature with traditional negative temperature coefficient (NTC) thermistors requires calibration at at least three different temperatures due to the non-linearity of NTCs across temperature. The TMP6x family of linear thermistors makes achieving high accuracy across temperature much more simple and cost effective. With the TMP6x thermistors, a single-point offset calibration can be performed at any temperature due to their linearity across temperature. Implementing oversampling and software filtering help eliminate noise from sensor readings and make it easier to see where the sensor truly is with respect to temperature. These methods can result in ±1°C accuracy or better across temperature with the TMP6x.
This document familiarizes the user with the steps needed to achieve high accuracy with the TMP6x thermistors. The document includes descriptions of a single-point offset correction, software methods of oversampling and filtering, as well as pseudocode for each to assist with evaluation and implementation.
All trademarks are the property of their respective owners.
High accuracy and precision temperature measurements can be easily achieved at low cost with TMP6x linear thermistors using the steps outlined in this application note. As an example, the data in Figure 1-1 shows the average error across temperature for one unit after implementing the methods explained here. The steps to achieve high accuracy with the TMP6x are:
Figure 1-1 shows the impact of a single-point offset, 32 × oversampling and software filtering with 0.1 alpha on accuracy and precision of one unit across temperature.
The following sections provide brief descriptions of each individual step, as well as pseudocode to begin evaluating quickly.
The TMP6x thermistors are unique in that these thermistors have a fairly consistent error across temperature as compared to traditional negative temperature coefficient (NTC) thermistors, as shown in Figure 2-1. As a result, an offset correction can be performed at any temperature to remove tolerance errors from the TMP6x and other components in the thermistor biasing circuit, such as VCC, VRef, ADC LSB, and RBias errors. The errors remaining after the offset are the parts per million (ppm) errors of each component across temperature. Using low-ppm components in your system helps mitigate the impact of these remaining errors on temperature measurements.
To determine the offset for each TMP6x thermistor, a highly-accurate temperature reference is needed, such as the TMP117, an I2C temperature sensor with ±1°C max accuracy from –20°C to 50°C. Use software filtering during the offset calculation to determine a consistent and accurate offset. In the following pseudocode, 5,000 ADC samples of the voltage across the TMP6x are rapidly taken, and a software filter with an alpha of 0.001 is used to eliminate noise from the offset value. The final filtered voltage is converted to a temperature measurement using the 4th order polynomial from the Thermistor Design Tool. Finally, the offset is calculated as the difference between the TMP6x filtered temperature and the reference temperature, and that value is can be stored and applied to all future temperature measurements for that TMP6x thermistor.
int sensorPin = ; // EDIT indicate pin # for analog input to read VTEMP from TMP6
float Vbias = ; // EDIT indicate bias voltage
int ADC_bits = ; // EDIT indicate number of bits of resolution for ADC
int ADC_resolution = powf(2, ADC_bits) - 1; // number of ADC steps
int rawADC; // variable for measured ADC value
float VTEMP; // variable for measured voltage
float VTEMPfiltered; // variable for filtered voltage
float alpha = 0.001; // recommend using strong alpha value to get most robust temperature reading
int samples = 5000; // recommend at least 5,000 samples to give software filter time to stabilize before calculating offset
float offset; // variable to store offset value
float TMP6filtered; // variable to hold the filtered temperature measurement
float referenceTemp; // temperature measurement from high-accuracy temperature reference (ex. TMP117)
/* EDIT 4th order polynomial coefficients from Thermistor Design Tool */
float THRM_A0 = ;
float THRM_A1 = ;
float THRM_A2 = ;
float THRM_A3 = ;
float THRM_A4 = ;
/* in SETUP code */
rawADC = analogRead(sensorPin);
VTEMPfiltered = Vbias / ADC_resolution * rawADC; // initialize the VTEMPfiltered variable to the first measured value to reduce ramp time
/* in MAIN code */
for(int i=0; i<samples; i++){
rawADC = analogread(sensorPin);
VTEMP = Vbias / ADC_resolution * rawADC;
VTEMPfiltered = VTEMPfiltered - (alpha * (VTEMPfiltered - VTEMP)); // continually filter VTEMP over 5,000 samples
}
TMP6filtered = (THRM_A4 * powf(VTEMPfiltered, 4)) + (THRM_A3 * powf(VTEMPfiltered, 3)) + (THRM_A2 * powf(VTEMPfiltered, 2)) + THRM_A1 * VTEMPfiltered + THRM_A0
referenceTemp = ; // EDIT insert code to read reference temp here
offset = TMP6filtered - referenceTemp; // calculate offset as difference between TMP6filtered and referenceTemp
Oversampling is one software method used to reduce the impact of noise. Simply put, oversampling indicates that rather than each individual sample resulting in a temperature measurement, N samples are accumulated and averaged, resulting in one averaged temperature measurement. This process reduces noise according to the number of oversamples, as shown by the difference between the raw and oversampled signals in Figure 3-1.
The following pseudocode provides an example implementation of oversampling, which allows modification of the number of oversamples.
int sensorPin = ; // EDIT indicate pin # for analog input to read VTEMP from TMP6
float Vbias = ; // EDIT indicate Vref voltage for ADC
int ADC_bits = ; // EDIT number of bits of resolution for ADC
int ADC_resolution = pow(2, ADC_bits) - 1; // number of ADC steps
int rawADC; // variable for measured ADC value
float VTEMP; // variable for measured ADC voltage
float VTEMP_averaged; // variable for averaged ADC voltage
int oversamples = ; // EDIT number of oversamples
float TMP6oversampled; // variable for oversampled temperature reading
/* EDIT 4th order polynomial coefficients from Thermistor Design Tool */
float THRM_A0 = ;
float THRM_A1 = ;
float THRM_A2 = ;
float THRM_A3 = ;
float THRM_A4 = ;
for(int i = 0; i < oversamples; i++){
rawADC = analogRead(sensorPin); // read ADC value
VTEMP += Vbias / ADC_resolution * rawADC; // convert to voltage and sum for desired number of oversamples
}
VTEMP_averaged = VTEMP / oversamples; // average the summed VTEMP
// convert voltage to temperature
TMP6oversampled = (THRM_A4 * powf(VTEMP_averaged, 4)) + (THRM_A3 * powf(VTEMP_averaged, 3)) + (THRM_A2 * powf(VTEMP_averaged, 2)) + (THRM_A1 * powf(VTEMP_averaged, 1)) + THRM_A0;
VTEMP = 0; // reset VTEMP to 0 for next sample to be taken