[En-Nut-Discussion] Question about ADC stability
Rich Wellner
ethernut at objenv.com
Mon Feb 19 05:22:03 CET 2007
I've hooked an lm35 to adc0 and am surprised at the results I'm getting.
double temp;
u_short value = 0;
//int i=0;
ADCInit();
ADCSetChannel(ADC0);
ADCBufferFlush();
ADCSetMode(FREE_RUNNING);
ADCStartConversion();
for(;;){
while (ADCRead(&value))
NutThreadYield();
printf("raw value: %i\n", value);
printf("Temp C: %f\n", (double)value / 1023.0 * 5.0 *100);
}
It goes without saying, I hope, that I haven't been changing the temp
dramatically. I've also confirmed that the sensor it putting out a
steady .232V, which is what I expect in my slightly warm workroom at the
moment. Are there additional things that need to be done to get steady
readings from this adc? Also, if I switch to SINGLE_CONVERSION then I
get a more correct reading on average (e.g. about 23C), but it's still
highly variable as with the readings below.
raw value: 96
Temp C: 46.920824
raw value: 79
Temp C: 38.611922
raw value: 79
Temp C: 38.611922
raw value: 79
Temp C: 38.611922
raw value: 79
Temp C: 38.611922
raw value: 79
Temp C: 38.611922
raw value: 79
Temp C: 38.611922
raw value: 79
Temp C: 38.611922
raw value: 79
Temp C: 38.611922
raw value: 71
Temp C: 34.701857
More information about the En-Nut-Discussion
mailing list