ADC interference when switching between ports?

I’m playing around with the ADC on an Uno board. I use a 555 IC with 50% square wave configuration as test signal. When logging two channels at a time (555 output and capacitor voltage), I get a nice plot, see double signal figure. The square wave (green trace) has nice flat tops. If however I only log the 555 output, the tops of the square wave trace looks as if it slants a bit. It therefore seems as if the shape of one measured signal depends to some extend on signals on other analog ports being measured. If more than one analog port is selected for logging I alternate the ADC between the ports, i.o.w. the ADC is cycled through the selected ports. I have varied the ADC clock prescaler but see the same effect at different prescaler values.

Any explanation for this? Which signal shape is the more accurate one? Unfortunately I don’t have a real oscilloscope to use as reference…

It therefore seems as if the shape of one measured signal depends to some extend on signals on other analog ports being measured.

It does (in some circumstances). There is only one ADC, shared between the analog pins. The result is that one reading can be impacted by the last. A common workaround is to read twice, ignoring the first reading. When I posted something like this recently, Grumpy Mike added this:

That is only true if the input impedance to the ADC is significantly higher than 10K. Keep it at 10K and you can sample at the maximum rate.

@wildbill: I am playing around with (yet another) oscilloscope application, so I'm not too keen on dropping 1/2 of the measurements.

It seems as if the impact of measuring other signals on different channels disappear if I add a resistor (1 MOhm) between the output pin of the 555 timer and ground. I can then take successive readings of the 555 output and either 5V or ground on another channel without seeing any drift or funny shapes of the 555 output.

I guess the next step is to use a voltage follower to buffer the signal to the analog pin since this sounds like a high output impedance problem of the 555 output pin? Perhaps a better test signal would be to use a digital output pin of the Arduino itself...

Now you're turning to the dark side. You need the hardware folks to help you - I'm going to have to punch out - good luck.

For results of an investigation on the accuracy of an ATmega328 ADC, have a look at the ATmega328Accuracy project, located with LXARDOSCOPE at Sourceforge. Some of the results shown are for two channels sampling close to 3kHz. Maybe you can use the preamplifier shown in the report ATmega328Accuracy.pdf for achieving an oscilloscope style input impedance of 1MegOhm as a buffer between the ATmega328 and the circuit you want to measure.

The ADC uses a Sample and Hold (S/H) capacitor (14pF) sourced from the input pin via an internal resistor. The S/H capacitor must be fully charged to the voltage you measure, in order the measurement be accurate. This means not only charging the capacitor, but also discharging it. This happens through the internal resistor AND the impedance of the source of the signal. So for example (with an assumption the internal resistor is small and the capacitor is grounded): a) if you measure on ADC0 a voltage of 3Volts and the source impedance is 1kohm and you switch to ADC1 with 0.2Volt and source impedance 30kohm, the S/H capacitor must discharge itself from 3V to 0.2V via 30kohm+ b) in an opposite directon (when you switch from ADC1 to ADC0) - it must charge itself from 0.2V to 3V via 1kohm+ impedance. So you may see the charging/discharging processes inside, how they differ in timings (in this example it takes 30x longer to discharge when switching from ADC0->ADC1, not considering the internal resistor). The charging/discharging timing follows k*R*C rule.

Therefore you have basically 2 options: 1. wait long enough until S/H charges or discharges (for all possible source impedances and voltage differences combinations) and then make the AD conversion 2. use input buffers (ie rail-rail opamps) with low output impedance (typically ~10ohm) thus the charging/discharging runs faster. Even so you have to consider the internal resistor charging the S/H capacitor, though. p.