Forbidden values in ADC output
reinier_3537311 Jun 29, 2018 8:28 PMWhen I use averaging in the ADC_SAR it seems that certain blocks of values are output very rarely or not at all. I tested this by measuring the ADC output with a gradually increasing voltage. Without averaging, all values between 0..2047 seem to be valid results. When I average 16 samples with fixed resolution, there are sudden jumps of around 40 counts. A histogram of ADC readings shows that the values come in groups of 64 of about 24 on 40 off. When I average 16 samples with accumulation, expecting all values between 0..32767 to be valid, I get jumps of about 650 in the plot of counts, and the histogram shows groups of 1024 of about 384 on 640 off.
Looking more closely at 16 samples averaged with fixed accumulation, I notice that the 32s bit and the 4s bit don't flip like I expect them to. For example, 795+1=832 in binary is 0011 0001 1011 + 1 = 0011 0100 0000.
This is the code I'm using to obtain measurements:
int16 _getADC(void) {
int16 val;
ADC_StartConvert();
ADC_IsEndConversion(ADC_WAIT_FOR_RESULT);
ADC_StopConvert();
val = ADC_GetResult16(0);
if (val < 0) val = 0;
return val;
}
I'm using PSoC 4 with ADC_SAR v2.40. Single-ended with Vss (hence the limitation to positive values).
Why does averaging make the output behave so strangely?
-
acc_16sa_fixed.txt.zip 2.6 K
-
adc_16sa_acc_hist.png 31.8 K
-
adc_16sa_acc_signal.png 37.0 K
-
adc_16sa_fixed_hist.png 35.9 K
-
adc_16sa_fixed_signal.png 36.2 K
-
adc_no_avg_hist.png 31.6 K
-
adc_no_avg_signal.png 35.1 K