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

false interupt triggering


  • Please log in to reply
18 replies to this topic

#1 ash

ash

    Advanced Member

  • Members
  • PipPipPip
  • 66 posts

Posted 07 May 2013 - 09:04 AM

i cant understand what is going on here and was wondering if someone could help me.

 

I've setup 2 two inputs to interrupt on ports D0 & D1

BallTrigOdd = new InterruptPort(NPIO.BallTrigOdd, true, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeLow);BallTrigOdd.OnInterrupt += new NativeEventHandler(BallTrigOdd_OnInterrupt);BallTrigOdd.EnableInterrupt();BallTrigEven = new InterruptPort(NPIO.BallTrigEven, true, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeLow);BallTrigEven.OnInterrupt += new NativeEventHandler(BallTrigEven_OnInterrupt);BallTrigEven.EnableInterrupt();
        private void BallTrigEven_OnInterrupt(uint data1, uint data2, DateTime time)        {            BallTrigEven.DisableInterrupt();            UpdateStatus(id.odd);            Cycle(id.even);            ballData.Lanes[(int)id.even].Data = (int)TestScores.Seven;            BallTrigEven.EnableInterrupt();        }        private void BallTrigOdd_OnInterrupt(uint data1, uint data2, DateTime time)        {            BallTrigOdd.DisableInterrupt();            UpdateStatus(id.even);            Cycle(id.odd);            ballData.Lanes[(int)id.even].Data = (int)TestScores.Seven;            BallTrigOdd.EnableInterrupt();        }

but for some reason it just keeps triggering and gets stuck in a loop. Is there something I'm doing wrong?



#2 hanzibal

hanzibal

    Advanced Member

  • Members
  • PipPipPip
  • 1287 posts
  • LocationSweden

Posted 07 May 2013 - 10:06 AM

Hi!

 

Depends on what's on the other end of the wires - if they are some kind of switches, you are probably experiencing the effect of contact bouncing.

 

In case you don't know, contact bouncing normally occur when you close a switch. Just as the name implies, the poles of the switch will mechanically bounce against each other ever so slightly but enough to make the switch go on and off very quickly (typically within the order of microsecond intervals). Interrupt handling on your Netduino is fast enough to pick up the switch toggling and therefore you will typically see 10 or more interrupts every time you operate the switch.

 

Could this be the cause you think?



#3 ash

ash

    Advanced Member

  • Members
  • PipPipPip
  • 66 posts

Posted 07 May 2013 - 10:23 AM

thats what i thought but it keeps triggering way after the button has been pressed. Also im in bedugging mode too. I placed a break point on the interrupt. When it occurs click go until the it clears. If it happens a few times then its a debounce issue but it just keeps going!



#4 ash

ash

    Advanced Member

  • Members
  • PipPipPip
  • 66 posts

Posted 07 May 2013 - 10:44 AM

with added debounce

        private void BallTrigEven_OnInterrupt(uint data1, uint data2, DateTime time)        {            string st = time.Second.ToString() + " - " + time.Millisecond.ToString();            Debug.Print("EVEN ball trigger: " + st);            if (ballData.Lanes[(int)id.even].LastPushed.AddMilliseconds(cDebounce) > time)                return;            BallTrigEven.DisableInterrupt();            UpdateStatus(id.even);            Cycle(id.even);            ballData.Lanes[(int)id.even].Data = (int)TestScores.Seven;            ballData.Lanes[(int)id.even].LastPushed = time;            BallTrigEven.EnableInterrupt();        }

break point set on the "if" statement. I triggered the input very crudely (needle nose pliers :)) and then F9 when the debugger hit the break point.

Below the debuggers output

 

EVEN ball trigger: 20 - 851 EVEN ball trigger: 20 - 851 EVEN ball trigger: 20 - 911 EVEN ball trigger: 20 - 938 EVEN ball trigger: 20 - 954 EVEN ball trigger: 20 - 955 EVEN ball trigger: 20 - 966 EVEN ball trigger: 21 - 105 EVEN ball trigger: 21 - 105 EVEN ball trigger: 21 - 105 EVEN ball trigger: 21 - 105 EVEN ball trigger: 21 - 105 EVEN ball trigger: 21 - 105 EVEN ball trigger: 21 - 105 EVEN ball trigger: 21 - 105 EVEN ball trigger: 21 - 105 EVEN ball trigger: 21 - 105 EVEN ball trigger: 21 - 105 EVEN ball trigger: 21 - 105 EVEN ball trigger: 21 - 105 EVEN ball trigger: 21 - 105 EVEN ball trigger: 21 - 105 EVEN ball trigger: 21 - 105 EVEN ball trigger: 21 - 105 EVEN ball trigger: 21 - 105 EVEN ball trigger: 21 - 105 EVEN ball trigger: 21 - 105 EVEN ball trigger: 21 - 105 EVEN ball trigger: 21 - 105 EVEN ball trigger: 21 - 105 EVEN ball trigger: 21 - 106 EVEN ball trigger: 21 - 106 EVEN ball trigger: 21 - 106 EVEN ball trigger: 21 - 106 EVEN ball trigger: 21 - 106 EVEN ball trigger: 21 - 106 EVEN ball trigger: 21 - 106 EVEN ball trigger: 21 - 106 EVEN ball trigger: 21 - 106 EVEN ball trigger: 21 - 106 EVEN ball trigger: 21 - 106 EVEN ball trigger: 21 - 106 EVEN ball trigger: 21 - 106 EVEN ball trigger: 21 - 106 EVEN ball trigger: 21 - 106 EVEN ball trigger: 21 - 106 EVEN ball trigger: 21 - 106 EVEN ball trigger: 21 - 106 EVEN ball trigger: 21 - 106 EVEN ball trigger: 21 - 106 EVEN ball trigger: 21 - 106 EVEN ball trigger: 21 - 106 EVEN ball trigger: 21 - 106 EVEN ball trigger: 21 - 106 EVEN ball trigger: 21 - 106 EVEN ball trigger: 21 - 106 EVEN ball trigger: 21 - 106 EVEN ball trigger: 21 - 106 EVEN ball trigger: 21 - 106

 

Now, thats very weird :wacko:



#5 ash

ash

    Advanced Member

  • Members
  • PipPipPip
  • 66 posts

Posted 07 May 2013 - 10:48 AM

here's a really long one!

 

ODD ball trigger: 28 - 123 ODD ball trigger: 28 - 123 ODD ball trigger: 28 - 123 ODD ball trigger: 28 - 123 ODD ball trigger: 28 - 123 ODD ball trigger: 28 - 123 ODD ball trigger: 28 - 123 ODD ball trigger: 28 - 123 ODD ball trigger: 28 - 123 ODD ball trigger: 28 - 123 ODD ball trigger: 28 - 123 ODD ball trigger: 28 - 123 ODD ball trigger: 28 - 123 ODD ball trigger: 28 - 123 ODD ball trigger: 28 - 123 ODD ball trigger: 28 - 124 ODD ball trigger: 28 - 124 ODD ball trigger: 28 - 124 ODD ball trigger: 28 - 124 ODD ball trigger: 28 - 124 ODD ball trigger: 28 - 190 ODD ball trigger: 28 - 191 ODD ball trigger: 28 - 191 ODD ball trigger: 28 - 191 ODD ball trigger: 28 - 191 ODD ball trigger: 28 - 192 ODD ball trigger: 28 - 237 ODD ball trigger: 28 - 237 ODD ball trigger: 28 - 237 ODD ball trigger: 28 - 237 ODD ball trigger: 28 - 237 ODD ball trigger: 28 - 249 ODD ball trigger: 28 - 249 ODD ball trigger: 28 - 249 ODD ball trigger: 28 - 249 ODD ball trigger: 28 - 249 ODD ball trigger: 28 - 249 ODD ball trigger: 28 - 249 ODD ball trigger: 28 - 258 ODD ball trigger: 28 - 259 ODD ball trigger: 28 - 259 ODD ball trigger: 28 - 259 ODD ball trigger: 28 - 259 ODD ball trigger: 28 - 259 ODD ball trigger: 28 - 260 ODD ball trigger: 28 - 261 ODD ball trigger: 28 - 261 ODD ball trigger: 28 - 262 ODD ball trigger: 28 - 262 ODD ball trigger: 28 - 262 ODD ball trigger: 28 - 263 ODD ball trigger: 28 - 263 ODD ball trigger: 28 - 263 ODD ball trigger: 28 - 263 ODD ball trigger: 28 - 263 ODD ball trigger: 28 - 264 ODD ball trigger: 28 - 264 ODD ball trigger: 28 - 264 ODD ball trigger: 28 - 264 ODD ball trigger: 28 - 268 ODD ball trigger: 28 - 268 ODD ball trigger: 28 - 268 ODD ball trigger: 28 - 268 ODD ball trigger: 28 - 270 ODD ball trigger: 28 - 270 ODD ball trigger: 28 - 270 ODD ball trigger: 28 - 270 ODD ball trigger: 28 - 270 ODD ball trigger: 28 - 270 ODD ball trigger: 28 - 270 ODD ball trigger: 28 - 270 ODD ball trigger: 28 - 270 ODD ball trigger: 28 - 270 ODD ball trigger: 28 - 270 ODD ball trigger: 28 - 270 ODD ball trigger: 28 - 270 ODD ball trigger: 28 - 270 ODD ball trigger: 28 - 271 ODD ball trigger: 28 - 271 ODD ball trigger: 28 - 271 ODD ball trigger: 28 - 272 ODD ball trigger: 28 - 272 ODD ball trigger: 28 - 272 ODD ball trigger: 28 - 320 ODD ball trigger: 28 - 462 ODD ball trigger: 28 - 468 ODD ball trigger: 28 - 468 ODD ball trigger: 28 - 468 ODD ball trigger: 28 - 468 ODD ball trigger: 28 - 468 ODD ball trigger: 28 - 468 ODD ball trigger: 28 - 468 ODD ball trigger: 28 - 468 ODD ball trigger: 28 - 468 ODD ball trigger: 28 - 468 ODD ball trigger: 28 - 468 ODD ball trigger: 28 - 468 ODD ball trigger: 28 - 468 ODD ball trigger: 28 - 468 ODD ball trigger: 28 - 468 ODD ball trigger: 28 - 468 ODD ball trigger: 28 - 468 ODD ball trigger: 28 - 468 ODD ball trigger: 28 - 468 ODD ball trigger: 28 - 468 ODD ball trigger: 28 - 468 ODD ball trigger: 28 - 468 ODD ball trigger: 28 - 469 ODD ball trigger: 28 - 469 ODD ball trigger: 28 - 469 ODD ball trigger: 28 - 469 ODD ball trigger: 28 - 470 ODD ball trigger: 28 - 470 ODD ball trigger: 28 - 470 ODD ball trigger: 28 - 470 ODD ball trigger: 28 - 470 ODD ball trigger: 28 - 470 ODD ball trigger: 28 - 470 ODD ball trigger: 28 - 470 ODD ball trigger: 28 - 470 ODD ball trigger: 28 - 470 ODD ball trigger: 28 - 470 ODD ball trigger: 28 - 470 ODD ball trigger: 28 - 470 ODD ball trigger: 28 - 470 ODD ball trigger: 28 - 470 ODD ball trigger: 28 - 470



#6 hanzibal

hanzibal

    Advanced Member

  • Members
  • PipPipPip
  • 1287 posts
  • LocationSweden

Posted 07 May 2013 - 11:40 AM

Ok, then I think you got a floating pin somewhere because there's something wrong with your wires.

 

...or your debouncer doesn't work.

 

What's the thing connected to the interrupt ports?

 

EDIT: What voltage do you measure from the "switches" when they output a high and low level respectively? Could be they barely reach the level that Netduino considers to be high.

 

EDIT: I see now that logging is done before the debouncer so no wonder you get multiple log entries.



#7 ash

ash

    Advanced Member

  • Members
  • PipPipPip
  • 66 posts

Posted 07 May 2013 - 12:34 PM

I've got the internal pull up resistor enabled so it should only go low when the switch is activated otherwise there's 3v3 on the inputs.

 

I've noticed when i attach the gnd of my scope on to the circuit it triggers it also but i know that my scope is not isolated.

 

another thing I've noticed is when i attach the gnd to my meter, it triggers it also. Now thats really weird!



#8 hanzibal

hanzibal

    Advanced Member

  • Members
  • PipPipPip
  • 1287 posts
  • LocationSweden

Posted 07 May 2013 - 12:46 PM

It really sounds like a case of floating pins, an open collector hanging in free air will typically react to magnetic fields like the ones induced when you hold your finger within a few centimeters away from the pin in question.

 

Since you got pull-ups, my guess is that it's actually happening in the "switches" - are they in any way active devices?

 

Please notice the last edit I made to my previous post above.



#9 ash

ash

    Advanced Member

  • Members
  • PipPipPip
  • 66 posts

Posted 07 May 2013 - 01:58 PM

with the switch not connected to the input stage it should not trigger but it does.

 

I can even trigger this when i put the neg lead of my meter on the gnd of my board!

 

So i dont belive its a floating pin issue.



#10 hanzibal

hanzibal

    Advanced Member

  • Members
  • PipPipPip
  • 1287 posts
  • LocationSweden

Posted 07 May 2013 - 02:19 PM

I see, please try and add actual external pull-ups, say 10k or so - that should help.

 

I know you have pull-ups set programmatically but I don't really trust those.



#11 ash

ash

    Advanced Member

  • Members
  • PipPipPip
  • 66 posts

Posted 07 May 2013 - 02:41 PM

i already have them too :P



#12 hanzibal

hanzibal

    Advanced Member

  • Members
  • PipPipPip
  • 1287 posts
  • LocationSweden

Posted 07 May 2013 - 03:47 PM

That is truly weird, with no switches and pull-up its like connecting the pins directly to Vdd. Still symptoms are exactly like floating pins and it could be in a different location. Is Vdd good when you look at the scope? What other stuff have you got connected?

#13 ash

ash

    Advanced Member

  • Members
  • PipPipPip
  • 66 posts

Posted 08 May 2013 - 07:41 AM

like i said if i connect the ground from either by meter or scope it triggers!



#14 hanzibal

hanzibal

    Advanced Member

  • Members
  • PipPipPip
  • 1287 posts
  • LocationSweden

Posted 08 May 2013 - 08:39 AM

Yes, but what about the other two questions of mine - is power good? Any other devices connected?

 

The ground of your scope or meter is unlikely to have the exact same potential as ground on your board so it's basically similar to holding your finger against it. Not all grounds are created equal  ;)

 

At this point, even just waving your hand above the board could probably trigger an interrupt. You can actually implement simple touch buttons with open collector inputs.



#15 ash

ash

    Advanced Member

  • Members
  • PipPipPip
  • 66 posts

Posted 08 May 2013 - 11:32 AM

just attached an NP v1 and works with no false triggering.

 

 

My input stage is simple : a connector (input from outside world, open collector source) ->  pull-up resisitor -> connector (micro switch but for testing, the connectors are shorted) -> Schmitt inverter input -> Netduino input! (D0).

 

I added the trigger inverter yesterday. :P



#16 hanzibal

hanzibal

    Advanced Member

  • Members
  • PipPipPip
  • 1287 posts
  • LocationSweden

Posted 08 May 2013 - 11:45 AM

[color=rgb(40,40,40);font-family:helvetica, arial, sans-serif;]Hmm..."open collector source" you say...[/color]

 

[color=rgb(40,40,40);font-family:helvetica, arial, sans-serif;]Are you saying the [/color]Schmittrigger [color=rgb(40,40,40);font-family:helvetica, arial, sans-serif;]solved the problem with the NP2?[/color]



#17 ash

ash

    Advanced Member

  • Members
  • PipPipPip
  • 66 posts

Posted 08 May 2013 - 12:08 PM

no i added it to see if it would fix it but alias not.

 

Thanks for your help but im getting no where :wacko:



#18 hanzibal

hanzibal

    Advanced Member

  • Members
  • PipPipPip
  • 1287 posts
  • LocationSweden

Posted 08 May 2013 - 12:12 PM

Sure, no problem.

 

[color=#ffffe0;]I still smell floating pins and that open collector source is a suspect.[/color]



#19 ash

ash

    Advanced Member

  • Members
  • PipPipPip
  • 66 posts

Posted 10 May 2013 - 09:58 AM

well, went on site yesterday to test and it was terrible. triggered once or a few time then nothing!!!

 

oh and even used the onboard switch too and that was flaky :D

 

Ended up having to write my interrruptPort class in the end and it was stable.






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.