Skip to content


PC Parallel Port Interfacing

PPortInterfaceAdaptorAndLCDUsing the parallel port is often easier to work with then a microcontroller. I find that testing code on the PC can be much easier then going straight to the firmware as the developer tools for the PC platform are better. This is especially true when working with a new device such as a graphic LCD. Once you get your code working through the PC printer port, then you can easily port the code and what you have learned into the firmware.

I have successfully used the parallel port in a few projects in the past and have recently built up some code and hardware for easy interfacing. The rest of this article provides software and hardware details that you may find useful.

A lot of information about the parallel port is available online. Rather then recreate a basic tutorial I offer a set of links you can review. All of these links include information about the various port modes, pin outs, sample code, schematics and operating system concerns. Fell free to post any other parallel port project links into a comment for this article.

As you will soon find out Windows does not let you directly access the parallel port. This limitation started with Windows NT for security reasons. Apparently accessing the I/O of a PC directly can cause crashes, who would have guessed. The solution is to use the Inpout32.dll for WIN NT/2000/XP from Logix4u.net. Get the Inpout32.dll which is linked at the bottom of the page. With this DLL you can access the PC I/O system directly.

PPortInterfaceAdaptorBottomFor prototyping work I made a parallel port to breadboard adaptor. Take a DB25 extension cable and cut off the female end. Strip the insulation and ohm out each of the connections. I labeled each connection as I went along. You can see the labeled wires under the adaptor in the picture. The wire is typically small gauge (26 Aug) so you may want to tin each wire with a soldering iron before you start.

A header socket provides connection points that work well with breadboard jumper wires. Make labels for each set of signals, D0-7, C0-3, and S3-7 to mark the connection points. Solder the connector to some perf-board and attach the labeled connections to the printer port. If you look close at the top side picture you can see that I lopped the wire through adjacent holes in the perf-board to serve as a strain relieve. Each of these holes had to be drilled out as the wire insulation would not fit thought the normal holes.

PPortInterfaceAdaptorTopYou can see in the pictures that the breadboard interface is connected to a project with a graphic LCD. Some printer ports have very weak pull-ups. The port can sink significant current so if you want fast rise times use pull-up resistors. I used 4.7K resistors and will likely build these into the adapter eventually.

I created two C# classes to work with Inpout32.dll. The first one, InpOut32.cs, provides an adapter for the dll and has only two functions, Input and Output. The second module, HardwareIOPort.cs, works with the first to wrap up an I/O port. The combination makes using the parallel port easy and clean.

Enjoy and let me know of any improvements.

Source Code
Required Inpout32.dll

Posted in Discovering, Hacks, Projects, Workshop Tools.


19 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

  1. gopal says

    so good!!

  2. paras says

    thanks

  3. John Lester Marquez says

    what if i have more than 5 inputs

  4. dfowler says

    You can use the 8 data lines for input and/or output.

    I have used the 8 data lines and the fixed outputs to implement a bus system. it is fairly easy to get up to 256 I/O ports using this method. Basicaly you strobe out an address on the data port that is latched then follow that with either a read or write. The address is decoded to drive the I/O select. The fixed output signals provide the bus control strobes.

  5. tim mulligan says

    sweet..where can i find a dll to access parrellel with visual basic?

  6. Vlad T. says

    Wow, this is pretty usefull. Although, I still find using the parallel port a bit more messy than using a microcontroller.

  7. jerome a. says

    I like this project, pretty cool.

  8. rol3ert says

    Cool, this should come in handy some time

  9. clifton Howard says

    For this project it is fine how you have it set up but people should be careful if driving things with inductive loads like motors using the parallel port, you should use a buffer or protection diodes or you could end up blowing out your parallel port and possibly whole motherboard.

  10. clifton Howard says

    On another note if you use a decoder/demux you can get more than 8 outputs. It just makes it harder to keep track of what is going on but you can get 2^n outputs which is nice

  11. Matt says

    This is so cool to learn how to reference stuff using a PC.

  12. xSmurf says

    I really like this project, not that it’s anything fancy, but the way you mounted the board is very clean and neat.

  13. dfowler says

    Tim,

    The DLL you need (inpout32.dll) it linked in the post and the source code is in C# and should be easy to convert to VB.

  14. dfowler says

    Vlad,

    The PC interfacing has the advantage of being very easy to do some basic experiments. It is very limited in terms of speed compared to a uC but is advanced in other ways. For example if you wanted to make an analog meter that showed the DOW. You would need to write some fairly complex code for the uC and support an Ethernet connection etc… With the PC you could use C# and web services to get the DOW value and write out a value to the parallel port to drive the meter. On the other hand, if you wanted to do a bench O-Scope, you would be much better off with a uC.

  15. dfowler says

    Clifton,

    Yes, you should not drive anything but basic digital loads from the parallel port directly. To use the parallel port one should include digital buffers then from those buffers drive high current switches or relays to control significant loads.

  16. Salaheddin I. Allid says

    Hi;
    I’am intrested in studying and practical training on interfacing electronics of PC for control, measurment & data acquizition .
    I need a one year training program in U.K
    Can you help me to got such a training program, and all the expenses will be paid by my goverment.

    sincerely yours.
    Salaheddin I. Allid

  17. dfowler says

    Salaheddin, I do not know about the avaialble training programs in the U.K. I sugest that you google around or maybe one of the other readers will have a sugestion. You might try IRC look for a UK chat room and ask in there.

    David

  18. Sebastian says

    I’ve have tried several methods accesing the parallel port.
    I’ve used inpout32.dll, and at first it seems OK. But checking the status of the pins with a voltimeter shows that nothing is changed. I’ve tried every resource to access the parallel port in Windows XP, but I think the last choice is to program a driver myself. Has anyone manage to use inpout32.dll successfully in Windows XP? Is there any secret config missing?

  19. dfowler says

    Sebastian,

    This project and it’s code was implemented and worked fine on Windows XP. One thing that might be causing you some problems is that the data line are input and output capable. You may need to put a pull up resistor on each line to see anything happen when you output. I sugest that you initaly play with one of the dedicated output signals to do a basic test.