 |
| Author |
Message |
|
|
Posted: Mar 10, 2010 - 09:30 AM |
|

Joined: Feb 11, 2009
Posts: 5
|
|
Hi, I'm currently using the Atmega168 in a project for controlling a stepper motor.
The micro is running at with the internal clock at 4Mhz. and the ADC clock is at 62,5 kHz, and I use an external +5V signal as reference. I have the adlar bit set so that i get the 8 msb (10 bit adc) in register ADCH.
My question is the following. en i read out the value from the ADCH 0v is represented by ~25 decimal and +5V is represented by ~230 decimal. Is this what i should expect? I thought the register would contain the full range 0-255 but with less accuracy or am i totally off track?
please help  |
|
|
| |
|
|
|
|
|
Posted: Mar 10, 2010 - 11:48 AM |
|


Joined: Jul 18, 2005
Posts: 34710
Location: (using avr-gcc in) Finchingfield, Essex, England
|
|
| If you connect the input to Vcc then yes you should expect 255 and if connected to Gnd it should be 0. Sounds like there may be more to your external circuitry and what you call +5V isn't really - does a DVM or scope confirm that the voltage on the input is the same as the Vcc pin. If you disconnect everything else and just wire direct to Vcc what happens? |
_________________
|
| |
|
|
|
|
|
Posted: Mar 10, 2010 - 01:57 PM |
|

Joined: Feb 02, 2009
Posts: 971
|
|
| Using 5V as reference, 25 would represent 0.5V and 230 would represent about 4.5V. The 0.5V in the GND may explain the 4.5V you see for the VCC. Do you have a capacitor at the ADC input? |
|
|
| |
|
|
|
|
|
Posted: Mar 11, 2010 - 07:59 AM |
|

Joined: Feb 11, 2009
Posts: 5
|
|
Thanks for your answer guys. I found the error and as always it was my own I forgot to wire the AVCC pin to 5V. When not connected i measured a voltage of 4,5V at the VCC pin which would explain the adc range being off by about 0.5V. Afte connecting avcc to Vcc everything is working perfect.
But isn't it strange that the adc works even without an external voltage? |
|
|
| |
|
|
|
|
|
|
|