Rather than use 1-wire temperature sensors, I am considering the LM35 at an alternative. It outputs 10mv/C*. While it can do -C* with a dual power supply, I don't want to bother with that complexity as the device outputs a negative voltage for below zero measurements in that context. I only need the positive range and between about 10*C and 45*C.
So the device would be outputting in the range of 0.1volts a and 0.450volts.
Since I have several ZX-24as, I took a peek at the ATmega644 document to see it it was possible to use the internal reference voltage to get the ADC down to 2.56 volts reference. To my surprise, i see that it might also offer a 1.1volt reference. Obvious this would mean the LM35 would be working with higher resolution (maybe unnecessarily high, but at this point it seems attractive).
Has anyone tried to use a 1.1 reference voltage? If so, how has it worked out? And of course, how do I go about using it?
LM35 Temperature sensor and the Z24a ADC with a 1.1volt ref
LM35 Temperature sensor and the Z24a ADC with a 1.1volt ref
Last edited by G Herzog on 30 June 2010, 1:11 AM, edited 1 time in total.
The Taiwanese
Re: LM35 Temperature sensor and the Z24a ADC with a 1.1volt
An earlier thread showed how to use the ADC in differential mode. To use a reference other than AVcc, the general idea is the same but the details are different. The code below, written specifically for the mega644-based devices, compiles but is otherwise untested. The code could be modified to utilize a specific channel (A.0=0, A.1=1, etc.).G Herzog wrote:how do I go about using [the 1.1V reference]?
Code: Select all
Private Function readADC(ByVal chan as Byte) As Integer
Dim lowByte as Byte, highByte as Byte
' Configure the ADC to use the 1.1V reference and the specified channel
Register.ADMUX = &H80 Or (chan And &H07)
' Start the conversion using the 128x prescaler.
' Note that bit 4 is also written as a 1 to reset the ADIF bit.
Register.ADCSRA = &HD7
' wait for the conversion to complete
Do Until (CBool(Register.ADCSRA And &H10))
Loop
' read the ADC value
readADC = CInt(Register.ADC)
' turn off the ADC
Register.ADCSRA = &H00
End Function
- Don Kinzer
Thank you very much Don. As always, you are the penultimate master of ZBasic. I did locate the register and bits that need to be configured for 1.1V reference. So I was getting near to trying something on my own.
Having read all the LM35 (and its cousin, the LM34) material, I chose to set up a very simple trial and now have the device being fed a 9 volt supply through about 10 meters of telephone extension cord (not even twisted pair, very light gauge wire). I did insert a 2K resistor in line with the output as recommended for high capacitance operation (meaning the use of a long wire between the sensor and the reader),
So far I am getting a steady .260 volts on my digital VOM that agrees with my air conditioner's readout of 26*C (.260 x 10 = 26) and another thermometer in the room -- regardless of the long wire.
Next, I will try to adapt it all to my ZX-24a (Your code, maybe adapted to be something similar to the ADC to serial port). This certainly is less effort than bothering with a single 1-wire drop. So I am happy. I will keep in mind that some calibration might be required due to the actual Vref, but I had expected some due to other factors (like a voltage drop in the long wire).
Frankly the LM34, which is Fahrenheit calibrated offers more positive voltage range in the low end and the ZXes could easily convert to Celsius if need be. But Taiwan is part of metric world majority, so the LM34 is not sold over the counter here.
Also, I did the ultimate snafu and initially powered up with reverse polarity. the LM35 got extremely hot to the touch and I feared I smoked it. But having immediate shut down and let it cool, it seems to be none the less for wear.
Having read all the LM35 (and its cousin, the LM34) material, I chose to set up a very simple trial and now have the device being fed a 9 volt supply through about 10 meters of telephone extension cord (not even twisted pair, very light gauge wire). I did insert a 2K resistor in line with the output as recommended for high capacitance operation (meaning the use of a long wire between the sensor and the reader),
So far I am getting a steady .260 volts on my digital VOM that agrees with my air conditioner's readout of 26*C (.260 x 10 = 26) and another thermometer in the room -- regardless of the long wire.
Next, I will try to adapt it all to my ZX-24a (Your code, maybe adapted to be something similar to the ADC to serial port). This certainly is less effort than bothering with a single 1-wire drop. So I am happy. I will keep in mind that some calibration might be required due to the actual Vref, but I had expected some due to other factors (like a voltage drop in the long wire).
Frankly the LM34, which is Fahrenheit calibrated offers more positive voltage range in the low end and the ZXes could easily convert to Celsius if need be. But Taiwan is part of metric world majority, so the LM34 is not sold over the counter here.
Also, I did the ultimate snafu and initially powered up with reverse polarity. the LM35 got extremely hot to the touch and I feared I smoked it. But having immediate shut down and let it cool, it seems to be none the less for wear.
The Taiwanese
I set up a loop that performed a Console.Writeline() in order to monitor the ADC function.
At first all my readings were nonsense as I neglected to initialize the ADC pins as proper inputs without pull up, but now I am getting stable consistent readings -- though they seem a bit lower than my VOM.
Actually I have 4 pins being read. One is connected to the LM35 and the three others have their inputs configured with their internal pull up resistor. The latter are to verify that the ADC software is doing what it is supposed to.
On the LM35, I am getting about 248-9 out of 1023.
On the others, I am getting 1023 out of 1023
With a 1.1 to 1.0 volt reference (lets just say 1.023 for the sake of math), that would indicate about 24.8*Celsius. A quick move over to a board using my VOM gives a reading of .279v or roughly 27.9*C on the same LM35.
I am not exactly sure why the ADC is reading .030-.031volts lower, but if the results are linear I can easily calibrate by adding in a fudge factor. Of course, if I've overlooked something, please make a comment.
I may try using the 2.56 internal reference or the 5.00 external reference to see if I get closer results or if they remain the same. But at this point, I really need a good thermometer to calibrate against. I might try a medical supply house for a mercury one.
At first all my readings were nonsense as I neglected to initialize the ADC pins as proper inputs without pull up, but now I am getting stable consistent readings -- though they seem a bit lower than my VOM.
Actually I have 4 pins being read. One is connected to the LM35 and the three others have their inputs configured with their internal pull up resistor. The latter are to verify that the ADC software is doing what it is supposed to.
On the LM35, I am getting about 248-9 out of 1023.
On the others, I am getting 1023 out of 1023
With a 1.1 to 1.0 volt reference (lets just say 1.023 for the sake of math), that would indicate about 24.8*Celsius. A quick move over to a board using my VOM gives a reading of .279v or roughly 27.9*C on the same LM35.
I am not exactly sure why the ADC is reading .030-.031volts lower, but if the results are linear I can easily calibrate by adding in a fudge factor. Of course, if I've overlooked something, please make a comment.
I may try using the 2.56 internal reference or the 5.00 external reference to see if I get closer results or if they remain the same. But at this point, I really need a good thermometer to calibrate against. I might try a medical supply house for a mercury one.
The Taiwanese
The datasheet indicates that the analog input voltage should never be higher than the reference voltage. I don't know if this simply means that that is the maximum useful input voltage or the level above which damage may occur.G Herzog wrote:Actually I have 4 pins being read. One is connected to the LM35 and the three others have their inputs configured with their internal pull up resistor.
Let's say that the actual voltage is 279mV and the ADC reading is 248. That would mean that the reference voltage (ignoring ADC offset and other error sources) is 0.279 * 1024 / 248 = 1.15V, well within the specified range of 1.0V to 1.2V.G Herzog wrote:On the LM35, I am getting about 248-9 out of 1023.
- Don Kinzer
Sometimes it is difficult for me to sort out what the PDF is exactly saying.
My reading of having internal reference voltages lower than the Vcc of about 5 volts is that I would just get readings of 3FFh for anything above the reference voltage without any harm. It seemed logical to me that the i/o pin remains intact up to the Vcc rail.
My rationale is that the hardware is entirely made for running at 5 volts and the I/O pins are all engineered for roughly -0.3 to +5.5 volts. But the internal reference is merely affecting the upper limit as calculated by the ADC - which is a R-C timing calculation (which it can do at as high as +5 volts).
As you suggest, I will get a 10-turn pot to create a voltage divider input to ADC and actually calibrate what the 1.1vol reference exactly is.
I've also noticed that the difference between the ADC measurement and my VOM measurement lessens when I removed the long wire and just use 6 inches of wire. And, I have noticed that my modular telephone connectors need to be reinserted at times to get back to a good readings (that infers that any final design should avoid such plugs).
Overall, I am very confident that I can use the LM35 with the ZX-24a and extremely happy that two internal reference choices are available. I don't really need the 1.1volt if the 2.56 is more stable. So often I've looked into add on ADC chips only to find that I need an additional voltage reference chip as well. It is much neater to have it all in one 24pin unit and your 'readADC' function makes it easy to select any and all the features offered.
I suppose for safety's sake, I can stop polling the inputs with internal pull ups. It was merely a means to verify operation. But it might be wiser to use an external pull down for verification instead or zener controlled reference..
My reading of having internal reference voltages lower than the Vcc of about 5 volts is that I would just get readings of 3FFh for anything above the reference voltage without any harm. It seemed logical to me that the i/o pin remains intact up to the Vcc rail.
My rationale is that the hardware is entirely made for running at 5 volts and the I/O pins are all engineered for roughly -0.3 to +5.5 volts. But the internal reference is merely affecting the upper limit as calculated by the ADC - which is a R-C timing calculation (which it can do at as high as +5 volts).
As you suggest, I will get a 10-turn pot to create a voltage divider input to ADC and actually calibrate what the 1.1vol reference exactly is.
I've also noticed that the difference between the ADC measurement and my VOM measurement lessens when I removed the long wire and just use 6 inches of wire. And, I have noticed that my modular telephone connectors need to be reinserted at times to get back to a good readings (that infers that any final design should avoid such plugs).
Overall, I am very confident that I can use the LM35 with the ZX-24a and extremely happy that two internal reference choices are available. I don't really need the 1.1volt if the 2.56 is more stable. So often I've looked into add on ADC chips only to find that I need an additional voltage reference chip as well. It is much neater to have it all in one 24pin unit and your 'readADC' function makes it easy to select any and all the features offered.
I suppose for safety's sake, I can stop polling the inputs with internal pull ups. It was merely a means to verify operation. But it might be wiser to use an external pull down for verification instead or zener controlled reference..
The Taiwanese
One last item.
I tested the reference voltage at a bounce between 1022-1023 output on the ACD by using a 10 turn 50k pot. I get 1.102 volts as the ZX-24a reference voltage.
My objective is a thermostatic control, so it is easily within the ballpark of the LM35 calibration. I plan to have the on temperature be at least 1 degree higher than the off temperature in cooling mode so that their won't be frequent toggles between on and off.
I tested the reference voltage at a bounce between 1022-1023 output on the ACD by using a 10 turn 50k pot. I get 1.102 volts as the ZX-24a reference voltage.
My objective is a thermostatic control, so it is easily within the ballpark of the LM35 calibration. I plan to have the on temperature be at least 1 degree higher than the off temperature in cooling mode so that their won't be frequent toggles between on and off.
The Taiwanese