Parallel Port Interface

By Jim Pye

This page describes a Parallel Port Interface that provides 4 input and 4 output independently controlled ports. It also descibes a control program that allows for the ports to be to controlled and monitored from another host via a TCP/IP connection.

Both the input and output ports are opto-isolated to provide electrical protection for the computer's parallel port. The inputs are designed to eliminate "keybounce" issues. The outputs use relays to allow for greater load capacities.

I have included a SVG graphic of the Vero® Board layout I used. This was generated using the Open Source vector graphics editor Inkscape. Also included is a plain board and component outlines for generating your own projects.

Disclaimer: Please note that even though I have been running this system for over a year now with no problems on my system. I can not have any control over your implementation of this information and therefore cannot be held responsible for any damage that maybe caused to any equipment.

If you do find issues with this information, or can see a better way of doing this, please do not hesitate to contact the author at his email address

Input circuit schematic

The input circuit uses a 555 timer circuit in a monostable mode to provide a key de-bounce function on the sensor switch. The output of the timer is feed into the input LED of a 4N25 opto-isolator which switches the computers parallel port data lines. The 5 volts DC is supplied from the computers USB port. The PS/2 port could be used, but on the particular computer used these were not available. Because there are 4 inputs, each which need a 555 timer, I used a 556 dual timer IC so we only need to duplicate the circuit below twice.

ResizedImage500310 iocontrol input

Output circuit schematic

The output circuit simply feeds the Hi/Lo of the parallel port pin into the LED input of the 4N25 opto-isolator. This controls a small NPN transistor which in turn controls the relay. The diode is required to stop feedback current damaging the transistor. The relay used here was a 12 volt, single pole, double toggle, allowing for choice of normally closed or normally open connections to the outside world.

ResizedImage500272 iocontrol output

Veroboard layout

The following graphic is a layout of the Veroboard circuit used for this project:

ResizedImage587403 iocontrol veroboard layout

Notes on the board layout

  • Relays mounted dead bug style
  • Input circuits (CH5 - 8) are 2 sets mirrored, therefore the second set of 556 and 4N25 ICs are mounted "upside down". Note the pin 1 positions.
  • I would like to make a bit more space for the external connectors, maybe move them off the board and mount on the enclosure.
  • The board, as designed, just fits nicely into a spare parallel port switching box I had lying around. This meant I could utilise one of the parallel port connectors easily.
  • The 12 volts DC comes from a old power pack. 12 VDC 800 mA. Just make sure you get the positive and negative correct when connecting it to the board.
  • The 5 VDC comes from the USB port. Information about the pinout of the USB port is in included in the references below.

Here is a SVG file of the veroboard layout. This file, if opened in Inkscape, has been constructed with layers and you can switch their visibilty on and off to get a clearer view of the components etc. Caution: the file is approximately 1.5MB in size.

Here is another Inkscape SVG file that has an empty Veroboard and separate component outlines I constructed for this project. This could be used for your own projects.

Control Program

The control program is written in C and compiles on GNU/Linux. It uses the Parapin library from SourceForge and this needs to be compiled and installed correctly before compiling and using iocontrol.

iocontrol is split into 2 parts; a server portion which initialises the parallel port that the iocontrol interface is physically connected to and then it then sits in the background waiting for connections from clients.

The clients either poll the inputs and act on their state or switch the outputs on or off.

I have included 2 forms of client. One I use to monitor a door. This client runs continuously on a host and every 10 seconds sends commands to the server monitoring an input. When the input changes the client then sends control commands to switch an output. In this way it is used to turn on and off a warning lamp indicating the state of the door.

The other client I have included is designed to just switch an output on or off depending on the options given on the command line. This can be called by a cron job that switches on a lamp at a predetermined time. Then the program is called again with options to switch off the lamp some time later. I use this in combination with a web camera to monitor a power meter that is usually in the dark. This setup allows for a lamp to be turned on, a photo to be taken and then turn the lamp off.

Haven't thought up any other ideas for the other ports at this stage...

The control language used for the iocontrol is based loosely on the HTTP/HTML standard and I have called it PPTL/PPCL Parallel Port Transport Language/Parallel Port Control Language. Nothing fancy just uses the PPTL header which contains a version number and a method and some values.

See the comments in the the code for details.

Cheers Jim


Here are some of the web sites and other references I used for this project

Web sites
Tools used to produce this documentation
  • Inkscape - a vector graphics editor.
  • XCircuit - an electronic circuit schematic drawing tool and more.
  • The Gimp - Image Manipulation.
  • Geany - A fast and lightweight IDE.