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.