Interaction between two Analog Inputs

Hi, I'm using two analog inputs on my Uno project.

One (A1) is wired to the wiper of a 10-turn preset potentiometer (5K linear) strapped to the 5V rail.

The other (A7) is connected to the centre-point of two 4M7 resistors, strapped to the VIN rail, which is 9V. This should give me a nice clean 4.5V input when VIN is 9V, and give me a much lower voltage when the 9V is not present.

The intention is to use A7 to detect that the board is using external power from VIN, rather than drawing from the USB connection (FYI a loud buzzer is inhibited if only USB power - for debugging and testing purposes).

I can get the A7 monitoring set-up correctly, and it works fine, but if I vary my project setpoint on A1, the reading changes dramatically on A7, upsetting my voltage monitor.

Any ideas why A7 is varying when A1 is altered ?

Perhaps a simple circuit diagram would explain what you mean by "strapped to a rail" because it's not clear to me where anything is connected.

Steve

By "Strapped to", I meant simple voltage dividers.

The pot feeding A1 from its wiper has the other two ends connected to +5V and GND.

The voltage monitor feeding A7 has the other two ends connected to VIN (+9V) and GND.

I'm beginning to think it has to do with input impedance of the analog inputs, and my 4M7 resistors making my potential divider on VIN are way too high a value.

Analogue inputs should see a source impedance <=10kohm (Atmel datasheet).
It takes to long for a high impedance (2*4.7Meg) divider do equalise the internal A/D sampling cap.

The solution is to add a 100n cap from A7 to ground.
Read the analogue input(s) twice (and use the second A/D value) if that does not fully fix the problem.
Leo..

I've changed the two 4M7 resistors making up the potential divider on the voltage monitor to two 2K2 resistors, and the problem has gone away.

Thanks Wawa for the detailed explanation, I'll keep potential dividers at around 5K rail-to-ground from now on, much simpler than adding caps.

The disadvantage of those low values is the higher current leakage. That is an issue when you're working with batteries, especially low-power batteries like 9V blocks. Using 10k+10k would work great, too, and already cut the current significantly. The 2x4M7 plus cap (don't know what makes it so hard to add one) would save even more precious electricity.

For really precise readings, remember to carefully measure the actual value of that voltage if using regular 5% tolerance resistors (you can be up to 10% off for the mid voltage).

wvmarle:
The disadvantage of those low values is the higher current leakage. That is an issue when you're working with batteries, especially low-power batteries like 9V blocks. Using 10k+10k would work great, too, and already cut the current significantly. The 2x4M7 plus cap (don't know what makes it so hard to add one) would save even more precious electricity.

For really precise readings, remember to carefully measure the actual value of that voltage if using regular 5% tolerance resistors (you can be up to 10% off for the mid voltage).

Neither power consumption or accuracy is important. I just need to know that the VIN supply is absent, so can kill the alarm buzzer when running tests.

9V across 2 x 2K2 resistors is only 2mA - I can live with that....