GetADC error and adjacent pins

Started by Tom Becker September 21, 2004
I've seen a number of comments that suggest interaction of digital and
analog neighboring pins but which offer no explanation nor a solution
other than reassigning the pins - if that works.

It appears that the culprit is sourcing current to digital outs, like an
LED. If the pin provides current, the internal ADC reference is
apparently pulled down. This causes GetADC to provide a larger than
expected value, in my case, by 14%.

The solution is simple; don't source current from the BX-24 outputs -
sink it, instead. If the LED current is provided externally, like
through a resistor from Vcc, the output pin logic must be inverted, of
course, to sink the LED current to ground when it's on. This way, the
internal reference source is not involved and is not affected. Tom
Tom Becker
--... ...--
www.RighTime.com
The RighTime Clock Company, Inc., Cape Coral, Florida USA
+1239 540 5700



Yes, this is correct.

If you look at the schematic of the BX24, you will see +5VDC supplied
through a series resistor and a shunt C. This provides a filter for
the A/Ds Vref.

Unfortunately, Vref is also the Vhi for this port. Thus, any
sourcing of current on this port will cause Vref to sag.

Thus, use this port for inputs or for sinking current.

Best wishes.

PHAnderson
http://www.phanderson.com/basicx/

--- In , "Tom Becker" <gtbecker@r...> wrote:
> I've seen a number of comments that suggest interaction of digital
and
> analog neighboring pins but which offer no explanation nor a
solution
> other than reassigning the pins - if that works.
>
> It appears that the culprit is sourcing current to digital outs,
like an
> LED. If the pin provides current, the internal ADC reference is
> apparently pulled down. This causes GetADC to provide a larger than
> expected value, in my case, by 14%.
>
> The solution is simple; don't source current from the BX-24
outputs -
> sink it, instead. If the LED current is provided externally, like
> through a resistor from Vcc, the output pin logic must be inverted,
of
> course, to sink the LED current to ground when it's on. This way,
the
> internal reference source is not involved and is not affected. > Tom >
> Tom Becker
> --... ...--
> GTBecker@R... www.RighTime.com
> The RighTime Clock Company, Inc., Cape Coral, Florida USA
> +1239 540 5700





> ... +5VDC supplied through a series resistor and a shunt C. This
provides a filter for the A/D's VRef...

Indeed, and further, from page 65 of the Atmel AT90S8535 PDF: "Note
that since AVCC feeds the Port A output drivers, the RC network shown
should not be employed if any Port A [pins] serve as outputs."

That means the 100ohm series resistance, in particular, since the cap
will otherwise have little effect. In my case, a 7mA load (two 1k-ohm
limited optocoupler LEDs in parallel) pulls the nominal 5v AVcc down
0.7v through 100ohms, or 14%, which is exactly the error I see.

I do not recall reading this qualification in the BX-24 docs, but using
GetADC when any PortA pin supplies any significant current will result
in a conversion error; just 1mA of sourced current will result in a 2%
error. If some combination of PortA pins supply current and the pin
states vary during GetADC conversions, the results will be highly
variable. Tom
Tom Becker
--... ...--
www.RighTime.com
The RighTime Clock Company, Inc., Cape Coral, Florida USA
+1239 540 5700