|
-
February 10th, 2000, 12:13 AM
#1
Controlling execution speed on variuos PCs
I have just written a software to control a machine with stepper motors. Now to move stepper motor some slowing down delay must be there between successive pulses, as:
For i=1 To 5000: Next
Now, when the same program is run on computers of differing capacities, it just looses control of the motor speed. I know how many times the For...Next must be executed to give a particular speed. However, it is system specific.
Can anybody tell me how can I make the program system independent, general-purpose, so that I can control motor speeds from any computer, whether it is a 386, 486 ot pentium.
I tried Timer, etc, but these do not work as i have to send hundreds of pulses per second.
Thankyou.
-
February 10th, 2000, 01:07 AM
#2
Re: Controlling execution speed on variuos PCs
Try using the sleep API, wich will force the PC to wait a number of milliseconds.
Should give the same result on 386 or 500 MHz
Declare Sub Sleep Lib "kernell32.dll" (byval dwMilliseconds as Long)
'just use it like this
sleep(numberOfMillisecondsToSleep)
Note: the use of a for next loop isn't the good way to implement a delay in a process. This will only cause your program the ask a lot of CPU-power. The sleep command does the opposit. It doesn't use any (or very little) CPU-power, and the interval will be the same on no matter what computer.
Tom Cannaerts
[email protected]
The best way to escape a problem, is to solve it.
-
February 10th, 2000, 01:56 AM
#3
Re: Controlling execution speed on variuos PCs
Thank you.
Now I can have a control down to milliseconds, but can I go even finer...!
Any horrible or tricky technique.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|