part 1 1750 bytes content-type:text/plain; (decoded 7bit)
While I'm a moderately competent digital electronics hobbyist, I avoid
delving into the analog realm whenever possible. I have what is probably a
simple problem here, but I don't know the best approach to solving it.
I'd like to use an LM20 to measure temperatures from -55C to +50C. The LM20
has a mostly linear voltage output in response to temperature. At -55C, the
output is 2485mV. At 80C, the output will be 919mV. (The datasheet doesn't
give a specific number for 50C and the chart is too small to interpolate
with any accuracy so let's play with the 80C value.) The LM20 is relatively
inexpensive ($1 in onesies) and is usable for the temperature range in which
I'm interested.
The LM20 and a PIC18F2xK20 are going to be powered from a 3.3V power supply.
The PIC chip has VREF- and VREF+ inputs to the ADC. I believe that if I can
set VREF- at 0.9V and VREF+ at 2.5V, I can greatly increase the resolution
of the ADC over the input range that the LM20 will deliver.
How do I approach building a voltage divider to provide me with these
voltage references? How do I select the best order-of-magnitude for the
resistors? What other considerations do I need to pay attention to?
(Now... I am aware that this may be a bit extreme. The PIC has a 10bit ADC,
and even if I leave VREF- and GND and VREF+ at 3.3V, I can probably get +/-
1 degree C resolution, but this still makes for a nice topic of discussion,
IMHO, and I'm bound to learn something new from the discussion.)
Another potential topic: what are the pro's and con's of the LM20 versus a
NTC thermistor for this application? The thermistor seems to require more
claibration and interpolation to correct for nonlinearities.
Thanks,
-Matthew
part 2 2543 bytes content-type:application/ms-tnef; (decode)
part 3 35 bytes content-type:text/plain; charset="us-ascii" (decoded 7bit)
> The LM20 and a PIC18F2xK20 are going to be powered
> from a 3.3V power supply.
> The PIC chip has VREF- and VREF+ inputs to the ADC. I
> believe that if I can
> set VREF- at 0.9V and VREF+ at 2.5V, I can greatly
> increase the resolution
> of the ADC over the input range that the LM20 will
> deliver.
Can't do that, it violates the deltaVRef spec
(parameter A20 in data sheet).
>
> How do I approach building a voltage divider to
> provide me with these
> voltage references? How do I select the best
> order-of-magnitude for the
> resistors? What other considerations do I need to pay
> attention to?
>
In general, pick resistors that are a relatively high
order of magnitude to minimize power consumption. Make
sure that the input current into the Vref pin (0-150uA)
is swamped out by the current in the external resistive
divider. See parameter A50 (IRef). Don't forget, that
if you use resistive dividers that there will be a
relatively large error in the VRefs. You will need to
take into account tolerance of the resitors (1% ?) as
well as tolerance of Vdd (5% ?). For better accuracy,
you can use high tolerance voltage references ($$). A
simpler, more cost effective approach is to calibrate
out the errors after the unit is built (but be careful
of VDD variation over input voltage and output
loading).
> (Now... I am aware that this may be a bit extreme.
> The PIC has a 10bit ADC,
> and even if I leave VREF- and GND and VREF+ at 3.3V,
> I can probably get +/-
> 1 degree C resolution, but this still makes for a
> nice topic of discussion,
> IMHO, and I'm bound to learn something new from the
> discussion.)
>
Probably not if you use resistive dividers from Vdd and
use a typical voltage regulator on Vdd.
We also didn't talk about system noise and filtering.
Comes down to accuracy, both on the sensor and reference. Higher accuracy will cost you more. Better than a voltage divider is a precision reference source, simple 3 terminal devices. On the sensor, depends on how critical the reading is...turning on a fan or controlling a life support system?
> From: Matthew Mucker <.....matthewKILLspam@spam@mucker.net>
> Subject: [EE] Voltage Divider
> To: piclistKILLspammit.edu
> Date: Sunday, February 8, 2009, 7:31 PM
> While I'm a moderately competent digital electronics
> hobbyist, I avoid
> delving into the analog realm whenever possible. I have
> what is probably a
> simple problem here, but I don't know the best approach
> to solving it.
>
> I'd like to use an LM20 to measure temperatures from
> -55C to +50C. The LM20
> has a mostly linear voltage output in response to
> temperature. At -55C, the
> output is 2485mV. At 80C, the output will be 919mV. (The
> datasheet doesn't
> give a specific number for 50C and the chart is too small
> to interpolate
> with any accuracy so let's play with the 80C value.)
> The LM20 is relatively
> inexpensive ($1 in onesies) and is usable for the
> temperature range in which
> I'm interested.
>
> The LM20 and a PIC18F2xK20 are going to be powered from a
> 3.3V power supply.
> The PIC chip has VREF- and VREF+ inputs to the ADC. I
> believe that if I can
> set VREF- at 0.9V and VREF+ at 2.5V, I can greatly increase
> the resolution
> of the ADC over the input range that the LM20 will deliver.
>
>
> How do I approach building a voltage divider to provide me
> with these
> voltage references? How do I select the best
> order-of-magnitude for the
> resistors? What other considerations do I need to pay
> attention to?
>
> (Now... I am aware that this may be a bit extreme. The PIC
> has a 10bit ADC,
> and even if I leave VREF- and GND and VREF+ at 3.3V, I can
> probably get +/-
> 1 degree C resolution, but this still makes for a nice
> topic of discussion,
> IMHO, and I'm bound to learn something new from the
> discussion.)
>
> Another potential topic: what are the pro's and
> con's of the LM20 versus a
> NTC thermistor for this application? The thermistor seems
> to require more
> claibration and interpolation to correct for
> nonlinearities.
>
> Thanks,
>
> -Matthew
So, before crunching resistor numbers, 50C -> 1.2792V
> How do I approach building a voltage divider to provide me with these
> voltage references? How do I select the best order-of-magnitude for the
> resistors? What other considerations do I need to pay attention to?
The accuracy of the sensor and accuracy and drift of the resistors and
their voltage source. 1% metal film resistors are cheap enough, can't do
too much about the sensor. Presumably the sensor is the only device
exposed to the temperature variations. If the voltage regulator and PIC
are too, then there's a problem that needs solving
> Another potential topic: what are the pro's and con's of the LM20
> versus a NTC thermistor for this application? The thermistor seems
> to require more calibration and interpolation to correct for nonlinearities.
I recall some people have reported very good results with thermistors
despite that
>
> > The LM20 and a PIC18F2xK20 are going to be powered
> > from a 3.3V power supply.
> > The PIC chip has VREF- and VREF+ inputs to the ADC. I
> > believe that if I can
> > set VREF- at 0.9V and VREF+ at 2.5V, I can greatly
> > increase the resolution
> > of the ADC over the input range that the LM20 will
> > deliver.
>
> Can't do that, it violates the deltaVRef spec
> (parameter A20 in data sheet).
Thanks. I never would have seen that on my own.
I guess I'll just leave the ADC at GND and V+, and see what results I get.
For those who asked, I do plan to have only the LM20 in the ambient temps
and have the PIC in a more controlled environment. I'm planning a mountain
climb later this year and thought it'd be fun to design (and maybe even
build) a helmet-cam that can record GPS coordinates and ambient temperature
as text overlays on the video. Mt. McKinley (Denali) can get down to -50C
regularly. Though I don't plan on climbing Denali, I figured I might as well
use that as a target temperature range. I'd plan to mount the GPS antenna
and temperature sensor outside, and keep the PIC, the GPS receiver, and the
video overlay generator in my jacket near my body. I doubt this project
will ever make it past the idea stage, but it's fun to think about it.
> I'll just leave the ADC at GND and V+, and see what results I get.
Matthew, with a 1.2V range covering 100C, and a 3.3V Vref, that's
36% of the available 10 bit range. IOW, ignoring the baseline, 50C =
0, -50C = 372, => 3.72 in the ADC result = 1C
It might be worth considering two sensors (eg one for -50C to 0C,
one for 0C to +50C) and offset subtraction then amplification of their
respective ranges. Then you would have say 0-3.3V for each sensor
for ADC inputs
For example, the 0C to 50C sensor. At 0C, o/p is 1864mV, at 50C
o/p is 1280mV, a 584mV range. Strip the 1280mV off and amplify
by 5.65 to get 0mV to 3300mV for 50 degree range -> 66mV/C,
rather than the original 12mV/C. This means more bits per degree
(20.46 value rather than the 3.72 above) in the ADC result. Might be
unlikely to see 50C so the range(s) could be reduced. You could also
bump up the PIC's Vcc/Vref to 5V (and a bit more)
> Another potential topic: what are the pro's and con's of the LM20 versus
> a NTC thermistor for this application? The thermistor seems to require
> more calibration and interpolation to correct for nonlinearities.
Matthew Mucker wrote:
> I'd like to use an LM20 to measure temperatures from -55C to +50C. The
> LM20 has a mostly linear voltage output in response to temperature. At
> -55C, the output is 2485mV. At 80C, the output will be 919mV. (The
> datasheet doesn't give a specific number for 50C and the chart is too
> small to interpolate with any accuracy so let's play with the 80C
> value.) The LM20 is relatively inexpensive ($1 in onesies) and is
> usable for the temperature range in which I'm interested.
>
> The LM20 and a PIC18F2xK20 are going to be powered from a 3.3V power
> supply. The PIC chip has VREF- and VREF+ inputs to the ADC. I believe
> that if I can set VREF- at 0.9V and VREF+ at 2.5V, I can greatly
> increase the resolution of the ADC over the input range that the LM20
> will deliver.
For small values of "greatly". Do the math. 2.5V - 900mV = 1.6V range with
special Vref- and Vref+ compared to the 3.3V range using Vss and Vdd.
That's only 2.1 times more resolution, or 1 bit.
Do the rest of the math. 2.485V - 919mV is a range of 1.566V that covers a
range of 80C - -55C = 135C. Since you say the sensor is linear, it is
putting out 1.566V / 135C = 11.6mV/degC. If using Vss and Vdd for the 10
bit A/D range, you get 3.3V / 1023 = 3.23mV/count, or 11.6mV / 3.23mV = 3.6
counts/degC. Is your sensor accurate to 1/3 degC? Probably not for a $1
sensor.
Then there is the issue of accuracy versus resolution. Selecting the
minimum A/D range that you really need will add one bit of resolution.
However, it won't do anything for the accuracy. First, both using resistor
dividers to make Vref- and Vref+ and using Vss to Vdd directly make the
readings a function of Vdd. Is your Vdd accurate to .1%? If not, you don't
have 10 bits of accuracy anyway. And even if Vdd were perfect, adding
resistor dividers would add errors due to the inaccuracy of the resistors.
Even if using .1% resistors, you loose the extra bit of accuracy gained by
using a smaller Vref- to Vref+ range. So all in all, you're not going to
get better accuracy. The only reason to do this at all is if you need
higher resolution than 1/3 degC. There are occasionally reasons where
resolution is more important than absolute accuracy, like with some kind of
control systems. But unless you know you've got one of these case, you're
just kidding yourself.
Then there is the additional issue of valid Vref- to Vref+ range. PICs
don't let you arbitrarily chose these. Ususally there are min and max
levels for each, and a min required range between the two. 1.6V range is
less than required for many PICs. You need to check the data sheet to see
it this is even a possibility on your PIC.
> The PIC has a 10bit
> ADC, and even if I leave VREF- and GND and VREF+ at 3.3V, I can
> probably get +/- 1 degree C resolution,
What's with this "probably" nonsense!? This list is for engineers, not
fortune tellers.
>
> Olin Lathrop wrote:
> > What's with this "probably" nonsense!? This list is for engineers, not
> > fortune tellers.
>
>
>
> Holy Cow! What the heck am I doing here then. The first I've heard of
> this...in 10yrs.
>
In the electrical/electronic repair industry you are expected to be both,
and some level of mage as well.
>
> Olin Lathrop wrote:
> > What's with this "probably" nonsense!? This list is for engineers, not
> > fortune tellers.
>
>
>
> Holy Cow! What the heck am I doing here then. The first I've heard of this...in 10yrs.
You're safe. Olin was speaking as an engineer - no absolutes, always some
margin of error ;-)
fred jones wrote:
>> What's with this "probably" nonsense!? This list is for engineers,
>> not fortune tellers.
>
> Holy Cow! What the heck am I doing here then. The first I've heard
> of this...in 10yrs.
If you had read what was immediately above what you quoted, you would have
seen I was referring to something that could have been resolved using a few
seconds of grade school arithmetic.
> fred jones wrote:
> >> What's with this "probably" nonsense!? This list is for engineers,
> >> not fortune tellers.
> >
> > Holy Cow! What the heck am I doing here then. The first I've heard
> > of this...in 10yrs.
>
> If you had read what was immediately above what you quoted, you would have
> seen I was referring to something that could have been resolved using a few
> seconds of grade school arithmetic.
I did read it. I also read where he said he was a hobbyist. So knowing he was no engineer, why did you even answer his question? Did it just make you feel good to belittle him?
On Mon, Feb 9, 2009 at 7:23 AM, Olin Lathrop <.....olin_piclistKILLspam.....embedinc.com> wrote:
> What's with this "probably" nonsense!? This list is for engineers, not
> fortune tellers.
fred jones wrote:
> I did read it. I also read where he said he was a hobbyist. So
> knowing he was no engineer, why did you even answer his question?
It's getting really silly beating this to death.
Specifically he said:
> The PIC has a 10bit ADC, and even if I leave VREF- and GND
> and VREF+ at 3.3V, I can probably get +/- 1 degree C resolution,
I thought it was amusing that he understood the details, but was guessing
what the temperature resolution would be. All he had to do was a little
arithmetic on the values he already supplied to know what the resolution
would be instead of guessing.
Hobbyist or not, he supplied all the relevant values earlier in the same
message:
> The LM20 has a mostly linear voltage output in response to
> temperature. At -55C, the output is 2485mV. At 80C, the output
> will be 919mV.
> I thought it was amusing that he understood the details, but was
> guessing what the temperature resolution would be
Given the possible analogue variables, is "probably" guessing ? I'm
sure it was just a filler word
Many times experienced engineers here will offer "might" or "probably"
or "likely" in even a considered and debated topic. When looking at
analogue components, superficially you have some idea of what might
be accomplished, but the real expectations are often determined by
experimentation
> > fred jones wrote:
> > >> What's with this "probably" nonsense!? This list is for engineers,
> > >> not fortune tellers.
> > >
> > > Holy Cow! What the heck am I doing here then. The first I've heard
> > > of this...in 10yrs.
> >
> > If you had read what was immediately above what you quoted, you would
> have
> > seen I was referring to something that could have been resolved using
> a few
> > seconds of grade school arithmetic.
>
>
> I did read it. I also read where he said he was a hobbyist. So
> knowing he was no engineer, why did you even answer his question? Did
> it just make you feel good to belittle him?
>
While I appreciate others stepping to my defense, the simple truth is that I
could have solved this for myself but didn't do so because I was lazy.
I believe it's my responsibility to solve as much as my problem as I can
before I ask others for help. I learn more that way, and bother y'all less
that way. There's value in encouraging others to think through their
problems, and while Olin might not always have the best bedside manner, the
more times that you experienced folk remind us newcomers that we should do
our homework before coming to the list, the better the quality of discourse
becomes, IMHO.
Olin, I think you were right to point out that I could have solved this on
my own. Fred, I appreciate you trying to make this a more friendly place for
the hobbyists.