Reference.AnalogReference History

Hide minor edits - Show changes to markup

June 01, 2010, at 12:50 AM by Equipo Traduccion -
Changed lines 78-79 from:
                                 //los valores de analogWrite values van desde 0 a 255, por eso ajustamos el ciclo de 
                                 //trabajo a el valor leído dividido por 4.
to:
                                 //los valores de analogWrite values van desde 0 a 255, por eso ajustamos  
                                 //el ciclo de trabajo a el valor leído dividido por 4.
June 01, 2010, at 12:49 AM by Equipo Traduccion -
Changed lines 78-79 from:

los valores de analogWrite values van desde 0 a 255, por eso ajustamos el ciclo de trabajo a el valor leído dividido por 4.

to:
                                 //los valores de analogWrite values van desde 0 a 255, por eso ajustamos el ciclo de 
                                 //trabajo a el valor leído dividido por 4.
June 01, 2010, at 12:48 AM by Equipo Traduccion -
Changed lines 77-78 from:
  analogWrite(ledPin, val / 4);  // los valores de analogRead van desde 0 a 1023 y los valores de analogWrite values van desde 0 a 255, por eso ajustamos el ciclo de trabajo a el valor leído dividido por 4.
to:
  analogWrite(ledPin, val / 4);  // los valores de analogRead van desde 0 a 1023 y 

los valores de analogWrite values van desde 0 a 255, por eso ajustamos el ciclo de trabajo a el valor leído dividido por 4.

June 01, 2010, at 12:42 AM by Equipo Traduccion -
Changed lines 36-37 from:

Ver también

to:
analogWrite()

Descripción

Escribe un valor analógico (PWM) en un pin. Puede ser usado para controlar la luminosidad de un LED o la velocidad de un motor. Después de llamar a la función analogWrite(), el pin generará una onda cuadrada estable con el ciclo de trabajo especificado hasta que se vuelva a llamar a la función analogWrite() (o una llamada a las funciones digitalRead() o digitalWrite() en el mismo pin). La frecuencia de la señal PWM sera de aproximadamente 490 Hz.

En la mayoría de las placas Arduino (aquellas con el ATmega168 o ATmega328), se podrá generar señales PWM en los pines 3, 5, 6, 9, 10, y 11. En la placa Arduino Mega, se puede llevar a cabo con los pines desde el 2 hasta el pin 13. Las placas Arduino más antiguas que posean el chip ATmega8 solo podrán usar la función analogWrite() con los pines 9, 10 y 11. No hace faltar configurar el pin como salida para poder usar la función analogWrite().

La función analogWrite no tienen ninguna relación con los pines de entrada analógicos ni con la función analogRead.

Sintaxis

analogWrite(pin, valor)

Parámetros

pin: Es el pin en el cual se quiere generar la señal PWM.

valor: El ciclo de trabajo deseado comprendido entre 0 (siempre apagado) y 255 (siempre encendido).

Devuelve

Nada

Notas y problemas conocidos.

Las señales PWM generadas en los pines 5 y 6 poseerán ciclos de trabajo superiores a lo esperado. Esto es así por que para esos dos pines se utiliza el mismo temporizador que se utiliza en las funciones millis() y delay(). Este efecto se notará mucho más en ciclos de trabajo bajos (por ejemplo de 0 a 10) y puede ser que aunque configuremos esos pines con una señal de ciclo de trabajo cero no llegue a ser verdaderamente 0.

Ejemplo

Produce una señal donde conectamos el LED, cuyo ciclo de trabajo es proporcional a la tensión leída en el potenciómetro.

 
int ledPin = 9;      // LED conectado al pin digital 9
int analogPin = 3;   // potenciómetro conectado al pin 3
int val = 0;         // variable en el que se almacena el dato leído

void setup()
{
  pinMode(ledPin, OUTPUT);   // sets the pin as output
}

void loop()
{
  val = analogRead(analogPin);   // lee la tensión en el pin
  analogWrite(ledPin, val / 4);  // los valores de analogRead van desde 0 a 1023 y los valores de analogWrite values van desde 0 a 255, por eso ajustamos el ciclo de trabajo a el valor leído dividido por 4.
}

Véase también

June 01, 2010, at 12:23 AM by Equipo Traduccion -
Changed lines 5-6 from:

Configura la el voltaje de referencia usada por la entrada analógica.La función analogRead() devolverá un valor de 1023 para aquella tensión de entrada que sea igual a la tensión de referencia. Las opciones son:

to:

Configura el voltaje de referencia usado por la entrada analógica.La función analogRead() devolverá un valor de 1023 para aquella tensión de entrada que sea igual a la tensión de referencia. Las opciones son:

June 01, 2010, at 12:19 AM by Equipo Traduccion -
Changed lines 1-40 from:

analogReference(type)

Description

Configures the reference voltage used for analog input. The analogRead() function will return 1023 for an input equal to the reference voltage. The options are:

  • DEFAULT: the default analog reference of 5 volts (on 5V Arduino boards) or 3.3 volts (on 3.3V Arduino boards)
  • INTERNAL: an built-in reference, equal to 1.1 volts on the ATmega168 or ATmega328 and 2.56 volts on the ATmega8.
  • EXTERNAL: the voltage applied to the AREF pin is used as the reference.

Parameters

type: which type of reference to use (DEFAULT, INTERNAL, or EXTERNAL).

Returns

None.

Warning

It is a good idea to connect external voltages to the AREF pin through a 5K resistor. This will prevent possible internal damage to the Atmega chip if analogReference() software settings are incompatible with the current hardware setup. 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.2V at the AREF pin.

Connecting external voltages through a resistor makes it possible to switch the AREF voltage on the fly, say from the 5 volt DEFAULT setting, to a 3.3 volt EXTERNAL setting (and applied voltage), without the hardware setup affecting either ADC configuration.

Use of the AREF pin

The voltage applied to the AREF pin directly governs the ADC and sets the voltage at which the ADC will report its highest reading, 1023. Lower voltages applied to ADC (analog) pins will be scaled proportionally, so at the DEFAULT setting (5 volt internal connection), 2.5 volts on an analog pin will report approximately 512.

The default configuration on all Arduino implementations is to have nothing connected externally to the AREF pin (Atmega pin 21). In this case the DEFAULT analogReference software setting connects the AVCC voltage, internally, to the AREF pin. This appears to be a low impedance connection (high current) and voltages, other than AVCC, applied (erroneously) to the AREF pin in the DEFAULT setting could damage the ATMEGA chip.

The AREF pin may also be connected internally to an (internal) 1.1 volt source (or 2.56 on the ATmega8) with analogReference(INTERNAL). With this setting voltages applied to the ADC (analog) pins that are at or above the reference will report 1023 when read with analogRead. Lower voltages will report proportional values, so 0.55 volts will report about 512.

The connection between the 1.1 volt source and the AREF pin is a very high impedance (low current) connection, so that reading the 1.1 (internally supplied) voltage at the AREF pin may only be done with a more expensive, high-impedance multimeter. An external voltage applied (erroneously) to AREF pin while using the INTERNAL setting will not damage the chip, but will totally override the 1.1 volt source, and ADC readings will be governed by the external voltage. It is still desirable to connect any external voltage to the AREF pin however, through a 5K resistor to avoid the problem cited above.

The correct software setting for using the AREF pin with an external voltage is analogReference(EXTERNAL). This disconnects both of the internal references and the voltage applied externally to the AREF pin sets the reference voltage for the ADC.

See also

to:

analogReference(tipo)

Descripción

Configura la el voltaje de referencia usada por la entrada analógica.La función analogRead() devolverá un valor de 1023 para aquella tensión de entrada que sea igual a la tensión de referencia. Las opciones son:

  • DEFAULT: Es el valor de referencia analógico que viene por defecto que de 5 voltios en placas Arduino de y de 3.3 voltios en placas Arduino que funcionen con 3.3 voltios.
  • INTERNAL: Es una referencia de tensión interna de 1.1 voltios en el ATmega168 o ATmega328 y de 2.56 voltios en el ATmega8.
  • EXTERNAL: Se usará una tensión de referencia externa que tendrá que ser conectada al pin AREF.

Parámetros

tipo: El tipo de referencia que se desea usar (DEFAULT, INTERNAL, or EXTERNAL).

Devuelve.

Nada.

Precaución

Es recomendable que cuando se use la referencia de tensión externa se conecte al pin AREF usando una resistencia de 5K. Esto evitará posibles daños internos en el ATmega si se la configuración de la referencia analógica es incompatible con el montaje físico que se ha llevado a cabo. Tenga en cuenta que esa resistencia afectará la tensión que se use como tensión de referencia ya que el pin AREF posee una resistencia interna de 32K. Ambas resistencias forman un divisor de tensión, por lo tanto, si por ejemplo se conecta una tensión de 2.5V con la resistencia de 5K la tensión que se utilice como tensión de referencia será de 2.2V ya que esa será la tensión que caiga en el pin AREF debido al divisor de tensión al que se ha hecho referencia.

El conectar la tensión de referencia externa a través de una resistencia permite pasar mediante software de usar tensión de referencia interna a una tensión de referencia externa sin que la configuración física del hardware nos afecte la configuración actual del conversor A/D.

Uso del pin AREF

La tensión aplicada en el pin AREF será la que haga que el conversor A/D de su máxima lectura (1023) cuando lea una tensión igual a la aplicada en ese pin. Tensión por debajo de esa tensión conectada a AREF será escalada proporcionalmente, así cuando se usa la tensión de referencia por defecto (DEFAULT) el valor que nos devuelve una tensión de 2.5V en una entrada analógica será 512.

La configuración por defecto del Arduino es la de no tener nada conectado de forma externa al pin AREF (El pin 21 del chip ATmega). En este caso la configuración de la tensión de referencia sera DEFAULT lo cual conecta AVCC(Alimentación positiva +5V) de forma interna al pin AREF. Este pin es un pin de baja impedancia (mucha corriente) por lo que si usando la configuración DEFAULT de la tensión de referencia se conecta otra tensión que no sea la que posee AVCC, podria dañar el chip ATmega.

El pin AREF también puede conectarse de forma interna a una fuente de referencia de 1.1 voltios (o 2.54 en los ATmega8) usando el comando analogReference(INTERNAL).Con esta configuración las tensiones aplicada a los pines analógicos que sean iguales a la tensión de referencia interna o superior nos devolverán 1023 cuando se lleva a cabo su lectura con la función analogRead(). Tensiones más bajas devolverán valores proporcionales, por ejemplo, si tenemos una tensión de 0.55 voltios en el pin analógico, nos devolverá 512.

La conexión entre la fuente de 1.1 voltios y el pin AREF es de muy alta impedancia (baja corriente), por lo que la lectura de la tensión de 1.1 voltios solo se podrá hacer con un multímetro que tenga alta impedancia de entrada. Si se aplicase por error una tensión de referencia externa en el pin AREF mientras se está usando la configuración INTERNAL para la tensión de referencia, no dañará el chip pero hará que la tensión de referencia sea la externa y no la de 1.1 voltios de la fuente interna. Aún así es recomendable que cualquier tensión externa que se conecte al pin AREF se haga a través de una resistencia de 5K para evitar el problema mencionado arriba.

La correcta confiuguración del software cuando se utiliza una tensión de referencia externa se hace mediante la función analogReference(EXTERNAL). Eso desconectará ambas tensión de referencia internas del pin AREF y por tanto será la externa la cual govierne la tensión máxima leída por el ADC.

Ver también

April 02, 2010, at 05:26 AM by David A. Mellis -
Changed lines 7-8 from:
  • DEFAULT: the default analog reference of 5 volts.
  • INTERNAL: an built-in reference, equal to 1.1 volts on the ATmega168 and 2.56 volts on the ATmega8.
to:
  • DEFAULT: the default analog reference of 5 volts (on 5V Arduino boards) or 3.3 volts (on 3.3V Arduino boards)
  • INTERNAL: an built-in reference, equal to 1.1 volts on the ATmega168 or ATmega328 and 2.56 volts on the ATmega8.
October 01, 2009, at 06:03 PM by David A. Mellis -
Changed lines 20-21 from:

It is a good idea to connect external voltages to the AREF pin through a 5K resistor. This will prevent possible internal damage to the Atmega chip if analogReference() software settings are incompatible with the current hardware setup. Connecting external voltages through a resistor also make it possible to switch the AREF voltage on the fly, say from the 5 volt DEFAULT setting, to a 3.3 volt EXTERNAL setting (and applied voltage), without the hardware setup affecting either ADC configuration.

to:

It is a good idea to connect external voltages to the AREF pin through a 5K resistor. This will prevent possible internal damage to the Atmega chip if analogReference() software settings are incompatible with the current hardware setup. 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.2V at the AREF pin.

Connecting external voltages through a resistor makes it possible to switch the AREF voltage on the fly, say from the 5 volt DEFAULT setting, to a 3.3 volt EXTERNAL setting (and applied voltage), without the hardware setup affecting either ADC configuration.

Changed lines 28-31 from:

The default configuration on all Arduino implementations is to have nothing connected externally to the AREF pin (Atmega pin 21). In this case the DEFAULT analogReference software setting connects the AVCC voltage, internally, to the AREF pin. This appears to be a low impedance connection (high current) and voltages, other than AVCC, applied (erroneously) to the AREF pin in the DEFAULT setting could damage the ATMEGA chip. For this reason, connecting external voltages to the AREF pin through a 5K resistor is a good idea.

The AREF pin may also be connected internally to an (internal) 1.1 volt source with analogReference(INTERNAL). With this setting voltages applied to the ADC (analog) pins that are 1.1 volts (or higher) will report 1023, when read with analogRead. Lower voltages will report proportional values, so .55 volts will report about 512.

to:

The default configuration on all Arduino implementations is to have nothing connected externally to the AREF pin (Atmega pin 21). In this case the DEFAULT analogReference software setting connects the AVCC voltage, internally, to the AREF pin. This appears to be a low impedance connection (high current) and voltages, other than AVCC, applied (erroneously) to the AREF pin in the DEFAULT setting could damage the ATMEGA chip.

The AREF pin may also be connected internally to an (internal) 1.1 volt source (or 2.56 on the ATmega8) with analogReference(INTERNAL). With this setting voltages applied to the ADC (analog) pins that are at or above the reference will report 1023 when read with analogRead. Lower voltages will report proportional values, so 0.55 volts will report about 512.

Changed lines 39-40 from:
to:
May 11, 2008, at 06:58 PM by Paul Badger -
Changed lines 20-21 from:

It is a good idea to connect external voltages to the AREF pin through a 5K resistor. This will prevent possible internal damage to the Atmega chip if analogReference() software settings are incompatible with the current hardware setup.

to:

It is a good idea to connect external voltages to the AREF pin through a 5K resistor. This will prevent possible internal damage to the Atmega chip if analogReference() software settings are incompatible with the current hardware setup. Connecting external voltages through a resistor also make it possible to switch the AREF voltage on the fly, say from the 5 volt DEFAULT setting, to a 3.3 volt EXTERNAL setting (and applied voltage), without the hardware setup affecting either ADC configuration.

May 10, 2008, at 09:21 AM by David A. Mellis - this is the Arduino documentation.
Changed lines 26-27 from:

The default configuration on all Arduino and Freeduino implementations is to have nothing connected externally to the AREF pin (Atmega pin 21). In this case the DEFAULT analogReference software setting connects the AVCC voltage, internally, to the AREF pin. This appears to be a low impedance connection (high current) and voltages, other than AVCC, applied (erroneously) to the AREF pin in the DEFAULT setting could damage the ATMEGA chip. For this reason, connecting external voltages to the AREF pin through a 5K resistor is a good idea.

to:

The default configuration on all Arduino implementations is to have nothing connected externally to the AREF pin (Atmega pin 21). In this case the DEFAULT analogReference software setting connects the AVCC voltage, internally, to the AREF pin. This appears to be a low impedance connection (high current) and voltages, other than AVCC, applied (erroneously) to the AREF pin in the DEFAULT setting could damage the ATMEGA chip. For this reason, connecting external voltages to the AREF pin through a 5K resistor is a good idea.

May 10, 2008, at 09:00 AM by Paul Badger -
Changed lines 28-34 from:

The AREF pin may also be connected internally to an internal 1.1 volt source with analogReference(INTERNAL). With this setting voltages applied to the ADC (analog) pins that are 1.1 volts (or higher) will report 1023, when read with analogRead. Lower voltages will report proportional values, so .55 volts will report about 512.

The connection between the 1.1 volt source and the AREF pin is a very high impedance (low current) connection, so that reading the 1.1 (internally supplied) voltage at the AREF pin may only be done with a more expensive, high-impedance multimeter. An external voltage applied (erroneously) to AREF pin while using the INTERNAL setting will not damage the chip, but will totally override the 1.1 volt source, and ADC readings will be governed by the external voltage. It is still desirable to connect any external voltage to the AREF pin through a 5K resistor to avoid the problem cited above.

The correct software setting for using the AREF pin is analogReference(EXTERNAL). This disconnects both of the internal references and the voltage applied externally to the AREF pin sets the reference voltage for the ADC.

to:

The AREF pin may also be connected internally to an (internal) 1.1 volt source with analogReference(INTERNAL). With this setting voltages applied to the ADC (analog) pins that are 1.1 volts (or higher) will report 1023, when read with analogRead. Lower voltages will report proportional values, so .55 volts will report about 512.

The connection between the 1.1 volt source and the AREF pin is a very high impedance (low current) connection, so that reading the 1.1 (internally supplied) voltage at the AREF pin may only be done with a more expensive, high-impedance multimeter. An external voltage applied (erroneously) to AREF pin while using the INTERNAL setting will not damage the chip, but will totally override the 1.1 volt source, and ADC readings will be governed by the external voltage. It is still desirable to connect any external voltage to the AREF pin however, through a 5K resistor to avoid the problem cited above.

The correct software setting for using the AREF pin with an external voltage is analogReference(EXTERNAL). This disconnects both of the internal references and the voltage applied externally to the AREF pin sets the reference voltage for the ADC.

May 10, 2008, at 08:56 AM by Paul Badger -
Changed lines 26-27 from:

The default configuration on all Arduino and Freeduino implementations is to have nothing connected externally to the AREF pin (Atmega pin 21). In this case the DEFAULT analogReference software setting connects the AVCC voltage, internally, to the AREF pin. This appears to be a low impedance connection (high current) and voltages, other than AVCC, applied (erroneously) to AREF pin in the DEFAULT setting could damage the ATMEGA chip. For this reason, connecting external voltages to the AREF pin through a 5K resistor is a good idea.

to:

The default configuration on all Arduino and Freeduino implementations is to have nothing connected externally to the AREF pin (Atmega pin 21). In this case the DEFAULT analogReference software setting connects the AVCC voltage, internally, to the AREF pin. This appears to be a low impedance connection (high current) and voltages, other than AVCC, applied (erroneously) to the AREF pin in the DEFAULT setting could damage the ATMEGA chip. For this reason, connecting external voltages to the AREF pin through a 5K resistor is a good idea.

May 10, 2008, at 08:54 AM by Paul Badger -
Changed lines 26-27 from:

The default configuration on all Arduino and Freeduino implementations is to have nothing connected externally to the AREF pin (Atmega pin 21). In this case the DEFAULT analogReference software setting connects the AVCC voltage, internally, to the AREF pin. This appears to be a low impedance conncetion (high current) and voltages, other than AVCC, applied to AREF pin in the DEFAULT setting could damage the ATMEGA chip. For this reason, connecting external voltages to the AREF pin through a 5K resistor is a good idea.

to:

The default configuration on all Arduino and Freeduino implementations is to have nothing connected externally to the AREF pin (Atmega pin 21). In this case the DEFAULT analogReference software setting connects the AVCC voltage, internally, to the AREF pin. This appears to be a low impedance connection (high current) and voltages, other than AVCC, applied (erroneously) to AREF pin in the DEFAULT setting could damage the ATMEGA chip. For this reason, connecting external voltages to the AREF pin through a 5K resistor is a good idea.

Changed lines 30-32 from:

The connection between the 1.1 volt source and the AREF pin is a very high impedance (low current) connection, so that reading the 1.1 (internally supplied) voltage at the AREF pin may only be done with a more expensive, high-impedance multimeter. An external voltage applied to AREF pin in this setting will not damage the chip, but will totally override the 1.1 volt source, and ADC readings will be governed by the external voltage.

to:

The connection between the 1.1 volt source and the AREF pin is a very high impedance (low current) connection, so that reading the 1.1 (internally supplied) voltage at the AREF pin may only be done with a more expensive, high-impedance multimeter. An external voltage applied (erroneously) to AREF pin while using the INTERNAL setting will not damage the chip, but will totally override the 1.1 volt source, and ADC readings will be governed by the external voltage. It is still desirable to connect any external voltage to the AREF pin through a 5K resistor to avoid the problem cited above.

The correct software setting for using the AREF pin is analogReference(EXTERNAL). This disconnects both of the internal references and the voltage applied externally to the AREF pin sets the reference voltage for the ADC.

May 10, 2008, at 07:55 AM by Paul Badger -
Changed lines 24-32 from:

The voltage applied to the AREF pin directly governs the ADC and sets the voltage at which the ADC will report its highest reading, 1023. Lower voltages applied to ADC (analog) pins will be scaled proportionally, so 2.5 volts on an analog pin will report approximately 512.

The default configuration on all Arduino and Freeduino implementations is to have nothing connected externally to the AREF pin (Atmega pin 21). In this case the DEFAULT analogReference software setting connects the AVCC voltage, internally, to the AREF pin. This appears to be a low impedance conncetion (high current) and other voltages applied to AREF pin in the default setting could damage the ATMEGA chip.

The AREF pin may also be connected internally to an internal 1.1 volt source with analogReference(INTERNAL). With this setting voltages at the analog pins that are 1.1 volts (or higher) will report 1023, when read with analogRead. Lower voltages will report proportional values, so .55 volts will report about 512.

The connection between the 1.1 volt source and the AREF pin is a very high impedance (low current) connection, so that reading the (internal) voltage at the AREF pin may only be done with a more expensive, high-impedance multimeter. An external voltage applied to AREF pin in this setting will not damage the chip, but will totally override the 1.1 volt source, and the analog readings will be governed by the external voltage.

to:

The voltage applied to the AREF pin directly governs the ADC and sets the voltage at which the ADC will report its highest reading, 1023. Lower voltages applied to ADC (analog) pins will be scaled proportionally, so at the DEFAULT setting (5 volt internal connection), 2.5 volts on an analog pin will report approximately 512.

The default configuration on all Arduino and Freeduino implementations is to have nothing connected externally to the AREF pin (Atmega pin 21). In this case the DEFAULT analogReference software setting connects the AVCC voltage, internally, to the AREF pin. This appears to be a low impedance conncetion (high current) and voltages, other than AVCC, applied to AREF pin in the DEFAULT setting could damage the ATMEGA chip. For this reason, connecting external voltages to the AREF pin through a 5K resistor is a good idea.

The AREF pin may also be connected internally to an internal 1.1 volt source with analogReference(INTERNAL). With this setting voltages applied to the ADC (analog) pins that are 1.1 volts (or higher) will report 1023, when read with analogRead. Lower voltages will report proportional values, so .55 volts will report about 512.

The connection between the 1.1 volt source and the AREF pin is a very high impedance (low current) connection, so that reading the 1.1 (internally supplied) voltage at the AREF pin may only be done with a more expensive, high-impedance multimeter. An external voltage applied to AREF pin in this setting will not damage the chip, but will totally override the 1.1 volt source, and ADC readings will be governed by the external voltage.

May 10, 2008, at 07:47 AM by Paul Badger -
Added lines 18-21:

Warning

It is a good idea to connect external voltages to the AREF pin through a 5K resistor. This will prevent possible internal damage to the Atmega chip if analogReference() software settings are incompatible with the current hardware setup.

Changed lines 26-27 from:

The default configuration on all Arduino and Freeduino implementations is to have nothing connected externally to the AREF pin (Atmega pin 21). In this case the DEFAULT analogReference software setting connects the AVCC voltage, internally, to the AREF pin.

to:

The default configuration on all Arduino and Freeduino implementations is to have nothing connected externally to the AREF pin (Atmega pin 21). In this case the DEFAULT analogReference software setting connects the AVCC voltage, internally, to the AREF pin. This appears to be a low impedance conncetion (high current) and other voltages applied to AREF pin in the default setting could damage the ATMEGA chip.

Changed lines 30-36 from:

The connection between the both of the internal connections and the AREF pin is a very high resistance (impedance) connection, so that reading the voltage at the AREF pin may only be done with a more expensive high impedance multimeter.

A voltage connected to the AREF pin, externally, will override either of the

to:

The connection between the 1.1 volt source and the AREF pin is a very high impedance (low current) connection, so that reading the (internal) voltage at the AREF pin may only be done with a more expensive, high-impedance multimeter. An external voltage applied to AREF pin in this setting will not damage the chip, but will totally override the 1.1 volt source, and the analog readings will be governed by the external voltage.

Added line 34:
May 10, 2008, at 07:28 AM by Paul Badger -
Changed lines 18-21 from:

Warning

It is a good idea to connect the external analog reference voltage to the AREF pin through a 1k resistor. This will prevent inadvertent short circuits caused because the pin defaults to an internal connection to 5 volts. This is a low impedance connection meaning that a short circuit to another voltage will draw significant current and possibly damage the analog system in the chip.

to:

Use of the AREF pin

The voltage applied to the AREF pin directly governs the ADC and sets the voltage at which the ADC will report its highest reading, 1023. Lower voltages applied to ADC (analog) pins will be scaled proportionally, so 2.5 volts on an analog pin will report approximately 512.

The default configuration on all Arduino and Freeduino implementations is to have nothing connected externally to the AREF pin (Atmega pin 21). In this case the DEFAULT analogReference software setting connects the AVCC voltage, internally, to the AREF pin.

The AREF pin may also be connected internally to an internal 1.1 volt source with analogReference(INTERNAL). With this setting voltages at the analog pins that are 1.1 volts (or higher) will report 1023, when read with analogRead. Lower voltages will report proportional values, so .55 volts will report about 512.

The connection between the both of the internal connections and the AREF pin is a very high resistance (impedance) connection, so that reading the voltage at the AREF pin may only be done with a more expensive high impedance multimeter.

A voltage connected to the AREF pin, externally, will override either of the

April 26, 2008, at 05:55 AM by Paul Badger -
Changed lines 20-21 from:

It is a good idea to connect the external analog reference voltage to the AREF pin through a 5k resistor. This will prevent inadvertent short circuits caused because the pin defaults to an internal connection to 5 volts. This is a low impedance connection meaning that a short circuit to another voltage will draw significant current and possibly damage the analog system in the chip.

to:

It is a good idea to connect the external analog reference voltage to the AREF pin through a 1k resistor. This will prevent inadvertent short circuits caused because the pin defaults to an internal connection to 5 volts. This is a low impedance connection meaning that a short circuit to another voltage will draw significant current and possibly damage the analog system in the chip.

April 26, 2008, at 05:54 AM by Paul Badger -
Changed lines 20-21 from:

It is a good idea to connect the external analog reference voltage to the AREF pin through a 1k resistor. This will prevent inadvertent short circuits caused because the pin defaults to an internal connection to 5 volts. This is a low impedance connection meaning that a short circuit to another voltage will draw significant current and possibly damage the analog system in the chip.

to:

It is a good idea to connect the external analog reference voltage to the AREF pin through a 5k resistor. This will prevent inadvertent short circuits caused because the pin defaults to an internal connection to 5 volts. This is a low impedance connection meaning that a short circuit to another voltage will draw significant current and possibly damage the analog system in the chip.

April 26, 2008, at 05:52 AM by Paul Badger - This is a better solution than a code fix - I still need to check data sheet for details
Changed lines 20-21 from:

Be sure to call analogReference() with the value that corresponds to the physical configuration of your board. In particular, if you have a voltage other than 5V connected to the AREF pin, you must call analogReference(EXTERNAL) before any calls to analogRead(). If the analog reference is at the default value of 5V or at the internal reference, that voltage will be applied to the AREF pin, creating a short with the externally-supplied voltage.

to:

It is a good idea to connect the external analog reference voltage to the AREF pin through a 1k resistor. This will prevent inadvertent short circuits caused because the pin defaults to an internal connection to 5 volts. This is a low impedance connection meaning that a short circuit to another voltage will draw significant current and possibly damage the analog system in the chip.

April 18, 2008, at 08:23 PM by David A. Mellis -
Changed lines 18-19 from:

Example

to:

Warning

Be sure to call analogReference() with the value that corresponds to the physical configuration of your board. In particular, if you have a voltage other than 5V connected to the AREF pin, you must call analogReference(EXTERNAL) before any calls to analogRead(). If the analog reference is at the default value of 5V or at the internal reference, that voltage will be applied to the AREF pin, creating a short with the externally-supplied voltage.

March 29, 2008, at 12:13 AM by David A. Mellis -
Changed lines 1-2 from:

void analogReference(type)

to:

analogReference(type)

March 29, 2008, at 12:12 AM by David A. Mellis -
Added lines 1-23:

void analogReference(type)

Description

Configures the reference voltage used for analog input. The analogRead() function will return 1023 for an input equal to the reference voltage. The options are:

  • DEFAULT: the default analog reference of 5 volts.
  • INTERNAL: an built-in reference, equal to 1.1 volts on the ATmega168 and 2.56 volts on the ATmega8.
  • EXTERNAL: the voltage applied to the AREF pin is used as the reference.

Parameters

type: which type of reference to use (DEFAULT, INTERNAL, or EXTERNAL).

Returns

None.

Example

See also

Share