jinorane / sf9domahrs

Automatically exported from code.google.com/p/sf9domahrs
0 stars 0 forks source link

ADC Oversampling doesn't actually increase resolution #25

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
The ADC has 10 bit resolution (integer values 0-1023)

The output values will be integer values between 0 and 1023. No change.

To increase res, you need to output a float or return a higher integer range - 
I'd suggest 0-65535 (uint_16t). In that case, you need to change the following 
line in the Read_adc_raw(void) method in the ADC.pde file to something like 
below:

if (temp2>0) AN[i] = (float)temp1/(float)temp2;

becomes

if (temp2>0) AN[i] = (((float)temp1/(float)temp2) * 64);

Cheers, Les

Original issue reported on code.google.com by l...@greemo.com on 3 May 2011 at 9:06

GoogleCodeExporter commented 9 years ago
Actually, AN is a signed int array, so if you don't change that, you need to do:
if (temp2>0) AN[i] = (((float)temp1/(float)temp2) * 64) - 32768;

Original comment by l...@greemo.com on 9 May 2011 at 7:57