Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   26.2ms loop question (http://www.chiefdelphi.com/forums/showthread.php?t=34004)

miketwalker 05-02-2005 00:47

26.2ms loop question
 
I've had some very interesting results when I've been working on using loop counts as timers for distance calculations. I kept getting results being half of what I wanted. So, I threw in a timer and manually timed how many loops would go by in a minute... and after dividing my results I found that each timer tick took very close to twice the 26.2ms data stream (since I did it by hand I don't know if it was exactly twice or just close). I was wondering why this is.

I was thinking... are the loops really 52.4ms for calculations and such? Or does it vary based on how many calculations you have or something? I'd like to find out why this seems to be occuring, and if it is 52.4ms that will be a simple fix by modifying the number used, but because of precision purposes I want to find out if I'm right or not... or if the loops will take longer and longer with more and more calculations. I've never used timers to do these types of calculations so I've never run into this before. Any ideas?

Joe Ross 05-02-2005 01:06

Re: 26.2ms loop question
 
Quote:

Originally Posted by miketwalker
I've had some very interesting results when I've been working on using loop counts as timers for distance calculations. I kept getting results being half of what I wanted. So, I threw in a timer and manually timed how many loops would go by in a minute... and after dividing my results I found that each timer tick took very close to twice the 26.2ms data stream (since I did it by hand I don't know if it was exactly twice or just close). I was wondering why this is.

Since you talked earlier about using a lot of floats, I'd assume you are doing more then 26.2ms worth of calculations. You can check the packet number. If you only get every other packet, your program is taking to long.

Mark McLeod 05-02-2005 08:43

Re: 26.2ms loop question
 
Quote:

Originally Posted by miketwalker
... are the loops really 52.4ms for calculations and such?

Just a thought...
You aren't by any chance testing on the EDU controller are you?
EDU = 17ms slow loop (~59 loops per second) as opposed to the FRC 26ms.

Nah. I'm going the wrong way aren't I? Faster rather than the slower you are experiencing. (Too early on a Sunday morning. I shouldn't post before noon.)

miketwalker 05-02-2005 10:41

Re: 26.2ms loop question
 
Quote:

Originally Posted by Joe Ross
Since you talked earlier about using a lot of floats, I'd assume you are doing more then 26.2ms worth of calculations. You can check the packet number. If you only get every other packet, your program is taking to long.

I ended up not using a bunch of floats. I was just curious with that thread as I was planning some things out. Currently I'm working with 2 floats, and when I don't run the functions using floats my counter is still counting at about half the speed it should be.

Ryan M. 05-02-2005 11:55

Re: 26.2ms loop question
 
I'm not sure why it would be greater than 26.2ms.

Doesn't the master uP stop your code if it exceeds the 26.2 refresh limit? (and the "code error" light comes on) Or does your code call putdata() in the middle of the loop?


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

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