<?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: Measuring remaining processor &#34;time&#34;</title>
		<link>http://forums.leaflabs.com/topic.php?id=10286</link>
		<description>A place to share, learn, and grow...</description>
		<language>en-US</language>
		<pubDate>Fri, 22 Jan 2016 00:16:16 +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=10286" rel="self" type="application/rss+xml" />

		<item>
			<title>gbulmer on "Measuring remaining processor &#34;time&#34;"</title>
			<link>http://forums.leaflabs.com/topic.php?id=10286#post-22689</link>
			<pubDate>Wed, 27 Feb 2013 22:09:42 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">22689@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;pyrohaz - There is no meaningful concept of &#34;remaining processor time&#34; on Maple. There is really only 'how fast my program executes one pass&#34;.&#60;/p&#62;
&#60;p&#62;The Maple is only doing what you program it to do, plus it handles two internal interrupts. &#60;/p&#62;
&#60;p&#62;It deals with a timer interrupt every millisecond (for a few us) which is used to derive millis() and micros(). You could turn this off if you don't use them but I'd suggest they may be useful to you. The other interrupt is for USB, which you could disable if you don't need it. &#60;/p&#62;
&#60;p&#62;So there is &#60;strong&#62;nothing&#60;/strong&#62; else for Maple to do. It runs your program as fast as it can.&#60;/p&#62;
&#60;p&#62;Of course, if you use delay(), the Maple is just 'twiddling its thumbs', and you are wasting processor time.&#60;/p&#62;
&#60;p&#62;If you have a time sensitive program within a loop(), just measure how long it takes for each time through the loop() by toggling a pin and measure it on your oscilloscope. If it is reasonably consistent you'll get an even duty cycle square wave, and the duration of one cycle of that square wave is 2x the duration of one pass through your program.&#60;/p&#62;
&#60;p&#62;I'd start with togglePin() or toggleLED() at the start of loop().&#60;br /&#62;
You could time a loop() containing nothing else, just toggleLED(), and measure that so that you can see the time needed to execute the loop() and that single call, and hence be able to correct for it.&#60;/p&#62;
&#60;p&#62;In the very unlikely event that you need the timing to be very precise and accurate, and need an answer better than within 1us, then once you know approximately the run-time, you could look in forum threads to see how to set a pin quickly using e.g. bit-band addressing. But do togglePin or toggleLED first.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>pyrohaz on "Measuring remaining processor &#34;time&#34;"</title>
			<link>http://forums.leaflabs.com/topic.php?id=10286#post-22687</link>
			<pubDate>Wed, 27 Feb 2013 20:03:49 +0000</pubDate>
			<dc:creator>pyrohaz</dc:creator>
			<guid isPermaLink="false">22687@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Ah well I have a time sensitive program within the loop() section so slowing it down would just slowdown the time &#34;response&#34; if you get me, I mean in the sense of like how much processing power say have I got left, is there time to add more things to my program? I can imagine that keep adding until it fails is an option but it'd be much easier to know of a way that I could know how much &#34;processing power&#34; I have left until it will no longer function properly.&#60;/p&#62;
&#60;p&#62;Hope thats easier to understand!&#60;br /&#62;
Cheers,
&#60;/p&#62;</description>
		</item>
		<item>
			<title>bnewbold on "Measuring remaining processor &#34;time&#34;"</title>
			<link>http://forums.leaflabs.com/topic.php?id=10286#post-22685</link>
			<pubDate>Wed, 27 Feb 2013 16:50:28 +0000</pubDate>
			<dc:creator>bnewbold</dc:creator>
			<guid isPermaLink="false">22685@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Not really sure what you mean... if you are using loop() there will be no &#34;remaining time&#34; as the loop will restart as soon as the previous iteration is complete. You could try adding a pin-high period with a sleep inside, and keep increasing the sleep time until your program stops working.&#60;/p&#62;
&#60;p&#62;If you are using interrupt handlers, you could pull the external pin high while handling the interrupt to get a feel for the proportion of time spent in that interrupt handler. You'll need to add a bit of overhead though, as some context switch time is wasted entering and exiting the interrupt handler.&#60;/p&#62;
&#60;p&#62;As a crude alternative to scoping an output, you could blink the LED. If the program loop period is fast enough that the pulses visually blur together, you could decipher (with some calibration) the amount of &#34;free time&#34; from the intensity of the light. Sort of like listening for the fan or hard disk to spin up on an older desktop computer.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>pyrohaz on "Measuring remaining processor &#34;time&#34;"</title>
			<link>http://forums.leaflabs.com/topic.php?id=10286#post-22684</link>
			<pubDate>Wed, 27 Feb 2013 12:19:07 +0000</pubDate>
			<dc:creator>pyrohaz</dc:creator>
			<guid isPermaLink="false">22684@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Hey guys,&#60;br /&#62;
Firstly I just want to say thanks for the instant help that the users on this forum provide! Its actually brilliant.&#60;/p&#62;
&#60;p&#62;What i'm wondering today is how I can easily measure the remaining processor time on the maple? I have a 40MHz oscilloscope so if its literally as simple as pulsing one of the outputs on and off to provide a duty cycle proportional to remaining time, that should be ok!&#60;/p&#62;
&#60;p&#62;Any help is appreciated :)&#60;br /&#62;
Thanks,
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
