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

Delay microseconds


  • Please log in to reply
8 replies to this topic

#1 Bendage

Bendage

    Advanced Member

  • Members
  • PipPipPip
  • 153 posts
  • LocationIrvine, CA

Posted 02 February 2012 - 11:03 PM

Hey guys, Thread.Sleep is millis How to delay Netduino down to the microsecond?

#2 Bendage

Bendage

    Advanced Member

  • Members
  • PipPipPip
  • 153 posts
  • LocationIrvine, CA

Posted 03 February 2012 - 12:11 AM

Actually I just ended up writing one myself...

private void DelayMicroseconds(int microseconds)
{
    long delayTime = microseconds * 10;
    long delayStart = Utility.GetMachineTime().Ticks;
    while ((Utility.GetMachineTime().Ticks - delayStart) < delayTime) ;
}


#3 CW2

CW2

    Advanced Member

  • Members
  • PipPipPip
  • 1592 posts
  • LocationCzech Republic

Posted 03 February 2012 - 07:17 AM

Please note due to Netduino timer resolution the code works in multiples of ~21µs.

#4 Mario Vernari

Mario Vernari

    Advanced Member

  • Members
  • PipPipPip
  • 1768 posts
  • LocationVenezia, Italia

Posted 03 February 2012 - 09:18 AM

If your goal is a well-defined pause, why don't use a surrogate such as:
temp++;
Just an example...I don't know how much it takes.
Cheers
Biggest fault of Netduino? It runs by electricity.

#5 Bendage

Bendage

    Advanced Member

  • Members
  • PipPipPip
  • 153 posts
  • LocationIrvine, CA

Posted 19 April 2012 - 01:19 AM

Please note due to Netduino timer resolution the code works in multiples of ~21µs.


Any idea what the Go timer resolution is?

#6 CW2

CW2

    Advanced Member

  • Members
  • PipPipPip
  • 1592 posts
  • LocationCzech Republic

Posted 19 April 2012 - 06:08 AM

Any idea what the Go timer resolution is?

1 µs Posted Image

#7 Jarrod Sinclair

Jarrod Sinclair

    Advanced Member

  • Members
  • PipPipPip
  • 50 posts
  • LocationSF Bay Area, CA

Posted 19 April 2012 - 07:55 PM

1 µs Posted Image



What about the hardware interrupts? I though they were 1 µs as well.

#8 Cornelius

Cornelius

    New Member

  • Members
  • Pip
  • 7 posts

Posted 24 August 2012 - 07:28 PM

Hi,

Here's a function that i wrote. I find it quite accurate: (loosely based on the functions mentioned above)

private static void delayMicroseconds(int microseconds)
{
   for (int temp = 0; temp < ((microseconds - 208)/61); temp++);
}

It works in ~65us wide steps, and it's minimum is about 240us.

have fun,

Attached Files



#9 Bendage

Bendage

    Advanced Member

  • Members
  • PipPipPip
  • 153 posts
  • LocationIrvine, CA

Posted 28 August 2012 - 10:49 PM

Hi,

Here's a function that i wrote. I find it quite accurate: (loosely based on the functions mentioned above)

private static void delayMicroseconds(int microseconds)
{
   for (int temp = 0; temp < ((microseconds - 208)/61); temp++);
}

It works in ~65us wide steps, and it's minimum is about 240us.

have fun,



Nice idea. I will play with this when my scope comes in the mail.




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.