Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 01-04-2001, 06:42 AM
Jurij Dreo Jurij Dreo is offline
Junior Member
 
Join Date: Jan 2001
Posts: 12
Default Repeating functions

Hi,

I'm developing a program that has to do a certain task that puzzles me. I need to repeat a function in regular time intervals in the range of down to say every 0,1 milisecond. In other words - the program must call a specific function(which is quite simple and fast, so this doesn't cause a problem) every 0,1 miliseconds or so (and even faster if possible). For obvious reasons I cannot use the timer component... I tried using a simple double(nested) loop (one repeats and the other is just there to slow the first loop down a bit) but when I measured the time it took to perform a single step in this loop, I found that these times vary of up to 0,5%. That might not seem much, but it poses a very big problem (for reasons I won't get into here).
Does anyone know of a way to call a function in such short intervals so that they are virtually the same (<0,2%). In DOS this could be done with program interrupts, but as far as I know they cannot be done under windows. Although I have heard of something called a
Reply With Quote
  #2  
Old 01-04-2001, 07:43 AM
hbah245 hbah245 is offline
Junior Member
 
Join Date: Jan 2001
Posts: 13
Default RE: Repeating functions

You might try using the Application.OnIdle event. You can find in the Help under "TApplication|Events". Set up a global variable and save the time in it every time you process your function. Every time you progress through the OnIdle event check the time and if 1 milisecond has passed, process the function again and update the time function. This will not be exact timing. The OnIdle event is not called at regular intervals, only when the program is idle. Hope this helps.
Reply With Quote
  #3  
Old 01-04-2001, 08:40 AM
Claude Claude is offline
Senior Member
 
Join Date: Jan 2001
Posts: 178
Default RE: RE: Repeating functions

I do not think that Windows is able to achieve such level of granularity/repeateability. Although some specialized pc cards that will accurately mesure the time and may generate regular events I did not go that way when I faced a problem similar to yours.

I bought an inexpensive single board computer (www.rabbitsemiconductor.com) that has TCP/IP capability. The SBC performs the real-time calculations/monitoring and communicates with a PC running Windows (using the TNMUdp component).
Reply With Quote
  #4  
Old 01-04-2001, 08:46 AM
hbah245 hbah245 is offline
Junior Member
 
Join Date: Jan 2001
Posts: 13
Default RE: RE: RE: Repeating functions

The OnIdle event is not hardware dependent. It is called when the program has idle time. The OnIdle event is in TApplication and is a warpper around a windows API.
Reply With Quote
Reply

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 On
HTML code is On

Forum Jump


All times are GMT. The time now is 08:04 PM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2018, vBulletin Solutions, Inc.