1

So I am building a project that uses the analog pins for precise measurements of resistance through a voltage divider and I have been having some seemingly unsolvable problems with nonlinear response to linearly changing resistances when using the A0 pin to measure.

I first realized this was the problem when I had a voltage divider consisting of a 76.8K and 100K 1% resistors with Vout connected to A0, and I was consistently getting wrong values. I measured the output voltage of the voltage divider and got 1.7V, instead of the ~2.7 volts I should be getting with my supply. When I disconnected the wire to A0, the voltage rose to the expected level.

I disconnected power and measured resistance between the analog pins of the Atmega328 I was using and ground and found that A0 had 220K of resistance, while all other pins measured as infinite. When using the other pins, the voltage divider returned the expected values and was able to measure a wide range of resistors with values just as accurate as my multimeter. I know I have changed a lot of low-level things with code (analog reference, the comparator, ADC clock prescalers, using analog pins as outputs, etc.) but I don't think any of this could persist while the chip is not powered on. Does doing any of these things connect a resistor in the way I was describing, and is there anything that could cause this to stay "stuck" this way?

  • The datasheet says: The ADC is optimized for analog signals with an output impedance of approximately 10 kΩ or less - your voltage divider of 76k and 100k does not appear to satisfy those requirements. – Nick Gammon Apr 28 '16 at 10:39
  • Try adding a small capacitor between the voltage you try to measure and ground. – Gerben Apr 28 '16 at 13:32
  • @NickGammon The voltage divider's impedance does not seem to be an issue, as it works perfectly on pins A1-A5 with a wide range of resistor values as the one being measured. The question is asking why there is the internal 220K resistance to ground that is causing it to work incorrectly on analog pin 0. – 3871968 Apr 28 '16 at 17:23
  • This is a raw chip is it? Not on some board? Try another chip, maybe this one is faulty. – Nick Gammon Apr 28 '16 at 20:40
  • Yes, it is a raw chip. I will try another one soon. – 3871968 Apr 28 '16 at 21:38
1

They don't connect a resistor as such, but analog input pins do have an impedance which can affect your readings.

If your output impedance (the resistance of your resistors) is within about a tenth of the impedance of the input pin then you will (and have) noticed skewing of the results. This is normal. The input impedance is somewhere in the region of 1MΩ - 10MΩ.

You have to keep your output impedance to a value below the order of a few tens of kΩ to minimise the effect the measuring of the value has on the value.

If you want to measure higher resistances then you will need to buffer the voltage with a very high impedance op-amp buffer.

Incidentally, your volt meter probably has an input impedance in the region of 10GΩ - around 1000x higher than the Arduino's ADC.

  • This does not answer the question. I am not experiencing skewing of the results as you said when I use any pins except A0. In fact, when using the other pins I can read a resistor and match the value my multimeter gives me. The question is asking why my Atmega has 220K of internal resistance between A0 and GND, but not any other analog pin. – 3871968 Apr 28 '16 at 17:18
  • It may be a faulty chip. I have never experienced differences between the different analog pins. Nevertheless, you should watch that impedance and keep it within the specifications of the input pin. – Majenko Apr 28 '16 at 20:51
  • It's also worth noting that the primary load impedance of an ADC is not something you can measure with the power off. In fact on some chips (though perhaps not the ATmega) it actually changes depending on the ADC clock rate, and can become a rather heavy load at the higher ones. What resistance an ohm-meter will see on a pin of an unpowered MCU depends in part if the test voltage is high enough to bias the protection diode into a measurable degree of conductance, and also on the test polarity. – Chris Stratton May 28 '16 at 19:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.