ADMUX Register in Arduino Mega

Hello, I am currently working on a project and I'm using the ADMUX register, can someone clarify bits 7 & 6 of that register ? And the use of them as I have no idea which one to select.

I have read about it and have done some research on it but didn't understand much of it quite frankly.

Thanks in advance.

For the ATmega2560 microcontroller ? ATmega2560

In the Complete Datasheet, page 281, bit REF0 and REF1 are for the reference voltage.
There are four options:

  • The external AREF pin is the reference voltage.
  • The AVcc (5V) is the reference voltage.
  • The internal 1.1V is the reference voltage.
  • The internal 2.56V is the reference voltage.

The default reference for the Arduino Mega 2560 is the AVcc 5V.

The reference voltage is used to read an analog signal with an analog pin.
If the reference voltage is set to the AVcc and the Arduino 5V is exactly 5.000V, then an analog pin can measure from 0.000V up to 4.995V (inclusive 0V and exclusive 5V).

The Arduino function analogReference() is for selecting the voltage reference.

1. Bit Layout and meanings for bit-6 and bit-7 of ADMUX Register of the MCU of MEGA Board.


Figure-1: ADMUX Register of MEGA

2. Conceptual Structure of the ADC Module of MEGA.


Figure-2: ADC Module of MEGA

3. VREF pin of the ADC determines the Full Scale of the ADC. The Full Scale can be selected either at:

5V, or
1.1V Internal, or
2.56V Internal, or
variable (1.1V to 5V) from external source via AREF-pin.

The bit-6 (REFS0) and bit-7(REFS1) of ADMUX Register helps to select one of the above four options of the voltages.

4. Role of VREF Voltage
(1) If VREF is 5V, resolution (weight for LSB) of ADC is: 5000/1023 = 4.89 mV. Input voltage to any analog channel is limited to: 0V to 5V.

(2) If VREF is 1.1V Internal, resolution of ADC is: 1100/1023 = 1.06 mV. Input voltage to any analog channel is limited to: 0V to 1.1V.

(3) If VREF is 2.56V Internal, resolution of ADC is: 2560/1023 = 2.50 mV. Input voltage to any analog channel is limited to: 0V to 2.56V.

Yes, I'm using the ATmega2560 microcontroller. However, what's confusing me is the external capacitor at the AREF pin according to Figure-1 of GolamMustafa's reply.

I guess my question is, do I have to connect an additional capacitor to my AREF pin or do I just use the Internal 2.56V and the capacitor mentioned in the image is already soldered on the arduino board.

Thanks again for the replies.

A little fix!

GolamMostafa:
4. Role of VREF Voltage
(1) If VREF is 5V, resolution (weight for LSB) of ADC is: 5000mV / 1024= 4.88 mV. Input voltage to any analog channel is limited to: 0V to 5V.

(2) If VREF is 1.1V Internal, resolution of ADC is: 1100mV / 1024 = 1.07 mV. Input voltage to any analog channel is limited to: 0V to 1.1V.

(1) If VREF is 2.56V Internal, resolution of ADC is: 2560mV / 1024 = 2.50 mV. Input voltage to any analog channel is limited to: 0V to 2.56V.

And limited is a bit ambiguous, in every mode it can handle voltage up to Vcc (+ 0,5V) just fine. Output will only not rise above 1023 if passed VREF

Also note, you can't actually set VREF to 5V, you set it to Vcc which might not be exactly 5,000V. Which will then influence the reading. But the internal references are not super accurate as well.

The 100nF to AREF is already on the Arduino board. It is C3 in the schematic.

That 100nF is just a little optimization to reduce noise. When the internal 2.56V is selected, that voltage is also on the AREF pin. You can measure the 2.56V with a voltage meter. The 100nF only reduces some noise. The value of 100nF is just a nice value because 100nF is used for decades to reduce digital noise, it does not have to be 100nF.

When there is no 100nF connected to AREF and the average of many samples is taken in software, then the result is about the same.

septillion:
Also note, you can't actually set VREF to 5V, you set it to Vcc which might not be exactly 5,000V. Which will then influence the reading. But the internal references are not super accurate as well.

Yes! I note it down. The AVcc-pin (Pin-100) of ATmega2650 is shorted by the MEGA Board with 5V (Pin-80, 61, 32, 10). So, AVcc is dynamically changing with Vcc supply. I am posting below the amended diagram.