Difference between revisions of "Debouncing Microcontroller Inputs"

From OpenCircuits
Jump to navigation Jump to search
Line 54: Line 54:
 
|
 
|
 
|
 
|
 +
<!-------------------------------->
 +
|-valign="top"
 +
|[http://www.labbookpages.co.uk/electronics/debounce.html Switch Debouncing]
 +
|
 +
|
 +
<!-------------------------------->
 +
|-valign="top"
 +
|[http://hackaday.com/2010/11/09/debounce-code-one-post-to-rule-them-all/#more-29916 Debounce Code – one post to rule them all]
 +
|
 +
|
 +
 +
<!-------------------------------->
 +
|-valign="top"
 +
|[http://www.engscope.com/pic-example-codes/basic-io-button-debounce/ Basic IO: Button Debounce]
 +
|
 +
|
 +
<!-------------------------------->
 +
|-valign="top"
 +
|[http://www.rentron.com/myke6.htm Button Debouncing]
 +
|
 +
|[
 
<!--------------------------------
 
<!--------------------------------
 
|-valign="top"
 
|-valign="top"
 
|[]
 
|[]
 
|
 
|
 +
|[
 +
<!--------------------------------
 +
|-valign="top"
 +
|[]
 
|
 
|
 +
|[
 
<!--------------------------------
 
<!--------------------------------
 
|-valign="top"
 
|-valign="top"
 
|[]
 
|[]
 
|
 
|
 +
|[
 +
<!--------------------------------
 +
|-valign="top"
 +
|[]
 +
|
 +
|[
 +
<!--------------------------------
 +
|-valign="top"
 +
|[]
 
|
 
|
 
+
|[
 
<!--------------------------------
 
<!--------------------------------
 
|-valign="top"
 
|-valign="top"
|[[]]
+
|[]
 
|
 
|
 +
|[
 +
<!--------------------------------
 +
|-valign="top"
 +
|[]
 
|
 
|
 +
|[
 
<!--------------------------------
 
<!--------------------------------
 
|-valign="top"
 
|-valign="top"
|[[]]
+
|[]
 +
|
 
|
 
|
|[[Special:Export/---]]
 
 
<!--------------------------------
 
<!--------------------------------
 
|-valign="top"
 
|-valign="top"

Revision as of 15:58, 28 December 2012

Debouncing

under construction

Debouncing is used on switches that are providing digital input to a device like a micro controller – here we will assume that the input is a micro controller. When the state of the switch is changed from open to closed and vise versa there is often a short period of time when the switch make many rapid transitions between open and closed. These transitions are called bouncing and they often cause problems in the application where the assumption is made that actuating the switch once caused only one transition. Getting rid of the effect of the transitions is called debouncing.

There are two general way of getting rid of the bounces, one called hardware debouncing add circuitry that actually gets rid of the unwanted transitions, the other is called software debouncing and causes the application to ignore the bounces.

Note: if the button press triggers an interrupt then the bounce may cause more problems than code that just polls the button state.

Method 1: Ignore it

This is actually a method that can work under some conditions. Suppose you have a lid you want opened when a button is pressed. Bounce may not matter for a couple of reasons: the lid can only be opened once so a bounce will not open it twice ( but bad code may be confused by the bounce ), the delay involved in opening the the lid will give time for the bouncing to end.

Method 2: Do not Ignore it

Links

What Comment Comment2
A Guide to Debouncing Good guide
Contact Bounce and De-Bouncing
How to de-bounce a switch using CMOS & TTL
Switch Debouncing
Debounce Code – one post to rule them all
Basic IO: Button Debounce
Button Debouncing [