Enabling 2.56v reference voltage on Arduino Mega

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 7.

Moderator: Benj

Post Reply
Coensk
Posts: 10
Joined: Tue Mar 14, 2017 10:38 am
Has thanked: 4 times

Enabling 2.56v reference voltage on Arduino Mega

Post by Coensk »

Hello,

I'm trying to enable the 2.56v voltage on the Aref pin of my Arduino Mega. I already tried numerous ways to write a "1" to bit 6 and 7 of the ADMUX register in C code but every time I measure 0v over the Aref pin..

2 questions:
1. How can I correctly measure the pin (Aref)? by placing a resistance between the pin and gnd, and then measure to voltage over the resistor?
2. Does anyone have an idea on how to enable this using Flowcode or C code?

Coensk

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times

Re: Enabling 2.56v reference voltage on Arduino Mega

Post by LeighM »

Hi,

Have a look at this post ...
http://www.matrixtsl.com/mmforums/viewt ... 54&t=18416

Also, the Atmel datasheet (p275) has this note ...

VREF can also be measured at the AREF pin with a high impedant voltmeter.
Note that VREF is a high impedant source, and only a capacitive load should be connected in a system.
If the user has a fixed voltage source connected to the AREF pin, the user may not use the other reference voltage
options in the application, as they will be shorted to the external voltage. If no external voltage is applied to the
AREF pin, the user may switch between AVCC, 1.1V and 2.56V as reference selection.

Coensk
Posts: 10
Joined: Tue Mar 14, 2017 10:38 am
Has thanked: 4 times

Re: Enabling 2.56v reference voltage on Arduino Mega

Post by Coensk »

Thanks LeighM,

Can i just use this component macro "RawEnable" and "RawSampleByte" with the C code in between, once at the beginning of my program and the ADMUX bits will stay enabled throughout the program?

Coensk

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times

Re: Enabling 2.56v reference voltage on Arduino Mega

Post by LeighM »

Hi,
It's going to get quite complex that way.
I think that the quickest way is to edit \CAL\AVR\AVR_CAL_ADC.c
(best to make a backup first, and make a note to yourself that you now have a custom version ;-)

Line 700 currently looks like this ..

Code: Select all

ADMUX = (Vref << REFS0) | (1 << ADLAR) | Chan;
Change it to this ...

Code: Select all

// Internal 2.56V Voltage Reference with external capacitor at AREF pin
ADMUX = (0xC0) | (1 << ADLAR) | Chan;
Then you can use the Flowcode ADC component macros in the usual way.
Hope that helps,
Leigh

Post Reply