I have a N+2 driving 2 stepper motors with the Sparkfun Easydriver. I have wired up several external buttons
InterruptPort ipT1 = new InterruptPort(Pins.GPIO_PIN_D0, false, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeLow);ipT1.OnInterrupt += Target_OnInterruptT1;InterruptPort ipT2 = new InterruptPort(Pins.GPIO_PIN_D1, false, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeLow);ipT2.OnInterrupt += Target_OnInterruptT2;
?
Here are my event handlers
static void Target_OnInterruptT1(uint data1, uint data2, DateTime time) { if (dtLastHit.AddMilliseconds(intBounceWait) > time) return; // prevent bounce dtLastHit = time; Debug.Print("Hit T1 = " + DateTime.Now.ToString("MM/dd/yy H:mm:ss.fff")); } static void Target_OnInterruptT2(uint data1, uint data2, DateTime time) { if (dtLastHit.AddMilliseconds(intBounceWait) > time) return; // prevent bounce dtLastHit = time; Debug.Print("Hit T2 = " + DateTime.Now.ToString("MM/dd/yy H:mm:ss.fff")); }
My problem is that when I press button T1 it randomly executes Target_OnInterruptT2 or Target_OnInterruptT1. No rhyme or reason. The same thing happens if I press button T2.
What is odd is that I've used this same exact board with 5 buttons, in the past, and had no problems. Any idea what is happening? I thought it might be EMI from the Easy driver, but I still get the same behavior even if I disconnect power to the stepper motors.
I'm scratching my head...