Timer

elettro
08-26-2002, 04:05 PM
I must interrogate the serial port once per second so I used
the TIMER CONTROL. (1000 msec.)

This control is not accurate, I don't know why.
How do I upgrade the time interval accuracy ?

Thank you.

ChiefRedBull
08-26-2002, 04:11 PM
Use the QueryPerformanceCounter and QueryPerformanceFrequency APIs.

MarkVB6
08-26-2002, 04:21 PM
I think the lowest interval of an object timer (the general control) is about 55 milliseconds. What was the interval set at?

ChiefRedBull
08-26-2002, 06:04 PM
The lowest interval is 1ms, but that is only accurate to about 55ms, because of the way the Timer control works internally. The APIs i mentioned above are (AFAIK) as good as it gets. There have been many threads about this though, search for "performance" or "timer"

Volte
08-26-2002, 06:14 PM
If you are simply looking for a timer that has an accurate 1ms
resolution (QueryPerformance APIs are much more accurate
than that, but more complicated to use), then I believe timeGetTime
would be sufficient for your needs.

If you are making some sort of absolute graphing program or a
stopwatch or something, you would need QueryPerformaceCounter,
but for general timer stuff, it's not needed.

elettro
08-27-2002, 06:16 AM
I have this code to do a thermometric curve length 2 hrs

Private Sub Timer1_Timer ()

MsComm1.Enabble = True
......
code
.....
End Sub

There is a time error of 20%. I suspect that the time interval is not real, but is the sum of the interval and an unknown time necessary to elaborate the code. I don't want this.
I ask you: How do i connect the code direct to the system watch ?

Volte
08-27-2002, 09:09 AM
Use a Do While loop, in conjunction with one of the APIs above.

Do
tempVar = timeGetTime
'... code ...'
Do Until timeGetTime > tempVar
'do nothing
Loop
Loop Until bEndSomething like that.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum