On 07/12/2013 10:47 AM, S. Dale Morrey wrote:
Ok dumb question I'm sure. But what does debounce mean in this context?
What are the dangers of not debouncing? How exactly does one go about
debouncing?
Thanks!
When you push a button or flip a switch, there is noise introduced into
the circuit for at least some small amount of time. Compared to a 50
MHz clock, though, it's a very long time, and depends on the quality of
the switch. The signal appears to be randomly bouncing between the high
and low voltages.
If you were to directly connect a switch to a finite state machine, you
very well could end up moving through several states you never intended
to. Say your FSM was something like
switch
IDLE ----------------> RUNNING ----+
|
^ |
| switch' |
+----------------------------------+
The bouncing signal coming from the switch would move you randomly
through both states until finally settling in the RUNNING state. I've
worked on some really crappy switches that after some wear-and-tear,
they would randomly and briefly bounce even though the switch had been
on for long time.
Debouncing a switch involves adding logic that will basically wait until
the signal has stabilized before passing the on or off signal to the
rest of your circuit. Ways of doing this include using three flip-flops
to do edge detection and store current state, and a timer that resets on
a rising or falling edge, with the current state flip-flop not updating
until the timer hits at least a certain count. Another (simpler) method
is to just have a flip-flop and a timer that triggers a sampling of the
switch every so often.
I think the analog way of debouncing uses an RC circuit to buffer the
noise, but I've never done so.
Grazie,
;-Daniel Fussell
/*
PLUG: http://plug.org, #utah on irc.freenode.net
Unsubscribe: http://plug.org/mailman/options/plug
Don't fear the penguin.
*/