Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > General > Timer


Reply
 
Thread Tools Display Modes
  #1  
Old 08-26-2002, 04:05 PM
elettro
Guest
 
Posts: n/a
Default Timer


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.
Reply With Quote
  #2  
Old 08-26-2002, 04:11 PM
ChiefRedBull's Avatar
ChiefRedBull ChiefRedBull is offline
ISearchGoogle

Retired Moderator
* Expert *
 
Join Date: May 2001
Location: england
Posts: 6,321
Default

__________________
Chuck Norris ordered a Big Mac at Burger King, and got one.
Reply With Quote
  #3  
Old 08-26-2002, 04:21 PM
MarkVB6's Avatar
MarkVB6 MarkVB6 is offline
Centurion
 
Join Date: Aug 2002
Location: Ontario, Canada
Posts: 170
Default

I think the lowest interval of an object timer (the general control) is about 55 milliseconds. What was the interval set at?
__________________
A silly idea is current that good people do not know what temptation means. This is an obvious lie. Only those who try to resist temptation know how strong it is... A man who gives in to temptation after five minutes simply does not know what it would have been like an hour later. That is why bad people, in one sense, know very little about badness. They have lived a sheltered life by always giving in. -C.S. Lewis
Reply With Quote
  #4  
Old 08-26-2002, 06:04 PM
ChiefRedBull's Avatar
ChiefRedBull ChiefRedBull is offline
ISearchGoogle

Retired Moderator
* Expert *
 
Join Date: May 2001
Location: england
Posts: 6,321
Default

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"
__________________
Chuck Norris ordered a Big Mac at Burger King, and got one.
Reply With Quote
  #5  
Old 08-26-2002, 06:14 PM
Volte's Avatar
Volte Volte is offline
Ultimate Contributor

Retired Leader
* Guru *
 
Join Date: Aug 2001
Posts: 5,343
Default

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.
Reply With Quote
  #6  
Old 08-27-2002, 06:16 AM
elettro
Guest
 
Posts: n/a
Default

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 ?
Reply With Quote
  #7  
Old 08-27-2002, 09:09 AM
Volte's Avatar
Volte Volte is offline
Ultimate Contributor

Retired Leader
* Guru *
 
Join Date: Aug 2001
Posts: 5,343
Default

Use a Do While loop, in conjunction with one of the APIs above.

Code:
Do tempVar = timeGetTime '... code ...' Do Until timeGetTime > tempVar 'do nothing Loop Loop Until bEnd
Something like that.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->