go_away

Author Topic: How do I set my ATmega168 to use the internal reference  (Read 2670 times)

0 Members and 1 Guest are viewing this topic.

Offline airman00Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 3,653
  • Helpful? 21
  • narobo.com
How do I set my ATmega168 to use the internal reference
« 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
Check out the Roboduino, Arduino-compatible board!


Link: http://curiousinventor.com/kits/roboduino

www.Narobo.com

Offline airman00Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 3,653
  • Helpful? 21
  • narobo.com
Re: How do I set my ATmega168 to use the internal reference
« Reply #1 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
Check out the Roboduino, Arduino-compatible board!


Link: http://curiousinventor.com/kits/roboduino

www.Narobo.com

Offline airman00Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 3,653
  • Helpful? 21
  • narobo.com
Re: How do I set my ATmega168 to use the internal reference
« Reply #2 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 ?
« Last Edit: February 09, 2009, 09:39:24 AM by airman00 »
Check out the Roboduino, Arduino-compatible board!


Link: http://curiousinventor.com/kits/roboduino

www.Narobo.com

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,166
  • Helpful? 111
Re: How do I set my ATmega168 to use the internal reference
« Reply #3 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.


Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk

 


Get Your Ad Here

data_list