Go Down

Topic: Analog pin problems (Read 7865 times) previous topic - next topic


Sep 14, 2011, 02:48 pm Last Edit: Sep 14, 2011, 08:54 pm by Coding Badly Reason: 1
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.




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.
Send Bitcoin tips to: 1G2qoGwMRXx8az71DVP1E81jShxtbSh5Hp


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
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]


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?
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.


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.
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]


Thanks but what does low impedance voltage source mean?


Sep 15, 2011, 05:32 pm Last Edit: Sep 15, 2011, 05:38 pm by eddiea6987 Reason: 1
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
I could print the Arduino logo on a box of cereal and sell it as "Arduin-O's"


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.
I could print the Arduino logo on a box of cereal and sell it as "Arduin-O's"


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!

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131