PC Parallel Port Interfacing
Using 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.
- Parallel Port Central
- Interfacing the Standard Parallel Port
- Parallel port interfacing made easy
- Parallel port Interfacing Tutorial
- Interfacing to the IBM-PC Parallel Printer Port
- Parallel Port Relay Interface
- Parallel Port Interfacing in C#.NET Programming
- How To Build Parallel Port Prototypes
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.
For 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.
You 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.





Stumble it!







December 26th, 2006 at 3:39 am
so good!!
February 2nd, 2007 at 4:17 am
thanks
February 22nd, 2007 at 1:35 am
what if i have more than 5 inputs
February 23rd, 2007 at 2:39 am
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.
April 20th, 2007 at 7:56 pm
sweet..where can i find a dll to access parrellel with visual basic?
April 21st, 2007 at 2:42 am
Wow, this is pretty usefull. Although, I still find using the parallel port a bit more messy than using a microcontroller.
April 21st, 2007 at 4:30 am
I like this project, pretty cool.
April 21st, 2007 at 9:44 am
Cool, this should come in handy some time
April 21st, 2007 at 10:21 am
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.
April 21st, 2007 at 10:27 am
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
April 21st, 2007 at 1:39 pm
This is so cool to learn how to reference stuff using a PC.
April 21st, 2007 at 3:03 pm
I really like this project, not that it’s anything fancy, but the way you mounted the board is very clean and neat.
April 21st, 2007 at 4:08 pm
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.
April 21st, 2007 at 4:12 pm
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.
April 21st, 2007 at 4:15 pm
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.
June 9th, 2007 at 9:11 am
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
June 10th, 2007 at 1:22 am
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
September 2nd, 2007 at 11:36 am
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?
September 2nd, 2007 at 1:50 pm
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.