I found this article interesting:

Basically, it looks into how the ADC was implemented and try to devise a formula closer to actual value.

I think the idea of the actual ACD was a binary search, according to this: Successive-approximation ADC - Wikipedia

The funny thing about this article is that it tries to prove that using this formula was wrong:

reading value / 1023 * 5

but instead using this:

(reading value + 0.5 ) / 1024* 5

In the article,

Reading value 736 for an input of 3.597V.

Let's see which one is closer:

Quote: " our reading of 736 gives Vmeasured= 736.5 * 5.000 / 1024 = 3.5962 Volts"

Using the "wrong formula":

736/1023 * 5 = 3.59726 volts

So which formula resulted in closer value? The "wrong one"!

Maybe for other values, the correct formula would handle it better?

I guess the author fumbled on that one

OK now you have started it. This argument has been ongoing for years with passionate arguments on both sides even though it, really, makes little difference.

Each value returned by the ADC corresponds to a RANGE of possible input voltages (about 5 mV per step in this case), not to any one value. So the detailed comparison is pointless.

Please, change/edit the title of the thread to: 10 bit ADC - divide by 1024 or 1023

In practice it makes no difference whether you divide by 1023 or 1024. But dividing by 1024 can be done much more quickly using a right shift.

```
dividedValue = originalValue >> 10;
```

...R

Why would one divide the 10-bit number from the ADC read by 1024?

@OP - show me your 5.0000V reference.

Now, ask yourself "does it matter?"

Also, why do 2.048V and 4.096V reference devices exist?

Thanks for all the replies.

I suppose they don't matter. I do agree with you all. Not to be argumentative, but for leisure discussion purpose. So if you bother entertain with this topic, please join.

A lot of engineering is pushing the envelope to the edge of limit.

I didn't know people discussed this before, and apologize for that.

For those questioning about reference voltage, that's a very good point. I use a regulated power supply, and with a "setting", the value can be measured, and entered into a box. That will be used instead of number "5.0". I probably can also measure the reference voltages itself as the config value.

For the second point of why? Well, if, say technically we can get a higher precision value, would I take it? Yes, I would, why? I don't know

Well, if, say technically we can get a higher precision value, would I take it?

You completely missed the point of reply #2.

Please don't take this too seriously.

What I meant to say, that "IF" it's possible to derive a closer value, using the existing capability. We can just say it's impossible.

From engineering school, this is done lots of time.

I think the simple answer would be to simulate (spreadsheet) the ACD with a values much higher resolutions, in increment. Then find out the output and input, and counts which method provides a closure approximation. Using statistics, we we maybe able to figure out. Or maybe it's almost even (approximate up or down).

To derive a more precise value from the existing ADC (more bits in the result), use oversampling and averaging.

The value returned by the ADC still corresponds to a RANGE of input voltages, but the procedure makes the RANGE of corresponding input voltages smaller.

Anyway, the correct answer to your title question is in the f. manual of the processor (controller) chip.

**1.** 1024 or 1023 does not matter; it is only 0.1% error; whereas, in practice we can go up to 2% error; but, the burning question (discussed many many time in this Forum) that remains is: what should be the division factor -- 1024 or 1023? Moreover, the ADC Module of ATmega328P has +/-2 LSB error in accuracy!

**2.** This is (Fig-1) the internal details (at conceptual/physical level) of the ADC Module of ATmega328P MCU.

Figure-1:

**3.** In theory, all the bits of the ADC (B9 - B0) will assume 1s (HIGH) when an analog voltage equal to V_{REF} (5V in Fig-1) is applied to any channel of the ADC. The Full Scale (FS) of the ADC (by definition) is 5V.

**4.** How much is weight for LSB (B0-bit) of the ADC? This is known as resolution.

resolution = 5V/(1x2^{9} + 1x2^{8} +, ..., 1x2^{1} + 1x2^{0})

==> resolution = 5000 mV/1023 ~= 4.89 mV.

**5.** Assume that the ADC's Bits are: B9 - B0 = 0110101010; how much analog voltage has been impressed into a channel of the ADC? (Let us forget the +/- 2 LSB error in accuracy.)

V_{IN} = (5000 mV/1023)*(0x2^{9} + 1x2^{8} +, ..., + 1x2^{1} + 0x2^{0})

==> V_{IN} = (5000 mV/1023)*426 = 2082 mV (2.082 V)

**6.** To attain higher/better resolution of 1.08 mV, we may use the Internal 1.1 V for the V_{REF} point of the ADC.

**7.** If we want exactly round figure (2 mV) for the resolution, we may use externally regulated 2048 mV voltage for the V_{REF} point of the ADC via the AREF-pin of the MCU (Fig-1).

**8.** Step-7 now convinces me that the division factor is ought to be 1024 and not 1023; henceforth, I will use 1024 in my computation formula.

groundFungus:

OK now you have started it. This argument has been ongoing for years with passionate arguments on both sides even though it, really, makes little difference.

The difference increases as the number of bits decreases. In this case (this particular ADC), there are usually many other factors that create more error than is created by this difference.

As explained above, 1024 is the correct scale factor.

aarg:

As explained above, 1024 is the correct scale factor.

If 1024 is correct, then 1023 should be incorrect which contradicts logical arguments of Post#15. Therefore, I would say that 1024 is the optimum scale factor.

And 1024 agrees with the data sheet.

Section 24.7:

ADC = (Vin * 1024)/Vref

Thus

Vin = (ADC * Vref)/1024

CrossRoads:

And 1024 agrees with the data sheet.

Section 24.7:

ADC = (Vin * 1024)/Vref

Thus

Vin = (ADC * Vref)/1024

Which means that if Vin = Vref the ADC is going to read 1024 (which would be a really neat trick and is one reason why the arguments will keep going on).

Steve

CrossRoads:

And 1024 agrees with the data sheet.

Section 24.7:

ADC = (Vin * 1024)/Vref

Thus

Vin = (ADC * Vref)/1024

thanks for extracting the info from datasheet.

The other GREAT part of these equations is the "Vref":

What is the "VCC" range (used for ref on a 328)?

What are the ranges of the ref bandgap diodes in a Mega?

Although 1024 is the correct answer, 1023 or 1024 is negligent in respect to "error" introduced by above mentioned ranges.