vb timer accuracy ??? 
Author Message
 vb timer accuracy ???

Hi,

after a few simple tests, it seems that VB timers are not accurate at all.
A one second timer counts 56 beats in one minutes on my PC...
Is it general on every PC ? By the way, my internal clock does not link.

Does anyone have a VB example using QueryPerformanceCounter to get
an accurate measure of time, with at least 10ms precision ?

thanks

david.

--
--------------------



Sun, 09 Jun 2002 03:00:00 GMT  
 vb timer accuracy ???
You can see this in your windows cd-player, when you play a cd, every 5 or 6
seconds there is a "fast" second. I don't know why that happens, but just
bind the timer to the time, so ask every second for the time and you get
nearly the correct time.
HTH, Sebastian

--
SOFTEYES - The World of Entertainment
Wir entwickeln Ihnen Ihr Wunschprogramm! Schnell und zuverl?ssig!

Fr mehr Infos besuchen Sie doch unsere Website www.softeyes.home.pages.de


Quote:
>Hi,

>after a few simple tests, it seems that VB timers are not accurate at all.
>A one second timer counts 56 beats in one minutes on my PC...
>Is it general on every PC ? By the way, my internal clock does not link.

>Does anyone have a VB example using QueryPerformanceCounter to get
>an accurate measure of time, with at least 10ms precision ?

>thanks

>david.

>--
>--------------------




Sun, 09 Jun 2002 03:00:00 GMT  
 vb timer accuracy ???
try with GetTickCount... Put these declarations in a module:
Declare Function GetTickCount Lib "kernel32" Alias_ "GetTickCount" () As
Long

In the form declarations:
dim t1, mul as integer
dim firsttime,exxit as boolean

Then in your form_load:

    Private Sub Form_Load()
    firsttime = true
    exxit = false
    mul = 0
    t1 = gettickcount
    do until exxit = true
        'To end the loop, set exxit to true
        t3 = gettickcount
        if t2 - t1 => (mul*10) then ' See below
            mul = mul + 1
            'Place your actions here
        end if
        doevents
    loop
    'To end the loop, set exxit to true
    End Sub

This should make your commands every 10 ms... To change the interval, just
change the factor that multiplies mul.  Don't hesitate to write back to have
more explanations!

Hope this helps,
Jean-Daniel Deschnes



Quote:
> Hi,

> after a few simple tests, it seems that VB timers are not accurate at all.
> A one second timer counts 56 beats in one minutes on my PC...
> Is it general on every PC ? By the way, my internal clock does not link.

> Does anyone have a VB example using QueryPerformanceCounter to get
> an accurate measure of time, with at least 10ms precision ?

> thanks

> david.

> --
> --------------------




Sun, 09 Jun 2002 03:00:00 GMT  
 vb timer accuracy ???


Quote:
>Hi,

>after a few simple tests, it seems that VB timers are not accurate at all.
>A one second timer counts 56 beats in one minutes on my PC...
>Is it general on every PC ? By the way, my internal clock does not link.

Hello,

the timer has 18.2 ticks per second, 19 ticks is a little bit longer
than 1 second.

The multimediatimer of winmm.dll is better, but you need a callback
function. If the timer is not stoped with timeKillEvent before the end
of the program, it may crash.

Declare Function timeKillEvent Lib "winmm.dll" Alias "timeKillEvent"
(ByVal uID As Long) As Long

Declare Function timeSetEvent Lib "winmm.dll" Alias "timeSetEvent"
(ByVal uDelay As Long, ByVal uResolution As Long, ByVal lpFunction As
Long, ByVal dwUser As Long, ByVal uFlags As Long) As Long

Public Const TIME_ONESHOT = 0  
Public Const TIME_PERIODIC = 1

Bye  

--
Uwe Hercksen
Elektronikwerkstatt
Universit?t Erlangen-Nrnberg
Cauerstr. 5
D91058 Erlangen



Mon, 10 Jun 2002 03:00:00 GMT  
 vb timer accuracy ???
One shouldn't use the timer control to measure time at all.  Instead use the
real-time clock which is more accurate (atleast to the milli-second) since
it runs indepent of CPU.  Another other timer, tick, clock function
eventually needs to be processed in order to increment the time which makes
them unreliable when during that instant the CPU is happen to be busy
handling a higher priority interrupt.

TimesUp = now + <delay>
do
    doevents
loop until now >= TimesUp


Quote:
> Hi,

> after a few simple tests, it seems that VB timers are not accurate at all.
> A one second timer counts 56 beats in one minutes on my PC...
> Is it general on every PC ? By the way, my internal clock does not link.

> Does anyone have a VB example using QueryPerformanceCounter to get
> an accurate measure of time, with at least 10ms precision ?

> thanks

> david.

> --
> --------------------




Mon, 10 Jun 2002 03:00:00 GMT  
 vb timer accuracy ???
depends on system speed and system resources

you could use GetTickCount or GetSystemTime (GetTickCount would be easier to
use if your making a stopwatch type counter)

trippz


Quote:
> Hi,

> after a few simple tests, it seems that VB timers are not accurate at all.
> A one second timer counts 56 beats in one minutes on my PC...
> Is it general on every PC ? By the way, my internal clock does not link.

> Does anyone have a VB example using QueryPerformanceCounter to get
> an accurate measure of time, with at least 10ms precision ?

> thanks

> david.

> --
> --------------------




Fri, 14 Jun 2002 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Accuracy of timers in VB?

2. Timer, accuracy in millisecs!

3. Timer Function Accuracy

4. Timer Accuracy - Help !

5. Accuracy of Timers in VB5

6. Timer with high accuracy

7. Timer Accuracy

8. Wanted: VB3 Timer with millisecond accuracy.

9. Timer accuracy??? -RFH ( Request for Help)

10. timer accuracy of mmsystem.dll

11. Timer accuracy

12. Timer accuracy

 

 
Powered by phpBB® Forum Software