pedvide / ADC

Teensy 4/3.x/LC ADC implementation
MIT License
211 stars 69 forks source link

Differential gain settings not working correctly #59

Open EclipseBoom opened 4 years ago

EclipseBoom commented 4 years ago

I was trying out the differential conversion options with various gain settings and I noticed that x8 and x16 settings seems to not be correct. I did a little sketch to read the same signal at 1,2,4,8,16,32x gain settings and these are the results (Teensy 3.2, A10,A11 inputs, 16-bit resolution)

1088, 2102, 3764, 7278, 9730, 17340 different level 502, 944, 1716, 3118, 4402, 8102

The signal is from a wheatstone bridge with a 3.3V supply so the common mode voltage is about 1.65V

// Differential reads adc->enablePGA(1); value = adc->adc0->analogReadDifferential(A10, A11); // read a new value, will return ADC_ERROR_VALUE if the comparison is false. Serial.print(value); Serial.print(", "); adc->enablePGA(2); value = adc->adc0->analogReadDifferential(A10, A11); // read a new value, will return ADC_ERROR_VALUE if the comparison is false. Serial.print(value); Serial.print(", "); adc->enablePGA(4); value = adc->adc0->analogReadDifferential(A10, A11); // read a new value, will return ADC_ERROR_VALUE if the comparison is false. Serial.print(value); Serial.print(", "); adc->enablePGA(8); value = adc->adc0->analogReadDifferential(A10, A11); // read a new value, will return ADC_ERROR_VALUE if the comparison is false. Serial.print(value); Serial.print(", "); adc->enablePGA(16); value = adc->adc0->analogReadDifferential(A10, A11); // read a new value, will return ADC_ERROR_VALUE if the comparison is false. Serial.print(value); Serial.print(", "); adc->enablePGA(32); value = adc->adc0->analogReadDifferential(A10, A11); // read a new value, will return ADC_ERROR_VALUE if the comparison is false. Serial.print(value); Serial.println();

pedvide commented 4 years ago

Yeah that seems off. Maybe I'll have time to look into in during the weekend, thanks for reporting it.