Log in

View Full Version : Printing Analog Input with Kevin's new code


govvijay
13-02-2008, 18:36
We are trying to print analog values from our autonomous switch, but we are only getting 0 values. I was just wondering how do you print analog inputs using Kevin's new code.

Thanks,
Vijay G.

psy_wombats
13-02-2008, 18:45
It should be normal, something like:

for (k = 1; k <= NUM_ADC_CHANNELS; k++) {
printf("ADC %d: %d\r\n", k, Get_ADC_Result(k));
}

If you want to get fancy. Make sure the number of ADC channels is set correctly in adc.h. This looks more like an electrical problem though. You may want to check with an oscilloscope that you are actually getting values from the ADC.

Kevin Watson
13-02-2008, 21:21
It should be normal, something like:

for (k = 1; k <= NUM_ADC_CHANNELS; k++) {
printf("ADC %d: %d\r\n", k, Get_ADC_Result(k));
}

If you want to get fancy. Make sure the number of ADC channels is set correctly in adc.h. This looks more like an electrical problem though. You may want to check with an oscilloscope that you are actually getting values from the ADC.Get_ADC_Result() returns an unsigned int, so you'll want to use %u in your printf() format string instead of %d.

-Kevin