Parallel port IO module

From uCtrl
This page is kept for historical interest. It may document projects or methods that are obsolete and/or no longer relevant. The information here is not kept up-to-date.

I'm not using this module anymore, there are much easier ways to interface inputs and outputs these days.
Parallel port IO module

Information

This unit is connected to a computer parallel port (the printer port). The circuit is very simple, a transistor and a resistor for every output. And a resistor for every input. The parallel port has 8 outputs with TTL-level, meaning active 5V and inactive 0V. A NPN transistor with a 4.7K resistor opens for a 12V current. Every output can sink 100mA using the transistors. Alone the parallel port can sink almost nothing.

The 5 inputs is made active by connecting the input to a 120R resistor to GND. This makes the input go low, but detected high by the computer (inverted). There is a LED for every output in the front of the module, together with a power switch. The connector is Centronics, female 36-pin. So a regular printer cable can be used.

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.

I/O

Connections

  1. Output 1
  2. Output 2
  3. Output 3
  4. Output 4
  5. Output 5
  6. Output 6
  7. Output 7
  8. Output 8
  9. Input 1
  10. Input 2
  11. Input 3
  12. Input 4
  13. Input 5
  14. When-on
  15. +12V
  16. 0V

Irssi Alias

Can be added in Irssi, making it possible to control the Parallel I/O module from there.

/alias lights /exec - /var/www/ctrl_files/set_port 1 32 1.5 0.5
/alias sub /exec - /var/www/ctrl_files/set_port 1 64 1.5 0.5
/alias aux /exec - /var/www/ctrl_files/set_port 1 96 1.5 0.5
/alias fan /exec - /var/www/ctrl_files/set_port 1 192 0.2 0.1
/alias mute /exec - /var/www/ctrl_files/turn_port 4 1
/alias unmute /exec - /var/www/ctrl_files/turn_port 4 0

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'); }

Images

Software screenshots

Schematic drawing

Parallel-i-o-module-circuit-6qj2m4.png

Parts used

Qty. Part
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