analogReference(EXTERNAL) on Arudino Mega

Hi,

I need to read four analog voltage for a project and am using arduino mega 2560 R3.

Requirement is to have a reference voltage as close to 5v as possible. As I found that the default to be considerably less than 5v and also inconsistent and decided to use an external voltage on AREF pin.

So, connected AREF pin to a 4.98v source and made the ground reference common for arduino and the source.

In code, made a call to analogReference(EXTERNAL) in setup() and am reading values one after the other in loop(). Please see attachment

However, I find that the analog readings for all channels shows some random value like “111” or “176” continuously.

Have tried giving a delay after reading, reading the analog pin multiple times and averaging the readings, all with the same error.

Unable to understand, where I am going wrong. Any suggestions would help a great deal.

thanks in Advance
Sagar

AnalogTest.ino (965 Bytes)

ideonics: I need to read four analog voltage for a project and am using arduino mega 2560 R3.

Requirement is to have a reference voltage as close to 5v as possible. As I found that the default to be considerably less than 5v and also inconsistent and decided to use an external voltage on AREF pin.

Why does the reference has to be exact if you use a pot as input (sketch comment). A pot set e.g. to 50% always gives a value of 512, independent of the voltage on Aref.

Make sure the [u]supply[/u] is [u]always[/u] higher than external Aref.

Why can't you use Mega's 2.56volt Aref. Leo..

Dear Leo,

Voltages on the analog pins are got from a signal converter having 4-20mA input and providing 0-5v output. So, I need AREF to be as close to 5v as possible.

regards,
Saagar

Use a 10k:10k voltage divider on the converter to half the output, and use 2.56volt Aref.

Or get rid of the signal converter, and replace it with a resistor. 4-20mA current produces a voltage across the resistor that can be measured with the analogue input. Use 51ohm for 1.1volt Aref, or 125ohm for 2.56volt Aref. Leo..