Page 1 of 1

Arduino UNO ADC

Posted: Sun Jan 10, 2021 4:36 pm
by medelec35
Changing VREF voltage not making any difference on the results.
The tooltip information is conflicting to the available options:
Arduino UNO ADC.png
Arduino UNO ADC.png (14.93 KiB) Viewed 10607 times

Re: Arduino UNO ADC

Posted: Mon Jan 11, 2021 10:38 am
by BenR
Hi Martin,

What conversion speed are you using? I've just checked the FCD ADC settings vs the datasheet and they all look to be correct.
ArdADC.jpg
ArdADC.jpg (61.44 KiB) Viewed 10595 times
For me a conversion rate of /16 and a charge time of 10 was working reasonably well.

Re: Arduino UNO ADC

Posted: Mon Jan 11, 2021 10:59 pm
by medelec35
Using conversion of FOSC/128

There are two issues causing confusion.
The tool tip has acronyms of VDD and Vref+, but the selection is AREF, AVCC and Internal 1.1V
So they don't match.
I would have thought AREF is suing using external AREF pin to set reference level and AVCC will be using internal VDD?
On hardware that is not the case.
For example used two resistors to set A0 at 0.5 VDD

Vref option to AREF.
ADC is not dependent on the voltage connected to AREF pin.
AREF pin at 5V, ADC = 511.
AREF pin at 3V3, ADC = 511
AREF pin at floating, ADC = 511


Changed Vref option to AVCC.
ADC is dependent on the voltage connected to AREF pin.
AREF pin at 5V, ADC = 511.
AREF pin at 3V3, ADC = 697
AREF pin at floating, ADC = 1023

Changed Vref option to Internal 1.1V.
ADC is still dependent on the voltage connected to AREF pin.
AREF pin at 5V, ADC = 511.
AREF pin at 3V3, ADC = 697
AREF pin at floating, ADC = 1023

Re: Arduino UNO ADC

Posted: Tue Jan 12, 2021 11:38 am
by BenR
Hi Martin,

Ok that's interesting so it looks like the AREF pin is always selected, no matter what you choose. The CAL code certainly looked ok but might be worth us playing with it and say reading the ADMUX register value back to ensure that the value has been placed in there correctly.

The datasheet states that for AVCC you need an external capacitor on the AREF pin which kind of suggests that AREF is still playing a part. I checked the Arduino schematic and there is a cap there but not sure if it's actually fitted or not.

Let's do some more digging and see if we can work out what's going wrong here.

Re: Arduino UNO ADC

Posted: Tue Jan 12, 2021 4:56 pm
by medelec35
Hi Ben,
Thanks for your reply.
I was interested in using AREF the same way as pic uses Vref+ pin.
So ADC = 1023 or 255 (depending on Int or Byte )when voltage on the ADC pin = VREF voltage.
Will the tool tip be amended for ATmega devices?

Re: Arduino UNO ADC

Posted: Wed Jan 13, 2021 12:37 pm
by BenR
Well it does sound like there is a problem lurking somewhere, the AREF floating doesn't seem to be working when selecting internal or VCC references.

I'll have a play and see if I can find anything that might help the situation.

The tooltip doesn't currently come from the FCD and so applies to all devices. Maybe we can find some more generic text that is still useful :lol:

Re: Arduino UNO ADC

Posted: Thu Jan 14, 2021 8:43 am
by andrewproffi
Are you seriously? The defect in the selection of the reference voltage source has not been fixed since version 5, so it also got worse ??? (AVR version) the internal supply cannot be selected as before, and the supply voltage and external supply are reversed... :?

Re: Arduino UNO ADC

Posted: Wed Jan 20, 2021 10:28 am
by BenR
Hello,

Ok I can confirm the ADMUX register is being set correctly, so I'll go through the rest of the code with a comb and compare to the Arduino code and see if I can find any discrepencies.

edit,

The main difference for the arduino is that the prescaler is automatically set to /128 for 16MHz or /64 for 8MHz devices.
AREF is enabled by default.
And the precharge time is set to 0, i'll make a change to the code to allow the precharge to be set to 0 without causing a large delay.

Re: Arduino UNO ADC

Posted: Tue Jan 26, 2021 11:58 am
by BenR
Aha found and fixed, finally.

Sorry and thanks for bearing with us.