Governance by those who do the work.

Friday, April 10, 2015

Temperature Sensor Calibration

Having gotten the digital-to-analog and analog-to-digital conversions working while connected to each other, I plugged the STM32F3DISCOVERY board into my apparatus and started to debug the program to do analog-to-digital conversions of the LM35CZ temperature sensors. The initial readings were quite noisy; I traced this back to power supply noise caused by current fluctuations from the STM32F3DISCOVERY LEDs being switched on and off. I changed the program to keep the LEDs off during conversions and improved the power supply conditioning. The STM32F3DISCOVERY board consumes about 90.mA while running.

I found that the plate heater was slightly heating even though my program had the DAC controlling it set to 0. It turns out that when its output buffer is enabled, the STM32F303VCTx isn't specified to drive that output below 0.2V. Disabling the buffer reduced the output to a few millivolts.

The next task was to calibrate the temperature sensors. The calculations for measurement of convection are most sensitive to the time-derivative of the plate temperature and the difference between temperatures of the plate and ambient air. I attached the two ambient sensors ("ambient" and "free") to the back of the plate with thermal adhesive so that they would be at the same temperature. The statistics of (triple) 621 samples taken once per second are:

nREPS = 1ambientplatefreeoffset

The plate-ambient offset is about -29 LSB = -24.mV = -0.36C. The 13.mV variance is rather large and matches measurements made by a RMS voltmeter at the ADC inputs; this bodes ill for the time-derivative of the plate temperature.

Note that voltage is measuread at the ADC input. There is a voltage gain of 6.56 from each LM35CZ (10.mV/C) output to the ADC input.

The STM32F303VCTx datasheet specifies a total unadjusted error of +/-4.5 LSB for the single-ended ADC at 25C and with a 3.3V supply.

The 16 LSB variance is much larger than the ADC error; thus it will act as a dither and smooth discontinuities in the ADC transfer function. So I rewrote the program to sum the result of converting each signal 16 times (per second). The statistics of 943 readings averaged over 16 conversions apiece are:

nREPS = 1ambientplatefreeoffset

The variance is reduced by a factor of 5, which will greatly reduce the effect of noise on the time-derivative of plate temperature.

This time the plate-ambient offset is about -33 LSB = -27.mV = -0.41C. All three temperatures are higher in the averaged test than in the single conversion test. This and subsequent sample runs in a thermostatically controlled building show that ambient and plate temperatures change enough to hamper calibration. The problem was worse when the plate was heated because the ambient sensor had only a small contact area with the plate, causing a temperature gradient which would be indistinguishable from a gain error.

So I fitted some insulation over the temperature sensors to protect them from air currents. This reduced the plate-ambient offset by an order of magnitude!

nREPS = 1ambientplatefreeoffset

A (304s) run near 20C also shows an offset smaller than the variance and guaranteed minimum offsets of the components.

nREPS = 1ambientplatefreeoffset

So the measurement program will not need to apply offset and scale corrections to the plate-ambient temperature difference. The ambient and plate sensors came from the same lot, the free sensor from a different batch. To convert the free temperature to the equivalent ambient temperature, multiply by 1.023 and subtract 1.318C.