Murray State University School of Engineering CourseWiki

Analog-to-Digital Conversion

Relate an Uno R3's 10-bit ADC reading to its reference voltage, step size and approximate sampling time.

Ten bits give 1024 codes, numbered 0 through 1023

Ten bits give 1024 codes, numbered 0 through 1023

An analog-to-digital converter (ADC) samples a voltage and reports a number. The classic Uno R3 has a 10-bit ADC: 210 = 1024 possible codes. analogRead(A0) reads analog input A0 and returns an integer from 0 to 1023.

The reference voltage sets the scale. With an assumed exact 5.000 V reference, one nominal step is 5/1024 = 0.0048828125 V = 4.883 mV, or about 4.9 mV. Resolution describes the step size; it does not guarantee that a real voltage measurement is accurate to that amount.

Arduino's resolution and timing figures

The official analogRead reference source gives “5 volts / 1024 units” and “about 100 microseconds (0.0001 s)”. That is roughly 10,000 reads per second on ATmega-based boards using the usual API, not an absolute ADC hardware limit or a guaranteed loop rate. Computation, communication and delays take additional time. The published analogRead reference is the learner's API lookup.

Use 1024 for the nominal voltage step

Use 1024 for the nominal voltage step

For these exercises, use a clearly defined ideal bin model: divide the 0–5 V span into 1024 equal bins, round down to the bin number, and limit the top code to 1023.

code = min(1023, floor(Vin × 1024 / Vref)). Here floor means round down. At 3.000 V with a 5.000 V reference: floor(614.4) = 614.

To report the nominal voltage represented by a code, use its lower bin edge: V = code × Vref/1024. Code 800 represents 800 × 5/1024 = 3.90625 V. In this model its bin extends up to, but not including, 3.9111328125 V.

Why dividing by 1023 answers a different question

There are 1024 codes but only 1023 intervals between code labels 0 and 1023. Multiplying by 5/1023 stretches those endpoints to exactly 0 and 5 V; that is endpoint scaling, not the nominal ADC step. The explorer and practice consistently use 1024. Real converters have transition offsets, noise and reference error; their exact thresholds are not predicted by this classroom bin model. A code cannot recover the original voltage exactly.

Explore the steps and check the units; Practice

Explore the steps and check the units

The two-way ADC controls in the PWM and ADC explorer let you enter a voltage or a code. Try nearby voltages within one bin, then cross its boundary. In reverse, code 1023 gives 4.9951171875 V as its lower edge, not proof that the input equals that value.

The same explorer also separates when a voltage is sampled from how its code is calculated. It shows instantaneous raw PWM or settled RC values, the finite mean of the selected point samples, and the mean of their reconstructed lower-edge voltages. Those are different from the waveform's complete-cycle time mean. A held code is the latest point result, not a window average.

Quantize first or average first?

ADC conversion floors each individual ideal sample into a bin. Averaging the reconstructed lower edges therefore need not equal converting the analog sample mean. For a 25% raw 0–5 V sequence with one HIGH and three LOW samples, the analog sample mean is 1.25 V; the lower-edge reconstructions average 4.9951171875/4 = 1.248779296875 V. Neither operation recovers information between sample instants.

Practice converting a reading to volts

Practice sampling phase