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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Timing code execution

Status
Not open for further replies.

kencat742

Programmer
Jun 30, 2005
23
US
I am writing a program which needs to send commands to the RS-232 port to turn valves on and off. I have that part done, but now i need to be able to time it so that it will go automatically. This has to be exact to the millisecond. From what i've read I'm assuming that I need to use QueryPerformanceCounter/QueryPerformanceFrequency but I am having difficulties finding the syntax for these commands. Any help would be much appreciated. Thanks :)
 
kencat742,

For milliseconds Timer control is sufficient in most cases.

Timer1.Interval = 1 means one millisecond

vladk
 
I thought that timer was only as accurate as the system clock which is 10ms in XP
 
Correct, kencat742 (well, depends on the version of XP, but correct enough).

Thread222-508991 has a succint example of the high performance counters (although it is worth pointing out that the multimedia timers - timeGetTime etc. - are accurate to 1ms, as per the requirements of the MIDI standard).

For those that want to know a little bit more about (current*) timing capabilities in Windows, try thread222-495997



* Microsoft and Intel have agreed a much higher precision timing standard for future Windows versions - but I can't find the relevant URL references at the moment.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top