# PIC A/D and Voltage Divider

Started by March 19, 2011
This group has been way too quite for too long. I thought I'd liven things up a bit by asking a question. I would like to use the on chip A/D converter in a Pic 16F887 and I have some Microchip MCP1541 4.096 voltage reference devices. I need to be able to measure voltages up to around 18 volts. If I use a voltage divider that divides the input voltage by 5, I could measure up to 20.46 volts. So far so good. Now there are a lot of combinations of resistors that could be used to divide by 5. This project will be battery powered so I want to keep the current through the resistors to a minimum to extend battery life. But if I use too high of resistance, the impedance of the A/D converter will affect the accuracy of the readings. Is there a formula to use when calculating resistance values? I am trying to avoid using an Op Amp as a buffer.

Max
Hi Max,
The potential divider chain will not load the battery it will load the voltage being measure. (Unless it is the devices battery voltage being measured.) Section 9.3 of the data sheet explains the things that need to be considered when using the ADC. It does suggest that the source resistance should not be above 10 K ohms. This would mean that the highest value resistors that you could use would be 12.5 K and 50 K The source resistance also depends on how fast you need to take samples.
Les.
Firstly because of the way the preferred values work its impossible to get a
ratio 4:1 as needed to get an analogue divide by 5. So there is 1K but only
3.9 or 4.1.

Secondly , when I saw this I thought the data sheet would say what the
resistance or impedance of the the input were but I can't find it anywhere.
All it says is that the the impedance of the voltage should be less than 10K
which seems very low,

I have a PIC based Ham Radio test tool that measures battery voltage and
that uses 16k/3.9k as the dividers to give a divide ratio of 5.1 , but
that's >10k

So as you can see its a complete mess......

You might want to consider 2k and 10K which gives a divide by 6., or even
16K and 2x2k in series to give divide by 5.

Dave
G4UGM
On 19/03/2011 12:07, Dave wrote:
> Firstly because of the way the preferred values work its impossible to
> get a ratio 4:1 as needed to get an analogue divide by 5. So there is 1K
> but only 3.9 or 4.1.
> Secondly , when I saw this I thought the data sheet would say what the
> resistance or impedance of the the input were but I can't find it
> anywhere. All it says is that the the impedance of the voltage should be
> less than 10K which seems very low,
> I have a PIC based Ham Radio test tool that measures battery voltage and
> that uses 16k/3.9k as the dividers to give a divide ratio of 5.1 , but
> that's >10k
> So as you can see its a complete mess......
> You might want to consider 2k and 10K which gives a divide by 6., or
> even 16K and 2x2k in series to give divide by 5.

Impedance must be below 10k for proper operation of the ADC.

Leon
--
Leon Heller
G1HSM
> Firstly because of the way the preferred values work its impossible to
> get a ratio 4:1 as needed to get an analogue divide by 5. So there is
> 1K but only 3.9 or 4.1.

You can get a lot of values these days. Check out Mouser or DigiKey
or any other full line distributor (I happen to be in the US).

> Secondly , when I saw this I thought the data sheet would say what the
> resistance or impedance of the the input were but I can't find it
> anywhere. All it says is that the the impedance of the voltage should
> be less than 10K which seems very low,

As Les inferred, if you can leave the sample and hold open for more
you might be able to read a higher impedance source.

> I have a PIC based Ham Radio test tool that measures battery voltage
> and that uses 16k/3.9k as the dividers to give a divide ratio of 5.1 ,
> but that's >10k

Not actually. Again, Les has it right here. You need two resistors of
value Rx and 4Rx to make a 5:1 voltage divider. The source impedance
seen by the ADC will be their Thevenin equivalent or (4 * Rx^2)/5Rx or
0.8Rx which wants to be <= 10K. Ergo Rx must be <= 12.5K and 4Rx
is 50K.

(16K * 4K)/(20K) ~= 3.2K so you're well below the constraint.

Max, I recently designed a sophisticated battery charger/monitor/UPS
using a PIC24H family part and need a high impedance source for
measuring battery voltage. Along with Les' suggestion on considering
a longer sample and hold period to charge the PIC16F877's internal
sample capacitor, you could put a 0.1uF cap on the input. This cap
would charge to the sample voltage and then at sample time would
provide extra current to charge the PIC's internal sample cap.

Some of this stuff may be discussed in a Microchip document called
something like "Midrange CPU Family Family Reference". It's always
seems to take me a couple of tries to find it at Microchip's website but
it probably has the background info on the A/D section.

Coop, AA1WW
> Firstly because of the way the preferred values work its impossible to
> get a ratio 4:1 as needed to get an analogue divide by 5. So there is
> 1K but only 3.9 or 4.1.

You can get a lot of values these days. Check out Mouser or DigiKey
or any other full line distributor (I happen to be in the US).

I am in the UK.but on checking on Radio Spares I can get a wide range of
values in surface mount, although some are 80p each in packs of 10 so thats
about \$1 each. I hadn't realized that was possible as I normally only use
wired components..
> Secondly , when I saw this I thought the data sheet would say what the
> resistance or impedance of the the input were but I can't find it
> anywhere. All it says is that the the impedance of the voltage should
> be less than 10K which seems very low,

As Les inferred, if you can leave the sample and hold open for more
you might be able to read a higher impedance source.

Ok I had forgotten it had a cap and used sample and hold, so that makes
sense now...

> I have a PIC based Ham Radio test tool that measures battery voltage
> and that uses 16k/3.9k as the dividers to give a divide ratio of 5.1 ,
> but that's >10k

Not actually. Again, Les has it right here. You need two resistors of
value Rx and 4Rx to make a 5:1 voltage divider. The source impedance
seen by the ADC will be their Thevenin equivalent or (4 * Rx^2)/5Rx or
0.8Rx which wants to be <= 10K. Ergo Rx must be <= 12.5K and 4Rx
is 50K.

(16K * 4K)/(20K) ~= 3.2K so you're well below the constraint.

Max, I recently designed a sophisticated battery charger/monitor/UPS
using a PIC24H family part and need a high impedance source for
measuring battery voltage. Along with Les' suggestion on considering
a longer sample and hold period to charge the PIC16F877's internal
sample capacitor, you could put a 0.1uF cap on the input. This cap
would charge to the sample voltage and then at sample time would
provide extra current to charge the PIC's internal sample cap.

Some of this stuff may be discussed in a Microchip document called
something like "Midrange CPU Family Family Reference". It's always
seems to take me a couple of tries to find it at Microchip's website but
it probably has the background info on the A/D section.

I think I have that on the main PC....

Coop, AA1WW

Thanks, very useful
Dave
Thanks for all of the replys. Now to check the suppliers and see what values they have that will work.

Max
> I am in the UK.but on checking on Radio Spares I can get a wide range
> of values in surface mount, although some are 80p each in packs of 10
> so thats about \$1 each. I hadn't realized that was possible as I
> normally only use wired components..

I've found a surprising range of values at the distributors I mentioned
(Mouser and DigiKey). You might check out Maplin, Farnell, and the like.
They may have minimum order requirements but at least it gives you an
idea. Also, never underestimate eBay.

> Thanks, very useful
> Dave

Best Wishes,
Coop, AA1WW
Check out Rapid, they are likely to be cheaper on the components.

0805 1% 46p/100

www.rapidonline.com

Colin

:: I am in the UK.but on
:: checking on Radio Spares I can get a wide range of values in
:: surface mount,
:: although some are 80p each in packs of 10 so thats about \$1 each.