Shop OBEX P1 Docs P2 Docs Learn Events
The perils of not debouncing — Parallax Forums

The perils of not debouncing

LoopyBytelooseLoopyByteloose Posts: 12,537
edited 2012-08-06 16:09 in General Discussion
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?

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2012-08-04 09:56
    There's a great article in July's Circuit Cellar on debouncing. Unless you've got a mercury switch, you're going to have some bounce. Some types of switch construction cause less bouncing. You can debounce using a simple RC filter or you can do it in software in a variety of ways, but you can't ignore it.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2012-08-05 06:27
    Thanks Mike.
    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.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2012-08-05 07:44
    The keyboard that I used for Cypherbot is '923-based.
    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.
  • tonyp12tonyp12 Posts: 1,951
    edited 2012-08-05 09:07
    if using hardware IRQ or with Props Waitpeg best to use hardware debounce like this.
    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.
    debouncerrc.jpg
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2012-08-05 09:07
    Here is a PDF that was on the Web. I've not yet gotten to the Circuit Cellar article, but this is a pretty good presentation. It covers using RC networks as well as the more classic methods.
  • GadgetmanGadgetman Posts: 2,436
    edited 2012-08-05 11:20
    Way back in ancient times...I built a bike speedometer system based on an old Psion Organiser II.

    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.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2012-08-06 00:52
    @Gadgetman
    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.
  • GadgetmanGadgetman Posts: 2,436
    edited 2012-08-06 04:14
    Actually, the reed switch and magnet was salvaged from an old(broken) bike speedometer...
    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.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2012-08-06 06:01
    I am very attached to using a netbook rather than an iPad or Android due to being so hacker friendly. And installing Linux makes it all even more so.

    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.
  • Mark_TMark_T Posts: 1,981
    edited 2012-08-06 16:09
    I was a bit surprised to find the price at $185NTD or about $6.25USD
    I'm not surprised - the more obscure logic family chips are hard/impossible to get hold of as no-one uses them in current designs... Micro controllers are cheaper and more flexible.
Sign In or Register to comment.