Society of Robots - Robot Forum

Software => Software => Topic started by: airman00 on February 08, 2009, 05:45:42 PM

Title: How do I set my ATmega168 to use the internal reference
Post by: airman00 on February 08, 2009, 05:45:42 PM
I saw this comment on one instructables project

Quote
You should be able to set your "ADC" AVR to use the internal 2.56V internal reference which is ideal for reading this sensor.

I am using AVRlib and the ATmega168 running at internal 8mhz clock.
How can I modify the code below to use the internal reference of 2.56V ?

Code: [Select]
a2dInit(); // initialize analog to digital converter (ADC)
a2dSetPrescaler(ADC_PRESCALE_DIV32); // configure ADC scaling
a2dSetReference(ADC_REFERENCE_AVCC); // configure ADC reference voltage
Title: Re: How do I set my ATmega168 to use the internal reference
Post by: airman00 on February 08, 2009, 05:47:46 PM
I saw this:
Quote
INTERNAL: an built-in reference, equal to 1.1 volts on the ATmega168 and 2.56 volts on the ATmega8.
Nevermind then , the ATmega168 can only do 1.1 volts for internal reference
Title: Re: How do I set my ATmega168 to use the internal reference
Post by: airman00 on February 09, 2009, 09:35:39 AM
Found this in the Datasheet
Quote
ADC Voltage Reference
The reference voltage for the ADC (VREF) indicates the conversion range for the ADC. Single
ended channels that exceed VREF will result in codes close to 0x3FF. VREF can be selected as
either AVCC, internal 1.1V reference, or external AREF pin.

Anyway I can boost up that 1.1V internal reference to 2.56V ?
Title: Re: How do I set my ATmega168 to use the internal reference
Post by: Webbot on February 09, 2009, 10:32:44 AM
No.


But if you used the normal Vcc (ie 5v) then could you not just sample the 2.56v inputs and then multiply your result by 2?

This would mean that you are effectively lowering the maximum precision from 10bit to 9bit. So IF you are storing it as an 8 bit value then it wont make any difference.