Professional Documents
Culture Documents
Electrical Equipement Control Using PC
Electrical Equipement Control Using PC
Household Device
Interfacing a Computer Parallel Printer Port
May 27, 2009 Martin Bell
Up to eight circuits may be controlled from one printer port. There are two key components:
software to control the switching, and an electronic interface to connect the computer to the
external switching circuit.
The parallel printer port on the PC has 8 lines, and by convention these are referred to as bits
0 to 7, and they represent an 8-bit binary number. They are all initialized at OFF, by writing
the number zero to the printer port. The section "Software to Control Device Via PC"
describes how to do this.
In the most simple case, where only one device needs to be controlled, the only numbers sent
to the printer port are 0 and 1, so no binary to decimal conversion is needed. If a known
combination of switches needs to be set, let OFF be represented by 0, and ON be represented
by 1.
For example, switch on the heating(switch 0), lighting (switch 1), and humidifier (switch 2).
The binary number is 111, and it can be converted using the Microsoft Excel function
BIN2DEC(111), and will return the number 7. To set the three switches, simply write the
number 7 to the parallel printer port. For a more complete description of decimal and binary
conversion, see Decimal, Binary, Octal and Hexadecimal Number Systems.
This can be written in any language, but the programming language C / C++ is used here. The
laptop or PC needs to be loaded with the software that controls the output or outputs.
Read on
#define LLEL_ADDR 0x378 /* Define the hexadecimal address of the parallel printer port */
void main(void)
{ }; /* Do nothing */
while() /* Enter the conditions to wait for e.g. Wait for 18 hours */
{ }; /* Do nothing */
} /* End of Main */
This example shows how to do the cycle once. For timer control of household devices that
need to be switched at certain times every day, a loop could be used:
do{}
while();
Figure 1 shows the circuit needed to interface one line from the parallel printer port to a small
motor. If all that is needed is to switch on a plug socket to operate mains-operated equipment,
then only the opto-isolator is needed, connected to a solid state relay.
A 12 Volt supply is needed, and can be obtained cheaply. On a standard 25-pin parallel port,
pins 2 to 9 (i.e. bits 0 to 7) can each supply about 5 volts when switched on. Each line from
the printer port needs to be completed by attaching it to the PC ground, and these can be
found at pins 18 to 25 of the 25-pin printer port.
R1 220 Ω
R2 2200 Ω
R3 10,000 Ω
Opto-Isolator OPI 110C
Diode - Any: IN4002 is rated at 100 Volts
Transistor TIP141 is heavy-duty darlington pair that can drive a small motor. The motor M
may be replaced with a solid state relay (SSR) that is used to switch on any mains electricity.
If a relay will be used to switch on household devices, then the circuit will change, as
described in the article Computer Control of External Devices Using a Relay should be
consulted.
Copy