Hello everybody, I want to share my finding with you. I had many problems with the noisy ADC of Mbed.
I managed to solve this problem with steady success with the use of a simple statistical filter.
My filter works this way:
1. Calculate the mean value among all values, since the beginning of acquisition.
2.Calculate the STANDARD DEVIATION (is this the correct term in English?) of the values
3. Reject the data which value is ABOVE the value of the sum: mean value + standard deviation
4. Reject the data which value is BELOW the value of the difference: mean value - standard deviation
Visualization: http://upload.wikimedia.org/wikipedia/commons/7/7e/Standard_deviation_illustration.gif
This way the very high peaks get cancelled because they don' t respect the condition of the filter. I had great results, the ADC now works perfectly.
But some issues have to be addressed, like the data accumulation and possible overflow.
I have very little time to work on this so I can' t post a fully wroking code or library. Hope this is useful!
Here it is a code snippet:
while(1){
read=analog.read();
sumx2+=read*read;
sum2x+=read;
acc=h*sumx2-(sum2x*sum2x);
sigma=(1.0/h)*sqrt(acc);
TC+=read;
TF=TC/h;
if(read<(sigma+TF)){
if(read>(TF-sigma)){
//Use your data here//
}
}
h+=1.0;
}
Bye
Every linear circuit is a 'filter' yes.. You don't need to quote to me what a filter is. I just wanted to point out that an LC filter isn't used in wide band applications. But since you insist on doing things your way, have fun! :)