I am building a pH meter and having a real close look into the analog components, and reading the Arduino documentation for analogRead()
.
https://www.arduino.cc/en/Reference/AnalogRead
I see it says the Arduino, in my case an 8-bit AVR ATmega328 Arduino Uno, yields a resolution between readings of: 5 volts / 1024 units or, .0049.
My question is whether that is accurate, or even possible. How can an 8-bit MCU provide a 10-bit analog read? how does that work?
Shouldn't the analog read be 2^8 or 256?
1 Answer 1
It can do a 10-bit reading quite simply - because the ADC is a 10-bit ADC. The CPU register size doesn't dictate what it can communicate with, either internally or externally. The only thing it dictates is how big a number it can cope with at any one time. Because of this the 10-bit result of the ADC is spread across two registers - 2 bits in the "high" ADC result register, and 8 bits in the "low" ADC result register.
-
2...or two bits in the 'low' and 'eight' in the high. You can decide which within your code. The purpose of this is to allow you to easily 'downscale' your 10-bit ADC result to 8-bit : With the eight most-significant-bits in one register you can use one single read command to get your result. This can be useful if you don't need a 10-bit resolution, for example if the input is so noisy that the lowest bits become irrelevant.CharlieHanson– CharlieHanson2015年06月24日 12:38:34 +00:00Commented Jun 24, 2015 at 12:38
-
3@chaaarlie2 Also the left-alignment option gives you in effect a 16-bit value (though with 6 lowest bits static) which is very useful if using standard mathematical algorithms etc that expect a 16-bit value. Means you don't have to do any expensive shifting of each and every sample.Majenko– Majenko2015年06月24日 15:13:15 +00:00Commented Jun 24, 2015 at 15:13