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

InterruptPort gives exception in Netduino Plus


  • Please log in to reply
6 replies to this topic

#1 Victor M.

Victor M.

    Advanced Member

  • Members
  • PipPipPip
  • 39 posts
  • LocationRio de Janeiro, Brazil

Posted 30 August 2012 - 12:51 PM

I need help to understand what happening in my code. When I run it an error in this line occur:

InterruptPort FlowMeterPulse = new InterruptPort(Pins.GPIO_PIN_D1, false,
            	Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeHigh);

The error is:

An unhandled exception of type 'System.Exception' occurred in Microsoft.SPOT.Hardware.dll

The code is:
public class Program
	{
    	//Flow Meter Settings
    	public const int INTERRUPT_TIMER_MS = 30000;


    	public static long pulsebuffer = 0;
    	public static double TotalFlow;


    	public static TimerCallback timerDelegate = new TimerCallback(TimeProcessEvents);
    	public static Timer FlowMeterTimer;
   	// public static ;
    	
    	
    	public static void Main()
    	{

        	InterruptPort FlowMeterPulse = new InterruptPort(Pins.GPIO_PIN_D1, false,
            	Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeHigh);
        	FlowMeterPulse.OnInterrupt += new NativeEventHandler(FlowMeterPulse_OnInterrupt);



        	FlowMeterTimer = new Timer(timerDelegate, null, 0, INTERRUPT_TIMER_MS);
        	//Thread FlowManagerThread = new Thread(new ManagerInterrupt().Initialize);
        	//FlowManagerThread.Start();

        	Server WebServer = new Server(PinManagement.OnboardLED, 80);

        	while (true)
        	{
            	PinManagement.OnboardLED.Write(true);
            	Thread.Sleep(100);
            	PinManagement.OnboardLED.Write(false);
            	Thread.Sleep(2400);            	
        	}
    	}

    	/// <summary>
    	/// 
    	/// </summary>
    	/// <param name="state"></param>
    	private static void TimeProcessEvents(object state)
    	{
        	double meanFlow = (double)((double)7.5 * (double)pulsebuffer  / (double)30);

        	TotalFlow += meanFlow * 0.5;
   	}


    	public static void FlowMeterPulse_OnInterrupt(uint data1, uint data2, DateTime time)
    	{
        	pulsebuffer++;
    	}
	}


I'm using the .NETMF 4.2

#2 Igor Kondrasovas

Igor Kondrasovas

    Advanced Member

  • Members
  • PipPipPip
  • 105 posts
  • LocationPorto, Portugal

Posted 30 August 2012 - 09:51 PM

Hi,

What if you declare FlowMeterPulse as static too? Does it help?

Igor.

Igor Kondrasovas

www.inovativatec.com


#3 Victor M.

Victor M.

    Advanced Member

  • Members
  • PipPipPip
  • 39 posts
  • LocationRio de Janeiro, Brazil

Posted 31 August 2012 - 07:11 PM

Put FlowMeterPulse static did not solve my problem but a solve it making a new solution :blink:...

Tanks Igor.

#4 Fred Werneck

Fred Werneck

    New Member

  • Members
  • Pip
  • 3 posts

Posted 08 April 2013 - 02:24 AM

Victor,

 

Como voc resolveu esse problema? Estou tentando usar o Web Server juntamente com um sensor DHT11 e est dando o mesmo erro.

 

Fred.



#5 Stefan

Stefan

    Moderator

  • Members
  • PipPipPip
  • 1965 posts
  • LocationBreda, the Netherlands

Posted 08 April 2013 - 07:04 AM

Hi Fred, and welcome to the Netduino forums.

 

So you can get the best help, I would like to ask you to post in English. That way everyone will understand you and be able to help you out.


"Fact that I'm a moderator doesn't make me an expert in things." Stefan, the eternal newb!
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs

#6 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 11 April 2013 - 01:19 AM

Hi Victor, For Netduino gen2, try using Port.InterruptMode.InterruptEdgeBoth instead. Then discard any "low" events. Also...I recommend using pins D0 and D2-D13 for interrupts. All of them have unique interrupt pins. D1 is the one digital pin that overlaps interrupts (with pin D9). Chris

#7 moses

moses

    New Member

  • Members
  • Pip
  • 1 posts

Posted 17 July 2013 - 07:50 PM

Hi. I am new to Netduino, help me for the codes for webserver and using  temperature and humidity sensor DHT11






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.