The testing of the LM35 temperature sensor in part also involved investigating the various parameters associated with the analog to digital convertor (ADC) from the PIC 16F876A. As described in the "Background Section" above, the LM35 provides a 10mV/oC linear output with temperature. Therefore, the ADC is required to measure and convert the voltage output from the LM35 to calculate/display the actual measured temperature. The PIC ADC Module page gives specific detail about usage of the ADC, whereas, Learning PIC Microcontrollers gives specific details about using PIC microcontrollers in general. Of particular revelence here is the ADC clock value and the reference voltage.
The following figure presents a number of graphs showing the results of differing ADC clock values and reference voltages used with the PIC 16F876A ADC connected to the LM35. The ADC clock value must be set appropriately for the PIC oscillator speed being used (10Mhz in this instance) in order that the PIC ADC module has sufficient time to perform the conversion of the input voltage to a digital value (see PIC ADC Module). The ADC_CLOCK_DIV32 (red graph) shows a greater range of voltages from the LM35 (ie temperature variation) compared to the ADC_CLOCK_DIV16 (black graph) in the following figure, as the "DIV16" setting for the PIC 16F876 at 10Mhz was insufficient to enable the full range of voltage to be sampled and was subsequently baised low.
The effect of input reference voltage to the ADC is shown by the comparison of the 1.25V (blue graph) compared to the 2.5V (red graph) using the same ADC clock setting. The ADC has a set number of "bits" resolution (10-bit in this case). The input reference voltage divided by the maximum bit value (1023 = 210 - 1) then gives the minimum voltage difference that can be measured by the ADC. Using a lower input reference voltage to the ADC then allows each "availabe" bit to represent a smaller difference in voltage. The 1.25V (blue graph) reference voltage shows a more "gaussian" shape to the measured voltage giving confidence that the reported temperature is likely of better resolution (25.5oC in this case as measured with a mercury bulb thermometer - see the Photographs Section).
However, using a lower input reference voltage to the ADC means of course a lower maximum voltage can be measured (1.25V in this case). Since the LM35 provides a 10mV/oC linear output with temperature, the 1.25V ADC reference voltage means a maximum temperature of 125oC, compared to 150oC that the LM35 is capable of measuring as per the datasheet.
Sensor Connection
As mentioned in the Circuit Details Section, a resistor (R4 in the schematic diagram) in conjunction with the bypass capacitor (C10 in the schematic diagram) acts as a low-pass filter and is beneficial when long sensor cable lengths are involved and or noisy environmental conditions.
The following graph 2 shows the results of observed temperature from a LM35 versus sensor cable length and use of the RC filter. The temperature reported by the LM35 when connected directly onto the breadboard (i.e the shortest possible connection) is given by the black-coloured points on graph 2 which is ~24.9oC. Ambient temperature as measured by a mercury-blub thermometer was 25.1oC.
When the LM35 was connected by ~1.2m cable length (the red-coloured points on graph 2) the recorded temperture dropped to ~24.2oC (due to voltage drop/loss across the cable). The addition of the RC low-pass filter (R2 and C10 in the schematic diagram) corrected the observed temperature reported by the LM35 (blue-coloured points on graph 2).
Sensor 'Probe'Construction
The LM35 used during the testing was in the form off a TO-92 package. This TO-92 package needs to be connected to the necessary cabling and sealed appropriately to form a 'probe' that can be used to measure the tempeature of environments remote from the control circuitry (PIC microcontroller, power supply etc). The desired environments includes liquids (aqueous) up to ~100oC (i.e. boiling water).
The Photographs Section shows two probes constructed from LM35 TO-92 packages, using alternatively hot-glue and a expoxy glue to seal the TO-92 package into a sealed plastic tube. The following graph 3 shows the results of measuring temperature using the constructed probes versus temperature as measured with a mercury-blub thermometer.
From graph 3, the temperature probe constructed using hot-glue (blue data points) has a 'lag' when comparing temperature as reported by the mercury-bulb thermometer. This is most readily explained as the hot-glue was acting as an insulator. The probe constructed using expoxy-glue (which allowed the majority of the LM35 TO-92 package to be exposed, yet enable a water-tight seal) gives temperature (red data points) in close agreement with that as measured by the mercury-bulb thermometer.
Graphs 4 and 5 show another factor in relation to the material used to construct a 'probe' using a LM35. The hot-glue (graph 4) does not hold-up well to elevated temperature and begins to leak.Whereas, the expoxy-glue constructed probe (graph 5) proved to be durable at the temperatures/times observed.
Oversampling to increase Resolution
The LM35 sensor 10mV/degree Celsius output measured with 10-bits ADC and 2.5V voltage reference input produces a "step" response when monitoring slowly fluctuating temperature changes. This is due to 10-bits with Vref=2.5V equating to 2.4mV per bit (2^10=1024, 2.5/1024 = 2.4mV/bit), and therefore, with 10mV = 1 degree Celsius, a minimum temperature difference of 0.24oC (without taking into account noise etc). For reference, with 10-bits ADC and Vref=5V this equates to 0.5oC per bit and 8-bits ADC with Vref=5V 2oC per bit.
Now while the accuracy of the LM35 (datasheet states ±0.5oC accuracy guaranteeable at 25oC) is set by the internal circuitry, the resolution between temperature measurements with the LM35 can be improved by the "oversampling" technique. This is desirable in circumstances such as measuring the relative changes in a slowly fluctuating temperature situation, or using/displaying the relative change in temperature as the signal changes between set points (for instance in a thermostat application). Again, to emphasise, oversampling does not improve accuracy, but can improve resolution.
The AVR article "AVR121: Enhancing ADC resolution by ovesampling" gives the background details about increasing ADC resolution by oversampling, averaging and decimation, and noise reduction by averaging samples (2). The interested reader is directed to this article for the theory of operation, Nyquist theorem and required criteria for applicability, however, using the method is fairly straight-forward.
The following code snippet implements ADC oversampling using CCS C code, and this was applied to measuring the temperature of cooling hot water using a LM35 temperature sensor (data presented in graphs 6 and 7 below).
Code Snippet 1: ADC oversampling
int16 overSampling_ReadADC(int8 numExtraBits) {
//numExtraBits over actual 10-bit ADC
int8 numSamples, i;
int16 sumSamples = 0, ADCvalue;
numSamples = 1 << (2*numExtraBits);
for (i=0; i < numSamples; i++) {
ADCvalue = Read_ADC();
sumSamples = sumSamples + ADCvalue;
}
sumSamples = sumSamples >> numExtraBits;
return (sumSamples);
}
Graph 6 and 7 below presents LM35 temperature data from monitoring a beaker of hot water allowed to cool to ambient room temperature using 10bit ADC with Vref=2.5V and then with "11-bit" and "12-bit" via using ADC oversampling. The 10bit ADC experimental run also had the water temperature monitored simultaneously by manually reading a mercury bulb thermometer.
The 10-bit temperature data shows the "steps" due to the limited resolution of the data, as discussed above, in what should have been otherwise a smooth continuous curve. The use of ADC oversampling to give in effect 11-bit and 12-bit resolution to the monitored temperature resulted in the expected "smoother" cooling curves.
The collected temperature data does indeed show that "software" ADC oversampling can improve resolution, but this does not alter the inherent accuracy of the LM35 which is ±0.5oC.
Only Logged-In Members can add comments