Zoomkat's "El Cheapo" Parallel Port Output line Control

December 28, 2003

Updated January 3, 2004

Zoomkat's home page

Homemade web controlled parallel port output line control. The schematic below shows how to wire up the data pins of the parallel port to the 74HCT259 chips. Usually the output from the chip (Q0-Q7) will control a transistor (look here to see a diagram of how to use a transistor and resistor on the chip output lines), which controls the external devices on/off. Note the placement of the "diode" between the MR and VCC on the chips. Use the below batch file example, with the out.com file you make below, in the ivista webcam cgi folder, or the cgi folder of your web server. A helper application called userport.zip available here will be needed to allow user level use of the parallel port with NT/2k/xp (the userport defaults will open LPT1 port 378). Download the 74HCT259 data sheet here so you can see the "addressable latch" logic for A0-A2 (page 5) on the chip. Also get wnpar011.zip here to help with setup and testing. Using two 74HCT259 chips for latching 15 lines as setup here (two chips outputing one line at a time), and fifteen 74HCT259 chips setup as below, you can have up to 120 seperate lines controlled from the 8 data pins on the parallel port. Start out with a couple of chips and work your way up. As usual, YMMV!!!

  Below is some info on making the batch files that control the output lines of the chips. "P pin" is the parallel port pin number, "chip" is where the parallel port pin connects on the 74HCT259 chip, and "value" is the decimal value of the associated parallel port pin. The "out.com" application needs to use hex values to change the parallel port pin status, so when the decimal values are added up, you convert them to hex using the windows calculator (RUN > calc.exe) in the scientific mode. Type in the calculated decimal value, then click the little "Hex" dot, and voila!, you have the hex value you need. In the batch examples below, pin #9 is being used to power the chips for testing only (use a wall wart feeding a 7405 +5V regulator chip, Radio Shack 276-1770, $1.49, to power the chips for best performance), so it needs to be set high at +5V all the time. In the batch file lines the :: and added numbers are for info showing how the numbers are added up. the :: and the added numbers don't need to be in the batch files used.

  In the first line of the batch file below, the 1 sets parallel port pin #2 at +5V, which feeds A0 on the chip, which will control chip output line Q1 ((see the "addressable latch" logic on the data sheet). The 8 sets parallel port pin #5 at +5V, which is connected to the chip D data line. When the data line is at +5V, the addressed Q line will be set to output +5V. If parallel port pin is is left at 0V, then the addressed chip output pin will be set to 0V output. this is how the chip output pins are set high/low, or on/off. the 128 keeps parallel port pin #9 high at +5V, as it is being used to power the chips.

  The second line in the batrch file keeps the previous parallel port pin settings, and also sets parallel port pin #6 high at +5V. This controls the latch on chip #1. When the latch on a chip is set to +5V and then back to 0V, The addressed output line Q will be latched to the current state of the data line (either +5V or 0V), and remain in that state until you change it later as desired.

  The third line in the batch file lets the latch line drop back to 0V, so the Q1 line will be latched at +5v output.

  The fourth line in the file sets all the parallel port pins back to 0V, except for pin #9, which must stay at +5V to power the chips. Note that if the chips have their power interrupted, all outputs will drop back to 0V. Look at the other batch file examples below and see how the same thing is being done.


p pin   #2    #3   #4   #5   #6   #7   #8   #9

chip    A0   A1   A2   D   LE   LE   LE   MR

value    1     2     4     8    16    32    64   128

=====Q1-on.bat===

@echo off
status: 204
echo.
echo.
out.com 89 378 :: 1+8+128 = 137 = 89 hex
out.com 99 378 :: 1+8+16+128 = 153 = 99 hex
out.com 89 378 :: 1+8+128 = 137 = 89 hex
out.com 80 378 :: 128 = 80 hex
cls

=====Q5-on.bat===========

@echo off
status: 204
echo.
echo.
out.com 89 378 :: 1+4+8+128 = 141 = 8d hex
out.com 99 378 :: 1+4+8+16+128 = 157 = 9d hex
out.com 89 378 :: 1+4+8+128 = 141 = 8d hex
out.com 80 378 :: 128 = 80 hex
cls

=======Q0-off.bat======

@echo off
status: 204
echo.
echo.
out.com 89 378 :: 128 = 128 = 80 hex
out.com 99 378 :: 16+128 = 144 = 90 hex
out.com 80 378 :: 128 = 80 hex
cls

===========================

The below batch file will make a program called out.com (by Herbert Kleebauer) when run. Copy the below batch file, paste in notepad, save on the desk top as out.bat. Double click on out.bat and the out.com file will appear. out.com can be used in win95/98 to conrol the parallel port as is. Use with userport (see link above) in XP to control the port (open 378-37A for use of LPT1). The command line out.com 00 378 sets port 378 to 00. Substitute the desired hex numbers for 00 to make the desired parallel port pin +5v. ***Watch for word wrap***. There are 7 lines, with the the long ones starting with echo and ending with out.com. When you copy/paste, make sure it looks as described or adjust as necessary. I also put out.txt here, so you can just copy, paste in notepad, and save as out.com if desired. Find out more about using the out.com file here.

=========out.bat file to make the out.com================

@echo off
echo Bj@jzh`0X-`/PPPPPPa(DE(DM(DO(Dh(Ls(Lu(LX(LeZRR]EEEUYRX2Dx=>out.com
echo 0DxFP,0Xx.t0P,=XtGsB4o@$?PIyU WwX0GwUY Wv;ovBX2Gv0ExGIuht6>>out.com
echo ?@}IIHpkg~K=H?H_CgRNWH?wpBmNEFQNS@CbwH@S?pkoECIQ{_K?\qoCve>>out.com
echo {Sx{X?{Eu@Pq`Dkfk?a@o{A@CoCEFr@B@K~Tj~@CeK??BB0>>out.com
out.com 00 378
rem del out.com

========end out.bat file=======================

Place the Q1-on.bat file (and other bat files you make), and the out.com file in the server cgi or cgi-bin folder (I use the ivista web server module), and make a link to the batch files to run them. Look at the source of my page here to see how to make the simple web based control page. If you don't want to use the web and just want to use control on your desk top, then make just make short cuts to the batch files and double click on them.

Below is a single 74HCT259 chip showing the basic wiring. The three wires on the chip bottlm left going to the left are attaching the parallel port pins #2, #3, and #4 to the chip A0-A2 pins. The blue wire on the bottom right going to the left is the chip ground going to parallel port pin #18. The wires on the chip top left are power from parallel port pin #9 going to the chip MR, parallel port pin #5 going to the chip D data, and parallel port pin #6 going to the chip LE latch. The four wires on the bottom of the chip and the four wires on the top of the chip that are going upward are the eight chip oputput lines Q0-Q7.

The basic schematic showing how the parallel port pins are connected to the 74HCT259 chips, and how multiple chips are wired up.

Counter