Click to See Complete Forum and Search --> : Controlling execution speed on variuos PCs


Atique Ahmad
February 9th, 2000, 11:13 PM
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.

Cakkie
February 10th, 2000, 12:07 AM
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
slisse@planetinternet.be

The best way to escape a problem, is to solve it.

Atique Ahmad
February 10th, 2000, 12:56 AM
Thank you.
Now I can have a control down to milliseconds, but can I go even finer...!
Any horrible or tricky technique.