Вы находитесь на странице: 1из 2

USO DE LA REFERENCIA ANALOGICA CON UN SENSOR DE TEMPERATURA PARA ARDUINO La Referencia Analgica fija el mximo valor de tensin que

podemos medir en una entrada analgica de nuestra placa. Por defecto la referencia es de 5V, as que la resolucin de nuestra medida es 5/1024 (no 5/1023, como ponen algunos, pgina 254 del manual del Atmega168). Cuando leemos una entrada analgica conseguimos una lectura de "cuentas del convertidor" que vara entre 0 y 1023. Si queremos pasar esta medida a voltios solo tenemos que multiplicarla por 5/1024. Efectivamente, nunca conseguimos 5V, como mucho 1023*5/1024. Ahora bien, si conectamos una tensin externa a la entrada "AREF" de nuestra placa, podemos modificar el valor mximo de nuestra medida (fondo de escala). Hay una manera de poner una Referencia Analgica distinta sin conectar nada (por sotware), llamando a la funcin analogReference(INTERNAL); en el setup, por ejemplo. De esta forma nuestra referencia pasa a ser 1,1V (110C en el caso del LM35), la resolucin 1,1/1024 y para convertir a voltios lo que conecte a una entrada analgica: lectura * 1,1/1024. De esta forma tu resolucin aumenta, aunque seguiras necesitando hacer promedios para disminuir el ruido. Una cosa importante. Si cambiamos la referencia analgica con analogReference(), esto afecta a todas las entradas analgicas de la placa. Si quiero combinar medidas con la referencia de 1,1 y 5V en el mismo programa, tendr que llamar a la funcin analogReference() antes de cambiar el tipo de medida en el programa.

analogReference(type) D e s c r i p ti o n Configures the reference voltage used for analog input (i.e. the value used as the top of the input range). 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 theATmega8 (not available on the Arduino Mega) INTERNAL1V1: a built-in 1.1V reference (Arduino Mega only) INTERNAL2V56: a built-in 2.56V reference (Arduino Mega only) EXTERNAL: the voltage applied to the AREF pin (0 to 5V only) is used as the reference. Parameters

type: which type of reference to use (DEFAULT, INTERNAL, INTERNAL1V1, INTERNAL2V56, or EXTERNAL). Returns None. Note After changing the analog reference, the first few readings from analogRead() may not be accurate. Warning Don't use anything less than 0V or more than 5V for external reference voltage on the AREF pin! If you're using an external reference on 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.

Aqu tienes la informacin de como usar la "tensin de referencia analgica" http://arduino.cc/en/Reference/AnalogReference

Вам также может понравиться