----- Original Message ----- From: Jose S. Samonte Jr. To: Sent: Saturday, January 20, 2001 1:21 PM Subject: Re: [Re: [PIC]: What is IIR filter?] How is it done, by software, or hardware? It can be either. It is often done in a DSP (digital signal processor) which is a special type of high-performance processor designed for this type of application. It can be done in a PIC, if the signals are of low enough frequency for the PIC to be able to keep up (typically sub-audio frequencies). Here is a very simple IIR in a pseudocode representation: filteredoutput = filteredoutput * (1-X) + newinput * X where 'X' is a value between 0.0 and 1.0. When 'X' is 1.0 no filtering takes place because the formula becomes: filteredoutput = filtredoutput * 0.0 + newinput * 1.0 When 'X' is 0.0 we ignore the input becuase the formula becomes: filteredoutput = filteredoutput * 1.0 + newinput * 0.0 Values in between give varying results. For example, when 'X' is 0.5 we have: filteredoutput = filteredoutput * 0.5 + newinput * 0.5 In other words, the output is average of whatever it used to be and the new input (sample) value. After a bunch of samples, what we have is a weighted average of samples (in theory going back infinitely, hence "I"IR): 1/2 of most recent sample 1/4 of sample before that 1/8 of sample before that 1/16 of sample before that etc. etc. etc. Note that the series 1/2+1/4+1/8+1/16... sums to 1.0, so the average is in the same 'scale' as the individual samples. Bob Ammerman RAm Systems (contract development of high performance, high function, low-level software) -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body