Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Keypad matrix hardware debouncing, help needed

Status
Not open for further replies.

rsatchel

New Member
I want to build a keypad matrix to interface to a microcontroller. In order to avoid constantly polling the switches I plan to utilize interrupts, which will require hardware debouncing (I believe).

My question is how to go about debouncing a keypad matrix (4x3) in hardware. I have googled this problem but have only found software debouncing.

Thanks in advance :)
 
You aren't going to make it any more efficient by using interrupts with a matrix keypad and you are going to make your code more complex. You have to cycle through the columns anyway so just read the rows into a ring buffer at the same time and debounce in software.
 
Hi,

Why do you want to debounce using hardware when you already have a microcontroller you are using. Doesnt make that much sense.
You dont have to KEEP polling, you only have to poll once you detect a first key press. Before that you can check for ANY key press which is much simpler because you can energize all of the scan lines at the same time. It's up to you of course.
There's also the possibility of using a second slave uC chip to scan and send the data to the master uC using any protocol you like.
 
you can energize all of the scan lines at the same time.

I hadn't thought of that, I suppose you could use interrupts if you did it that way. The only reason I can think of that you would want to is if you were short on cycles, in which case moving to a faster chip would be my preference, but it should be possible.
 
Why do you want to debounce using hardware when you already have a microcontroller you are using. Doesnt make that much sense.
You dont have to KEEP polling, you only have to poll once you detect a first key press. Before that you can check for ANY key press which is much simpler because you can energize all of the scan lines at the same time. It's up to you of course.
There's also the possibility of using a second slave uC chip to scan and send the data to the master uC using any protocol you like.


I had previously thinking of using an OR gate driven by the 3 columns (3x4 keypad) to an external interrupt. That would then cause the uC to read the keypad lines and determine which button had been pressed. Is that what you are describing?

From my understanding, when polling buttons it is possible to miss button presses, hence my interest in hardware debouncing and interrupts.
 
From my understanding, when polling buttons it is possible to miss button presses, hence my interest in hardware debouncing and interrupts.

Check that your problems are actually problems before solving them, unless you're running your uC right at the limit of what it is capable of there is no reason that you should miss key presses when polling, and if you are then you should fix your code or get a faster micro.
 
I had previously thinking of using an OR gate driven by the 3 columns (3x4 keypad) to an external interrupt. That would then cause the uC to read the keypad lines and determine which button had been pressed. Is that what you are describing?

From my understanding, when polling buttons it is possible to miss button presses, hence my interest in hardware debouncing and interrupts.

Hi,

Well, yes and no. Yes if you use an external extra chip, but no if you do it in software. Couldnt you just set all of the 3 or 4 lines as interrupt on change (after energizing the other set of lines) ? If either of the 3 or 4 lines generated an interrupt, you would then jump to service the keypad in the normal way.
It's up to you how you handle the normal scan then, possibly doing other things between each scan.

Then there's always just straight multitasking where you scan the keypad every so often looking for a change, and do other things in between scans. Scans can be pretty fast so they dont eat up much time.
 
Setup a 50Hz timer interrupt and scan the keypad. Debounce is automatic, the scan takes micro seconds and you can implement automatic rollover and auto repeat. Simples.

Edit, seems the video still works.
Edit2, just fixed the original article. This would be a simple solution.

Mike.
 
Last edited:
There is this http://www.analog.com/en/interface-...ypad-controller/adp5585/products/product.html chip and it's big brother. Digilent has it as a PMOD. http://digilentinc.com/Products/Detail.cfm?NavPath=2,401,960&Prod=PMOD-IOXP

The datasheet also mentions that ghosting is a possibility and thus the keyboard arrangement plays a role.

It can detect a few two or 3 keys at a time like control+ALT+DEL and even use that to activate reset.

The chip uses interrupts and a FIFO AND your power consumption can be much less.
 
I want to build a keypad matrix to interface to a microcontroller. In order to avoid constantly polling the switches I plan to utilize interrupts, which will require hardware debouncing (I believe).

My question is how to go about debouncing a keypad matrix (4x3) in hardware. I have googled this problem but have only found software debouncing.

Thanks in advance :)

I am trying to do the same thing

I have connected keypad columns to CD74HC4002 or gate ic. I am able to trigger interrupt on keppad press. I am right now trying to apply debouncing solution mentioned in below links.

http://hackaday.com/2015/12/09/embed-with-elliot-debounce-your-noisy-buttons-part-i/
http://www.all-electric.com/schematic/debounce.htm

Finally how did you solve your debouncing problem?
 
This thread is 5 years old and the original poster hasn't been here for 5 years. What hardware do you currently have?

Mike.
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top