Pages: [1]   Go Down
Author Topic: ADC interference when switching between ports?  (Read 2331 times)
0 Members and 1 Guest are viewing this topic.
South Africa
Offline Offline
Newbie
*
Karma: 1
Posts: 46
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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...


* Double signal.png (41.42 KB, 836x581 - viewed 42 times.)

* Single signal.png (38.2 KB, 836x581 - viewed 40 times.)
Logged

New Jersey
Offline Offline
Faraday Member
**
Karma: 67
Posts: 3675
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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:

Quote
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.
Logged

South Africa
Offline Offline
Newbie
*
Karma: 1
Posts: 46
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

@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...
Logged

New Jersey
Offline Offline
Faraday Member
**
Karma: 67
Posts: 3675
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

California
Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Rapa Nui
Offline Offline
Edison Member
*
Karma: 60
Posts: 2071
Pukao hats cleaning services
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: August 01, 2012, 04:19:15 am by pito » Logged

Pages: [1]   Go Up
Jump to: