Analog pin problems

The idea of this project is to build a modular synth interface working with arduino. The idea is to connect DC sources with different voltages to the analog inputs. The inputs read the value and send it through serial connection to the computer. It is vital that when nothing's connected to the an analog input, it should measure zero voltage (I check the state of analog pins on the Arduino IDE serial monitor). Hence I connected the inputs to the ground. In practice the analog pins measure zero when nothing's connected. However, when I connect a voltage source, other pins start measuring random values. For instance, if pin 0 is connected, it measures 856 and other pins measure fraction of this value at the same time... Why? How can I isolate the pins from each other? It is paramount that all pins read correct values! I have a feeling that the problem is somewhere with the connection to the ground. Any help would be appreciated!

Moderator edit: duplicate posts merged.

https://picasaweb.google.com/lh/photo/j14psrgmnOSBSx0ECvyIjQ?feat=directlink

There is only one A/D converter in the ATmega and it's shared through a multiplexer and sampling capacitor. If the input signal has an impedance higher than 100k the capacitor doesn't discharge in time when you switch inputs. Try connecting all the inputs to ground through 100k resistors. That should not cause problems with a voltage source but should cause the unconnected pins to read 0.

In fact it is not correct that an unconnected pin always reads zero. In electronics, an unconnected analog or digital pin (which has no pull-up or pull-down) has an undefined state. The value may be any value, and it may change in time, either many times per second or just once every 10 years. Take the "undefined" word literally.

Try something like 100k pulldown and 10nF decoupling to reduce noise - the input voltages are supposed to be basically DC so a capacitive load shouldn't be a problem.

Not only are the analog inputs high input impedance, they are effectively infinite input impedance at DC due to the nature of CMOS - thus e.ven a weak pulldown like 100k should have a dramatic effect. For AC the capacitor should reduce pickup substantially

Fast sampling might still cause an issue if adjacent pins have different levels on them - typical solution is to read the input twice & use the 2nd result.
How fast do you need to sample?

Thanks for the answers! The sampling needs to be pretty fast since it's a modular synthesizer interface. When you make a connection with the patch cable (for instance, LFO to oscillator frequency), the user should hear the result instantly. I will try the pull down resistor and the capacitor! I also thought about adding a feature in the code that checks if the read value changes over time but that wouldn't help. Unfortunately the 'noise' on the other pins doesn't change. It's just appears as a different value. For example, if a DC source is 568 and is connected to pin 1, pin 0 and 2 will measure 57 and 129 (these ara not exact values obviously). Thanks for the help!

The crosstalk between channels happens when switching between channels in a high-impedance circuit, shouldn't be a problem if low-impedance voltage source connected.

Thanks but what does low impedance voltage source mean?

according to my book :

when output impedance is small a relatively large output current can be drawn from a devices output without significant drop in in output voltage.

When the output impedance is large a relatively small output current can be drawn from the output of a device before voltage at the output drops substantially.

A rule of thumb for efficient signal transfer is to have an output impedance that is at least 1/10 of the loads input impedance to which it is attached.

Now i do not know what half of that means or how one would go about measuring this impedance, it seems like in a very simple simple way its the resistance "outward" being that high impedance lowers current output.. so yeah maybe you can decipher that better then i.

UPDATE: dam! i think it just clicked, so if i have a million things in a circuit all taking a chunk out of its current then furthermore if i try to output something it will be at a very low current since it is all being used up... interesting

It turns out to be pretty easy to measure source (or output) impedance. You need only a variable resistor (like a pot) and a volt/ohms meter. Measure the unloaded output voltage from the mystery source. Then attach a variable load (your pot) across the output and increase the load until it is 1/2 the open circuit (unloaded) voltage which you previously measured. Then disconnect the pot and measure the resistance. That resistance is equal to your source impedance.

The principle is that you are forming a voltage divider. The "top" resistor in the divider is the mystery source impedance, and the "bottom" resistor is your pot. When the voltage is 1/2, then the two resistors are of equal value.

Of course, if you are measuring something at the extreme ends of the spectrum, conventional parts and techniques don't apply. So measuring the source impedance of a guitar pickup or a car battery can't be done using this simple scheme.

if i could pay you for posting that i would, thanks for that.

The voltage sources are trimpots (see the link I posted earlier) connected to the VCC pin.

Fantastic! Will give it a try! Thank you for all your help, guys!

Wow, that worked! However pin 3 reads nothing, even when connected but I guess that must be a contact trouble or breadboard issue. Guys, thank you sooooooo much!

BTW, 100 K potentiometer and resistor was the solution! Again, big thanks!

Since my last post I've been experimenting with different pull-down resistor and pot values. Unfortunately, whatever resistor I use the connections effect each other. I came to the conclusion that I have to break the connection between the pull-down and the analog pin the moment I connect a voltage source. Alas, I tested the concept on the breadboard and it works (I simply removed pull-downs from the connected analog pins). I wonder, is there a plug socket that breaks the existing connection between the pull-down while creating a new connection? Or should I add a transistor switch driven by the voltage source inserted?

When switching analog inputs quickly, SOP is to sample the new pin twice and ignore the first read.

alkopop79:
I wonder, is there a plug socket that breaks the existing connection between the pull-down while creating a new connection?

Yes. Many mono and stereo phone jacks (like for headphones) have a switch which opens when you plug in a cable. In normal use this disconnects the speaker(s) when you plug in headphones but can be used for your pull-down resistors.

Brilliant! Thanks!

Unfortunately, whatever resistor I use the connections effect each other.

That is because the values you are using are too large.
If the impedance of anything fed into the analogue inputs is greater than 10K, there is not enough time to charge the sample capacitor before the sample is taken.
So can you lower your impedance?
Your solution of shorting it out will only result in you not getting the right value the first time you take the reading although you might miss this.