The perils of not debouncing
LoopyByteloose
Posts: 12,537
I have long had great ambitons of having ten key and sixteen key keyboards for my microcontroller projects, but I have gotten bogged down with all the finer points of matrices and debouncing.
Recently, I was going through an online list of 74xxx chips just to see what I had missed and never understood and I came across the 74C922 for 10 and 16 key pushbuttons with complete debouncing and more. I was actually considering programing an SX28 to do this, but the fact that there is an existing chip made a lot of sense.
So I visited the local electronics shop and picked up one. I was a bit surprised to find the price at $185NTD or about $6.25USD, but I bought it anyway.
But in the back of my mind, I tend to feel that debouncing push buttons that are just used occasionally is rather a waste of energy. Somewhere I've gotten the feeling that most of the arguments for debouncing are for very fast processors and keyboards that are used heavily for data entry.
Nonetheless, I am reading in detail how to properly code for keyboards with the SX28 chip. After all, Parallax is now selling that chip ofr $1.25 and this feature doesn't require a crystal to drive it.
Am I wrong to think that this can be ignored?
Recently, I was going through an online list of 74xxx chips just to see what I had missed and never understood and I came across the 74C922 for 10 and 16 key pushbuttons with complete debouncing and more. I was actually considering programing an SX28 to do this, but the fact that there is an existing chip made a lot of sense.
So I visited the local electronics shop and picked up one. I was a bit surprised to find the price at $185NTD or about $6.25USD, but I bought it anyway.
But in the back of my mind, I tend to feel that debouncing push buttons that are just used occasionally is rather a waste of energy. Somewhere I've gotten the feeling that most of the arguments for debouncing are for very fast processors and keyboards that are used heavily for data entry.
Nonetheless, I am reading in detail how to properly code for keyboards with the SX28 chip. After all, Parallax is now selling that chip ofr $1.25 and this feature doesn't require a crystal to drive it.
Am I wrong to think that this can be ignored?
Comments
Circuit Cellar articles are usually excellent and they let me buy single ones even though I don't subscribe. This is something I rarely do, I suspect I will.
So far, the ideal way that I figure I can make the problem of bounce go away is to use a universal remote and an IR receiver to completely side-step the problem. Using a simple RC network is very appeals when I consider how much code one might have to write for just one button.
Debouncing is important when "lively" keys are required. It's critical where activations are counted. If a key is pressed and there follows a period where the keys aren't scanned, and that wait is acceptable, then there's no problem.
As there is resistors on either side of switch it will smooth out both opening and closing of switch.
Two 20k and one 2-10nF cap should suffice.
http://home.c2i.net/trygveh/english/download/org2/t2bike.html
Here's the schematic:
http://home.c2i.net/trygveh/english/download/org2/t2schema.gif
The sensor was a reed relay and a magnet(placed on a wheelspoke).
Debounce was a 150nF cap, a 12K resistor and a 74AHC14 Schmitt Trigger.
Should probably have had an extra resistor,but it worked OK.
Thanks, several threads recently have been people that wanted to make their project work with salvaged parts they have on hand. I am is a similar position here in Taiwan as I cannot always source leading edge components without buying from afar.
So, the demonstration of how a simple resistor and capacitor will work with a Schmitt Trigger is very useful. The 'full Monty' engineered software solutions are not very appealing to me. And making my own sensors from items like magnets and reed switches is very appealing. These components appeal to kids and empower them to dream about doing more.
Then it was just a question of debouncing the signal and feeding it into a counter.
Added another magnet for a 'smoother' update, too.
The Psion Organiser II is a very 'hack friendly' device as it has 3 'large' I/O ports where you can have direct SW control of each pin.
(Not quite as easy as on the BS2, but then again, not much is... )
Biggest hurdle was in writing and hand-coding the Assembly stuff.
Regardless of the r/c network, it seems everything is much easier to manage with the inclusion of a Schmitt trigger to increase the zone where no change is recognized.