Changing VREF voltage not making any difference on the results.
The tooltip information is conflicting to the available options:
Arduino UNO ADC
-
- Matrix Staff
- Posts: 1971
- http://meble-kuchenne.info.pl
- Joined: Wed Dec 02, 2020 11:07 pm
- Has thanked: 629 times
- Been thanked: 659 times
-
- Matrix Staff
- Posts: 1936
- Joined: Mon Dec 07, 2020 10:06 am
- Has thanked: 506 times
- Been thanked: 688 times
Re: Arduino UNO ADC
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.
For me a conversion rate of /16 and a charge time of 10 was working reasonably well.
What conversion speed are you using? I've just checked the FCD ADC settings vs the datasheet and they all look to be correct.
For me a conversion rate of /16 and a charge time of 10 was working reasonably well.
Regards Ben Rowland - MatrixTSL
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
-
- Matrix Staff
- Posts: 1971
- Joined: Wed Dec 02, 2020 11:07 pm
- Has thanked: 629 times
- Been thanked: 659 times
Re: Arduino UNO ADC
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
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
Martin
-
- Matrix Staff
- Posts: 1936
- Joined: Mon Dec 07, 2020 10:06 am
- Has thanked: 506 times
- Been thanked: 688 times
Re: Arduino UNO ADC
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
-
- Matrix Staff
- Posts: 1971
- Joined: Wed Dec 02, 2020 11:07 pm
- Has thanked: 629 times
- Been thanked: 659 times
Re: Arduino UNO ADC
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?
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?
Martin
-
- Matrix Staff
- Posts: 1936
- Joined: Mon Dec 07, 2020 10:06 am
- Has thanked: 506 times
- Been thanked: 688 times
Re: Arduino UNO ADC
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
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

Regards Ben Rowland - MatrixTSL
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
-
- Posts: 6
- Joined: Tue Dec 15, 2020 10:28 am
Re: Arduino UNO ADC
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... 

-
- Matrix Staff
- Posts: 1936
- Joined: Mon Dec 07, 2020 10:06 am
- Has thanked: 506 times
- Been thanked: 688 times
Re: Arduino UNO ADC
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
-
- Matrix Staff
- Posts: 1936
- Joined: Mon Dec 07, 2020 10:06 am
- Has thanked: 506 times
- Been thanked: 688 times
Re: Arduino UNO ADC
Aha found and fixed, finally.
Sorry and thanks for bearing with us.
Sorry and thanks for bearing with us.
Regards Ben Rowland - MatrixTSL
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel