Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

Looping issue with "InterruptEdgeBoth"


  • Please log in to reply
3 replies to this topic

#1 Christopher Gilmore

Christopher Gilmore

    Member

  • Members
  • PipPip
  • 12 posts
  • LocationBurlington, MA

Posted 07 December 2010 - 03:56 AM

Below is a simple example of the issue I am seeing. This program is supposed to call the DoorBellPort_OnInterrupt method ONLY when GPIO_PIN_D7 changes from low to high or high to low. What I am experiencing, is that everytime it switches.....the method is called multiple times (sometimes the board actually runs out of memory). I discovered this by setting a break point in the method itself. I manually switch the connection to pin 7 between the 3.3V and Gnd pins on the Netduino Plus to ensure that my input is not in fact switching quickly. public static void Main() { InterruptPort DoorBellPort = new InterruptPort(Pins.GPIO_PIN_D7, false, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeBoth); DoorBellPort.OnInterrupt += new NativeEventHandler(DoorBellPort_OnInterrupt); Thread.Sleep(Timeout.Infinite); } static void DoorBellPort_OnInterrupt(uint data1, uint data2, DateTime time) { return; //Breakpoint here. Called multiple times per edge?? } Everytime the method is called, I do see that the data2 variable switches between 1 and 0 each time. What I dont understand is how this is even possible???

#2 Fred

Fred

    Advanced Member

  • Members
  • PipPipPip
  • 302 posts
  • LocationUK

Posted 07 December 2010 - 08:29 AM

Physical switches bounce a lot when pressed. There's a glitch filter option that helps a bit, but you may need to add some debounce circuitry. By the way, you're not the same Chris Gilmour I used to kitesurf with are you?

#3 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 07 December 2010 - 01:05 PM

Christopher, If you connect D7 to GND and then start your app, how many times is the event called? Chris

#4 Christopher Gilmore

Christopher Gilmore

    Member

  • Members
  • PipPip
  • 12 posts
  • LocationBurlington, MA

Posted 08 December 2010 - 02:05 PM

Yeah.... Fred's suggestion worked (glitch filter = true and adding a debouncing circuit). I did a quick google on debouncing circuit and saw some examples. The problem ended up being fixed by putting a 1uF capacitor between the input to the netduino and ground. Below shows an example of how i added a capacitor C1. Also, R1 = 10Kohms. http://www.ikalogic....ng/debounce.jpg After that, the interupt only got called once for each edge. Thanks for the help! I've never been kitesurfing....




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.