I think you perhaps meant: Filt=3D(Total)/Factor In that case, I often use the structure you are talking about. It allows you to do only one division for both the output computation and the internal filter computation, while avoiding resolution issues with fixed-point math. For example, if we have a filter factor of 16, with Olin's example, and using integer math, we have: FILT<--FILT + (NEW-FILT)/16 If the absolute value of the difference NEW-FILT is less than 16, nothing ever happens. With Kerry's version: Total<--Total+New-Filt Any nonzero value of New-Filt causes a change in Total. To scale the output, we just divide Total by 16 (filt=3DTotal/16). However, that also gives us the value Filt which we need in order to compute the filter's difference equation, too. Sean On Tue, Nov 23, 2010 at 9:30 AM, Kerry Wentworth wrote: > I would normally implement such a filter as: > > Total =3D Total + New - Filt > Filt =3D (Total+1) / Factor > And I usually =A0make Factor =3D 2^N so I can divide by right shifting. > This keeps everything as integers, and if you want the extra resolution, > you can use Total. > > Kerry > > > Olin Lathrop wrote: >> RussellMc wrote: >> >>> 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 ... >>> >> >> It's pretty easy to apply on the firmware end. =A0Just 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. =A0It = gets >> you a little extra resolution if the right kind of input noise is presen= t as >> you said, but it also reduces quantization noise and relaxes anti-aliasi= ng >> filtering requirements on the external hardware. >> >> Fortunately a single pole low pass filter is easy to compute: >> >> =A0 FILT <-- FILT + FF(NEW - FILT) >> >> where FILT is the low pass filter being updated with input value NEW eac= h >> iteration. =A0FF is the "filter fraction". =A0FF =3D 1 is just a pass th= ru filter, >> and FF =3D 0 is a infinitely heavy filter. =A0Useful values are obviousl= y in >> between. =A0In a small system with limited math capabilities, you often >> arrange FF =3D 1/(2**N), so that the multiply by FF becomes a right shif= t by >> N. >> >> >> ******************************************************************** >> Embed Inc, Littleton Massachusetts, http://www.embedinc.com/products >> (978) 742-9014. =A0Gold level PIC consultants since 2000. >> > > > > -- > 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 > > -- > http://www.piclist.com PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist > --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .