Go to Post The greatest lesson we can teach our kids is how to win. - AdamHeard [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #11   Spotlight this post!  
Unread 09-02-2004, 11:33
Chris Hibner's Avatar Unsung FIRST Hero
Chris Hibner Chris Hibner is offline
Eschewing Obfuscation Since 1990
AKA: Lars Kamen's Roadie
FRC #0051 (Wings of Fire)
Team Role: Engineer
 
Join Date: May 2001
Rookie Year: 1997
Location: Canton, MI
Posts: 1,488
Chris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond repute
Re: How to measure execution time? And code size?

Quote:
Originally Posted by Chris Hibner
To measure the time, you should toggle a digital I/O pin every cycle. Then, hook an oscilliscope up to that pin. Using the scope, you can measure your timing very accurately.

Some example code (place this at the very beginning of your code):

static char TimingFlag;

if (TimingFlag)
TimingFlag = 0;
else
TimingFlag = 1;

Then immediately set the digital I/O pin equal to TimingFlag.

This code will produce a square wave on the scope. The time that the wave is high (or low) is your cycle time. I hope this helps.

-Chris
Oh yeah, I forgot one thing.

My first post only works if you're running the loop time as fast as possible. It doesn't work if you're setting your loop time with an interrupt. To measure this way do the following:

1) At the VERY BEGINNING of your loop, set a digital I/O pin high.
2) At the VERY END of your loop, set the same digital I/O pin low.
3) Measure the pin voltage on a scope.

The amount of the the pin stays high is the amount of time that your code takes to run.

(By the way, this is how code time is usually measured in industry.)
__________________
-
An ounce of perception is worth a pound of obscure.
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Interrupt timer, executing code asap? SeanCassidy Programming 10 07-03-2004 01:47
Actual execution time measurement Dan Technical Discussion 5 24-03-2003 11:36
Autonomous Code From Experience EbonySeraphim Programming 7 14-03-2003 21:56
Ok one problem cantwell03 Programming 3 13-02-2003 07:28
Solution to Timing Loops Steven Carmain Programming 39 10-02-2003 13:33


All times are GMT -5. The time now is 00:03.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi