Go Down

Topic: Analog reference setting (Read 3661 times) previous topic - next topic

Marsheng

Do you do this once in a stand alone program to set the chip or once each time when you run the program.

analogReference(DEFAULT)

PaulS

The default setting for analogReference is DEFAULT. If you never change it, you never have to change it back.

The default setting is assumed every time the Arduino starts. If you need to change it, it needs to be part of the sketch that is running.
The art of getting good answers lies in asking good questions.

Marsheng

Before reading through the manual completely, I added a pot to my board thinking that it was for a simulated analog input.  From then on, all I got was 1023 from all the analog inputs.

I removed the pot - added the DEFAULT setting, it started working. It looks like the Aref signal I gave it messed up it up.?


AWOL

Quote
I added a pot to my board thinking that it was for a simulated analog input


That doesn't make a great deal of sense; can you expand a little?

Marsheng

I'm using an SB  freeduino board. It has a position for a pot. The pot is actually to set AREF and it is not for analog simulation. Possibly taking Aref from 0 volts to 5v reset the internal reference.

PS resetting the chip did not restore the internal Analog reference.

mpeuser

#5
Aug 16, 2010, 01:34 am Last Edit: Aug 16, 2010, 01:35 am by mpeuser Reason: 1
This discussion sounds extremely dangerous. The AREF is internally connected to the used reference voltage, be it AVcc or 1.1V if those options have been selected. In that cases, a decoupling condensor is strongly recommmended, and one of the awkwardnesses of the Arduino is, that it does not provide this. Only - ond only - in the case of selected external reference voltage may a voltage be applied to this pin! It will definitely do harm otherwise when the involved current from that source exceeds some uA!

PaulS

Quote
In that cases, a decoupling condensor

A what?
The art of getting good answers lies in asking good questions.

mpeuser

#7
Aug 16, 2010, 02:27 am Last Edit: Aug 16, 2010, 02:27 am by mpeuser Reason: 1
Sorry - it's late again... The English speaking world calls this capacitors, for unclear reasons...
Something of 10 to 100nF between Aref and GND.

macegr

Which wouldn't really protect anything...you'd also want a resistor between the external voltage and AREF.
Unique RGB LED Modules and Arduino shields: http://www.macetech.com/store

mpeuser

#9
Aug 16, 2010, 10:56 am Last Edit: Aug 16, 2010, 10:57 am by mpeuser Reason: 1
This is not meant as a protection but as a means to reduce noise.

There are good reasons for NOT putting 1MOhms resistors in front of every pin, which would be a nearly bulllet proof protection for most electrical issues :-)

But there are situations where the hobbydesigner is aware that he shoud care and where he is not. The Aref is such a case, as this thread proves again. A 10nF capacity between Aref and ground would have done no harm and a lot of good....

retrolefty

Quote
The Aref is such a case, as this thread proves again. A 10nF capacity between Aref and ground would have done no harm and a lot of good....


 Well I read a posting around here lately where a cap on Aref to ground slowed the A/D conversion sufficiently enough to cause accuracy errors when switching reference sources and then reading analog inputs. Forget the details but it should be researched and dealt with in one's software.

Also there is the caution in the Arduino reference section about how to wire external voltages to Aref:

Quote
Warning
If you're using an external reference voltage (applied to the AREF pin), you must set the analog reference to EXTERNAL before calling analogRead(). Otherwise, you will short together the active reference voltage (internally generated) and the AREF pin, possibly damaging the microcontroller on your Arduino board.


Alternatively, you can connect the external reference voltage to the AREF pin through a 5K resistor, allowing you to switch between external and internal reference voltages. Note that the resistor will alter the voltage that gets used as the reference because there is an internal 32K resistor on the AREF pin. The two act as a voltage divider, so, for example, 2.5V applied through the resistor will yield 2.5 * 32 / (32 + 5) = ~2.2V at the AREF pin.


Lefty

Go Up