Freesteel Blog » In pursuit of a good temperature measurement

In pursuit of a good temperature measurement

Thursday, May 21st, 2015 at 10:33 pm Written by:

The question is: Is it be possible to measure the temperature of the air in a thermal from a hang-glider?

A really good fast responsive thermometer that isn’t degraded by noise is probably going to be useful.

I have been entertaining the unconventional notion that one ought to observe the character of the noise before attempting to filter it out — particularly if it appears that all the errors are on one side due to voltage drops as other sensor circuits take readings on their own independent schedules. (No I do not believe there is any way to synchronize every one of them simultaneously.)


So, as I did with the barometer, I created an electrically isolated circuit running off its own battery and Trinket ATTiny that communicates its data via an optocoupler in 6-bit triples that are received using a timed interrupt pin. Although I could reuse a lot of code, it still took ages to debug and get the circuitry right. The basics are the analog TMP36 and the 16 bit analog to digital converter which in theory gives a resolution of about 0.003degC.

Also, nobody else believes that running this system off its own separate power supply is right way to do it because “a voltage regulator will make everything smooth”.

Not so according to the MIC5255 data sheet which is the type chosen for the Trinket
Clearly, when there is a power surge into a device, the only way this information can be communicated to the regulator is via a change in the voltage (which the regulator quickly compensates once it begins delivering more power). Accordingly, that is the voltage variation that’s going to screw up your analog temperature voltage measurement if it occurs at the wrong time. Doesn’t matter if you put a capacitor there. The voltage still has to drop in order for the demand to be communicated. If there was a separate wire going to the voltage regulator from each device informing it when to deliver more power, then perhaps it could be logically possible to keep the power line perfectly stable. But there isn’t such a wire, so it isn’t.

Never fear. The bodging will commence once all other viable and ugly options have been exhausted.

Having isolated the circuit, I was able to produce a temperature graph like so:
The 3 horizontal lines are degreesC, and the sample rate is approx 10 times a second.

This is what happens when I breathed on the sensor, where you can see the exponential rise in temperature, followed by the exponential decay back to the room temperature.

Unfortunately that down-spike down every 7 or so readings offends me. What’s causing it?

The 16 bit ADC allows for all kinds of configurations.

While I’ve programmed the main Trinket microcontroller to take a reading about every 100milliseconds, the ADC has been programmed to continuously take readings at the rate of 128 samples per second. Could it be that there’s some sort of beat between these two frequencies wherein occasionally the read sample command, which draws some power, is issued at exactly the moment when a sample is taken?

My calculations were inconclusive. But I was able to change the wave form and error consistencies by varying the frequencies.

Here we get a kind of 6 reading oscilation:

I tried making the readings as fast as possible to see if there was a shape to the distortion, and got one with alternating highs and lows.

This one has an interesting saw-tooth pattern. Someone with some deep knowledge could probably come up with an immediate diagnosis from this. (No I don’t think it’s from any radio frequency interference!)

Here’s another one where it seems to enter and exit a phase lock.

I tried the single shot readings (non-continuous mode), but that didn’t give any joy.

I also tried putting the ADC frequency very high to make dozens of readings during the trinket cycle which would be averaged or maximized to remove the spikes, but that didn’t work either. (No idea why not.)

The only non-nasty-noise case was when I set the ADC frequency down to 8 samples-per-second, but continued to take readings at around 20 times a second, so that most of them were the same. In this case there were no spikes.

Setting it up to 16 samples-per-second and it’s back to tight zig-zags (plotted below for contrast).
I’ve also shown the barometric readings (in red) when I tested the system with a quick ride in the elevator.

I am satisfied that the barometric readings are giving me random noise on either side of the true value, so it’s at the limit of what can be done.

This temperature issue is closed for now, with a new ugly circuit glued onto the outside of the flight box into which it does not fit. What a mess.

As a side note, the barometric readings are quite jagged in flight, suggesting there’s some alternative influence on it aside from altitude.

Meantime, the barometer is used for the PALvario haptic actuators. I’ve printed out slightly smaller units (in red) as well as a new box that is better able to protect the cable connections when wedged in the harness.

Who knows? It might just not work!

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <blockquote cite=""> <code> <em> <strong>