> This is about using an IBM PC parallel port to drive a bipolar stepper > motor. So I hope it not too far off topic here. > > I would like to use C to to send the appropriate signal to the data port > bits on the parallel port. P.H. Anderson gives a very nice and clear > explanation of how to do it . > > The problem I have is in defining the delay between two > subsequent commands > to write the bit to the port. This time interval will define how fast the > motor will turn. > > The command to wrie data to the port is > outportb(port address, data). > > The interval between writing data is controlled by the > delay(time) command. > This command seems to read time in milliseconds. > > If this correct, the shortest delay I can specify is 1 millisecond between > steps. This would mean that on stepper motor with 200 steps per > revolution I > can, at best get 5 rpm. > > This does not make sense to me. Where am I going wrong ? Nowhere, that is about the best you will get using the delay routine. Solution? Don't use the delay routine! As a small good side to this is I have found that the delay routine isn't very good, multitasking environments seem to really screw it up. How important is the accuracy of how fast you need to go? If it isn't too critical you can use a simple FOR loop as a delay. Stick an inp to nowhere in the loop (since inp's can't be cached they almost always take an equal amount of time to execute) and run through the loop a bunch of times. Unfortunately this is highly machine dependant. If you do indeed need good accuracy or machine independence you'll have to do it another way. Interrupts would probably be the solution using the timer in every PC. Unfortunately this is MUCH more complicated to accomplish well. TTYL -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads