Debounce matrix keypad

Discussion in 'The Projects Forum' started by diamondman, May 24, 2010.

  1. diamondman

    Thread Starter New Member

    May 23, 2010
    19
    0
    I have been a C++ coder for some time now, but i wanted to get into some hardware, and after taking a digital logic class in college i found the transition between code and digital components quite easy, however I still suck at analog so that is partially my problem.

    My project I am working on is a 4 pin security system and i need the input from the keypad to be bounce free(for obvious reasons). I found this site and it seems to present an easy enough solution (for someone who sucks at analog circuits like me) for debouncing a push button. Unfortunately, I don't know if this circuit will work with a matrix keypad the same as it would with normal push buttons or switches, if i have to do something special, or if i am completely SOL. Thanks to replies in advanced.

    Also, I have seen some posts of people suggesting pics to decode and debounce the matrix outputs automatically, but for now i am trying to get everything working using only gates, (de)multiplexers, latches, etc.. (It would kind of defeat the point to have a state machine made out of gates and latches get it's info through a microcontroller)
     
  2. beenthere

    Retired Moderator

    Apr 20, 2004
    15,815
    282
    Keypads only make a single contact at a time. The dual NAND debouncer requires the switch input to be a SPDT type.

    One dodge for the keypad is to use a Schmitt trigger gate. The keypress can discharge a capacitor through a resistor to suppress the bounce, and the Schmitt trigger will signal on the absolute voltage change.
     
  3. jpanhalt

    AAC Fanatic!

    Jan 18, 2008
    5,677
    900
    Here is another method from an MIT site for push button switches:
    [​IMG]

    Unfortunately, the original link is dead, so here are notes copied from when it was up.

    I have used it on a few projects and like it.

    John
     
  4. diamondman

    Thread Starter New Member

    May 23, 2010
    19
    0
    That is why I am trying to use the schmitt trigger because from what i have found it is the simplest way to do it, and I have the equations to calculate the resistor values I would need based on the voltages i want to occur over the capacitor, i just don't know if hooking up each output pin from a matrix keypad to it's own debounce circuit and then putting those debounced outputs into the rest of the logic circuit will work just like using 12 push buttons with 12 individual debounce circuits.

    This should clarify. Will this diagram i made work to debounce all 7 outputs from the matrix so i can use them for Boolean logic.


    Also, thanks for the help, but I looked into using a 555 timer, but I would have to use 7 separate 555 times because i am debouncing 7 outputs (Unless I am completely wrong) and would then be having the same problem i am now, except with your 555 timer circuit.
     
  5. rjenkins

    AAC Fanatic!

    Nov 6, 2005
    1,015
    69
    If you are reading the keypad in software, just copy the last read value to a temp location before each new read and compare the two.

    Only use the new value once there have been no changes between reads for eg. 10mS. That guarantees you only use valid states and any transients are ignored.

    If working in hardware, at some point you must be generating an 'any key pressed' signal to latch the key into the logic.

    Use a similar principle on that, an R-C delay and a schmitt trigger so the data latch signal does not occur until the key bounce has had time to settle.
     
  6. diamondman

    Thread Starter New Member

    May 23, 2010
    19
    0
    The point of the project is to do it with no software, all with basic digital components (Nothing more complicated than a shift register or a decoder), and whatever analog components i need to clean things up. I am just gonna order the parts to do that schematic i made and update on how it works out.
    Wish me luck.
     
  7. John P

    AAC Fanatic!

    Oct 14, 2008
    1,632
    224
    This contact debouncing stuff is a bugaboo that doesn't have to exist. It's only a problem if you use the contact closures (or openings, perhaps) to trigger events. If you arrange things so that the buttons are read according to a clock, and if you set the time of that clock to be longer than the maximum bounce time, you never need to worry. The data sheet for that keypad lists it: maximum bounce time, 12msec. Just read slower than that, and you can ignore the issue.

    I'm editing this after a minute to add: I really think you do have to run this device with a clock. How can you read a matrix on a static basis? Well, I can imagine pulling up each column to Vcc through a different resistor, and pulling down each row to Gnd through another different resistor, and then looking for deviations from Vcc and Gnd on those lines (actually maybe only the rows, or only the columns, need to have different resistors--some could be the same) but then it's an analog design project. You'd need a lot of comparators.
     
    Last edited: May 25, 2010
  8. beenthere

    Retired Moderator

    Apr 20, 2004
    15,815
    282
  9. diamondman

    Thread Starter New Member

    May 23, 2010
    19
    0
    Thanks both of you.
    First off, I do have a clock (33 khz) running the state machine that does the necessary things with the data in the four 4bit shift registers. the registers have to be shifted only when there is a button press, so i didn't want to hook them to the main clock. Instead I am made a logic circuit (diagram as of yet) that with turn on a bit (1-4) based on which buttons are pressed (eg. 0001 for 0, 0010 for 1 etc. I am using 0001 for 0 because the machine initializes with all registers at 0 and i want '0000' to be a valid pin so i am treating the register's state 0000 as NULL) and then have an OR gate checking if any of the bits are high and clocking the shift registers to store them.
    Because of this, I am wanting to make sure there is no bouncing because it could cause the shift registers to count several button presses and cause havoc.

    And secondly... well i guess i don't have a second thing to say.

    Anyways, I would like to thank you all. I will post the results when i finalize my part list and the parts come in. (Special thanks to beenthere for the link)
     
Loading...