Hi all I just finished up my routines for de-bouncing switches. They use a timer on a low priority interrupt to count the number of switch presses/closures in the background. You can use them two ways one is where you have to press the button down and then release it to get a valid closure. Or you and call a function and get a closure after a number of counts with out releasing the switch. This lets me use the switches to run settings up and down or to single select items from a menu. Right now the counts for the closure onetime and the hold it down are the same but it would be easy enough to make the counts different for each situation. If anyone is interested I'd be happy to post the code it but I'm not sure how exactly to do it I've only been on this forum for a couple of days. Do I just attach to a message of post the text in my message? I just gotter done today so no guaranties that it is bug free. Phillip Things should be as simple as possible but no simpler = = = Phillip Coiner CTO, GPS Source, Inc. = = Your source for quality GNSS Networking Solutions and Design Services, Now! -----Original Message----- From: piclist-bounces@mit.edu [mailto:piclist-bounces@mit.edu] On Behalf Of Scott Dattalo Sent: Monday, April 03, 2006 3:34 PM To: Microcontroller discussion list - Public. Subject: Re: [PIC] debouncing in c David P Harris wrote: > Wouter van Ooijen wrote: > = > = >>>I am looking for an example to debounce several push buttons = >>>in c. While = >>>debouncing the micro shouldn=B4t be blocked by a timer. >>> = >>> >> >>Easy method: check the buttons only each xxx ms. xxx must be longer than the bounce time. When unknown xxx =3D 50 ms is a good guess. >> >>Wouter van Ooijen >> = >> > = > You know this is dead simple, and I cannot think of any criticism of = > it. Nobody has commented otherwise, have they? = Well, no one's commented on it because the thread has only been alive = for a day or so. N*6 months ago when we last talked about this thread, = the same group of people chimed in as this time and this same point was = discussed (maybe it was discussed for N being even)! But Wouter's method = is more than sufficient for most cases - if the switch isn't bouncing, = then you can reliably read its state without having to resort to = elaborate filtering. My debouncing routine has its roots in RTU relay = time tagging; a environment far different than a snap dome. But, there are at least two reasons why you might want a = debouncer/filter: 1) faster response 2) remove "spurious" transitions. = Both of these are probably insufficient reasons for normal switches. If = a switch can be pressed at a rate faster than it bounces, then it will = suffer from usability issues. If there are chances for spurious = transitions then there again usability issues. -- = http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist -- = http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist