Target Switch Control From Parallel Port

Controlling Target board pins from a Parallel Port
This page describes a module which can control (turn on or off) up to 4 switches on target board using the parallel port on a standard PC.

How to use the module (overview)

 * Build the module using the circuit diagram below
 * Connect this module to PC and the pins on the target board(s) which you want to control.
 * Use a program on the PC to control the signals to the parallel port - and the pins on the target board.

Building the Module
The module is very simple, essentially just consisting of a single board which uses optical isolators to use the data bit from the parallel cable to control the switch status of the pins connected on the other side.

Circuit Diagram:

How to connect the module to the PC and the target
See the diagrams below for pictures of how to connect the module to the PC and to the target board switches.

Basically, it is very simple:
 * Attach the DB25 connector to the PC parallel port
 * For each switch on the target board you wish to control, connect the two lines from the switch on the module to the contact points on the target board for that switch.
 * Some boards have the switch contacts available as pins. For these, put the wires into a jumper than can be placed on the pins.
 * For some boards, you may have to remove the existing switch and/or solder the wires from the control module onto the target board.

How to control the module with software
The program 'paraport' can be used to control the data signals on the parallel port on the PC.

It can be downlaoded from here: [[Media:paraport.c]]

Building and installing 'paraport'
The program can be compiled with:

gcc paraport.c -o paraport

/\ Note that in order to control the I/O ports for the parallel port, the program must be run as root. It is easiest to make it setuid root, so that an ordinary user can run it without having to login as root.

Also the program should be installed somewhere in the user's PATH (usually /usr/local/bin).

This can be done as follows:

chown root paraport chmod u+s paraport cp paraport /usr/local/bin

Running 'paraport'
This program is simple and accepts one argument, which specifies the switches to turn on and off. The bits in the argument stand for each corresponding switch.

For instance,

% paraport 1     "Push the 1st. switch, release others" % paraport 2     "Push the 2nd. switch, release others" % paraport 4     "Push the 3rd. switch, release others" % paraport 8     "Push the 4th. switch, release others" % paraport 0     "Release all switches"

On many boards, switches are edge-triggered. For instance, to reset the board, you have to push down the reset switch then release it.

If you connect the 1st connector to the reset switch PIN on the target, you can reset the target with following procedure;

% paraport 1 % usleep 1000 % paraport 0

Sample scripts
Here are sample scripts which control the power and reset on an IBM Ebony (PowerPC 440) board: Note that switch 1 is connected to the Ebony reset switch pins, and switch 2 is connected to the Ebony power switch pins.

Script to "press and release" the reset button on the board:

ebony-reset.sh:


 * 1) ! /bin/sh

paraport 1 sleep 1 paraport 0

Toggle the power switch on the board:

ebony-power.sh:


 * 1) ! /bin/sh

paraport 0 sleep 1 paraport 2 sleep 1 paraport 0

The following script will make sure the power is removed and restored to the board. (This performs a complete power cycle, making sure the board is on independent of whether the power was on or off to start with.)

ebony-power-cycle.sh:


 * 1) ! /bin/sh

paraport 0 sleep 1 paraport 2 sleep 1 paraport 0

sleep 2

paraport 2 sleep 1 paraport 0