Interrupts

So as part of my tabletop competition robot I am using encoders. They are simple encoders only 3 pins 1 for signal the other 2 for power and ground. I have run into a issue. I am using An0-3 as my interrupt ports to read them on the interruptedgehigh I have tried all the modes available as that does not seem to make a difference to my issue. Two of the interrupt ports seem to be acting as other ports. if that makes any sense. I have pasted the basic code below. I put the print in my events as a last ditch effort 2 of them never fire off when manually spinning the wheel. Has anyone run into anything like this. I know the encoders are good i swapped wires and had it work. I tested them with my scope they fire as expected even to the interrupt pin on the shield. Has anyone run into something like this? Am i missing something here?


            InterruptPort EncoderB = new InterruptPort((Cpu.Pin)FEZ_Pin.Interrupt.An0, true, Port.ResistorMode.PullDown, Port.InterruptMode.InterruptEdgeHigh);
            EncoderB.OnInterrupt += new NativeEventHandler(EncoderB_OnInterrupt);
            InterruptPort EncoderD = new InterruptPort((Cpu.Pin)FEZ_Pin.Interrupt.An1, true, Port.ResistorMode.PullDown, Port.InterruptMode.InterruptEdgeHigh);
            EncoderD.OnInterrupt += new NativeEventHandler(EncoderD_OnInterrupt);
            InterruptPort EncoderA = new InterruptPort((Cpu.Pin)FEZ_Pin.Interrupt.An2, true, Port.ResistorMode.PullDown, Port.InterruptMode.InterruptEdgeHigh);
            EncoderA.OnInterrupt += new NativeEventHandler(EncoderA_OnInterrupt);
            InterruptPort EncoderC = new InterruptPort((Cpu.Pin)FEZ_Pin.Interrupt.An3, true, Port.ResistorMode.PullDown, Port.InterruptMode.InterruptEdgeHigh);
            EncoderC.OnInterrupt += new NativeEventHandler(EncoderC_OnInterrupt);
            EncoderACount = 0;
            EncoderBCount = 0;
            EncoderCCount = 0;               
            EncoderDCount = 0; 
 static void EncoderB_OnInterrupt(uint port, uint state, DateTime time)
        {
            EncoderBCount++;
            Debug.Print("EncoderB Hit " + time + " " + port);
        }
        static void EncoderD_OnInterrupt(uint port, uint state, DateTime time)
        {
            EncoderDCount++;
            Debug.Print("EncoderD Hit " + time + " " + port);
        }
        static void EncoderA_OnInterrupt(uint port, uint state, DateTime time)
        {
            EncoderACount++;
            Debug.Print("EncoderA Hit " + time + " " + port);
        }
        static void EncoderC_OnInterrupt(uint port, uint state, DateTime time)
        {
            EncoderCCount++;
            Debug.Print("EncoderC Hit " + time + " " + port);
        }

I didn’t understand what you mean. Can you provide an example that demonstrate the problem without using encoders?

yeah i will see if i can recreate with 4 buttons i guess.

Hey,

Have you tried setting the interupt mode to [quote]Port.InterruptMode.InterruptEdgeLow[/quote]

:smiley:

Here’s how I used it (trackball, similar to encoder as it uses a hall effect):


        #region FEZ_Components Extended Partial Classes
        // The only modification you will need to make to the Button class supplied by GHI is to add the 'partial' type definition.
        // This has already been done for you if you are using the Trackball example
        public partial class Button
        {
            public Button(FEZ_Pin.Interrupt pin, Port.InterruptMode interruptMode)
            {
                button = new InterruptPort((Cpu.Pin)pin, false, Port.ResistorMode.PullUp, interruptMode);
                button.OnInterrupt += new NativeEventHandler(OnInterrupt);
            }
        }
        #endregion

Calling it:

Why pull down resistors?

i tried all the different modes inconsistent results is what i got no mater what. port 23 reporting as port 24 and port 24 reporting as port 24. Pull up or pull down that leading or falling edge thatis straight up weird and is doubtfully the resistor setting that is causing it.

Please note that what the interrupt report is not the FEZ pin number but the actual USBizi pin number. For example, Di1 will not return 1.

See this for actual pin numbers [url]http://www.ghielectronics.com/downloads/USBizi/FEZ%20boards%20to%20evaluate%20USBizi%20chipsets.pdf[/url]

thanks found that mapping before i posted I am not seeing IO26 and 28 fire off as expected. 22 and 24 fire of all the time.

Gus i am a idiot. That covers this 100%. Helps if 2 of the encoders are plugged in the the right pins. i had them in analog 4-5 not 0-1.