# Need better understanding of analog pins - resolution and voltage steps

Hi,

I'd like to understand "bits" and "steps" more regarding the analog pins on the Arduino UNO board.

As I understand, the A0-5 pins are each 10 bit, and range from 0-1023 in values (steps). To get the individual voltage per step for 5V, it's 5V / 1024 ~ 0.0049V per step. That is, if I used a potentiometer and attached the power to 5V, I could have a max resolution of about 4.9mV per step.

So 2 questions:

1. What does "10 bits" or "10 bit resolution" actually mean for an analog pin? How is the number 1024 arrived at?

2. How would I calculate the number of volts per step for a 3V supply on a potentiometer? What I think it is: 5V is about 1/3 larger than 3V, so I'd multiply: 1024 * 2/3 = 683 steps, so 3V / 683 = 4.39mV per step.

I think this means that the accuracy of each step is better for a device powered by 3V vs 5V, but a trade off is that there are less total steps with 3V. Is this correct?

(deleted)

Ok, first, yes there are analog input, but they go thru an analog multiplexer and can only connect one at a time to the Analog Digital converter.

Yes, there are 1024 steps. Voltage from -0.00244 to 0.00244 will be read as 0,
then 0.00244 to 0.00732 will read as 1,
etc. in 0.00488V steps.
Ending with 1023 representing 4.995 to 5.00488V.

As long as Vcc = 5V! If Vcc is less, like when the Arduino is powered from a PC, then Vcc could be lower due to the USB spec’ed output of 5V +/-5% (so as low as 4.75V) and the current protection device betweem the USB connector and the 5V line on the board.

10 bits means just that; 0 to 1023 (decimal), or 0x00 to 0x03FF (hex), or 0b0000000000000000 to 0b0000001111111111
Count the 1s there - ten of them.

From the '328P datasheet, I’ll leave to you to read up on how a successive approximation ADC works.

24.2 Overview
The ATmega48A/PA/88A/PA/168A/PA/328/P features a 10-bit successive approximation ADC. The ADC is connected to an 8-channel Analog Multiplexer which allows eight single-ended voltage inputs constructed from the pins of Port A. The single-ended voltage inputs refer to 0V (GND). The ADC contains a Sample and Hold circuit which ensures that the input voltage to the ADC is held at a constant level during conversion.
The ADC has a separate analog supply voltage pin, AVCC. AVCC must not differ more than ±0.3V from VCC. See the paragraph ”ADC Noise Canceler” on page 252 on how to connect this pin.
Internal reference voltages of nominally 1.1V or AVCC are provided On-chip. The voltage reference may be externally decoupled at the AREF pin by a capacitor for better noise performance.
The ADC converts an analog input voltage to a 10-bit digital value through successive approximation. The minimum value represents GND and the maximum value represents the voltage on the AREF pin minus 1 LSB. Optionally, AVCC or an internal 1.1V reference voltage may be connected to the AREF pin by writing to the REFSn bits in the ADMUX Register. The internal voltage reference may thus be decoupled by an external capacitor at the AREF pin to improve noise immunity.

So, 3V/5V * 1024 = 614.4, so a reading of 614 to 615 would be returned.

If you wanted, you could use the internal reference voltage of 1.1V, and then divide your to-be-measured voltage down into that range. Then one LSB would represent 1.1V/1024 = 1.07mV

More accurate? In the end, 1023 represents 1.1V or 3V or 5V. If you have to divide your to-be-measured voltage to fit in the 1.1V or 3V range, and then you have to multiply it by a 5V/3V or 5V/1.1V to get up to your starting voltage, are you gaining any accuracy?