Atmega328p ADC & CPU frequency
Re: Atmega328p ADC & CPU frequency
Re: Atmega328p ADC & CPU frequency
Re: Atmega328p ADC & CPU frequency
Re: Atmega328p ADC & CPU frequency
Re: Atmega328p ADC & CPU frequency
The internal voltage reference may thus be decoupled by an external capacitor at the AREF pin to improve noise immunity.
Re: Atmega328p ADC & CPU frequency
fat16lib wrote:You may not get max accuracy with a slow ADC clock, not the full 10-bits.
Re: Atmega328p ADC & CPU frequency
I have not seen a clear description of what happens at slower ADC clock rates for the AVR ADC. The normal problem with a slow ADC clock isBy default, the successive approximation circuitry requires an input clock frequency between 50 kHz and 200 kHz to get maximum resolution.
The conversion must complete in some minimum time or droop on the sample-and-hold can degrade conversion results.
Re: Atmega328p ADC & CPU frequency
fat16lib wrote:The Arduino software should take F_CPU into account but it works OK for 8-16 MHz CPUs.
// set a2d prescale factor to 128
// 16 MHz / 128 = 125 KHz, inside the desired 50-200 KHz range.
// XXX: this will not work properly for other clock speeds, and
// this code should use F_CPU to determine the prescale factor.
Re: Atmega328p ADC & CPU frequency
#define V_REF 1.076 // measured value of reference
#define CAL_OFFSET -0.2 // TMP36 correction degrees C
void setup(void) {
analogReference(INTERNAL);
Serial.begin(9600);
}
void loop(void) {
uint16_t sum = 0;
for (uint8_t i = 0; i < 16; i++) {
sum += analogRead(0);
}
float adcAvg = sum/16.0;
float v = V_REF*adcAvg/1023;
float temp = 100.0*(v - 0.5) + CAL_OFFSET;
Serial.print("adc: ");
Serial.print(adcAvg);
Serial.print(", temp C: ");
Serial.println(temp);
delay(1000);
}
adc: 682.25, temp C: 21.56
adc: 682.31, temp C: 21.57
adc: 682.13, temp C: 21.55
adc: 682.25, temp C: 21.56
adc: 682.25, temp C: 21.56
adc: 682.50, temp C: 21.59
adc: 682.06, temp C: 21.54
adc: 682.31, temp C: 21.57
adc: 682.13, temp C: 21.55
adc: 682.13, temp C: 21.55
adc: 682.31, temp C: 21.57
adc: 682.25, temp C: 21.56
adc: 682.25, temp C: 21.56
adc: 682.19, temp C: 21.55
adc: 682.75, temp C: 21.61
adc: 682.44, temp C: 21.58
adc: 682.38, temp C: 21.57
adc: 682.25, temp C: 21.56
adc: 682.06, temp C: 21.54
adc: 682.13, temp C: 21.55
adc: 682.63, temp C: 21.60
adc: 682.25, temp C: 21.56
Re: Atmega328p ADC & CPU frequency
room temp 19.8 8Mhz int // CKDIV8 // CPU 1MHz
adc: 652.31, temp C: 19.76
adc: 652.19, temp C: 19.75
adc: 652.31, temp C: 19.76
adc: 652.38, temp C: 19.77
adc: 652.19, temp C: 19.75
adc: 652.63, temp C: 19.79
adc: 652.06, temp C: 19.73
adc: 652.13, temp C: 19.74
adc: 652.19, temp C: 19.75
adc: 652.19, temp C: 19.75
adc: 652.31, temp C: 19.76
room temp 19.8 16MHz crystal // CKDIV8 // cpu 2MHz
adc: 643.63, temp C: 18.83
adc: 643.44, temp C: 18.81
adc: 643.25, temp C: 18.79
adc: 643.13, temp C: 18.78
adc: 642.88, temp C: 18.75
adc: 642.94, temp C: 18.76
adc: 642.75, temp C: 18.74
adc: 642.88, temp C: 18.75
adc: 642.88, temp C: 18.75
adc: 643.19, temp C: 18.78
room temp 19.8 8Mhz internal // CPU 8MHz
adc: 580.44, temp C: 12.07
adc: 576.94, temp C: 11.70
adc: 583.19, temp C: 12.37
adc: 588.19, temp C: 12.90
adc: 581.56, temp C: 12.19
adc: 577.00, temp C: 11.70
adc: 583.06, temp C: 12.35
adc: 587.19, temp C: 12.79
adc: 580.81, temp C: 12.11
adc: 577.06, temp C: 11.71
room temp 19.8 16MHz crystal // cpu 16MHz
adc: 602.56, temp C: 14.44
adc: 600.13, temp C: 14.18
adc: 600.56, temp C: 14.22
adc: 604.50, temp C: 14.65
adc: 604.56, temp C: 14.65
adc: 600.44, temp C: 14.21
adc: 598.63, temp C: 14.02
adc: 598.25, temp C: 13.98
Re: Atmega328p ADC & CPU frequency
Re: Atmega328p ADC & CPU frequency
Re: Atmega328p ADC & CPU frequency
didier wrote:It may be a silly trivial question: How did you, both tcharron and fatlib16 bind the sensor to what ?
Re: Atmega328p ADC & CPU frequency