Page 1 of 1

AtMega328p A/D inaccuracy

PostPosted: Fri Jun 23, 2017 2:55 am
by yamadanao
I'm getting A/D readings from an AtMega328p chip that are about 10% higher than I can read on the input signal with a meter.

I'm measuring room temperature with an LM34CZ Fahrenheit temperature sensor (10mv/degF) output. The sensor has a 5v supply. The chip is running on 3.3 volts derived from the same 5v supply with an LM1117 regulator, but the crystal a 16MHz one which is out of spec for the chip (Fmax at 3.3v is about 12MHz). The chip is otherwise apparently running properly and has done for hours to days at a time. I've checked both supplies with a meter - they're within mV of where they should be.

Here is the date sheet:http://www.componentschip.com/details/Atmel/ATMEGA328P.html


The A/D is using its internal 1.1v reference with an external .1uF cap from AREF to ground. The sensor and chip grounds and the two supply grounds are all common. The analog signal from the sensor has maybe a 2cm run to the A5 input pin on the chip.

Acknowledging that I'm using a part out of spec, does anyone see a plausible reason for the A/D to read high in this circumstance?

Update: To those wondering why I'd expect a device, operated out of spec, to yet perform to spec, I held no such expectation. I was prepared for anything from instability to a totally non-functional device. That it runs at all, let alone stably, is a pleasant surprise. Given that, I thought it useful to look for a slightly better explanation for the errors than "Beyond here there be dragons". Dragons there may be, but this time at least, they seem to have held their fiery breath - the issues lay elsewhere, specifically, with the sensor.

Re: AtMega328p A/D inaccuracy

PostPosted: Wed Jul 05, 2017 4:33 pm
by rickj
In most A/D converters, there is a maximum clock rate which is set to allow adequate settling time in the converter analog circuitry. If you violate this maximum, as you seem to be doing, the results from the ADC will naturally be erratic. It would not even be wise to rely on the discrepancy being constant, either as a voltage offset or as a proportion of full scale.