View Single Post
  #1   Spotlight this post!  
Unread 29-01-2003, 18:17
rbayer's Avatar Unsung FIRST Hero
rbayer rbayer is offline
Blood, Sweat, and Code
no team (Teamless Orphan)
 
Join Date: Mar 2002
Rookie Year: 2001
Location: Minnetonka, MN
Posts: 1,087
rbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of light
Send a message via AIM to rbayer
There is no advantage to converting Stamp loops to "real" time. It is a 1-to-1 conversion, meaning that each "real" time value corresponds to some fixed number of loops and vice-versa. For example, the following code would do exactly the same thing:

Code:
loopCnt VAR byte
loopCntHigh VAR nib
loopCnt=0
loopCntHigh=0

SERIN...

if (loopCnt + 1 + delta_t > 255) then loopCntHigh=loopCntHigh + 1 : loopCnt=loopCnt+1+delta_t-255 else loopCnt=loopCnt+1+delta_t

SELECT (loopCntHigh<<8 + loopCnt)
CASE range1Low TO range2High
  'do stuff
CASE range2Low TO range2High
  'do other stuff
CASE ELSE
  'do even more stuff
ENDSELECT

SEROUT...
This will let you count up to 4096 loops, which is approx 1min 45s worth of autonomous time. Plus, it only uses 1.5 bytes!

Questions about the above stuff? Email or PM me and I'd be more than happy to explain.
__________________
New C-based RoboEmu2 (code simulator) available at: http://www.robbayer.com/software.php