[comp.sys.ibm.pc] Still more on reading from the parallel port

pfales@ttrde.UUCP (Peter Fales) (01/18/89)

There has been a lot of information (as well as misinformation, some from
me) about using the parallel port on a PC for input.  Some clarifications
are in order:

The "standard" PC parallel port on IBM PCs and most clones is wired as
follows (some clone manufacturers may have made changes for additions).
This is a simplified block diagram, no decoding or chip selection
circuitry is shown.


			-----------
PC Internal Data Bus	|	  |
----------------+-------|  Output |-----+-------------> 8 bit data
		|	|  Latch  |	|
		|	|  	  |     |
		|	|     OE  |     |
		|	-----------     |
		|	       |        |
		|	      GND       |
                |			|
		|	-----------	|
		|	|	  |	|
		|	|  Input  |	|
		+-------|  Buffer |<----+
		|	|	  |
		|	-----------
		|
		|	-----------
		|	|	  |
		|	|  Output |
		+-------|  Latch  |-----+------------> 4 Control Lines
		|	|	  |     |
		|	-----------     |
		|			|
		|	-----------	|
		|	|         |	|	
		|	|  Input  |<----+
		|	|  Buffer |
		+-------|	  |<-----------------< 5 Status lines
			|	  |
			-----------

When I said that it was not possible to do input from the parallel
port, I was referring to reading the 8 data bits directly.  A number
of people have written back to me saying "It works.  I have done it."
All I can say is that I would not recommend it - you are depending
on the external device being able to overcome the signal being
driven by the output latch.  Since TTL drivers can't source much current
you might be able to get away with it by writing all "ones" to the
port and then reading the external device, but it can't be good for the
hardware.

As others have pointed out, you can freely do input and output to
the status and control ports, though these are not the full eight
bits wide.  Though I don't know for sure, I imagine that this is
the way commercial interconnection programs like Laplink work.  i.e.
they are creating a "null modem" for the parallel port that maps
the control outputs from one port to the status inputs of the other.

I hope this has helped shed a little more light on the subject.
-- 
Peter Fales			AT&T, Room 2F-217
				200 Park Plaza
UUCP:	...att!ttrde!pfales	Naperville, IL 60566
Domain: pfales@ttrde.att.com	work:	(312) 416-5357		

t31662k@kaira.hut.fi (Andreas Gustafsson) (01/24/89)

According to the IBM XT Techical Reference Manual the four command
lines in the printer adapter have open-collector drivers with 4.7k
pullup resistors, although the eight data lines have push-pull
drivers.  This means you should actually be able to use a total of 9
lines as inputs: the five status lines and the four command lines
(which should be written as all ones when used as inputs).  Note,
however, that the status and command bits are at different port
addresses and some of the bits are inverted... 

--
Andreas Gustafsson
Internet: gson@hupu.hut.fi
UUCP: ...uunet!mcvax!santra!hupu!gson
Voice: +358 0 563 5592