This post is part of the Rack Box Project series.
Get 5 inputs and 8 outputs from a computer printer port using only a few transistors and resistors.
Table of contents
Details
With this unit a regular computer parallel (printer) port will give you 5 inputs and 8 outputs to use for something fun. And it’s very simply to build; one transistor and one resistor per output, and a single resistor for each input.
The parallel port is pretty simple to access in most programming languages. The module has a 36 pin Centronics connector, making it easy to connect to the computer using a regular printer cable.
By connecting the module to the parallel port of a Linux server, and using some scripts, signals and alarms can be triggered. Making it possible to create a Linux server status panel.
With a web server you can set up a PHP website controlling your module, and with your cell phone you can access this site. But I’ve only managed to use the outputs in Linux.
I’ve even made a data sheet for this module: MJ-8050.pdf
Inputs
The parallel port has 5 status pins that can be used as inputs by pulling them low with a 120 ohm resistor to ground. Some experimentation might be needed as not all the status pins have the same behavior with regards to high and low state.
Outputs
The parallel port also has 8 data pins with TTL-level, meaning active 5V and inactive 0V. Using an NPN transistor with a 4.7K resistor will give you a open collector output. Each output has an LED indicator.
Some history
This was the first computer controller I/O module I built. I originally made it in a wooden box; with LEDs in the front, a xenon strobe on top, and car relays on the back.
I got the schematics and QBasic code on a Usenet newsgroup, and used salvaged parts. Unfortunately I don’t have any photos of it, and I don’t exactly remember what year this was. But I think it in my last years on primary school, so probably around 1995 or 1996.
In 2002 I moved the “electronics” (if you can call it that 😛) into a new enclosure, replaced the LEDs and removed the relays.
The module has been used in multiple projects over the years, like my wooden rack and the rack box.
I/O
Terminal connectors
- Output 1
- Output 2
- Output 3
- Output 4
- Output 5
- Output 6
- Output 7
- Output 8
- Input 1
- Input 2
- Input 3
- Input 4
- Input 5
- When-on
- +12V
- 0V
Parallel port
DB-25 pin-out
The data pins (D0-D7) are outputs, and the status pins (S3-S7) inputs. The green pins (18-25) are ground. See table below for details.
DB-25 to Centronics
Description | DB25 pin | Centronics pin |
---|---|---|
Strobe | 1 | 1 |
Data bit 0 | 2 | 2 |
Data bit 1 | 3 | 3 |
Data bit 2 | 4 | 4 |
Data bit 3 | 5 | 5 |
Data bit 4 | 6 | 6 |
Data bit 5 | 7 | 7 |
Data bit 6 | 8 | 8 |
Data bit 7 | 9 | 9 |
Acknowledge | 10 | 10 |
Busy | 11 | 11 |
Paper out | 12 | 12 |
Select | 13 | 13 |
Autofeed | 14 | 14 |
Error | 15 | 32 |
Reset | 16 | 31 |
Select | 17 | 36 |
Signal ground | 18 | 33 |
Signal ground | 19 | 19 + 20 |
Signal ground | 20 | 21 + 22 |
Signal ground | 21 | 23 + 24 |
Signal ground | 22 | 25 + 26 |
Signal ground | 23 | 27 |
Signal ground | 24 | 28 + 29 |
Signal ground | 25 | 16 + 30 |
Shield | Cover | Cover + 17 |
Bash scripts
Life-signal
Done every 5 minutes, using crontab, and sends a signal to a monitoring unit. One 0.5 second pulse is sent to binary address 8.
/var/www/ctrl_files/set_port 1 8 0.5 0.5 > /dev/null
Reset alarm
Sends life-signal to a monitoring unit and closes additional alarm outputs.
/var/www/ctrl_files/turn_port 1 0 > /dev/null
/var/www/ctrl_files/turn_port 2 0 > /dev/null
echo "signal closed to ltcu"
/var/www/ctrl_files/set_port 1 8 0.5 0.5 > /dev/null
echo "life-signal sent to mmu"
Turn port
Turns an output on or off.
PORTSTATUS=`cat /var/www/ctrl_files/port_status`
PORTSTATUSBIT=`cat /var/www/ctrl_files/$1`
let ON=PORTSTATUS+$1
let OFF=PORTSTATUS-$1
if [ $2 -eq 0 ]
then
if [ ! $PORTSTATUSBIT -eq $2 ]
then
echo $OFF > /var/www/ctrl_files/port_status
echo $2 > /var/www/ctrl_files/$1
/usr/sbin/parout $OFF > /dev/null
echo "$1 off"
fi
fi
if [ $2 -eq 1 ]
then
if [ ! $PORTSTATUSBIT -eq $2 ]
then
echo $ON > /var/www/ctrl_files/port_status
echo $2 > /var/www/ctrl_files/$1
/usr/sbin/parout $ON > /dev/null
echo "$1 on"
fi
fi
Set port
Gives a pulse on an output.
COUNTER=0
while [ $COUNTER -lt $1 ]; do
let COUNTER=COUNTER+1
PORTSTATUS=`cat /var/www/ctrl_files/port_status`
let ON=PORTSTATUS+$2
echo $ON > /var/www/ctrl_files/port_status
/usr/sbin/parout $ON > /dev/null
echo "$2 on"
sleep $3
PORTSTATUS=`cat /var/www/ctrl_files/port_status`
let OFF=PORTSTATUS-$2
echo $OFF > /var/www/ctrl_files/port_status
/usr/sbin/parout $OFF > /dev/null
echo "$2 off"
sleep $4
done
Web ping
Gives visual alarm if the ping is higher then 400ms, and sound alarm if above 800ms. If no reply then the “internet failure” alarm will sound.
WEBPING=`ping -c 10 -W 10 catch.no |grep rtt |awk -F '/' '{print $5}' |sed -e 's/time=//' |sed -e 's/\.[0-9]*//'`
PORTSTATUS=`cat /var/www/ctrl_files/port_status`
MAXPING=400
OVERPING=800
if [ $WEBPING ]
then
echo $WEBPING > /var/www/ctrl_files/ping
if [ $WEBPING -gt $MAXPING ]
then
/var/www/ctrl_files/set_port 1 2 3.6 0.5 > /dev/null
if [ $WEBPING -gt $OVERPING ]
then
/var/www/ctrl_files/set_port 1 16 0.75 0.25 > /dev/null
fi
fi
fi
if [ ! $WEBPING ]
then
/var/www/ctrl_files/turn_port 2 1 > /dev/null
/var/www/ctrl_files/set_port 3 16 0.25 0.25 > /dev/null
echo "failed" > /var/www/ctrl_files/ping
fi
PHP Script
Controlling the Parallel I/O module using php and GPRS.
if(isset($Lamp)) {
echo "<b>Lamp signal sent to LCU.</b><br>";
$output = shell_exec('/var/www/ctrl_files/set_port 1 32 1.5 0.5'); }
Software
The first program I made to control this module was in QBasic, but I don’t have any screenshots or code from that unfortunately.
DVC
DVC Port Kontroll (port control) was written in Pascal using Delphi. It was pretty simple, it could control the outputs, read the inputs, and had a simple security system functionality. I don’t really remember much about it, or why it was called DVC 😛
HEBO
HEBO was a collaboration between myself (hebron) and a friend (bonedawg). It was written in Visual Basic and allowed the parallel port to be controlled using network socket.
Socket communication with the I/O module, through HEBO:
- Read output byte value
- Read input byte value
- Set output byte value
READ &H378
READ: &H378 255
READ 889
READ: 889 127
WRITE &H378 5
WRITE: &H378 5 5
Web and WAP
My very first IoT attempt used the parallel I/O module, PHP and some bash scripts. It wasn’t pretty, but it kind of worked.
Photos
Server status
Rack box
Schematic drawing
Parts used
- 1 × Centronics, chassi, 36-pin
- 1 × Enclosure, plastic (1591 FL), 150x80x50mm, flange
- 1 × LED 3mm, Green, 2.1V, 20mA, 3.5mcd, 38°
- 8 × LED 3mm, Red, 2.1V, 20mA, 1.0mcd, 38°
- 1 × LED 3mm, Yellow, 2.0V, 20mA, 2.5mcd, 38°
- 10 × LED holder 3mm, Chromed metal
- 5 × Resistor, carbon film, 0.25W, 120 Ω, 5%
- 8 × Resistor, carbon film, 0.25W, 4.7 kΩ, 5%
- 10 × Resistor, metal film, 0.6W, 1 kΩ, 1%
- 2 × Switch, toggle, 1-pole, micro, on-on
- 16 × Terminal block, screw, 2.5 mm
- 8 × Transistor, NPN, 100 mA, 45V, 0.5W, BC547B
Last commit 2024-11-27, with message: Add some missing figure captions.
All posts in Rack Box Project series
- Parallel port I/O module
- Power supply and fuse monitoring module, AVR
- Monitored fuse box, 6 channels
- Stack lights and horn controller — with AVR
- Mute and light controller for the Rack box — AVR module
- Monitored fuse box, 4 channels
- Module heartbeat monitor, 6 inputs — AVR
- Controller for lights and relays — AVR driven
- Emergency power off controller — controlled by 555 timers
- Fan controller with LCD — AVR powered
- Sound alarm control unit — AVR module
- Multiplexer output extender
- Multi-purpose AVR module
- Electric heater and timer controller — AVR
- Module heartbeat monitor, 15 inputs — LCD and AVR
- Serial port I/O module with 11 inputs — AVR
- Serial port I/O module with 9 in and outputs — AVR
- Serial interface for emergency power off — AVR
- Status panel for the Rack box project
- Intruder alarm system controller — AVR
- Serial port I/O module with 15 inputs — AVR
- Serial interface module, with analog and digital I/O — AVR
- The rack box project — an overview