Searching \ for 'Debounce question' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/index.htm?key=debounce+question
Search entire site for: 'Debounce question'.

Truncated match.
PICList Thread
'Debounce question'
1997\08\06@144242 by Martin R. Green

picon face
I am planning to debounce a simple pushbutton connected to a PIC input with
weak pullups enabled.  My strategy is to read the button every 10ms, and
when 4 successive reads are the same, consider the level valid.  This will
of course mean that the button level must be the same for at least 30ms to
be considered valid.  The algorithm I am using will easily allow checking
for up to 8 matching reads, any more than that and I'll have to change the
method.

Any comments on this?  Is 10ms about right?  How about using 4 successive
reads, is this enough, too many, etc.?


TIA - Martin R. Green
spam_OUTelimarTakeThisOuTspambigfoot.com

1997\08\06@160929 by Aydin Yesildirek

flavicon
face
It sound very noisy button. I have not seen 30 ms bouncing signal
coming from a button. I assume you did not see it under a
osciloscope. My avagare bouncing lasts for less than one ms. I use
three successive stable readings to validate a keystroke within 12ms
periodic polling to read matrix key strokes and it works just fine.

Aydin

{Quote hidden}

1997\08\06@170018 by sdattalo

face
flavicon
face
Martin R. Green wrote:
>
> I am planning to debounce a simple pushbutton connected to a PIC input with
> weak pullups enabled.  My strategy is to read the button every 10ms, and
> when 4 successive reads are the same, consider the level valid.

Here is another algorithm that does the same thing:
http://www.interstice.com/~sdattalo/technical/software/pic/debounce.html

> Any comments on this?  Is 10ms about right?  How about using 4 successive
> reads, is this enough, too many, etc.?

Depends. I presume that the time the switch (or switches) is pressed is
not
too critical. In which case you could get by with two samples spaced
50ms
apart. (This assumes of course that the switch is pressed fewer than 10
times per second and is held down for more than 100ms.) If you change
from
switches to say monitoring relay contacts, then the filtering criteria
certainly change. In one instance for example, I needed 1ms time
stamping
resolution for relay contacts. In that case I chose a ~500us sampling
period with 8 consecutive samples. So pulses shorter than 8 * 500us =
4ms
were rejected as glitches.

So ask your self these questions:
1) How many changes/second do you need to monitor?
2) What is the minimum time the switch is pressed?
3) How 'noisy' is the switch or in other words how
  long does it take the switch to complete a transition?

Perhaps someone else can add to this list.


Scott
--
                                __o
 I buy pizza instead of gas.    \<
                             (*)/(*)

Or as Mike#99 might say: I get gas instead of buy gas.

1997\08\06@172051 by Eric van Es

flavicon
face
Martin R. Green wrote:

{Quote hidden}

I've always used approx. 50ms delay
between testing buttons. You then don't
have to test the button repeatedly, but
you might loose a little "feeling".
Tweaking this value  improves this but
then you might need quick fingers!

--
Eric van Es               | Cape Town,
South-Africa
Mailto:.....vanesKILLspamspam.....ilink.nis.za | WWW:
http://www.nis.za/~vanes/
TEMPORARY/HOLIDAY ACCOMMODATION?
http://www.nis.za/~vanes/accom.htm

1997\08\06@231158 by myke predko

flavicon
face
>It sound very noisy button. I have not seen 30 ms bouncing signal
>coming from a button. I assume you did not see it under a
>osciloscope. My avagare bouncing lasts for less than one ms. I use
>three successive stable readings to validate a keystroke within 12ms
>periodic polling to read matrix key strokes and it works just fine.

I've got a truckload of those buttons  :(

I shouldn't really complain because it has allowed me to come up with some
pretty efficient routines for debouncing.

If you're polling the button (no interrupts) the algorithm is:

DebounceLoop:                   ;  Come Back Here to Wait for the keypress
 if Button_Up goto DebounceLoop

 Counter = 20 msec delay       ;  Wait a solid 20 msec to assume good down
DebounceWaitLoop:               ;  Button in this loop
 Counter = Counter - 1
 if Counter == 0 goto DebounceEnd
 if Button_Up goto DebounceLoop  ;  If Button goes up, start over
 goto DebounceWaitLoop

DebounceEnd:                    ;  Button is down and Debounced

Note that I continuously poll the button and if it ever goes back up I
restart the process.  Note that the same thing should be done for the button
release.

If you want to do this concurrently with something else, TMR0 and the INT0
Pin (or Interrupt on State Change Pins) can be used as part of an interrupt
handler.

If you have a noisy switch, just polling it every 10 msec or so will not
give you a reliable keypress.  For a good quality switch, it should be fine
(read the specs and get one that "clicks" down and up - this will minimize
the problems).

Good luck,

myke

{Quote hidden}

"If at first you don't succeed, then maybe sky diving isn't the sport for
you" - Steve Smith

1997\08\07@063734 by nvdw

flavicon
face
Martin R. Green wrote:
>
> I am planning to debounce a simple pushbutton connected to a PIC input with
> weak pullups enabled.  My strategy is to read the button every 10ms, and
> when 4 successive reads are the same, consider the level valid.  This will
> of course mean that the button level must be the same for at least 30ms to
> be considered valid.  The algorithm I am using will easily allow checking
> for up to 8 matching reads, any more than that and I'll have to change the
> method.
>
> Any comments on this?  Is 10ms about right?  How about using 4 successive
> reads, is this enough, too many, etc.?
>
> TIA - Martin R. Green
> elimar@bigfoot.c

This means that if your input is high, with a low going glitch
you are going to get an output...........

Nic

1997\08\07@075436 by STEENKAMP [M.ING E&E]

flavicon
picon face
{Quote hidden}

Since nobody's mentioned it yet, there is the debouncing system that uses
parallel counters to debounce buttons.  It uses simple boolean logic to
low pass filter 1 to 8 inputs.  It has the advantage of requiring only
one counter (spread over two bytes) and can debounce up to 8 inputs
simultanously.
I found it on 'n PIC related web page a while back - I cannot remember
the URL or the original author anymore, but it really works well.

Niki

1997\08\07@121805 by sdattalo

face
flavicon
face
N STEENKAMP [M.ING E&E] wrote:

> Since nobody's mentioned it yet, there is the debouncing system that uses
> parallel counters to debounce buttons.  It uses simple boolean logic to
> low pass filter 1 to 8 inputs.  It has the advantage of requiring only
> one counter (spread over two bytes) and can debounce up to 8 inputs
> simultanously.
> I found it on 'n PIC related web page a while back - I cannot remember
> the URL or the original author anymore, but it really works well.

Niki,

I mentioned it yesterday - at least indirectly. The URL (again) is:

http://www.interstice.com/~sdattalo/technical/software/pic/debounce.html

And if you're interested in changing the debouncing window width, then
check out these other boolean logic counters:
http://www.interstice.com/~sdattalo/technical/software/pic/vertcnt.html

Scott
--
                                __o
 I buy pizza instead of gas.    \<
                             (*)/(*)

1997\08\07@122904 by Mike

flavicon
face
At 02:01 PM 8/6/97 -0700, you wrote:

>Scott
>--
>                                 __o
>  I buy pizza instead of gas.    \<
>                              (*)/(*)
>
>Or as Mike#99 might say: I get gas instead of buy gas.

hehe - I think I was Mike #14 (missed the number thirteen...)

                         O  o  . __o
 I get gas after a Taco.         \<
                              (*)/(*)

Rgds

Mike
Perth, Western Australia
PS: Good to hear our 'magic' maths analyst is on the ball - err wheel ;-)

More... (looser matching)
- Last day of these posts
- In 1997 , 1998 only
- Today
- New search...