Jeff Mitchell

Achieving Noise-Free Temp Sensor Readings

Discussion created by Jeff Mitchell on Nov 6, 2014
Latest reply on Nov 7, 2014 by Pedro Augusto Panecatl Salas

Achieving stable, accurate, noise-free data using the on-chip ADC is a challenge in all but the least-demanding applications.


Freescale does a great job with app notes explaining how to use the ADC and achieve good results, and many more esoteric corner-case issues get addressed here in the forums.


However, despite many app notes and forum posts on the subject, I was unable to find a clear explanation of the behavior that I was observing when attempting to read the on-chip temp sensor. I was having difficulty getting stable readings from the sensor.


In my application I am using a Kinetis KL26, although I believe the results obtained can be generalized to most if not all Freescale temp sensor implementations.


Here is a plot of a software loop sampling the temp sensor:



Not bad at all. But the perfectionist in me thinks that I should be able to get readings stable to +/- 1 LSB.


Here is a plot of the same software loop sampling the temp sensor, but this time averaging the readings over 32 samples:



That's what I'm talk'n about! That's the kind of results I want for my application.


So now I want to optimize the sample-and-average loop. The Kinetis ADC can autonomously average up to 32 samples with no software intervention. Perfect! So I enable this the ADC averaging functionality and here is the result.



What Happened??? All I did was change from software averaging to hardware averaging. What could be causing this horrible, unusable data?


After much head scratching and research, I discovered AN1980 "Using the 56F83xx Temperature Sensor". I don't know if this temp sensor shares any commonality with the Kinetis family temp sensor, but I found section 4.2 "Temperature Sensor Output Impedance" very illuminating. It says that the temp sensor output is very high impedance, and if it is sampled at a high rate it is unable to properly drive the ADC input.


From the App Note:


"However, if the ADC is used to sample the node continuously and at a high-enough frequency, the temperature sensor output will see a low load impedance and this source of measurement error will re-manifest itself."


Whether this is the is the cause of the behavior in the Kinetis temp sensor I can't be certain, but my experimental results indicate that using ADC hardware averaging when sampling the temp sensor will provide worse, not better results than software averaging, and even worse results than no averaging at all!