Many microcontrollers contains internal on-chip ADC. Typical devices would be Atmel Atmega series microcontrollers like Atmega8 and further. Internal ADC are successive way to integrate analog world in to your embedded systems using only one microcontroller die. Many applications doesn’t require high speed or high accuracy ADC conversions, thus on-chip ADC is best choice.
Lets look at Atmega8. It contains 10-bit approximation ADC with analog input multiplexer of 8-single-ended input voltage (refers to 0V) channels.
Atmega microcontrollers have separate analog supply voltage pins – AVCC (Atmega8 has known bug – digital and analog grounds are interconnected inside chip).
Reference voltage is provided inside chip. It is nominally 2.56V or AVCC. AREF pin is used to decouple voltage reference by a capacitor for better noise performance.
The reference voltages nay be selected between:
-
Internal reference 2.56V;
-
AVCC (must not differ from VCC more than ±0.3V);
-
Or reference voltage can be connected to external pin AREF.
If we have 8 bit ADC, then our conversion would look like this:
Digital Code=(Vin/Vref)x256
Lets say we use 5V reference and we measure 3.2V input signal. So result:
Result=(Vin*256)/Vref=(3.2V*256)/5V=163=0xA3
Jus remember, that on-chip ADC accuracy isn’t perfect. Atmega8 datasheet states that absolute accuracy is ±2LSB. This means that last two bits gives gives an error. So same our calculated result may vary it can be like 0xA0 or 0x0xA2 …
Another issue is supply voltage stability and accuracy. Let us say that voltage is 1% higher than we expect. It would be 5.05V. Then our calculation will give:
Result=(Vin*256)/Vref=(3.2V*256)/5.05V=162=0xA2
So 1% change in voltage will change conversion result in one bit. Typically voltage may vary by 2 or 3%.
The voltage variation may occur because of supply source instability, temperature changes, loads. It is hard to avoid this. But absolute accuracy can be increased by selecting external ADC like MAX1242.
Pingback: Read This Link » Using Internal microcontroller ADC