Interrupt Port Fail - General Discussion - Netduino Forums
   
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

Interrupt Port Fail

Interrupt Port

Best Answer Fahdil, 11 February 2014 - 10:46 AM

What The....

Sorry My mistake...

Notice that I call the class with wrong method:

Encoder MyEncoder = new Encoder(Cpu.Pin.GPIO_Pin4, Cpu.Pin.GPIO_Pin5, Cpu.Pin.GPIO.GPIO_NONE);

and now work again using:

Encoder MyEncoder = new Encoder(Pins.GPIO_PIN_D4, Pins.GPIO_PIN_D5, Pins.GPIO_NONE);

huff.... one another silly mistakes

 

waste my 2 hours for this .... it's really a big lesson.

Go to the full post


  • Please log in to reply
1 reply to this topic

#1 Fahdil

Fahdil

    Advanced Member

  • Members
  • PipPipPip
  • 59 posts
  • LocationJakarta, Indonesia

Posted 11 February 2014 - 09:42 AM

Hi guys,

 

Lately, I try to use a rotary encoder. I get the code from wiki 

http://wiki.netduino...oder-Input.ashx

namespace RotaryEncoder{    /// <summary>    /// For use with quadrature encoders where signal A and B are 90° out of phase.    /// </summary>    /// <remarks>    /// For a detented rotary encoder such as http://www.sparkfun.com/products/9117    /// Written by Michael Paauwe    /// Tested with .NETMF 4.2RC1 and Netduino Plus FW4.2.0RC1    /// </remarks>    class Encoder    {        private InputPort PhaseB;        private InterruptPort PhaseA;        private InterruptPort Button;        public bool buttonState = false;        public int position = 0;        /// <summary>        /// Constructor for encoder class        /// </summary>        /// <param name="pinA">The pin used for output A</param>        /// <param name="pinB">The pin used for output B</param>        /// <param name="pinButton">The pin used for the push contact (Optional:GPIO_NONE if not used)</param>        public Encoder(Cpu.Pin pinA, Cpu.Pin pinB, Cpu.Pin pinButton = Pins.GPIO_NONE)        {            PhaseA = new InterruptPort(pinA, false, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeBoth);            PhaseA.OnInterrupt += new NativeEventHandler(PhaseA_OnInterrupt);            PhaseB = new InputPort(pinB, false, Port.ResistorMode.PullUp);            if (pinB != Pins.GPIO_NONE)            {                Button = new InterruptPort(pinButton, false, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeBoth);                Button.OnInterrupt += new NativeEventHandler(Button_OnInterrupt);            }        }        void PhaseA_OnInterrupt(uint port, uint state, DateTime time)        {            if (state == 0)            {                if (PhaseB.Read() == true)                    position++;                else                    position--;            }            else            {                if (PhaseB.Read() == true)                    position--;                else                    position++;            }        }        void Button_OnInterrupt(uint port, uint state, DateTime time)        {            buttonState = (state == 0);        }    }} 

the code works fine for a week, but today it's goes fail. I see my encoder just fine when I test it by using LED attached on the Pins (it's still blinking). So I guess that the Interrupt Port doesnt work well anymore.

 

I put a breakpoint on the If statement(shown below), and debuging never reach this code, even I rotate the encoder.

 void PhaseA_OnInterrupt(uint port, uint state, DateTime time)        {            if (state == 0)

hope someone could see my problem and come up solution.



#2 Fahdil

Fahdil

    Advanced Member

  • Members
  • PipPipPip
  • 59 posts
  • LocationJakarta, Indonesia

Posted 11 February 2014 - 10:46 AM   Best Answer

What The....

Sorry My mistake...

Notice that I call the class with wrong method:

Encoder MyEncoder = new Encoder(Cpu.Pin.GPIO_Pin4, Cpu.Pin.GPIO_Pin5, Cpu.Pin.GPIO.GPIO_NONE);

and now work again using:

Encoder MyEncoder = new Encoder(Pins.GPIO_PIN_D4, Pins.GPIO_PIN_D5, Pins.GPIO_NONE);

huff.... one another silly mistakes

 

waste my 2 hours for this .... it's really a big lesson.







Also tagged with one or more of these keywords: Interrupt Port

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.