Another related issue is the digital filter methods. Right now I have two choice. I am using a simple +1/-1 method now. The filter counter will be increased by 1 (up to 8) or decreased by 1 (down to 0). The output will be triggered when the counter reaches 8 (or 6 and then promoted to 8) or 0. Another slightly different scheme is to trigger the output when the counter reaches 6 (then promote it to 8) or 2 (then downgrade it to 0). The other idea is to use a shift register, every time when the MCU detected the signal, it shifts a 1 into the shift register. Only 8 consecutive detected signal (or undetected signal) will trigger the output. It will reject the noise better but then it will slow the response time significantly even in the low noise situation. Any better solutions? Regards, Xiaofan -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist