Hello all.
I am using the ATmega644P and 5 ADC inputs for reading several analog voltages. When I read 100mV if I convert the the analog reading into volts again I have a difference of 30mV, reading only 70mV. If I read 2,5 volts the difference is only 10mV. As we go up in the voltage read the difference is smaller. I used a potentiometer to make a voltage divider and if we read voltages of 50mV the ADC reading is equivalent to 25mV.
The AVCC voltage pin is 5V and I have a low pass filter with 100uH choke and a 4.7uF tantalum capacitor and a .1uF. Connected to the AREF pin I have a 0.1uF capacitor.
The ADC setup is the following:
// ADC Enable ADCSRA |=(1<<ADEN); ADCSRA |=(1<<ADPS2)|(1<<ADPS1)|(1<<ADPS0); ADMUX |=(1<<REFS0); DIDR0 =0b00011111;
The function call and the ADC reading routine is the following:
adc_value = Read_ADC(0+64); // +64 is the REFS= bit, AVCC with external capacitor at AREF pin /**************************************************************** * This routine is to read the ADC. The ADC is going to read the * motor battery voltage, receiver battery voltage, temperature and * air speed. */ uint16_t Read_ADC(uint8_t adc_adr) { uint16_t adc_value =0; ADMUX = (adc_adr); ADCSRA |=(1<<ADSC); while(ADCSRA & (1<<ADSC)); {} adc_value=ADCW; return adc_value; }
Do you see any thing wrong in the code? Can you please help me on solve the problem.
Regards,
Manuel