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

Microsecond timing


  • Please log in to reply
8 replies to this topic

#1 Joshua Watkins

Joshua Watkins

    New Member

  • Members
  • Pip
  • 2 posts

Posted 21 July 2012 - 07:10 AM

Is there a way to get microsecond level timing from the netduino+?

#2 Stefan

Stefan

    Moderator

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

Posted 21 July 2012 - 07:14 AM

Hi, could this thread point you in the right direction? http://forums.netdui...e-system-timer/
"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

#3 CW2

CW2

    Advanced Member

  • Members
  • PipPipPip
  • 1592 posts
  • LocationCzech Republic

Posted 21 July 2012 - 10:55 AM

Could you please provide some more details on what exactly you need? The current implementation of .NET Micro Framework cannot provide microsecond precise timing when executing managed code, but there are certain ways to overcome that limitation, for example by using PWM, SPI, USART hardware modules, or there might be already a native driver (C++ code that can have precise timing) for a particular device or protocol.

#4 Victor M.

Victor M.

    Advanced Member

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

Posted 21 July 2012 - 12:07 PM

Is there a way to get microsecond level timing from the netduino+?


Why you need "us" ? Netduino have troubles when you reduce so much the interruption time and events. Around 100ms the periodic count start to be very unstable and the oscillate between 80ms and 120ms. This problem occur because your code staying on the high level code and the code of bootloader and .NET Microframework stay under it. To make some type of aplication you need to use other processor or try to put you code compiled with the bootloader.

Other solution for this problem is use other processor to manage fast process.

#5 Stefan

Stefan

    Moderator

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

Posted 21 July 2012 - 02:29 PM

Other solution for this problem is use other processor to manage fast process.

Or to see if there's a native class for the kind of job you want to do, like CW2 pointed out.

If you want to drive a specific chip, you could bitbang, but also use native SPI, I2C, PWM or UART classes.
"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 Nobby

Nobby

    Advanced Member

  • Members
  • PipPipPip
  • 70 posts

Posted 23 July 2012 - 07:59 AM

Microsoft.SPOT.Hardware.Utility.GetMachineTime().Ticks has 100ns precision(0.1us) but the accuracy is skewed by +- a few hundred microseconds due to the runtime overhead. If you need to measure an interval less than one millisecond, you end up with an error of about 20% but this error is negligable for slightly larger intervals. The 100ns precision is definitely usefull for cumulative timing functionality. Are you using the timer as a measurement interrupt?

#7 jfriedman

jfriedman

    New Member

  • Members
  • Pip
  • 1 posts

Posted 12 April 2013 - 06:42 AM

You may be able to squeeze less than 20% of error out if you cause the processor to use interrupts.

 

See this article

 

http://www.codeproje...recision-in-NET



#8 Morpheus

Morpheus

    New Member

  • Members
  • Pip
  • 2 posts

Posted 26 April 2013 - 02:51 PM

Dear all

 

what i did in order to overcome this error is the following:

I made some tests in order to find how many ticks are for each microsecond. I calculated the ticks for 1 microsec to 1 sec in some discrete steps. I assumed that the greatest the time is the greatest the precision for the ticks counting so for various tests for 1 sec i found that there are about 10,1 ticks per 1 microsec (eg 1010347 ticks for 100ms (100000microsec) thus 1010347/100000=10,10347 ticks per microsec.

				    long startTick = Utility.GetMachineTime().Ticks;				    Thread.Sleep(1);				    long endTick = Utility.GetMachineTime().Ticks;				    long Delta = endTick - startTick;				    Debug.Print("1ms:" + Delta.ToString());				    startTick = Utility.GetMachineTime().Ticks;				    Thread.Sleep(10);				    endTick = Utility.GetMachineTime().Ticks;				    Delta = endTick - startTick;				    Debug.Print("10ms:" + Delta.ToString());				    startTick = Utility.GetMachineTime().Ticks;				    Thread.Sleep(100);				    endTick = Utility.GetMachineTime().Ticks;				    Delta = endTick - startTick;				    Debug.Print("100ms:" + Delta.ToString());				    startTick = Utility.GetMachineTime().Ticks;				    Thread.Sleep(1000);				    endTick = Utility.GetMachineTime().Ticks;				    Delta = endTick - startTick;				    Debug.Print("1s:" + Delta.ToString()); 

Then i wrote a function that creates a delay in microseconds.

 

 

 double ticksPerMicrosec=10; // this came after calculation (see above)	    public static void WaitMicroseconds(double microseconds)	    {		    long ticks = Utility.GetMachineTime().Ticks;		    while ((Utility.GetMachineTime().Ticks - ticks) < (microseconds * ticksPerMicrosec)) ;	    } 

You have to let it all go. Fear, doubt, and disbelief. Free your mind.

#9 YuvaRaja

YuvaRaja

    New Member

  • Members
  • Pip
  • 8 posts
  • LocationINDIA

Posted 23 May 2013 - 01:47 PM

I found a link for Microsecond delay in the Netduino.

 

http://www.j2i.net/b...-Framework.aspx

 

But this is only for netduino and depends upon the Hardware also.






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.