From: markb@tplrd.tpl.oz.au (Mark Bower) Newsgroups: comp.sys.ibm.pc.hardware Subject: Bi-directional I/O on printer port - Hardware mods Summary: make you old PC printer port bi-directional Keywords: printer port, bi-direcional Message-ID: <1991Jul10.034144.11106@tplrd.tpl.oz.au> Date: 10 Jul 91 03:41:44 GMT Sender: markb@tplrd.tpl.oz.au (Mark Bower) Organization: Telectronics Pacing Systems Lines: 250 MAKING YOUR PC PARALLEL PORT BI-DIRECTIONAL ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ By Mark F. Bower I have had a large number of requests for this information so here it is. Disclaimer: Doing this modification may void your warranty on your computer components, and I take no responsibility for any damage that may be caused by making this modification. Introduction: ~~~~~~~~~~~~~ This simple modification allows a standard IBM PC type parallel port to be used as a bi-directional 8 - 12 bit I/O port for use in applications such as control, sensing, monitoring, and high speed data trasfer. WARNING: Do NOT attempt to read data in from the parallel port using a (non modified) a standard printer port card. The LS373/374 octal buffer can sink current and may overheat if this is done. The 4 handshake lines are also open collector outputs. Requirements: ~~~~~~~~~~~~~ o 1 piece of insulated copper wire (1 - 2 inches long). o Soldering Iron. o Solder, maybe some de-soldering wick. o A sharp tool for cutting PCB tracks. o A TTL data book is handy. o A parallel printer port schematic helps. o A digital multimeter for testing. o An IBM type parallel printer card - either an original single card or multi- function card. It may be possible to modify other types of parallel ports since most are of similar design (in PC's). However, special cards that use a single VLSI controller chip to perform the functions of the entire multi-function card may not be modified (of course!). Note: Laptop computers generally have a bi-directional parallel printer port - note however that these bi-directional port use open-collector outputs on the parallel data bus which may require pull-up resistors if they are to be connected to a 'standard' modified port for data trasfer. Method: Hardware mods ~~~~~~~~~~~~~~~~~~~~~ The following step are meant as a guide to performing the modification. When handling circuit cards, be aware that static electicity and carelessness can easily cause damage - be extra careful and patient when working on them! NOTE: The LS abbreviation may be F, L, or HC in you printer card. 1. Remove the parallel printer card/multi I/O card from the PC. 2. Locate the IC named 74LS374 (on standard PC printer port cards) or 74LS373 (multi I/O cards). If there is more than one of these IC's, select the one which connects to pins 9 to 2 of the 25 pin printer port connector. On the IBM PC printer schematic this is U4. This IC is an octal buffer. 3. Pin 1 of this IC (the output enable pin) should be currently tied to ground (on the underside of the board). Cut the track at pin 1 so that it is now NOT connected to ground. (alternatively it my be possible to cut pin 1 and bend it up - this is not recommended however). This pin was originally connected to gound. In this configuration, the LS373/374 was hard wired to OUTPUT mode. 4. Now locate the IC named 74LS174. This IC (a hex latch) is connected to pins 1,15,14, and 16 of the 25 pin printer connector through either a 74LS05 (IBM PC printer card) or a 74LS06 (multi I/O card) invertor. NOTE: Both the LS373 and LS174 IC's are also connected to the Address/ Data bus on the card through a LS243 IC. 5. This IC (LS174) is a hex latch. In the IBM printer port design, only 5 of the 6 available latches are used. The state of the sixth latch can be controlled in software, and by attaching its output to pin 1 of LS373, we can control the direction of data by toggling a single bit. 6. To determine which D flip flop is not used, trace the outputs from the LS174 (use a TTL/LS data book for a pinout of the chip) and see which one does not connect to the 74LS05 or 74LS06. On the standard PC printer adapter, pin 15 of the LS174 was not connected (the input from the data bus should already be connected (on pin 14 in this case). If it is not, then another wire jumper connected may be necessary). 7. Now solder a piece of insulated wire from pin 1 of the LS374/373 to the output of the unused D flip flop (e.g. pin 15 in this case). The printer port should now be configurable to be readable and writeable. (Notes: This only works because the original printer port could read the data back that it just printed. When data was sent to the printer, it passed through LS373 and onto the connector pins and was also stored in the LS244 latch - this data was then re-read by the printer software to ensure that the data that appeared on the pins was correct. Unfortunately, you could not read data that came in from the printer port connector because the octal buffer was hard wired for output. Using this modification, the octal buffer can be read (rather than written) and the data that is latched from this printer port connector can be read by the system). Compatibility ~~~~~~~~~~~~~ When the computer is powered on as normal, the BIOS should initialise the printer port to be in output mode (0 in the direction register). Therefore, all software should work as normal - printing operations will work as before. If custom software alters the direction register, then some software may have problems printing (a printer not ready signal or paper out error may be generated). This can be resolved by either clearing the data direction register (use debug for example) or by resetting the computer. Software Interface: ~~~~~~~~~~~~~~~~~~~ To use this 8 bit I/O port for data trasfer the following software can be used. This assumes that the parallel printer port is located at 378 hex. If this os not the case, subtract the suitable value (e.g. 100h for a printer as 278 hex) from the register addresses. 1. Setting the port for output mode (normal printer output): Clear bit 6 of the data direction register (formerly unused) at 37A (hex). e.g. i = inportb(0x37A); outporb(0x371, i & 0xDF); /* output mode */ or outporb(0x37A, 0); 2. Setting the port for input mode: Set bit six of the data direction register at 37A (hex). e.g. i = inportb(0x37A); outportb(0x37A, i | 0x20; or outportb(0x37A, 0x20); 3. Sending 8 bit bytes to the port (output): Send the data to 378 (hex) e.g. outportb(0x378, 0xAE); /* send 0xAE over port */ 4. Reading 8 bit bytes from the port (input): Read data from 378 (hex) e.g. x = inportb(0x378); /* read data from port */ 5. Hardware handshaking - essential for any communications: For successfull communiucations, some sort of hardware handshaking is required, This requires a couple of extra lines in you connection cable. For example, the ACK and STROBE lines can be used to signal data ready between two systems. An example is an A-D convertor on the port. To sample a value, send a pulse on the strobe line (or any oth spare line), wait for an interrupt (acknowledge/sample taken) from the A-D and then read it from the port. e.g. to send pin 14 of the connector high (and set input mode at the same time): outportb(0x37A,0x28); e.g. wait until pin 14 of connector is low : while (inportb(0x37A) & 0x08) == 0) ; Pinouts: ~~~~~~~~ Name Pin -Strobe 1 < +Data 0 2 <> \ +Data 1 3 <> | +Data 2 4 <> | +Data 3 5 <> |- now bidirectional +Data 4 6 <> | +Data 5 7 <> | +Data 6 8 <> | +Data 7 9 <> / -Acknowledge 10 > +Busy 12 > +Paper out 13 > +Select 14 > -Auto Feed 15 < -Error 16 > -Initialize 17 < -Select input 18 - 25 Ground 2 - = active low, + = active high. > from printer/other computer < from printer adapter Comments: ~~~~~~~~~ People who wish to attempt to use this modification to construct a parallel port SCSI interface should have a look at the Tiny Tiger SCSI hard drive interface which is used on the Commodore Amiga 500 and 1000 computers to provide a SCSI hard-drive interface. I am in no way connected with the manufacturers of Tiny Tiger. Any followups, extensions, or developments : email me any time. Please email me if you have success with this modification - I've done it and it works. Cheers, Mark | /\ ------------------------------------------------------------|/ \ /----------- Mark F. Bower. (markb@tplrd.tpl.oz.au) || \/ Design Engineer, || "Synchronize watches! - 11.45!" Telectronics Pacing Systems R & D. || "2.33!" 7 Sirius Rd, Lane Cove 2066, || "7.54!" Australia | Phone (Voice) 413 6913|| "Perfect, lets go!" - Maxwell Smart -------------------------------------------------------------------------------