On Sun, 25 Mar 2001, Olin Lathrop wrote: > > how are you doing a low pass filter in software ? > > > > maybe just point me in the right direction with the "extra 2 or 4 bits" > part > > A single pole low pass filter is easy and fast in software. If NEW is a new > reading and FILT is the filter value to update with the new reading then the > algorithm is: > > FILT <-- FILT * (1 - W) + NEW * W > > where W is a 0 to 1 weighting fraction for the new value. This type of > filter has the same response as an RC low pass filter with NEW as the input > and FILT as the output. W determines the time constant of the filter if new > values come in at regular intervals. Here's an efficient implementation of that algorithm http://www.dattalo.com/technical/software/pic/twist.asm Here's a small snippet of the comments. ;;; -------------------------------------------------- ;;; twist ;;; ;;; The purpose of this routine is to evaluate: ;;; ;;; A*x + B*y ;;; ------------ ;;; A + B ;;; ;;; Such that A+B = 2^N 'x' and 'y' are the "FILT" and "NEW" parameters. The weighting factor is W = B/(A-B) (note: 1-W = A/(A-B) Which is the coefficient on 'x' and "FILT".) My algorithm limits 'x' and 'y' to 8 bits and 'A' and 'B' to 4 bits. The algorithm is computed with 8-bit arithmetic, so the "2-4" extra bits alluded to above will not be obtainable. Now, Tony K. has written a similar routine for 24-bit numbers. (See http://www.dattalo.com/technical/software/software.html ). Scott. -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body