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

Getting Started with Interrupts


Best Answer Chris Walker, 28 December 2013 - 07:17 AM

Hi Mark, With .NET Micro Framework, your hardware interrupts will generally result in C# events, and you'll handle those with EventHandlers. When the event occurs, your existing code will be interrupted to run your event's code (in your EventHandler). This will generally stop your currently-running code, but you could also run your main code on a separate thread at which point NETMF would make sure that both pieces of code got processor time. As far as NMIs and the such go...those happen down in the microcontroller, but NETMF apps run at a much higher level. So for most purposes, you just have events (raised either by interrupts or by other code). Chris Go to the full post


  • Please log in to reply
3 replies to this topic

#1 Mark Anderson

Mark Anderson

    Member

  • Members
  • PipPip
  • 25 posts
  • LocationChciago

Posted 27 December 2013 - 09:48 PM

Hi Guys

 

I'm just getting started with Netduino (done a little arduino stuff). My first project is a sump pit/pump monitor. I have the water level monitoring working on arduino and figure that will be easy to move over when I get my netduino (next week).

 

What I need to add are two things:

 

  • Pump operation stats 
  • RS232 messaging to a home automation server (send current water level, pump stats)

 

For No 1, I need to detect when the pump runs (from an external sensor: currently a float switch, but will change to current sensor later). So this will need to be interrupt driven. I reckon I can figure that out from the examples I've seen. Where I'm "stuck" is what happens when there is an interrupt (new area for me, but I do do know difference between a regular interrupt and NMI).

 

Right now I'm thinking a tread that loops continually and takes a reading of the water level every x-seconds. It will then send a message over RS232 with the value. I may use a network connection to something like thingsalk later. If the pump runs while reading the distance sensor or sending the message, it will generate an interrupt, but I don't know what that does to any executing code. 

 

Can someone give me a brief explanation or point me in right direction?

 

TIA 

 

Mark



#2 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 28 December 2013 - 07:17 AM   Best Answer

Hi Mark, With .NET Micro Framework, your hardware interrupts will generally result in C# events, and you'll handle those with EventHandlers. When the event occurs, your existing code will be interrupted to run your event's code (in your EventHandler). This will generally stop your currently-running code, but you could also run your main code on a separate thread at which point NETMF would make sure that both pieces of code got processor time. As far as NMIs and the such go...those happen down in the microcontroller, but NETMF apps run at a much higher level. So for most purposes, you just have events (raised either by interrupts or by other code). Chris

#3 ShVerni

ShVerni

    Advanced Member

  • Members
  • PipPipPip
  • 138 posts
  • LocationNew York, New York

Posted 28 December 2013 - 07:40 AM

Looks like Chris beat me to the answer (that'll teach me to take so long composing), but if you're interested in the nitty-gritty of interrupts, this post is pretty excellent:

 

http://www.tinyclr.i...management.aspx



#4 Mark Anderson

Mark Anderson

    Member

  • Members
  • PipPip
  • 25 posts
  • LocationChciago

Posted 29 December 2013 - 12:46 AM

Hi All

 

I just read this book and it answered all my questions about threading and interrupts. So if you're in the same boat, I'd highly recommend it. It's excellent.

 

http://www.amazon.co...k/dp/B006UZUCEI

 

Regards

 

mark






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.