Armia Wagdy
Newbie level 4
- Joined
- Nov 14, 2013
- Messages
- 5
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Activity points
- 38
I've been working in an ADC project on ATmega 32
my ADC is 10-bit resolution, Vref = 2.56V (internally
from this information I can conclude that step size = 2.56/1024 = 2.5mV
then, if the input voltage is 2.5 volt, the Digital data output must be 2.5V /2.5mV = 1000 = 0b1111101000
I've made that code and make a simulation in proteus, but when the input voltage was 2.5V, the output was 999 (decimal) = 0b1111100111 instead of 1000 why??!!
Note: the digital data output is right adjusted
that's my code:
and this is the output of the proteus simulation
my ADC is 10-bit resolution, Vref = 2.56V (internally
from this information I can conclude that step size = 2.56/1024 = 2.5mV
then, if the input voltage is 2.5 volt, the Digital data output must be 2.5V /2.5mV = 1000 = 0b1111101000
I've made that code and make a simulation in proteus, but when the input voltage was 2.5V, the output was 999 (decimal) = 0b1111100111 instead of 1000 why??!!
Note: the digital data output is right adjusted
that's my code:
Code:
#include <avr/io.h>
int main(void)
{
DDRB = 0xFF;
DDRD = 0xFF;
DDRA = 0;
ADCSRA = 0x87; //ADC enable, clk/128
ADMUX = 0xC0; //Internal vref, single ended ADC0
while(1){
ADCSRA |=(1<<ADSC); //start conversion
while(ADCSRA & (1<<ADIF) == 0);
PORTD = ADCL;
PORTB = ADCH;
}
return 0;
}
and this is the output of the proteus simulation
Last edited: