
Timer accuracy??? -RFH ( Request for Help)
Quote:
>We are trying to use the timers in VB to time an external event,
>however we seem to be getting a timing error of about 5sec/min.
>This is demonstrated by setting up a timer with an interval of
>1000mS and using it to update a counter. The count is 'losing'
>about 50sec in 10mins.
>What are we doing wrong??
The timer interval is not truly a interval, but rather a frequency.
In your timer event, check the timer() function and compare it to the
value of the timer() function at the start of your interval. (the
timer function returns the number of seconds since midnight.) Use the
interval property of the timer control to control the *accuracy* of
your timing loop rather than using it to establish the elapsed time
itself. (ie. setting the interval smaller causes the timer_event to
fire more frequently and thus you can check the value of the timer()
function more often.
Using this method, you are limited only by the accuracy of the system
clock which is available to VB. We used it to obtain an accuracy of
about 15ms (if I remember correctly) on a one second control loop
interval.
HTH