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. Best regards, =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Spehro Pefhany --"it's the network..." "The Journey is the reward" speff@interlog.com Info for manufacturers: http://www.trexon.com Embedded software/hardware/analog Info for designers: http://www.speff.com Contributions invited->The AVR-gcc FAQ is at: http://www.bluecollarlinux.com =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=