Pages: [1] 2   Go Down
Author Topic: When do you use the AREF pin in arduino?  (Read 4676 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Full Member
***
Karma: 0
Posts: 213
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I would like to know whether I have to connect a reference voltage to AREF pin, if I am not using the Vcc pin in arduino uno to power up a circuit. Instead i am using a 9V battery to power up the circuit, in this case do I need to connect an external 5V to AREF pin as reference voltage?
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 602
Posts: 33362
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
in this case do I need to connect an external 5V to AREF pin as reference voltage?
No.
It is taking the 5V Vref from the supply it is switched internally. Don't connect anything to this pin unless you know what you are doing.
Logged

0
Online Online
Shannon Member
****
Karma: 200
Posts: 11690
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Specifically you need to call analogReference (see http://arduino.cc/it/Reference/AnalogReference)

The AREF input has a resistance of 32k according to the datasheet so a low-impedance source is required if 10bit accuracy is to be obtained.

If you do provide an external voltage reference to this pin you must call analogReference(EXTERNAL) in setup () before any call to analogRead() - otherwise you will internally short your reference to 5V and potentially burn out the chip.  After setting the analogReference() it is advised to call analogRead() at least once to allow the voltage to settle down in the ADC circuitry.  So in summary:

Code:
void setup ()
{
  analogReference (EXTERNAL) ;
  analogRead (0) ;
  ...
}

The Mega has some other options, note.

Note that if your circuit has an external voltage on AREF you have to be careful to never upload the wrong sketch (ie one which calls analogRead() before analogReference())...

You could connect an external voltage via a 1k resistor as a temperary testing setup - then the chip is safe (but analogRead() will be upto 3% wrong...)

[ To actually answer the question, one circumstance might be when inputting values from 3V3 sensors - setting AREF to EXTERNAL (3V3) gives 50% more resolution... Or for sensing very low voltages the internal 1.1V reference might be selected: analogReference(INTERNAL) ]
« Last Edit: February 10, 2012, 05:54:39 am by MarkT » Logged

[ I won't respond to messages, use the forum please ]

Offline Offline
Newbie
*
Karma: 0
Posts: 47
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I was looking into AREF a couple of days ago and I read that you should NOT supply a voltage into the AREF pin LARGER than 5V, if you need 9V look into op amps.
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 602
Posts: 33362
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
i am using a 9V battery to power up the circuit,
This makes no difference because the arduino has a 5V regulator on board so although you are powering it with a 9V battery there is no more that 5V powering the processor chip.
Applying anything over 5V to the analogue input damages the chip.
Logged

Offline Offline
Full Member
***
Karma: 0
Posts: 213
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I guess my question wasn't clear. So, here is a simple diagram of what I meant. For example, when you use a pot resistor, you connect the 3 pins to ground, 5V on arduino, and finally to analog pin. So, in that case by connecting to 5V you are setting ADC to 5V reference, right?

In my case I am not using the 5V in arduino uno to power the circuit instead i am using an external 9V battery to power my circuit. And arduino Uno is connected to laptop USB. So, my question is do I need 5V connected to AREF to set reference voltage? If not, how does arduino uno know the reference voltage of ADC.

In arduino website its mentioned by default its either 5V or 3.3V. But thats only if you are powering the circuit using the 5V or 3.3V port of arduino uno, right?

I hope the question is understood.


* Diagram.png (6.12 KB, 529x235 - viewed 150 times.)
« Last Edit: February 10, 2012, 11:25:27 am by yaantey » Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17262
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

In your drawing, as long as the output voltage is always within the 0-5vdc range (that is important, more then +5 or less then 0 can damage the arduino) then there is nothing you need to do with the Aref pin on the arduino, the arduino will convert the 0-5vdc measurement voltage into a digial value of 0-1023 counts. You do however need to add a wire from the negative terminal of your 9vdc voltage source to a arduino ground pin. That is both the external circuit and the arduino must share a common ground connection, which you don't show in your drawing.

That make sense?

Lefty

Logged

Offline Offline
Full Member
***
Karma: 0
Posts: 213
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok, I forgot to put the common ground. So which reference will arduino uno take by default 1.1V or 5V or 3.3V?
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17262
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok, I forgot to put the common ground. So which reference will arduino uno take by default 1.1V or 5V or 3.3V?

5V

Lefty
Logged

Offline Offline
Full Member
***
Karma: 0
Posts: 213
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

So basically, when ever you plug something into arduino uno analog pin it reference it as 5V even if you are using USB to power up arduino Uno and you are powering the circuit whose output is connected to arduino by external source greater than 5V.
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17262
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

So basically, when ever you plug something into arduino uno analog pin it reference it as 5V even if you are using USB to power up arduino Uno and you are powering the circuit whose output is connected to arduino by external source greater than 5V.

That is a confusing statement starting with the "and you are".

Rules on using analog input pins:

1. Default measurement range for a standard arduino Uno or Mega board is 0-5vdc
2. External voltage to be measured must be within 0 and +5vdc, over or under will cause damage.
3. external circuit supplying voltage to be measured must share common ground with arduino.

Which of these don't you understand?

Logged

Offline Offline
Full Member
***
Karma: 0
Posts: 213
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

There is 6 analog pins in arduino Uno, right? By default all of them is referenced to 5V. So meaning you don't have to put any command in the program to set it nor you need any other connection on arduino board to enable it, right? To connect an analog output from a circuit you just connect the analog output to the arduino uno analog pin and have common ground, right?

I understand you statement. Its just I have made a circuit and its not showing the results I expected. The circuit is working fine. So, I am trying to find the solution for my problem. So, just wanted to clarify whether my connections were correct. Here is the thread link for the circuit and my current problem if you would like to give me some help. (http://arduino.cc/forum/index.php/topic,90759.msg685080.html#msg685080)
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17262
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

There is 6 analog pins in arduino Uno, right? By default all of them is referenced to 5V. So meaning you don't have to put any command in the program to set it nor you need any other connection on arduino board to enable it, right?

Correct, default measurement range is 0-+5vdc when using no special reference commands.

 To connect an analog output from a circuit you just connect the analog output to the arduino uno analog pin and have common ground, right?

Correct. As long as the measurement voltage stays within 0 and +5vdc, nothing need be done other then wiring to a arduin analog input pin.

I understand you statement. Its just I have made a circuit and its not showing the results I expected. The circuit is working fine. So, I am trying to find the solution for my problem. So, just wanted to clarify whether my connections were correct. Here is the thread link for the circuit and my current problem if you would like to give me some help. (http://arduino.cc/forum/index.php/topic,90759.msg685080.html#msg685080)

If you mean the microphone/audio amp circuit, that is not outputting a 0-+5vdc signal, the series cap will only allow AC voltages to pass through. AC voltages have negative values 50% of the time, negative voltages are damaging to an analog input pin. Also there is nothing to prevent the signal output from going higher the +5vdc, also damaging to the analog input pin. Trying to measure AC audio with an arduino is a very difficult depending on what you are trying to do with the signal in your program. If you just want a clap-on-clap-off type function then one usually rectifies and filters and clamps the audio signal before wiring it to a analog input signal. Then you have a 0-5vdc signal that's average value is proportional to the average audio amplitude.

Lefty
« Last Edit: February 10, 2012, 12:40:01 pm by retrolefty » Logged

Offline Offline
Full Member
***
Karma: 0
Posts: 213
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
the series cap will only allow AC voltages to pass through
The ADC is used for converting the analog signal to digital signal. If you look at the circuit I have biased it in such a way that the analog wave does not have negative voltage. The analog wave will oscillate on the DC bias voltage off 2.5V roughly. Like I have said, I tested on the oscilloscope and the min amplitude is few mV and max amplitude is around 4.6V. Hence there is no negative voltage and the voltage doesnt exceed 5V either.

Quote
Also there is nothing to prevent the signal output from going higher the +5vdc, also damaging to the analog input pin.
The zener diode has a zener voltage of 4.7 and prevents voltage going above +5V.
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17262
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

That was a rather long thread, I must have been looking at the wrong drawning.

Sounds like you got it's conditioning under control.

Lefty
Logged

Pages: [1] 2   Go Up
Jump to: