I want to use a parallel port to control some stepper motors (many of them). So far I've got it connected to a little test board with LEDs and I've written a C program in Linux to set the pins using
outl calls. Because I want to use all 12 output pins I'm setting both the data byte and the control byte. (Actually, more than 12 pins would be nice, but 12 will have to do.)
This all works and the LEDs light up as expected, but it's a bit too slow for my needs. A loop with 1,000,000 iterations that call
outb twice (data and control byte) takes ~3.9 seconds. If I replace that with a single
outl call that takes ~3.6 seconds, so it looks like each
outl takes about 3.6 us. From what I read it should work in about 1 us or even less. The question is: how do I make it faster?
The machine is an AMD Sempron with an on-board parallel port. There are 3 settings for the port in BIOS: "Bi-directional", "ECP" and "EPP". ECP gives the numbers above. Bi-directional is slightly slower and EPP is much slower (running exactly the same code). Is there something special I need to do in code to take advantage of the faster modes? Is it a limitation of the hardware so maybe a dedicated PCI IO card would be faster? Do I need to use DMA (which I think requires a kernel-mode driver)?
Alternatively, is there some add-on device out there like a parallel port, but with more pins and/or lower latency for setting all the pins? (I don't need to change one pin at a time.)
Edit (more details):
I want to control 1,000 stepper motors in total. The original design was to have 5 Arduinos controlling 200 motors each using logic gates to address each motor in sequence. A 6th Arduino would be the "master" controller, sending data to the other 5. However, an Arduino doesn't have enough memory to store all the data I want to send, so that's where a PC came in. Once a PC was involved it seemed much simpler if I could cut out the Arduinos entirely and use 2 (maybe 4) parallel ports to control the motors directly, probably under RTLinux (though the test above was done on regular Linux). I don't think I'd need a 1 us timer resolution as such. I was thinking of a timer firing every 1500-2000 uS and each time sending signals to all 1000 motors, one by one (500 or 250 per parallel port). The parallel port speed seems to be the limitation here.
I understand that there are dedicated stepper motor controllers, but buying 1000 of them gets expensive. Is there something that can control many of them? Ideally I'd like to keep as much of the work as possible on the PC, because it's just so much easier to program and debug.