1. I have a pressure switch that is either open or closed (short circuit). When there is light weight on it, it is closed. When there is heavy weight on it, it is open.
2. One side of the switch is connected to ground, the other to pin 5 of the Mini.
3. The port is configured as follows:
weightSensor = new InterruptPort(Pins.GPIO_PIN_5, true, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeBoth); weightSensor.OnInterrupt += OnSenseWeight; private void OnSenseWeight(uint pin, uint state, DateTime time) { if (state == 0) Debug.Print("Weight Off"); else Debug.Print("Weight On"); }
4. When the weight is removed from the sensor, it bounces 2 or 3 times before coming to a stop. This is just how it works and I can't change it.
Here's the problem: About 25% of the time, the final state of the pin gets out of sync with the actual state of the switch. I would get a series of interrupts, but the last debug output would then show "Weight On", when in fact the weight has been removed. I can see that the switch is closed, the voltage is 0V, and an oscilloscope shows the signal is clearly going to 0V. There is no other noise on the signal - it is very clean, other for the bouncing of the switch.
I tried to pass in "true" for "glitchFilter" but it doesn't make any difference.
To me this clearly looks like a bug since I'm just not getting the final event when the voltage on the pin goes to 0V. The only way I can currently think to work around this is to create a polling loop that continuously checks the state of this pin.
I'm currently using build 4.1.2821.0.
Any ideas what is going on here?