View Full Version : Time precision better than seconds??
For a while out team has been looking to use a timer. The timer works well, except we need to have a more precise timer than the one that the documentation says is available. Is there a way to make a timer that is more precise (milliseconds/microseconds)?
Eric Finn
31-01-2009, 13:20
If I recall correctly, pretty much everything having to do with time is doubles, so that you have millisecond resolution for the time, but it is measured in seconds. That is, 200 ms would be 0.2 seconds.
Shinigami2057
31-01-2009, 13:24
How accurate is the timing using floating-point precision? IEEE floating point representation isn't always 100% accurate; many times floats won't represent your value exactly as entered (e.g., 0.3 might become 0.2999...) so your times may end up slightly misrepresented internally.
Any reason as to why floating-point numbers were used instead of milli or microseconds?
Uberbots
31-01-2009, 13:28
The real-time timer has a precision down to microseconds i believe, but you wont have any luck searching for anything more fine than that (eg processor ticks)
gvarndell
31-01-2009, 20:49
For a while out team has been looking to use a timer. The timer works well, except we need to have a more precise timer than the one that the documentation says is available. Is there a way to make a timer that is more precise (milliseconds/microseconds)?
You can call vxTimeBaseGet(), which is a function provided in vxLib.
IMPORT void vxTimeBaseGet (UINT32 * pTbu, UINT32 * pTbl);
This function reads the 64-bit PPC timebase, storing the upper 32 bits at pTbu and the lower 32 bits at pTbl.
The least significant bit should be worth 1/132,000,000 of a second.
It would pay to do a little experimentation with it though, to see if that number is right -- it may actually be 1/133,000,000 seconds.
In any event, it's a very high resolution 64-bit counter.
Precise enough for ya?
vBulletin® v3.6.4, Copyright ©2000-2017, Jelsoft Enterprises Ltd.