user1258: I have an issue with debouncing.
I am using a MCP23017 as an I/O-extender with an Arduino. This uses I2C to communicate with each other.
A variable amount of switches is connected to the MCP23017 (0-16 switches). On change of the inputs, an interrupt is generated and the Arduino captures this on rising edge. So whenever a button is pushed or released, an interrupt is generated.
Now I'm confused as how I should debug them. One option would be to set a delay after an interrupt (of let's say 50 ms), before turning the interrupts back on. This could have an issue however, since multiple inputs are connected to the same interrupt line.
Another option is to have a timestamp or something for the last time each switch was changed, and check if the time difference is big enough, otherwise ignore the next pulse. The problem with this is that it uses quit some resources as I have limited memory and there can be up to 8 extenders (so 8 * 16 = 128 inputs).
What is the most efficient way to handle these interrupts with debouncing?

user-1: Add debouncing circuitry if you can; it's not that difficult.

user-1: Depends on the application. 
Define efficiency. What are you looking to optimize for? Manhours spend coding/testing, processor speed, response time?
Are theses keys to a piano synth? Yes you'll want interrupt speed, and each key needs to not affect the surrounding keys. 
Is it going to be rare that two keys are pressed anywhere near each other? a timeout for the ISR is perfectly legitimate. 
Will the user not observe any lag when he flips a switch and resources are tight? Then polling could be a viable option. 
Are the EMI concerns and you need to filter out false positives? Well you're going to need do some more. Like sampling for sustained values or counting how long until the falling edge occurs. 
There are so many options depending on what you want it to do. 

1258: <p>I have an issue with debouncing.
I am using a MCP23017 as an I/O-extender with an Arduino. This uses I2C to communicate with each other.</p>

<p>A variable amount of switches is connected to the MCP23017 (0-16 switches). On change of the inputs, an interrupt is generated and the Arduino captures this on rising edge. So whenever a button is pushed or released, an interrupt is generated.</p>

<p>Now I'm confused as how I should debug them. One option would be to set a delay after an interrupt (of let's say 50 ms), before turning the interrupts back on. This could have an issue however, since multiple inputs are connected to the same interrupt line.</p>

<p>Another option is to have a timestamp or something for the last time each switch was changed, and check if the time difference is big enough, otherwise ignore the next pulse. The problem with this is that it uses quit some resources as I have limited memory and there can be up to 8 extenders (so 8 * 16 = 128 inputs).</p>

<p>What is the most efficient way to handle these interrupts with debouncing?</p>
 -1: <p>Add <a href="http://www.labbookpages.co.uk/electronics/debounce.html" rel="nofollow">debouncing circuitry</a> if you can; it's not that difficult.</p>
 -1: <p>Depends on the application. </p>

<p>Define efficiency. What are you looking to optimize for? Manhours spend coding/testing, processor speed, response time?</p>

<p>Are theses keys to a piano synth? Yes you'll want interrupt speed, and each key needs to not affect the surrounding keys. </p>

<p>Is it going to be rare that two keys are pressed anywhere near each other? a timeout for the ISR is perfectly legitimate. </p>

<p>Will the user not observe any lag when he flips a switch and resources are tight? Then polling could be a viable option. </p>

<p>Are the EMI concerns and you need to filter out false positives? Well you're going to need do some more. Like sampling for sustained values or counting how long until the falling edge occurs. </p>

<p>There are so many options depending on what you want it to do. </p>
