15 posts / 0 new
Author
Message

I want to us use an Analog input pin on an AVR to read a voltage from 0 to 30 volts.

I'm thinking I will divide the incoming voltage equally 6 times to give me 0-5 volts to connect to the pin, then use the software to multiply the value by 6.

To figure the values of the resistors I need to know the input impedance of the analog pin as this will be seen as a resistance in parallel to the divider.

I looked through the 300+ page data sheet but didn't see any min/max values for the pin - but I could have missed it.

Anyone know the input impedance of the analog pins - or is there a better way to do this?

Don't Let the smoke out!

Hello,
which AVR do you want to use?
If I have a look on the ATmega8 datasheet it tells me an analog input resistance of 55MOhm. But this half of the truth. It is the DC leakage resistance only and not the dynamic switched capacitor.
On another place it tells me that the Adc input is optimized for 10kOhm impedance. Therefore your input divider should have 50kOhm upper and 10kOhm lower resistor.
If you want to have higher input impedance you need a longer setup time or an impedance buffer.

The value of input impedance is nominally infinite except for the short time the sample/hold gate is on. During that time, it charges an internal capacitor.

The recommendation is for the source resistance, as seen by the analog input pin, to be less than 10K ohms.

Jim

Until Black Lives Matter, we do not have "All Lives Matter"!

Thanks!

Others I have worked with were also 10K, but some were 20K however those could accept a 0-10volt input.

Thanks again.

EDIT
Forgot to ask, the input voltage is described as 0-Vcc or in this case, 0-5 volts. What is the max on the ADC pins? should I take precautions to keep the voltage from going to 5.5 or 6 volts on that pin?

Should I use a 5volt Zener to shunt the voltage to ground through a resistor if it goes over 5 volts?

Don't Let the smoke out!

You can put a 5v zener after the divider and it should work OK. It will be insurance, and the only negative effect might be from the leakage current causing the input to read slightly low. I would think that this would be negligible. You don't need any additional resistors.

The divider will have an equivalent source resistance of 50k in parallel w/ 10K -- slightly less than 10K.

If this is a one off, you can just measure some 5% resistors and adjust your scale factor. 52K and 10K would seem to be the nominal values to use.

If your voltage source is stiff enough, you could use 4.7K and 27K. Max voltage at 30v in would be ~4.5.

ford2go wrote:
You can put a 5v zener after the divider and it should work OK. It will be insurance, and the only negative effect might be from the leakage current causing the input to read slightly low. I would think that this would be negligible. You don't need any additional resistors.

The divider will have an equivalent source resistance of 50k in parallel w/ 10K -- slightly less than 10K.

If this is a one off, you can just measure some 5% resistors and adjust your scale factor. 52K and 10K would seem to be the nominal values to use.

If your voltage source is stiff enough, you could use 4.7K and 27K. Max voltage at 30v in would be ~4.5.

Thanks for the response,
I was just working this out my self, I came up with 25k for R1 and 10K for R2. Reading the voltage across R2, and assuming that the input impedance in parallel with R2 is 10K also, the voltage should be 5 volts with an input at 30 volts.

I'll probably use a 15K ohm pot for R2 so I can tweek it. - time to test!!

I'll post the final.

Don't Let the smoke out!

Correct me if I am wrong, but the "upper" resistor is in parallel with the "lower" resistor when you are calculating the impedance seen by the ADC pin.

This means that the impedance seen by the ADC pin will always be under 10K if you use a 10K "lower" resistor.

Recall that zener diodes don't have a sharp cut off voltage. It may be labeled "5.1 V", but it will start conducting a bit below that voltage. If your accuracy at the high end is important, then you need to keep this in mind.

Probably overkill, but an alternative is a 3 resistor divider. ADC tap is from the lower junction. Zener is tied to the upper junction, using a higher Zener break point. The zener clamps the upper junction, and the divider using the lower two resistors will then keep the ADC input < 5V. The soft shoulder of the zener is then immaterial.

JC

DocJC wrote:
Correct me if I am wrong, but the "upper" resistor is in parallel with the "lower" resistor when you are calculating the impedance seen by the ADC pin.

This means that the impedance seen by the ADC pin will always be under 10K if you use a 10K "lower" resistor.

I'm not calculating the impedance "seen" by the ADC, The internal input impedance of the ADC is, which the manual states, 10K.

It is this input impedance that is in parallel with the "lower" resistor, R2. the divider, R1 and R2 are in series.

I'm using this calculator,
http://hyperphysics.phy-astr.gsu...

I can always switch it to R1 = 37K and R2 = 25K, haven't had a chance to test it yet, but that gives me a lower power dissipation.

Don't Let the smoke out!

I suspect you are mis-interpreting this.

I believe the SOURCE driving the ADC is suppose to have an impedance of <= 10K. The higher the impedance of the source driving the ADC, the longer it will take to charge up the internal capacitor of the internal sample and hold.

I do believe there is a typo in the Atmel data sheet(s), in the ADC section. I think the word "slowly" should be "rapidly" varing signals, since this....

But this is not the point being discussed.

For the Atmel ATMega 328P, as an example, Section 21.6.1 says:

Quote:
The ADC is optimized for analog signals with an output impedance of approximately 10 kÎ© or
less. If such a source is used, the sampling time will be negligible. If a source with higher impedance
is used, the sampling time will depend on how long time the source needs to charge the
S/H capacitor, with can vary widely. The user is recommended to only use low impedance
sources with slowly varying signals, since this minimizes the required charge transfer to the S/H
capacitor.

Have another look at it and see what you think.

JC

DocJC wrote:
I suspect you are mis-interpreting this.

Quite Possibly, but thats why I am here :P

So, am I to understand then that the resistor that is used to take the V reading across should be less than 10K?

In a similar project with a different processor, I can input 0 to 10 volts with a 20K input impedance. the divider consist of 3 29.4K Resistors. Taking the reading across one 29.4K resistor gives me ~0-10 volts on the input. It is quite accurate. I know this is apples to oranges, but I'm hoping to apply the same principal here.

Thanks

Don't Let the smoke out!

Jassper wrote:
DocJC wrote:
I suspect you are mis-interpreting this.

Quite Possibly, but thats why I am here :P

So, am I to understand then that the resistor that is used to take the V reading across should be less than 10K?

No. It means the voltage divider output impedance (both resistors in parallel) should be 10k or less.

For example, if you divide by 2, you can use two 20k resistors which would make the divider output impedance to 10k. Basic circuit theory, Thevenin etc..

For the ADC, the input is definitely not 10k. You could approximate the ADC input DC impedance as infinity or 1Mohm - almost nothing. But the way the measurements are made by charging a capacitor at high frequency, the output impedance of something you are measuring should be 10k or less.

The attached pic shows what I am trying to do.

The resistors are in series, however R2 will be seen in parallel with the AVR.

To calculate the values for R1 and R2, I'm looking for the resistance - if any that will be in parallel with R2.

Some say it is 10k - some say it is infinity - some say it is almost nothing. ???

If it is negligible, then the 25k and 4.7k should work. I'll be able to test it closer to the weekend.

## Attachment(s): pic.png

Don't Let the smoke out!

There is no resistance parallel to R2 anywhere and there should not be. You are mixing two completely separate things, one is the ADC input and one is the output of the voltage divider.

The ADC input impedance at DC voltage can be thought as infinite or 1Mohm however you like, it is not 10k!

The way it does measurements from anything requires the output impedance of the measured thing to be less than 10k or it will be inaccurate.

You can divide by six any way you like, but as you propably know, 1 ohm and 5 ohms are bad values as they cause too much wasted current, but also 1 Mohm and 5 Mohms are bad too, because the values are too big for the ADC to read reliably.

10k and 50k will keep the ADC happy, as the impedance (total resistance) seen by the ADC is 10k and 50k in parallel, 8.3k in fact. Don't put 20k and 100k there as they are too big. 4k7 and 25k should will work fine, putting divider output impedance to tad less than 4k and divides by 6.3, close enough.

Don't let the smoke out like you say :)

Edit: like you said in your post, regarding the 30V input, the resistors are in series, but regarding the ADC input, both resistors are in parallel to each other (Mr. Thevenin says voltage sources have zero output impedance so they are short circuits making the resistors parallel in calculations).

Jepael wrote:

Edit: like you said in your post, regarding the 30V input, the resistors are in series, but regarding the ADC input, both resistors are in parallel to each other (Mr. Thevenin says voltage sources have zero output impedance so they are short circuits making the resistors parallel in calculations).

Ahh, :idea: thats the point I was missing in all this - ok, things said earlier make much more sense.

THANKS!

I'm a bit thick in the skull some times - so it takes a wack with a 2x4 once in a while.

Don't Let the smoke out!