Netduino home hardware projects downloads community

Jump to content

The Netduino forums have been replaced by new forums at This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.

Triggering Thread

  • Please log in to reply
2 replies to this topic



    New Member

  • Members
  • Pip
  • 2 posts
  • LocationTurkey

Posted 28 April 2012 - 03:37 PM

Hi Netduino Users, I have a problem. I want to get analog input (in my case this is a potentiometer) in a specific period. Like 100 Hz. At the end an infinite loop will be perform. Under that there may be a thread which triggers analog input 100 times in a second. How can I do that ? Thanks for your answer. NOTE: After finishing my project, i will share with you.

#2 Mario Vernari

Mario Vernari

    Advanced Member

  • Members
  • PipPipPip
  • 1768 posts
  • LocationVenezia, Italia

Posted 28 April 2012 - 04:30 PM

Hello Kodozani.
You can do a dedicate thread running endlessly a loop, but it's an overkill, I think.
I'd use a Timer which is also the most accurate way to perform a certain task.
Try this:

class Program
  private static Timer _clock;
  private static AnalogInput _pot = new AnalogInput(Pins.GPIO_PIN_A0);
  public static void Main()
    _clock = new Timer(Tick, null, 10, 10);


  private static void Tick(object state)
    int read = _pot.Read();
    // do whatever ...

Note: I written the above code by could contain some error, but it should be pretty near to a working program.
Biggest fault of Netduino? It runs by electricity.

#3 Nevyn


    Advanced Member

  • Members
  • PipPipPip
  • 1072 posts
  • LocationNorth Yorkshire, UK

Posted 29 April 2012 - 06:17 AM

You can do a dedicate thread running endlessly a loop, but it's an overkill, I think.

There may also be a problem with timing as threads execute for 20ms at a time on NETMF. If you are interested on how threading works then you can find out more in the article Threads and Thread Priorities in NETMF.


To be or not to be = 0xFF


Blogging about Netduino, .NET, STM8S and STM32 and generally waffling on about life

Follow @nevynuk on Twitter

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.