On Fri, 19 May 2000, Spehro Pefhany wrote: > At 02:01 PM 5/19/00 +0200, Quentin wrote: > >My A/D input signal is such that I will always have a +/- 10 fluctuation > >in my register value. Can somebody tell me how to get an average reading > >over say 5 A/D samples? > > If your readings are periodic, one method is to pick a constant 'a' > > and do value = (1-a) * value + a*reading > > (you might also use a flag to preload value=reading the first time. > > This forms a low pass filter, and more recent values have a higher weight > than previous values. It has the advantage that it only uses one ram > location and you get a value every A/D conversion. > > If you just want to take a bunch of readings in succession and average > them, just add n values together and then divide by n. Obviously you > need to avoid overflow during the add, so you might use 16 bit math > for an 8/10/12 bit A/D reading with 256/64/16 values or less being > averaged. I guess this is a record for repeated thread frequency. Quentin, look at the archives from just a few days back when we were talking about this exact issue and proposed the exact solutions you've seen posted today. Scott