To overcome the ADC reading instability, several type of software filters have been devised and
among these the average, or mean value, is the simpler and most widely used.
I came to the conclusion that a better method is the MEDIAN and not the MEAN since the average
incorporate into the final result (the mean) also any anomalous reading due to spikes or other
electrical noisy phenomenon could occur during the sampling.
The MEDIAN which is the central value of the frequency distribution of our ADC reading, coincide
with the mean if the frequency distribution is normal, while the MEAN drift from the MEDIAN
all the time that anomalous reading are taken.
Here the contradiction, we make the average to get rid of anomalous reading but we just incorporate
them, in other words, the mean value is a way to dilute anomalous reading while, the MEDIAN is a mean to
get rid of them.
Rock stable results have been obtained extracting the MEDIAN out of 15 consecutive readings, with
the INCLUDE module "Al_ADC_Median.PBP", which I am glad to post here and share it with the community.
The use is rather simple, just assign the ADC channel to the channel variable and call the module
with "GOSUB GetADC" the ADC_Value (word variable) returned, will contain the ADC MEDIAN of 15 reading.
I have also posted a working code using PIC 12F683 as an example on how to use the include module.
Place the "Al_ADC_Median.PBP in the PBP folder, add the include to your code and you are done.
I hope the folks working with analog can find it useful. Comments on the subject and on the stability
of the MEDIAN filter are welcome.
Cheer and All the best wishes for the new year.
Al.
PS. You need to rename the extention form .TXT to .PBP since I was anable to upload the files with the original extention
Bookmarks