Analog To Digital Converter Averaging
Travis M. Best
Posts: 9
Is their a easy way to average 100+ samples from a A/D Converter without having a ton a variables???
Thanks
Travis Best
Thanks
Travis Best
Comments
MacGeek117
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
BS2: $49
SX48 Protoboard: $10
Propeller Protoboard: Priceless
www.apple.com
www.parallax.com
www.goldmine-elec.com
www.expresspcb.com
www.jameco.com
Leon
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Amateur radio callsign: G1HSM
An alternative is to use something along the lines of this algorithm which works ok when there isn't large noise
AverageVal = AverageVal + (NewSample-AverageVal) / 128
effectively each above/below average new sample increases/decreases the long term average by a smidge. You need to either use floating point or shift up AverageVal a few digits (like a fixed decimal point)
This particular example is for a 16 element moving average, but you could easily make it into a 128 point moving average by changing the buffer size, the mask, and and the shift arithmetic right. There are a variety of additional filter examples in this thread.
Post Edited (BR) : 12/13/2009 11:38:26 PM GMT