InterruptInput with simple button

Ive a simple test project with a button like this:

I want to fire an interrupt event every time I push the button.

Button is connected to +5V and (at the other side) to 10K ohm resistor to GND. Pin n° 6 of my extender is connected with gnd-resistor side.

I implemented this code:

 _btnMotorSwitch = extender.SetupInterruptInput(GT.Socket.Pin.Six,
                GT.Interfaces.GlitchFilterMode.Off,
                GT.Interfaces.ResistorMode.Disabled,
                GT.Interfaces.InterruptMode.RisingEdge);

If I start my application and press the button the event is fired twice!

Can someone explain me why?

@ danyolgiax - You can use the button module design as a reference. You should probably not be connecting to 5v but rather to the 3.3v. Here is a link to the design of the button module.

http://www.ghielectronics.com/downloads/Gadgeteer/Module/Button%20sch.pdf

1 Like

Perhaps the use of the glitchfilter solves the problem of the event being fired twice.


TimeSpan ts = new TimeSpan(0, 0, 0, 0, 200); // 200 ms
Microsoft.SPOT.Hardware.Cpu.GlitchFilterTime = ts;

_btnMotorSwitch = extender.SetupInterruptInput(GT.Socket.Pin.Six,
                GT.Interfaces.GlitchFilterMode.On,
                GT.Interfaces.ResistorMode.Disabled,
                GT.Interfaces.InterruptMode.RisingEdge);

Normally you would debounce a button - which is what I assume to glitch filer does.

http://www.labbookpages.co.uk/electronics/debounce.html

Hopefully that helps.

1 Like

Here’s a simple tutorial I created on this topic a while back using NETMF. As Patrick said, you probably just need to use the GlitchFilter. If that doesn’t do it then you’ll need to debounce through code.

Interesting! What is the C2 DNP component?

DNP means “do not place”. C2 is a capacitor. Looking at the diagram it’s there to add more analog glitch filtering, but obviously was decided to be omitted unless analysis showed it was required.