Vref arduino mega2560

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

Moderator: Benj

Post Reply
maxtisc
Posts: 110
Joined: Mon Dec 23, 2013 9:34 pm
Has thanked: 2 times
Been thanked: 9 times
Contact:

Vref arduino mega2560

Post by maxtisc »

hello and best wishes to all,
I'm following a project with Arduino Mega2560, the problem is that the default analog Vref is 5V, but this is too high, I read that Arduino can work with vref of 1.1 or 2.56v or from an external value using Aref, all these are selectable via software, you can select one of these through FC6?
Thanks and happy new year

maxtisc
Posts: 110
Joined: Mon Dec 23, 2013 9:34 pm
Has thanked: 2 times
Been thanked: 9 times
Contact:

Re: Vref arduino mega2560

Post by maxtisc »

Hello
no one has any idea how to do?
thank you

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

Re: Vref arduino mega2560

Post by LeighM »

Hi,
The Flowcode V6 Analogue input components implement two "Vref options" : AVCC or VREF pin
See the component property.
The internal options are not directly supported.
However, you could edit the AVR_CAL_ADC.c file to change the Vref option ...

Code: Select all

// Internal 1.1V Voltage Reference with external capacitor at AREF pin
ADMUX = (0x80) | (1 << ADLAR) | Chan;

Code: Select all

// Internal 2.56V Voltage Reference with external capacitor at AREF pin
ADMUX = (0xC0) | (1 << ADLAR) | Chan;
Or you could add this adjustment as C code in your project,
but for this to work you would need to use the component Raw functions,
that is, use RawEnable, then run some C code to change the ADMUX setting, then use RawSampleByte to read the result.
When changing the ADMUX setting, you will need to at least wait for the previous conversion to complete (triggered in RawEnable)
or even re-enable the ADC, I'm not sure about that based on a quick read of the datasheet.

Hope that helps,
Leigh

maxtisc
Posts: 110
Joined: Mon Dec 23, 2013 9:34 pm
Has thanked: 2 times
Been thanked: 9 times
Contact:

Re: Vref arduino mega2560

Post by maxtisc »

thanks LeighM
Solved with external Vref

Post Reply