This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: © 2004 The Ganssle Group. This work may be used by individuals and companies, but all publication rights reserved A Guide to Debouncing August 2004 Rev 1: April, 2006 Rev 2: April, 2007 Rev 3: June, 2008 Jack G. Ganssle [email protected] The Ganssle Group PO Box 38346 Baltimore, MD 21231 (410) 504-6660 fax (647) 439-1454 Page 1 A Guide to Debouncing The beer warms a bit as you pound the remote control. Again and again, temper fraying, you click the “channel up” key until the TV finally rewards your efforts. But it turns out channel 345 is playing Jeopardy so you again wave the remote in the general direction of the set and continue fiddling with the buttons. Some remotes work astonishingly well, even when you bounce the beam off three walls before it impinges on the TV’s IR detector. Others don’t. One vendor told me reliability simply isn’t important as users will subconsciously hit the button again and again till the channel changes. When a single remote press causes the tube to jump two channels, we developers know lousy debounce code is at fault. The FM radio on my sailboat has a tuning button that advances too far when I hit it hard. The usual suspect: bounce. When the contacts of any mechanical switch bang together they rebound a bit before settling, causing bounce. Debouncing, of course, is the process of removing the bounces, of converting the brutish realities of the analog world into pristine ones and zeros. Both hardware and software solutions exist, though by far the most common are those done in a snippet of code. Surf the net to sample various approaches to debouncing. Most are pretty lame. Few are based on experimental bounce parameters. A medley of anecdotal tales passed around the newsgroups substitute for empirical evidence. Ask most developers about the characteristics of a bounce and they’ll toss out a guess at a max bounce time. But there’s an awful lot going on during the bounce. How can we build an effective bounce filter, in hardware or software, unless we understand the entire event? During that time a long and complex string of binary bits is hitting our code. What are the characteristics of that data? We’re writing functions that process an utterly mysterious and unknown input string. That’s hardly the right way to build reliable code. The Data So I ran some experiments. I pulled some old switches out of my junk box. 20 bucks at the ever-annoying local Radio Shack yielded more (have you noticed that Radio Shack has fewer and fewer components? It’s getting hard to buy a lousy NPN transistor there). Baynesville Electronics (http://www.baynesvilleelectronics.com), Baltimore’s best electronics store, proved a switch treasure trove. Eventually I had 18 very different kinds of switches....
View Full Document
- Winter '09
- Logic gate, switch, embedded system, msec, bounce, Debouncing