<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="bbPress/1.0.2" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>LeafLabs Garden &#187; Topic: delayMicroseconds(us)  and delay has anyone used them and are they semi-acurate?</title>
		<link>http://forums.leaflabs.com/topic.php?id=168</link>
		<description>A place to share, learn, and grow...</description>
		<language>en-US</language>
		<pubDate>Fri, 22 Jan 2016 00:10:15 +0000</pubDate>
		<generator>http://bbpress.org/?v=1.0.2</generator>
		<textInput>
			<title><![CDATA[Search]]></title>
			<description><![CDATA[Search all topics from these forums.]]></description>
			<name>q</name>
			<link>http://forums.leaflabs.com/search.php</link>
		</textInput>
		<atom:link href="http://forums.leaflabs.com/rss.php?topic=168" rel="self" type="application/rss+xml" />

		<item>
			<title>poslathian on "delayMicroseconds(us)  and delay has anyone used them and are they semi-acurate?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=168&amp;page=2#post-1255</link>
			<pubDate>Tue, 14 Sep 2010 14:22:28 +0000</pubDate>
			<dc:creator>poslathian</dc:creator>
			<guid isPermaLink="false">1255@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Go with the newer post. I made a bunch of find &#38;amp; replace style changes to be compatible with the current libmaple and i actually tested that it works - rather than just built it!
&#60;/p&#62;</description>
		</item>
		<item>
			<title>crenn on "delayMicroseconds(us)  and delay has anyone used them and are they semi-acurate?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=168&amp;page=2#post-1235</link>
			<pubDate>Mon, 13 Sep 2010 18:54:44 +0000</pubDate>
			<dc:creator>crenn</dc:creator>
			<guid isPermaLink="false">1235@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;No, but I did see this!&#60;br /&#62;
&#60;a href=&#34;http://forums.leaflabs.com/topic.php?id=121&#34; rel=&#34;nofollow&#34;&#62;http://forums.leaflabs.com/topic.php?id=121&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;I'll look into to it in about an hour. I currently need an I2C bus to talk with a couple of speed controllers.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>poslathian on "delayMicroseconds(us)  and delay has anyone used them and are they semi-acurate?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=168&amp;page=2#post-1232</link>
			<pubDate>Mon, 13 Sep 2010 18:46:42 +0000</pubDate>
			<dc:creator>poslathian</dc:creator>
			<guid isPermaLink="false">1232@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;did you see this? &#60;a href=&#34;http://forums.leaflabs.com/topic.php?id=182&#34; rel=&#34;nofollow&#34;&#62;http://forums.leaflabs.com/topic.php?id=182&#60;/a&#62;
&#60;/p&#62;</description>
		</item>
		<item>
			<title>crenn on "delayMicroseconds(us)  and delay has anyone used them and are they semi-acurate?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=168#post-1228</link>
			<pubDate>Mon, 13 Sep 2010 18:38:14 +0000</pubDate>
			<dc:creator>crenn</dc:creator>
			<guid isPermaLink="false">1228@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Currently only need single master mode (our robot is designed around a single micro, which at this stage I'm hoping to be a Maple although there is a little bit of debating behind the scenes) and a software implementation will work fine for what we need.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>poslathian on "delayMicroseconds(us)  and delay has anyone used them and are they semi-acurate?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=168#post-1226</link>
			<pubDate>Mon, 13 Sep 2010 18:33:19 +0000</pubDate>
			<dc:creator>poslathian</dc:creator>
			<guid isPermaLink="false">1226@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;days, and yes - software i2c with single master mode only. the hardware i2c with slave and multimaster is weeks.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>crenn on "delayMicroseconds(us)  and delay has anyone used them and are they semi-acurate?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=168#post-1225</link>
			<pubDate>Mon, 13 Sep 2010 18:31:20 +0000</pubDate>
			<dc:creator>crenn</dc:creator>
			<guid isPermaLink="false">1225@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;So a couple of weeks away? And is some form of I2C included in that release?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>poslathian on "delayMicroseconds(us)  and delay has anyone used them and are they semi-acurate?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=168#post-1220</link>
			<pubDate>Mon, 13 Sep 2010 18:17:30 +0000</pubDate>
			<dc:creator>poslathian</dc:creator>
			<guid isPermaLink="false">1220@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;0.0.7 is just a regular incremental release. the &#34;alpha&#34; stuff was referring to our snazzy new IDE (completely redone) for 0.1.0. Well push the 0.0.7 as soon as the last straggling tickets are closed, which are very minor. For example &#34;grep todo in codebase&#34; is currently on the top of the stack ;)
&#60;/p&#62;</description>
		</item>
		<item>
			<title>crenn on "delayMicroseconds(us)  and delay has anyone used them and are they semi-acurate?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=168#post-1219</link>
			<pubDate>Mon, 13 Sep 2010 18:12:27 +0000</pubDate>
			<dc:creator>crenn</dc:creator>
			<guid isPermaLink="false">1219@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;The most important question I'd ask is when is an alpha (or beta) of v0.0.7 going to be out!
&#60;/p&#62;</description>
		</item>
		<item>
			<title>poslathian on "delayMicroseconds(us)  and delay has anyone used them and are they semi-acurate?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=168#post-1218</link>
			<pubDate>Mon, 13 Sep 2010 17:55:14 +0000</pubDate>
			<dc:creator>poslathian</dc:creator>
			<guid isPermaLink="false">1218@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Ahh, yea I pulled this out of git. I suspect then that this was a known bug in 0.0.6 and someone (bnewbold? iperry? mbolivar?) fixed it - Good!
&#60;/p&#62;</description>
		</item>
		<item>
			<title>CarlO on "delayMicroseconds(us)  and delay has anyone used them and are they semi-acurate?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=168#post-1197</link>
			<pubDate>Mon, 13 Sep 2010 14:59:07 +0000</pubDate>
			<dc:creator>CarlO</dc:creator>
			<guid isPermaLink="false">1197@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;poslathin,&#60;/p&#62;
&#60;p&#62;The code for delay and delayMicroseconds distributed with V0.6 is different.  I have not been able to get the new delay code to compile, too many dependency changes.  I assume the new code will work correctly, but I'll test it when released.&#60;/p&#62;
&#60;p&#62;CarlO.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>poslathian on "delayMicroseconds(us)  and delay has anyone used them and are they semi-acurate?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=168#post-1185</link>
			<pubDate>Mon, 13 Sep 2010 12:21:23 +0000</pubDate>
			<dc:creator>poslathian</dc:creator>
			<guid isPermaLink="false">1185@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;hmm, the off by 1 in delay is very interesting: See the implementation:&#60;/p&#62;
&#60;pre&#62;
void delay(unsigned long ms)
{
   uint32 i;
   for (i = 0; i &#38;lt; ms; i++) {
      delayMicroseconds(1000);
   }
}

void delayMicroseconds(uint32 us) {
    us *= 12;

    /* fudge for function call overhead  */
    us--;
    asm volatile(&#34;   mov r0, %[us]          \n\t&#34;
                 &#34;1: subs r0, #1            \n\t&#34;
                 &#34;   bhi 1b                 \n\t&#34;
                 :
                 : [us] &#34;r&#34; (us)
                 : &#34;r0&#34;);
}
&#60;/pre&#62;
&#60;p&#62;If delayMicros works, then delay should work. Odd. Perhaps what we should be doing for delay isnt a over delayMicroseconds anyway but instead a delayMicroseconds(1000*ms). This would roll over delayMircroseconds for calls to delay longer than 72 minutes (~4200 seconds, ~4200000 ms), which I think is OK. Or we could bump everything up to long, and add a little more overhead to the microseconds loop. &#60;/p&#62;
&#60;p&#62;In general, I am a fan that there is so little overhead for delayMicroseconds, only ,72us! Good stat CarlO!
&#60;/p&#62;</description>
		</item>
		<item>
			<title>CarlO on "delayMicroseconds(us)  and delay has anyone used them and are they semi-acurate?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=168#post-1147</link>
			<pubDate>Thu, 09 Sep 2010 18:41:17 +0000</pubDate>
			<dc:creator>CarlO</dc:creator>
			<guid isPermaLink="false">1147@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;gbulmer,&#60;/p&#62;
&#60;p&#62;I have a Racal model 1992, 9 digit counter that is stable down to 1ns.  I also have a GPS Disciplined timebase that I use when I need high accuracy.  I only recorded the digits that weren't dithering on the display.  Due to the fact that the delay and delayMicroseconds functions are implemented in software, there is a tiny amount of jitter in the width of the pulse.&#60;/p&#62;
&#60;p&#62;Carl
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gbulmer on "delayMicroseconds(us)  and delay has anyone used them and are they semi-acurate?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=168#post-1145</link>
			<pubDate>Thu, 09 Sep 2010 18:14:57 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">1145@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;CarlO - very nice piece of work! As the young folks say, &#34;Respect&#34; :-)&#60;/p&#62;
&#60;p&#62;How are you measuring the pulse width so precisely (6 significant figures)?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>CarlO on "delayMicroseconds(us)  and delay has anyone used them and are they semi-acurate?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=168#post-1115</link>
			<pubDate>Wed, 08 Sep 2010 18:03:01 +0000</pubDate>
			<dc:creator>CarlO</dc:creator>
			<guid isPermaLink="false">1115@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Update,&#60;/p&#62;
&#60;p&#62;I found a small bug in the version of time.c that was released with v0.0.6 that was causing the delay function to delay for an extra millisecond.  Now I see that in the code repository the delay functions have already been re-written.  I'll try to compile my code with the new delay functions and re-run the tests.&#60;/p&#62;
&#60;p&#62;CarlO.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>CarlO on "delayMicroseconds(us)  and delay has anyone used them and are they semi-acurate?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=168#post-1113</link>
			<pubDate>Wed, 08 Sep 2010 16:04:23 +0000</pubDate>
			<dc:creator>CarlO</dc:creator>
			<guid isPermaLink="false">1113@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;So I did some testing on the accuracy of the delay and delayMicroseconds functions.  Here are the results:&#60;/p&#62;
&#60;p&#62;Using this code I measured the width of the pulse&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;void loop()
{
  digitalWrite(Pin, HIGH);   // set the LED on
  delay(100);
  digitalWrite(Pin, LOW);    // set the LED off
  delay(1);
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;I measured the following pulse width for each value of delay&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;Delay           Width
100             101.002ms
200             201.005ms
300             301.007ms&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;Then I used this code and again measured the width of the pulse&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;void loop()
{
  digitalWrite(Pin, HIGH);   // set the LED on
  delay(100);
  delay(100);
  delay(100);
  digitalWrite(Pin, LOW);    // set the LED off
  delay(1);
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;I measured a pulse width of 303.007ms&#60;/p&#62;
&#60;p&#62;So for the delay function it looks like you get a delay of 1ms greater than the value passed to the function. (within the accuracy of the crystal)  Note that the overhead for the function call etc. is very small compared to the minimum delay value.&#60;/p&#62;
&#60;p&#62;Then I used this code and again measured the pulse width&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;void loop()
{
  digitalWrite(Pin, HIGH);   // set the LED on
  delayMicroseconds(1000);
  digitalWrite(Pin, LOW);    // set the LED off
  delay(1);
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;I measured the following pulse width for each value of delay&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;Delay            Width
1000             1000.72us
2000             2000.77us
3000             3000.74us&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;And then again with this code&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;void loop()
{
  digitalWrite(Pin, HIGH);   // set the LED on
  delayMicroseconds(1000);
  delayMicroseconds(1000);
  delayMicroseconds(1000);
  digitalWrite(Pin, LOW);    // set the LED off
  delay(1);
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;And measured a pulse width of 3000.93us&#60;/p&#62;
&#60;p&#62;So for the delayMicroseconds function it looks like you get a the proper delay with an overhead of about 0.1us for the function call etc. and about 0.5us for the function call to turn the pin off.&#60;/p&#62;
&#60;p&#62;CarlO
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
