R. KARTHICK
T
he PC parallel port is a powerful platform, though expensive, for implementing projects dealing with the control of real-world peripher-als. It can be used to control the printer as well as household and other electrical appliances. The computer program included as part of the project controls the relays through the interface circuit, which, in turn, switch the appliances ‘on’or ‘off’.
The parallel port has 12 outputs in-cluding 8 data lines and 4 control lines.
The circuit described here can be used to control up to 255 electrical appliances us-ing only eight data output lines from the parallel port. Besides, the software pro-gram allows the users to know the current status of the devices.
Block diagram
The block diagram in Fig. 1 shows the main components of the system for switch-ing multiple devices usswitch-ing PC. The con-trol command to switch on/off the appli-ances is given through the keyboard. The software program scans the input and, as per the input command, the data is avail-able at the parallel port.
Out of eight data output lines from the PC, bits D0 through D3 serve as ad-dress lines for decoders 2 and 3, which, in turn control the devices to be switched
on/off. Bits D4 through D7 are used as address lines for decoder 1, whose out-puts are used as enable signals for decod-ers 2 and 3 as shown in Fig. 1.
The output of decoders 2 and 3 drive D-type flip-flops, which, in turn, control the relays via relay drivers inside IC ULN2803.
The parallel port
The parallel port or line printer ter-minal (LPT) port terminates into a 25-pin D-type female connector available at the back of your PC. A basic IBM PC usually comes with one or two LPT ports. The original parallel port, called standard par-allel port (SPP), is a bundle of three ports (or registers), namely, data port, status port, and control port. Pins 2 through 9 form the 8-bit data output port. This port is purely a write-only port. This means it can be used only to output some data through it. Pins 1, 14, 16, and 17 form the control port, which is capable of reading/
writing. Pins 10 through 13 and pin 15 together form the status port. The status port is a read-only port.
The base address of the first parallel port (LPT1) is 0378 in hexadecimal (hex) notation (or 888 in decimal notation). The base address of the second parallel port (LPT2) is 0278 (hex). In this project, we’ve used only LPT1.
Circuit description
The circuit comprises decoder, in-verter, latch, and relay driver sections.
The circuit, excluding relay drivers and relays, is powered by a 5V DC regulated supply. Relay drivers and relays are driven by a 12V DC regulated supply.
Each relay is rated 12V, 200-ohm.
The interface circuit for switching on/
off 16 devices is shown in Fig. 2. For more than 16 loads, you can add more ICs in a similar way as shown in this circuit. IC 74LS154 is a 24-pin, 4-to-16-line decoder IC. It accepts four inputs and provides 16 outputs. Input address lines A1 through A4 (to pins 20 through 23) of IC1 and IC2 (IC 74LS154) each are connected to data bits D0 through D3 of the data lines of the computer parallel port.
In the circuit, only pins 2 through 9 of the parallel port 378 (hex) are used. D4 through D7 form the address-select. Pins
Fig. 1: Block diagram of the system for multiple device switching using PC’s parallel port
PARTS LIST Semiconductors:
IC1, IC2, IC3 - 74LS154 1-of-16 decoder IC4, IC5, IC6 - 74LS05 inverter IC7-IC14 - 74LS74 D-type flip/flop IC15, IC16 - ULN2803 octal Darlington
array driver Miscellaneous:
Power supply - 5V regulated DC, 12V regulated DC
Relay - 12V, 200-ohm, 1C/O SPDT
Fig. 2: The interface circuit for multiple device switching using PC’s parallel port
18 through 25 are shorted to ground. Data lines D0 through D3 are input addresses for IC2 and IC3, and data lines D4 through D7 are input addresses for IC1.
When Enable pins E1 and E2 (active low) are high, all the outputs go high irespective of the address inputs (A1 through A4). Enable pins E1 and E2 of
IC1 are grounded (permanently enabled) and its output pins Y0 through Y15 are connected to Enable pins of the respec-tive decoder ICs 74LS154 of the next stage Fig. 3: Actual-size, single-side PCB for multiple device switching
using PC’s parallel port
Fig. 4: Component layout for the PCB
(here IC2 and IC3).
Initially all the data input lines (D0 through D7) are low. Thus, except Y0, all the outputs of IC1 and IC2 are high. The output Y0 of IC2 is not used, for the rea-son that when all the input data lines are low, none of the outputs can be used for switching the loads. Suppose, out of eight input data lines, D0 is high. So, except Y1, all the outputs of IC2 will be high. Y1 is then inverted using IC4 (IC 74LS05).
The output of IC4 at pin 2 is given to pin 3 of IC7 (IC 74LS74). IC 74LS74 is a dual D-type flip-flop used in toggle mode for latching the data.
With an active rising edge of the clock pulse (CP1 or CP2), the data input will be locked into IC7 through IC14. Thus, the output data will be latched until the next rising edge of the input clock pulse ar-rives. The outputs of ICs 74LS74 are given
to relay driver ICs ULN2803 (IC15 and IC16), which, in turn, drive the relays.
The relays switch on/off the appliances. It means that alternate rising edge of clock pulses will toggle the state of relay/device.
The actual-size, single-side PCB for the interface circuit for multiple device switching using a PC’s parallel port is shown in Fig. 3 and its component layout in Fig. 4. Please note that IC3 is not shown on the PCB since only a single output (Y0) is used from this IC, which may be mounted on subsequent PCB if more than 15 devices are to be controlled.
Software program
The program to control the appliances is written in C. It is compiled using Turbo C compiler. The program can be written on any Windows text editor (notepad, Screenshot of the program output
wordpad, etc). The C programming lan-guage is more user-friendly and easy to understand than other programming lan-guages. The source code (PCL.C) of the program is given at the end of this article.
On running the program, a menu-like screen appears, which prompts you to en-ter your choice, viz, 1 for Switching, 2 for Load’s Status, and 3 for Exiting the pro-gram.
The Switching option 1 is used to switch on/off the appliance interactively.
The Load’s Status option 2 displays the status of all the loads that are already
‘on’. The Exit option enables you to exit from the application program. A screenshot of the program output is shown above.
The advantage of this software is that the users would know the current device/
load status. If a particular load is already
‘on’ and by mistake the user tries to turn it on again, the software automatically tells the user that the load is already ‘on’.
In the program, the ‘outportb’ command outputs the desired data from the parallel port.
This software program can control up to 255 electrical loads. However, due to limitation of space, we’ve presented here the circuit for switching only up to 16 loads.
Note. The source code and executable file of the program are included in the CD.
PCL.C
/* R.KARTHICK,III ECE,K.L.N.COLLEGE OF ENGG,MADURAI.
printf("POWER CONTROL USING PC");
gotoxy(1,8);
case 2:status();break;
case 3:ext();break;
} } }
void load()
{ clrscr();
printf("Enter the load number(1-255):");
scanf("%d",&nt);
if(nt<=255 && nt>0)
{ clrscr();
printf("Your load no %d is on",nt);
v[nt]=1;
delay(10);
outportb(PORT,0);
else if(n1==1 && v[nt]!=0) }
printf("Your load no %d is already on",nt);
if(n1==2 && v[nt]==1)
{ outportb(PORT,nt);
printf("Your load no %d is off",nt);
v[nt]=0;
delay(10);
outportb(PORT,0);
else if(n1==2 && v[nt]!=1) }
printf("Your load no %d is already off",nt);
getch(); } }
void status() { int x1;
clrscr();
printf("The following loads are on:\n");
for(x1=0;x1<=255;x1++)
if(v[x1]==1) printf("%d\t",x1);
getch();
} void ext() {
int x2;
clrscr();
for(x2=0;x2<=255;x2++) if(v[x2]==1)
outportb(PORT,x2);
exit(0);
Readers’ comments:
Q. The circuit is showing short-circuit at 5V supply. I’ve checked all the tracks of the PCB but found no short-circuit.
There is no short circuit when IC 7405
is removed. What could be the problem?
Nilesh Todarmal Through e-mail The author, R. Karthick, replies:
A. The IC 7405 may be faulty, or check
for any external short circuit. If the problem persists even after replacing IC 7405 with IC 7404 (both the ICs are used for inverting the signal), check your PCB again.