I have to check a button with a FALLING interrupt. It works great when the button is pressed. The problem is that when i get up from my chair or move around in the room or close the door, the interrupt will fire too. When i attach the oscilloscope to the interrupt input pin, i see very short peaks during those events. I need to get rid of those interferences, can you please help?
The pin is connected via 10 kOhm resistor to 3.3V (pull-up). I also tried various pull-ups from 470 Ohm to 80 kOhm, with no success.
The button pulls the pin to GND when pressed. Pretty standard setup...
Or are you using an external pullup resistor? If so, what value?
What layout are you using? It sounds like you may be picking up static electricity. Are your wires really long? Is the pullup resistor really high value? Try shorter wires, using twisted pair, and a 1k pullup resistor.
A lesson in just how sensitive floating inputs are to ambient static electricity or
capacitive coupling to mains. And an interrupt pin will detect pulses as short
as a few tens of nanoseconds just to make things worse...
Or are you using an external pullup resistor? If so, what value?
What layout are you using? It sounds like you may be picking up static electricity. Are your wires really long? Is the pullup resistor really high value? Try shorter wires, using twisted pair, and a 1k pullup resistor.
We need more information to help you.
Thanks for the reply, but read my initial post. I am using an external pull-up resistor. I tried varioius values (for example: 470 Ohm, 1 kOhm, 5.6 kOhm, 10 kOhm, 18 kOhm, 33kOhm, 82kOhm). Did not solve the problem.
I attached the button to 2m of wire and on an other experiment just a couple of centimeters of wire directly at the breadboard. Did not solve the problem either.
Btw: That is all of my code. I dont think you need more for an interrupt.
MarkT:
A lesson in just how sensitive floating inputs are to ambient static electricity or
capacitive coupling to mains. And an interrupt pin will detect pulses as short
as a few tens of nanoseconds just to make things worse...
Is there a technical (maybe hardware) solution to filter this ultra-short static pulses? I have some serious equipment and electronic parts here, so i could built some circuits if that helps...
Note that alternatively, with some register level programming of the D10 input, the hardware debouncing feature in the SAM3X can be used.
Note that there is a difference as to how a typical debouncer and a filter work:
A debouncer will respond instantaneously to a signal transition then have a time-out interval.
A filter slows the rise and fall time of the signal.
The average response time for a person to react and press a button is around 1/4 second.
Note that alternatively, with some register level programming of the D10 input, the hardware debouncing feature in the SAM3X can be used.
Note that there is a difference as to how a typical debouncer and a filter work:
A debouncer will respond instantaneously to a signal transition then have a time-out interval.
A filter slows the rise and fall time of the signal.
The average response time for a person to react and press a button is around 1/4 second.
Hey Thanks!
Your circuit works very good in my firt test. It only triggered one false positive and that was when i touched the door handle nearby and got zapped bystatic electricity ( I did not have physical contact with any part of the circuit at that point, so it mustve transmitted through the air).
I had another circuit used in hardware debouncing of interrupts by Jeremy Blum using an inverted schmitt trigger and an rc circuit. This reduced the bouncing but didnt help with the eletrostatic noise / false positives whatsoever.
Your circuit works very good in my firt test. It only triggered one false positive and that was when i touched the door handle nearby and got zapped bystatic electricity ( I did not have physical contact with any part of the circuit at that point, so it mustve transmitted through the air).
As per your Thomas Edison quote, an improvement might be to add 1K series resistance in the ground wire to the switch and clhange the capacitor to 2.2µF.
dlloyd:
As per your Thomas Edison quote, an improvement might be to add 1K series resistance in the ground wire to the switch and clhange the capacitor to 2.2µF.
Haha, yeah you got me on that one...can you please explain why the change of the capacitor and the resistor should bring improvement? I am not from an electronics background.
the interrupt fires ONE time, then after that it works like it should. Where does that initial interrupt come from? How can i prevent this? This seems to be a huge flaw in the Arduino provided interrupt functions.
I tried to solve this problem in this Thread, but so far no luck.
I need a clue, tried so many things already, nothing helped. Please help guys!
I'm going to move this to the Due section, as this is a Due problem now.
However on the Uno, an initial interrupt will come because the flag for that interrupt has been set in the processor before you do the attachInterrupt, and thus it immediately fires. There may be a way of clearing that flag on the Due (like there is on the Uno).
MaxBlitz:
I still haven't totally solved the problem with the interrupts, since now I don't get false positives, ...
All very well and good for "an academic/ learning exercise", but the bigger question here, is why you would be using an interrupt in the first place, for a totally inappropriate purpose - monitoring a pushbutton?
Haha, yeah you got me on that one...can you please explain why the change of the capacitor and the resistor should bring improvement? I am not from an electronics background.
The series resistor would help reduce transients or spikes on the ground wire to the switch and the capacitor change is probably not required if the original filter on the interrupt input already works. As Paul__B has pointed out, I'm also curious why an interrupt would be required in monitoring a pushbutton.