Society of Robots - Robot Forum

Electronics => Electronics => Topic started by: Aurbo on November 20, 2008, 07:39:14 PM

Title: Time to try a new project
Post by: Aurbo on November 20, 2008, 07:39:14 PM
Greetings,

I'm looking to build a new project that will allow me to control several of my old parallel port devices such as pic programmers and stepper motor drivers from a USB port instead.

I know there are several USB-LPT adapters out there, but I would like to try to build one of my own.

Any suggestions?
Title: Re: Time to try a new project
Post by: ArcMan on November 20, 2008, 09:56:17 PM
Being a PIC guy, I would start with a USB PIC dev board from Sparkfun.
Title: Re: Time to try a new project
Post by: izua on November 20, 2008, 10:34:04 PM
There are no usb/parallel port adapters (or there aren't any I am aware of, and I looked a lot for them).
The reason why such adapters do not exist, is because USB is slow and packetized, while the parrallel port is fast and resides on the MMIO (memory mapped IO). What this basically means is: when you send in software a command to change a bit on the parallel port, it takes exactly one clock cycle of your CPU to do it. when you send the same command over usb, it takes a whole lot more. And sending individual bits over usb is highly inefficient.

Now, to offer a solution, FTDI makes some chips that have parallel I/O. But they are not LPT compatible, they are simply a parallel port that hangs over usb, and can't be controlled in the same fashion as an old style LPT. No other lpt based programs will work.

However, with enough patience, you can hack that chip up to work as a LPT emulator. Write software you put the chip in parallel mode (and depending on the register 2 setting at LPT's address - set by your software, you decide if the port should act as an enhanced parallel port or a standard one - which means choosing direction of data pins). Then a second thread should keep reading the output pins (0x278, 0x378 - register 0 of LPT). When it detects a change, it will output an usb packet to the FTDI chip. Also, the reverse needs to be hacked, the 5 input pins should be set by your software (0x279, 0x379) depending on what data has been received from the chip.

When this is finished, your program will read the LPT output and configure the chip's output as such, and read the chip's input, and configure the LPT input as such. I've done such a program ages ago, for FT232RL, but the speeds suck. I haven't been able to go above 200Hz, on a dual core 3GHz CPU. But that's because USB is packetized and thus, a bottleneck.

The only type of USB-LPT adapters, are the ones for printers, so you should go with that, if your old devices are mainly printers. They have an USB connector at one end and a centronics (36 pin) at the other end. When you install their drivers, it installs as a spooler driver, and not as a LPT port. It might be hackable, but I haven't try. This means you can only print with them, and not toy with the I/O.


However, the best way to go is upgrade. Just use an usb/serial converter and dump your old devices. Their software will become legacy soon, too.
Title: Re: Time to try a new project
Post by: Aurbo on November 26, 2008, 08:34:24 AM
Turns out this project is well beyond me at this point.  Thanks for the assisance.


On a different note, I'll step back a few levels and try to interface an ATTiny2313 with an SD memory card and use the SD card as an expanded Eeprom to run larger files with an LED Matrix.

Anyone know if this has been done already?
Title: Re: Time to try a new project
Post by: Soeren on November 27, 2008, 04:20:22 PM
Hi,

There are no usb/parallel port adapters (or there aren't any I am aware of, and I looked a lot for them).
[...]
The only type of USB-LPT adapters, are the ones for printers
Err?
Title: Re: Time to try a new project
Post by: izua on November 27, 2008, 04:28:31 PM
a parallel port is a I/O port.
the LPT is a generalised case of the parallel port, controlled by the spooler/printer driver
Title: Re: Time to try a new project
Post by: Soeren on November 27, 2008, 07:49:16 PM
If that's what you've got, find (or make) another driver.