7

Preliminary story

There is this program which uses the Parallel Port to synchronize with other hardware. It will set the Parallel Port output to a specified (byte) value. This works without problems when using the built-in Parallel Port of a PC. The target platforms are Windows XP to 7, all worked fine so far. Source code is in Delphi, accessible and can be modified.

How it works

In Delphi I can use the io.dll to set the value of the Parallel Port, but there are also other solutions available, like inpout32.dll or port.dll. I call something like PortOut, specify a port number and the byte value and the port is set.

What I now want to do - and where I need help

Now the change: this needs to work on a machine which has no Parallel Port built-in (not even on the mainboard). There are several options available:

  • use a USB to Parallel Port adapter to add a LPT port to the PC
  • use a PCI card which adds a LPT port to the PC
  • use a PCI Express card which adds a LPT port to the PC

I am currently heading for and concentrating on the easiest and cheapest possibility: a USB to Parallel Port adapter.

Main question

There seem to be differences between Parallel Port adapters which are made to connect just a printer and other adapters which seem to be more powerful. Is there really a difference? Or can I just use one of these 5$ printer-adapters, plug in my own hardware and access the port from Delphi code? Or do I need a special adapter? Has anyone experience with this? There is a related question here, but the different adapter types (if existent) are not mentioned there. This page suggests that there are indeed differences:

Contrary to all other USB parallel ports which can connect to printers only, this makes connection to most hardware.

I hope there exists a solution via USB because for this you don't have to open the PC, which means the adapter can be added on demand.

Sub-question

Do you have experience with PCI (Express) solution? I have to use one if the USB approach is not successful.

Community
  • 1
  • 1
Heinrich Ulbricht
  • 10,064
  • 4
  • 54
  • 85

1 Answers1

9

Since I've been wrestling with this very thing recently here's what I've discovered; If you mean by using IO port addressing (indicated by your reference to inpout32.dll), no. Unless your USB-parallel port driver supports full port emulation or virtualization, which most do not, this is generally not possible. If you need to directly access the port to do normal "bit-twiddling", you should get a separate Parallel port PCI-card. Most of them present themselves as normal IO at the standard address(es). I am presuming you're not planning on using the parallel port to actually communicate with a printer, right?

What is interesting is that USB-Serial adapters are much easier to use since they appear as simple virtual devices where you can merely "open" them using a simple stream; TFileStream.Create("COM1", fmOpenRead) or Windows.CreateFile("COM2", ...);

Here is some devices that purport to do full emulation of a parallel port through USB:

https://www-user.tu-chemnitz.de/~ygu/bastelecke/PC/USB2LPT/index.en.htm

Vishnu
  • 11,614
  • 6
  • 51
  • 90
Allen Bauer
  • 16,657
  • 2
  • 56
  • 74
  • 1
    Thank you very much for sharing your insights! We now also did some tests here and our findings correspond with yours. There are some hacky ways to get a grip on the USB device (also via CreateFile), but setting single bits via WriteFile fails, (probably) because the adapter then sends a response and waits for answer. And no, we have no printer attached. We just want to set single bits for custom devices. But no way :( I also came along the page of TU Chemnitz, but this seemed to be overkill. It just has to work quickly and without the overhead of custom-made devices. – Heinrich Ulbricht Nov 23 '10 at 09:06