Electronic – arduino – Why does adding an analog input change the voltage in this circuit

analogarduinoresistors

I have an Arduino and am trying to measure the voltage across R1. To do this I am connecting SW1 to an analog input. Using a multimeter I measure the voltage across both R1 and R2 to be 1.56V which is what I expect.

However, when I close SW1 the voltage across R1 jumps to 1.83V – why is this?

schematic

simulate this circuit – Schematic created using CircuitLab

Best Answer

You have a very high source impedance (we normally keep this quite low).

The AVR ADC input has this general structure: AVR ADC input

There will be some leakage current flowing either in or out of the pin and the total leakage is represented by I(ih) and I(il); assuming I(ih) is larger than I(il), then some extra current will flow into the lower resistor, thereby raising the voltage you measure.

In this case, that extra current looks like 270nA, a not unexpected value.

High source impedances are a well known source of ADC errors.

Note that connecting a high impedance source to an analogue input that has some leakage (and can be in either direction, generally specified as +/- something, usually in the order of microamps) will change the voltage you read across the resistor to a higher or lower voltage, depending on whether the effective leakage is sinking or sourcing current.

I would recommend this thread to understand the pain input leakage current can cause.

As noted, you can use a buffer amplifier to go from a high impedance world to a low impedance one (preferred in ADCs), but you need to ensure that the input offset current (the analogue of leakage current above) is low enough such that

R(source)*I(offset)

does not cause a significant error.

Most rail to rail input amplifiers have a dual input stage, but the input bias current is usually significantly different across the input stages; input offset current is usually directly related to input bias current. This simply means you need to be careful in the selection of such a buffer amplifier.

Another excellent reference on input bias current.