// Seeed XIAO RA4M1 ADC Test
// Michael Koch, September 2024
double x, mean, sigma;
double sum_x, sum_xx;
int n;
// the setup function runs once when you press reset or power the board
void setup()
{
analogReadResolution(12);
Serial.begin(115200);
while (!Serial)
delay(10);
}
// the loop function runs over and over again forever
void loop()
{
n = 10000;
sum_x = 0;
sum_xx = 0;
for(int i = 0; i < n; i++)
{
x = (double)analogRead(A1);
sum_x += x;
sum_xx += x*x;
}
mean = sum_x / n;
sigma = (sum_xx - n * mean * mean) / n;
Serial.print("Mean: ");
Serial.print(mean);
Serial.print(" Sigma: ");
Serial.print(sigma);
Serial.println();
delay(500);
}
The mean value is as expected, but there is a standard deviation of about 135.
The same software with a SAMD21 module has a standard deviation of about 4 (in the same test circuit).
Why does the RA4M1 have more noise by a factor 30? The ADC is almost unusable.
I did already try to use an external reference instead of the 3.3V reference (after removing R5 from the module) but it didn’t help much.
I forgot the square root in the formula for the standard deviation:
sigma = sqrt((sum_xx - n * mean * mean) / n);
But the problem remains the same: RA4M1 has much more noise than SAMD21 in the ADC values.
Hi,
We found that the problem was that the noise of the power supply to the ADC was too large. We changed the R4 from 0Ω to 15Ω, and the variance after repair is about 1~3. We will release the optimized version v1.01 soon.