At 04:10 AM 6/21/2004, Alan B. Pearce wrote: >I'm interested to see what you consider a "conventional" debounce algorithm >, and how you would implement it. Any button press detection will have >problems if the user does not push the button firmly, or for long enough. >Surely both pressure and time are required on any implementation for a good >detection without false triggers. The mickey mouse routine I use is an up-down counter clocked at my tick rate (1.024 ms in most of my projects). It is clamped so as to not roll over in either direction (min 0x01, max 31 or 63, depending on how responsive I want the button to feel). The counter is usually active LO - a valid button press is 0x01. This is easy to detect even in mainline code by using decfsz BUT01,W . If detecting button both pressed and released is important, the background task that looks after reading the switches will also implement a SR latch based upon the up/down counter reaching its limits. If I have lots of buttons to look after, I use Scott's vertical counters (only once so far, I think). dwayne -- Dwayne Reid Trinity Electronics Systems Ltd Edmonton, AB, CANADA (780) 489-3199 voice (780) 487-6397 fax Celebrating 20 years of Engineering Innovation (1984 - 2004) .-. .-. .-. .-. .-. .-. .-. .-. .-. .- `-' `-' `-' `-' `-' `-' `-' `-' `-' Do NOT send unsolicited commercial email to this email address. This message neither grants consent to receive unsolicited commercial email nor is intended to solicit commercial email. -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.