## A/D equation

6 posts / 0 new
Author
Message

Hello,

In most AVR datasheets (at least those i have read), the A/D result equation is:

ADC = (Vin * 1024) / Vref

If Vin = Vref then the ADC result, according to the above equation, is ADC = 1024 which is not correct.

Is there something i'm missing or it is a known datasheet error?

Copied the text below from ATmega8 datasheet page 205:

Quote:
where VIN is the voltage on the selected input pin and VREF the selected voltage reference
(see Table 74 on page 206 and Table 75 on page 206). 0x000 represents ground,
and 0x3FF represents the selected reference voltage minus one LSB.

This is valid for all AVR devices.

Regards
Sebastian

Hello,

Still i don't get it. I mean isn't the same to use the equation:

ADC = (Vin * 1023) / Vref

The reference voltage is divided in 1024 parts
but the max. value the ADC can measure is LSB * 1023.

Example:
Vref = 2.048V
-> LSB (0x0001) = 2mV
-> max ADC value (0x03FF) = 1023 * LSB = 2.046V

Any ADC input voltage higher than 2.046V gives
the same result = 1023 (0x03FF)

since the ADC starts counting at 0.

Regards
Sebastian

The 1024 is technically more correct, though perhaps you should use 1023.999... Using 1023 you are saying that the ADC will be 1023 only if Vin is exactly equal to Vref. In reality, it will read 1023 when Vin is 1023/1024ths of Vref and above. To say it another way, Vref is divided into 1024 equal steps. The first step in 0-0.999, the last step is 1023-1023.999.

Edit: Sebastian beat me, but we are saying basically the same thing.

Regards,
Steve A.

The Board helps those that help themselves.

Hi,

@Koshchi.
I think you and sebastian are correct.

in my eyes the upper and the lower limit is something like infinite/not_known.
All steps are equal in analog voltage size = VRef/1024 but:
* Step "0" has input range from -??V to VRef/1024
* Step "1023" has input voltage range from VRef * 1023 / 1024 to ??V

Klaus
********************************
Look at: www.megausb.de (German)
********************************