Parallel port IO module
I'm not using this module anymore, there are much easier ways to interface inputs and outputs these days.
Get 5 inputs and 8 outputs from a computer printer port using only a few transistors and resistors.
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 inputs. The parallel port is pretty easy to access in most programming languages. The module as 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 scripts, signals and alarms can be triggered. Making it possible to create a Linux server status panel (see images). By using 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.
Inputs
The parallel port has 5 status pins that can be used as inputs by pulling them low using 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 pin 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 a LED indicator.
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 | |
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
Lifesignal
Done every 5. minute, using crontab, and sends a signal to a monitoring unit. One puls on 0.5 seconds is sent to binary address 8.
#!/bin/bash
/var/www/ctrl_files/set_port 1 8 0.5 0.5 > /dev/null
Reset_alarm
Sends lifesignal to a monitoring unit and closes additional alarm outputs.
#!/bin/bash
/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 "lifesignal sent to mmu"
Turn_port
Turns an output on or off.
#!/bin/bash
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.
#!/bin/bash
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.
#!/bin/bash
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'); }
Gallery
MJ-8050 in the Rack box
Software screenshots
- DVC
- Hebo
- Web