I'm building a MIDI guitar, using an Arduino, sound synthesising and wood.

To properly know which note I'm pressing, I built a voltage divider with 12 equal resistors (10K). One side is connected at +5V and the other end at GND, so each of the 6 strings connects the right tap to the ADC. I had just calculated the expected value w/ a bit of math considering I also needed a pullDown resistor(1M) and capacitor for every analog channel to keep the readings stable when no key is pressed.

When measuring with my multimeter the readings are stable, and there are variations of less than 0.02V, and since the difference from tap to tap is about 0.4V that's quite good.

The problem is when reading the 6 channels together: channels supposed to be pulled down to gnd read voltages caused by nearby channels, readings are shaky and similar errors.
This mess disappears on one channel when I connect the multimeter to that one. Instead of buying 6 multimeters, I figured I could ask you if someone has an idea on why this happens, my guess is on the pulldown resistor, but I'm not sure about Arduino's ADC; I'm also worried about having 6 wires half of a meter each so close, so any other idea on finding the keys is welcome.

EDIT
@EdgarBonet was right, I used 12x220ohm resistors, and at first the results were absolute garbage, then I made it so the code would read each channel about 10 times, discard the readings, wait a millisecond and finally read and store the value. Now it is perfect. Thanks again.

• Circuit link doesn't work. Sep 4, 2016 at 13:42
• Excuse my naiveté but... why 12 taps for 6 strings? And why can't you wire those switches the usual way into digital inputs? Sep 5, 2016 at 7:41
• @EdgarBonet each string makes 12(+1 open) notes, and there are 6 strings; this means 72 inputs. That's too many switches Sep 5, 2016 at 7:49
• Oh, I see. Your circuit now makes perfect sense to me. You could simply reduce the resistances, e.g. R1 = ... = R12 = 1 kΩ and R_PD = 10 kΩ. Sep 5, 2016 at 8:12

The datasheet of the ATmega328P (the main chip of the Uno) states:

The ADC is optimized for analog signals with an output impedance of approximately 10 kΩ or less.

The Thevenin equivalent output impedance of most taps of your voltage ladder is higher than 10 kΩ. You 1 MΩ pulldown is way beyond that limit. Cross talk from previously read channels is exactly the symptom you expect from excess output impedance.

Taking each reading multiple times, until the value stabilizes, should help. A buffer (e.g. an OP-amp set as a unit gain amplifier) is the usual solution to this kind of impedance problems.

Actually, the whole works perfectly with R as 220 and pull downs as 10K. The problem comes when connecting more than 3 strings at the same time, on any tap, as the pull down resistors become part of the ladder (i belive).

The pull down resistors will indeed have an effect on the potentials of the voltage ladder, especially if you connect several strings. This could be minimized by having the pull-downs be a lot more resistive than the resistors along the ladder, but then you would need very low resistances along the ladder, which is not desirable because of current consumption and heating.

Here is an idea for an alternative solution: If you can spare 6 digital pins, you could build for each analog input a pull-down circuit that is switchable between a “strong pull” mode and a “weak pull” mode. Assuming D0 is the “pull strength control” pin for A0, it would look like this:

``````A0 ---+--- 1 kΩ --- D0
|
1 MΩ
|
GND
``````

Whenever you want to read A0, you:

• set D0 to `OUTPUT` `LOW`, which creates a strong pull-down to ground
• take a couple of analogRead()s
• set D0 as `INPUT`, which leaves only the weak 1 MΩ pull down
• take a couple of analogRead()s, keep the last one.

If A0 is not connected to the ladder, then the first reads will discharge the internal sampling capacitor of the ADC. The final read is done with only a weak pull-down, but this should be OK since the capacitor has already been discharged.

The potentials along the voltage ladder will be disturbed by any string connecting a tap to its strong pull-down, but this disturbance will disappear when you switch to weak pull-down, so it will not affect the readings.

• I'm well open to changes in the circuit, and I used the first resistors I had. Sep 4, 2016 at 19:27
• Actually, the whole works perfectly with R as 220 and pull downs as 10K. The problem comes when connecting more than 3 strings at the same time, on any tap, as the pull down resistors become part of the ladder(i belive). Would raising R from 220 to 1k ohm solve anything? Sep 5, 2016 at 22:11
• @sassoPera: Connecting several pull-downs to any tap will indeed affect the potentials along the ladder. Raising R can only make this worse. See the amended answer. Sep 6, 2016 at 9:09