0
\$\begingroup\$

I've built a fairly simple Temperature logging device on an Arduino Mega 2560 R3. I'm using TMP36's, 12 of them in total to log the data. Each sensors VS and GND pins are connected to common rails and each V_out pin is then connected directly to their own analog sensor pin on the Arduino.

The method for logging the temperatures is to record ten successive measurements on one sensor (pausing for 20ms between each measurement) then averaging those ten values, log that value to a data file, then move onto the next pin, repeating until all sensors have recorded a value. Then, wait until 10 seconds has passed and then repeat the process. (doesn't need to be faster since my experiment is hours to days long).

The first image (labeled Sensor 14) is the plot that i'm getting from one of the sensors attached to my heat source, which is about what I'm expecting (X-axis is seconds, Y axis is temperature in Celsius)

Sensor 14 temp log

On my last test I only needed to needed to log a few locations and I left the rest of the sensors sitting on the desk essentially measuring the ambient temperature, which I'm 90% sure should be constant. However, I logged the data from the sensors anyways and plotted them for giggles and got the following plot (same axes as first)

Sensor 3

This image has a pretty clear periodic temperature change, albeit a very small difference. The results I've gotten from this have no effect on my actual analysis, but the source for the periodic signal is what I'm curious about.

I'm no signals analyst, or electrical engineer, I'm wondering if seeing this type of periodic 'noise' indicative of some type of problem with my test rig or if this is fairly normal to see. (The sensor has a listed +- 2 degrees C accuracy with a 0.5 degree C linearity)

And as a second part to the question, would there be anything 'wrong' with removing this periodic signal from my temperature data? (running an fft on the noise signal, identifying the frequency and then using a bandstop filter to clear it out).

Many thanks for any advice!

(Edit 1)

I made a better plot in python and zoomed in on one section to show how the two signals look over a shorter period of time:

Short period sensor data

\$\endgroup\$
  • \$\begingroup\$ Looks like quantization noise. \$\endgroup\$ – Ignacio Vazquez-Abrams Jun 13 '18 at 17:59
  • \$\begingroup\$ How do you know that the sensor isn't responding correctly to thermal variations in its environment? Can't you just average over several hundred samples? \$\endgroup\$ – Elliot Alderson Jun 13 '18 at 18:06
  • \$\begingroup\$ I"m reasonably sure the room didn't fluctuate during the test, HVAC system was off, but it for sure is a possibility. I ruled it out just because the fluctuation seems to be so consistently periodic \$\endgroup\$ – Diesel Jun 13 '18 at 18:26
  • \$\begingroup\$ how will 50Hz power line noise enter into this? \$\endgroup\$ – analogsystemsrf Jun 18 '18 at 5:01
2
\$\begingroup\$

If you zoom in on the top graph you'll see about the same thing going on (look at the width of the line).

This is a problem with having the graphs auto-scale, you will eventually see something, either quantization noise as @Ignaciao suspects (most likely correct) or maybe some mains hum aliased into your sample bandwidth (which would look a bit different).

If your data acquisition system is using the internal ADC in the 2560, the resolution is only 10 bits. Simple averaging over many samples (which appears to be going on here) can appear to give more resolution but without proper dithering and proper filtering it won't work that well.

Keep in mind that without a preamplifier and using the ADC reference as the supply your ADC resolution is about 0.5°C (the accuracy and linearity are worse). Resolution is 4.9mV and TMP36 output is 10mV/°C.

You may note that it's bouncing back and forth by just about exactly 0.5°C, this is not a coincidence. The intermediate values are evidence of averaging, the fact it's not moving smoothly between states is because signal processing and dithering is inadequate.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ I added an image that's a little better quality and zoomed in on the data. After reading the wikipedia entry on quantization I think that makes a lot of sense. Does the additional plot support that conclusion still? The periodic seems less pronounced in this one \$\endgroup\$ – Diesel Jun 13 '18 at 18:45
  • \$\begingroup\$ The "period" is probably the room temperature changing and sliding through the various codes. The faster the sensor temperature change, the shorter the period. Make sense? In your room temperature chart the temperature is slowly increasing (real) and you are getting a bunch of noise because the ADC is crap (not real). \$\endgroup\$ – Spehro Pefhany Jun 13 '18 at 19:02
  • \$\begingroup\$ AH!! Gothca, That 0.5 bounce wasn't lost on me, I just couldn't wrap my head around the why. This makes a lot more sense now. I wasn't too concerned about the change in the range since it's so small relative to what I'm looking to analyze. I think I've got a bit of a handle now on quantization noise. I'll look into both a better ADC, and re-think my filtering (averaging). I'll try removing the averaging script, increase the record rate, and then try filtering the data after the experiment. Thanks a ton! \$\endgroup\$ – Diesel Jun 13 '18 at 20:01
3
\$\begingroup\$

A bit of speculation:

If you look at figure 5 in the data sheet for the TMP36 you can see that load regulation is broadly 0.006 degrees per micro amp drawn: -

enter image description here

If during the ADC process the current peak is (say) 1 mA (certainly not unheard of) then you will get an error of 6 degrees.

So, if your ADC is a multiplexed and unbuffered type that draws a spike of current during conversion then you'll get odd results. If you applied the maximum capacitance of 10 nF across the sensors output to ground you may well see this error fall dramatically.

| improve this answer | |
\$\endgroup\$
0
\$\begingroup\$

Here's my guess for what you're seeing: The sensors only have a resolution 0.5c So they can put out the values 19.8, 20.3, and 20.8. Which can all be clearly seen in your graph. Now what about all those points on the slopes that are not one of the 3 values? I think those are occurring when the sensor changes during your 10 read average.

So the question remains. Is the room actually fluctuating back and forth by half a degree as the graph seems to indicate? It's hard to say. I think the only conclusion that you can come to based on this data is that you need more resolution if you care about 0.5c changes. I can say from experience that a fluctuation of 1-2 counts in the sensor reading is "normal"

Edit: I don't know who downvoted me. But here's more proof: The TMP36 has a scaling factor of of 10mV/degC. The arduino has 1024 counts of resolution, and assuming a vRef of 5v that gives 0.48degC per count. Almost exactly what I predicted. I said "sensor" in abstract, but what I should have said is that the system has a resolution of 0.5c.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ I didn't downvote you, but the sensors are analog and don't have a resolution per se. From Figure 21. Voltage Noise Spectral Density vs. Frequency, at a 20Hz BW, the noise spectral density of 1000nV/sqrt(Hz) is about 4.5uV RMS, which corresponds to 0.45mK, or perhaps 3mK peak-to-peak, more than 1000 times better than that. \$\endgroup\$ – Spehro Pefhany Jun 13 '18 at 19:20
  • \$\begingroup\$ Sure, but it's being digitized by the arduino. And as you said yourself the arduino only has a 10bit adc. The TMP36 has a scaling factor of 10mV/degC. Assuming the arduino is using a Vref of 5v, 5v/1024 = 4.8mV per count, which would correspond to .... 0.48 degC per count. \$\endgroup\$ – Drew Jun 13 '18 at 20:26
  • 1
    \$\begingroup\$ I agree with Drew but I think’s better to terminate the sensors with a cap to 20Hz with cable and source impedance like a snubber but not with a microphonic ceramic cap. 10 samples only reduces std Dev. by sq.rt(10) whereas long UTP or better STP cables act as antenna noise to stray fields and a carefully placed cap to analog ground can reduce noise far more \$\endgroup\$ – Tony Stewart Sunnyskyguy EE75 Jun 14 '18 at 20:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.