Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

QB Timer precision 2

Status
Not open for further replies.

Stab

Programmer
Feb 1, 2002
3
ES
Hello,
Qb timer precision seems to be about 50ms
Is it possible to have more precision ?
I need 1 ms.

Thanks.
 
Try this.

1st loop checks machine's speed, to get number of loops in 1 sec. 2nd loop runs DO routine for 1/1000 of that time.

Dummy lines are to keep the contents of the loop equal.

'test machine speed
n&=0: b&=0: t!= TIMER
DO
IF TIMER>=t! + 1 THEN EXIT DO
n& = n& + 1 'count
IF n& = b& THEN EXIT DO 'dummy
LOOP
ms& = n&/1000

CALL millisec(ms&)

SUB millisec(ms&) 'loop for 1 millsec
n& = 0 : t! = TIMER
DO
IF TIMER >= t! + 100 THEN EXIT DO 'dummy
n& = n& + 1
IF n& = ms& THEN EXIT DO
LOOP
END SUB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top