Assuming the pump runs at a relatively reasonable speed (maybe 1800RPM = 30 pulses per second?) you might be able to do everything inside the PIC with software based on the existing A/D value (if the PIC isn't too busy already): > >In analog electronics, this could be done by low-pass filtering the > >signal Low pass filtering in software is very easy. The simplest technique is probably an IIR filter, for example: NewFilteredValue = OldFilteredValue * (1-k) + NewSample*k Values of K like 1/2, 1/4, 1/8, 1/16 make for a particularly efficient implementation. >> AC coupling it This can be done by maintaining a longer term average (ie: a much slower digital filter) to track the average value of the signal. > and applying a zero-crossing detector with Just compare the outputs of the two filters. > >some hysteresis. Before doing the compare of the two filters, add a small value to the one which was higher on the last pass. This will help it continue to be higher, hence adding hysteresis. Bob Ammerman RAm Systems (contract development of high performance, high function, low-level software) -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu