Temperature measurements with AS35

dusko

New Member
Hello,
This is my first post--trying to learn how to use PICAXE and measure the temperature. I am playing with AS35--a replacement for LM35. I am using an almost exact copy of the program by Peter H Anderson:

Code:
'based on http://www.phanderson.com/picaxe/lm34.html
'using AS35
Symbol ADVal = W0
Symbol TF_10 = W1
Symbol Whole = B5
Symbol Fract = B6

main:
	ReadADC10 1,ADVal
	TF_10 = ADVal * 4
	TF_10 = ADVal * 8 / 10 + TF_10
   TF_10 = ADVal * 8 / 100 + TF_10
   Whole = TF_10 / 10
   Fract = TF_10 //10
   SerTxD ("T = ",#Whole, ".", #Fract,"°C",", 13, 10)
   pause 1000
   goto main
I am also using a mercury thermometer as a "reference". Its reading is ~20.5 degC. Here is a table of the values I get on my computer screen, using different voltage sources:

Source________________Voltage (V)_____Temp.(degC)
"old" 3x1.5V batteries_______4.40__________21.9
fresh 3x1.5V batteries_______4.95_________19.9
4x1.2NiMH rechargables_____5.09__________19.5
regulated Power Supply_____5.02__________19.0

I am doing my experiments on a breadboard. I've also measured the voltage between the mid-pin of AS35 and ground--it was 0.203 V, which based on the slope from the product datasheet of 10 mV/deg corresponds to 20.2 degC, which is close to the mercury thermometer reading. Any ideas what is going on here?
Thanks
Dusko
 

hippy

Senior Member
What happens is that READADC10 returns a value 0..1023 which is -

ADC Voltage
------------ * 1023
PSU Voltage

So as the PSU Voltage changes, so does the READADC10 reading, even though ADC Voltage read from the AS35 stays rock solid.

The code you are using is most probably designed to be run in a system using a regulated supply which will not vary, unlike batteries. That's the easiest solution, otherwise you need to create a constant reference voltage, read that, calculate what the PSU voltage currently is, and then adjust the temperature reading you are getting approriately.
 

dusko

New Member
Thanks for this clarification. However, it is still unclear why the reading with the regulated power supply gives the largest difference (error?) from the mercury thermometer and the voltmeter directly connexted to AS35. (I've also checked the value of ADValue from my program---it was in the range 39--44.)
 

hippy

Senior Member
I haven't checked the maths, but it's probably the conversion code in the three 'TF_10=' lines that follow the READADC10 giving the error for a regulated supply. Also, in PHA's code, he averages 64 consecutive readings, so what you could be seeing is instantaneous error caused by external electrical noise and interference. The range of values seen in ADValue suggests there is some noise being picked up.
 

dusko

New Member
Thank you again. However, the results that I get with all four supplys are stable--they hardly change in, say, 60 seconds. What I was refering to was that the ADValue's for each of the voltage sources are stable, but differ. For example, for "old" batteries ADValue = 44, for the regulated power supply it was 39 etc. I've also checked the math part of the code in excel (just in case...) and there is no error--if I enter 39, I get 19.04, the same value I see on the screen when running my program. It is still misterious why the regulated power supply (probably the best of all and the only one regulated) gives dT of 1.2 degC (second worst). Thanks again. I think I understand that it is around 5am in the UK.
 

hippy

Senior Member
I think I understand that it is around 5am in the UK.
About an hour before (BST), and my brain was too foggy to do the math :)

Taking 20.3'C giving 0.203V, for a 5.02V supply, the READADC should be -

Code:
0.203
----- * 1023  => 41
 5.02
To turn that reading into a temperature we need a multiplication factor, which can be determined by -

Code:
                                         temperature
temperature = reading * multiplier       -----------  = multiplier 
                                           reading
Putting in the values we have -

Code:
20.3
---- = 0.495
  41
[code]

If we apply that multiplier, 41 * 0.495 = 20.295, which due to rounding errors will probably display as 20.2'C.

The multiplier in PHA's code is 0.488, and, 41 * 0.488 = 20.0'C, which is quite close but a way off the 19.0'C result you actually got. The reason for that coub be because PHA has tuned the maths for a 5.00V supply and to give better overall accuracy. You will probably want to tune the 0.495 multiplier in the same way, because a whole range of temperatures will give a READADC10 value of 41.

As can be seen, small differences can have a huge impact on results, and these differences can occur everywhere. It may not be that the PICAXE conversion is wrong, but that your thermometer and DMM are inaccurate. The old adage, "a man with two watches never knows what the time is" applies.

To use the LM35/AS35 directly ( no amplification ) with a fixed correction factor in code requires very stable supplies and noise immunity. 'Thrown together' and you can probably expect +/- 2'C. To get very accurate results requires careful design and accurate measurement all round.
 

dusko

New Member
After all my experiments and calculations, your conclusion sounds right:

To use the LM35/AS35 directly ( no amplification ) with a fixed correction factor in code requires very stable supplies and noise immunity. 'Thrown together' and you can probably expect +/- 2'C. To get very accurate results requires careful design and accurate measurement all round.
This morning, the AS35 temperature reading is 17°C, the ADValue=35, the digital voltmeter reads V=0.186, and the mercury thermometer temperature is 18.9°C. Although, when one analyze the error, AS35 never overestimates the temperature--it's always below the actual (if one is willing to thrust the voltmeter/mercury thermometer which are very close). I am trying to think what might cause this--you can call it systematic error. And also, another fact--out of 10 bits, only five are used in this ADC (your remark "no amplification").

Anyway, thanks again for your helpful discussion and doing the math. I've learned a lot.
 

premelec

Senior Member
In my experience it is very hard to get two different sense units reading the same - consider the bulb thermometer which ideally has an imersion line on it that is supposed to be in the medium... and the electronic unit which has thermal conductivity to ambient through its wire leads... if all the apparatus and transducers are at the same temperature they should run the same temp - all electronic units have _some_ dissipated power from the measuring voltage/current and part of your job is to minimize this component. Even in fluids there are convection currents and variation of a few degrees if there is no stirring going on. Why would you want more than one thermometer if they all read the same :) perhaps averaging is useful. Anyhow good luck and have fun learning the art of precision and/or accurate measurement - it's not easy...
 
Top