I would normally implement such a filter as: Total =3D Total + New - Filt Filt =3D (Total+1) / Factor And I usually make Factor =3D 2^N so I can divide by right shifting. This keeps everything as integers, and if you want the extra resolution,=20 you can use Total. Kerry Olin Lathrop wrote: > RussellMc wrote: > =20 >> Simplistic example. If random noise is added to a signal and it reads >> 145 mV 60% of the time and 146 mV 40 % of the time then actual voltage >> MAY be about 145.4 (not 145.6) mV. Take care when arttempting to apply >> this magic. It does work, but ... >> =20 > > It's pretty easy to apply on the firmware end. Just low pass filter > multiple A/D readings. > > When you have the cycles and real time available, it's a good idea to > oversample with the A/D, then low pass filter in firmware anyway. It get= s > you a little extra resolution if the right kind of input noise is present= as > you said, but it also reduces quantization noise and relaxes anti-aliasin= g > filtering requirements on the external hardware. > > Fortunately a single pole low pass filter is easy to compute: > > FILT <-- FILT + FF(NEW - FILT) > > where FILT is the low pass filter being updated with input value NEW each > iteration. FF is the "filter fraction". FF =3D 1 is just a pass thru fi= lter, > and FF =3D 0 is a infinitely heavy filter. Useful values are obviously i= n > between. In a small system with limited math capabilities, you often > arrange FF =3D 1/(2**N), so that the multiply by FF becomes a right shift= by > N. > > > ******************************************************************** > Embed Inc, Littleton Massachusetts, http://www.embedinc.com/products > (978) 742-9014. Gold level PIC consultants since 2000. > =20 --=20 Internal Virus Database is out-of-date. Checked by AVG Anti-Virus. Version: 7.0.289 / Virus Database: 267.11.13 - Release Date: 10/6/05 --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .