🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: alt.msdos.programmer
Article #976

Re: Programming the printer port to read in data.

#976
From: nathan engle
Date: Wed, 22 May 1991 16:06
96 lines
5929 bytes
In article <1991May22.104513.22169@msuinfo.cl.msu.edu> draper@buster.cps.msu.edu (Patrick J Draper) writes:
>Some people have given suggestions to use a joystick port, etc to read
>a switch.
>
>What if someone wanted to read a signal from a sound digitizer?
>How do you get the port to read a parallel data stream?

    Different parrallel ports use different techniques. In the original
IBM printer card and many subsequent clones, the data register of a
parrallel port CAN be read and is supposed to come back with whatever
the last value was that you wrote to the outgoing data register. The
ways this works is as follows:

               +-----+  (the LS245 is a bidirectional transceiver that
               |     |   "buffers" (boosts and isolates) the signals
               |     |   from the data bus in the card slot)
===============|     |=========================================\
Bidirectional  |LS245|                                         I
Data from      |     | Bi-directional data on LPT card         I
PC card slot   |     |                                         I
===============|     |========\    /=====================\     /
               |     |        I    I                     I     I
               +-----+        I    I Out             In  I     I
                           +----------+               +-----------+
                           |  LS244   |               |  LS374    |
                           +----------+               +-----------+
                              I    I In              Out I     I
                              I    I                     I     I
                              I    \                     /     I
                              \     \===================/      /
                               \      Data wires to/from      /
                                \    the DB25 connector on   /
                                 \    the back of the PC    /
                                  \=======\     /==========/
                                          I     I
                                          I     I
                            DB25 connector going out to the "Real
                                         World" (tm)

    When you write data to the LPT card it passes from the card slot
through the LS245 transceiver and finally into the "In" side of an LS374
(octal latch). Once data is written to the 374 that data is also echoed on
the "Out" side of the 374, and subsequently is available to be read
either by a device attached to the DB25 or by the LS244 (one-directional
buffer).

    So the trick you need to use in reading back data from the outside
world is to somehow get the 374 to "shut up", thus allowing the inputs
of the LS244 to be driven exclusively by whatever is outside. There are
a two methods that can be used to do this, and different cards use
different methods.

    The first method doesn't require any hardware mods, but should only
be used when you're absolutely sure that the output chip is an LS374.
Basically what you do is write the value 0xFF to the 374 which will then
make all of the 374's data bits 1's (voltagewise that usually comes out to 
about 3V). Then you can individually ground any of the data pins on the
DB25 and the value for the bit that you read back from the LS244 will
be 0 for as long as that pin is pulled down to 0V.

    The drawback of method 1 is that the LS374 remains active during
this time, and grounding one of the pins that it's trying to drive to 3V
causes a little extra strain to be placed on the output driver.
Fortunately, LSTTL is a very hardy logic family and chances are that
you'll never damage anything this way.

    However, if the output driver is just about anything else (i.e. CMOS
or higher powered Schotsky TTL), then the strain could blow the output 
driver.

    So when people realized this, along came method 2. In newer LPT
ports, the card is modified so that the outputs of the 374 (or whatever
is being used for the output driver) can be completely disabled. Older
cards can also be modified to do this. The bit that is used to enable/ 
disable the outputs is usually bit 5 of the control register, but I've
also seen bit 7 used in a Toshiba laptop. Check your manual to see which
bit to use. I haven't bothered to list the I/O addresses of the data or
control registers but they're well documented. Try Thom Hogan's 
_PC_Sourcebook_ (ISBN 1-55615-118-7) for the hard facts.

    Obviously there's a lot more that could be said on this topic. If
you'd like to read something I recommend Bruce Eckel's _Computer_
_Interfacing_With_C_And_Pascal_ (not sure of the ISBN, try your local
bookstore).

>------------------------------------------------------------------------
>Patrick Draper     "College is supposed to prepare you for the future,
>cps.msu.edu               but all my future's behind me." 
>draper@cps.msu.edu      -- My GrandPa, age 85, Fall 1990 graduate
>                           of Western Michigan University 
>------------------------------------------------------------------------

--
Nathan Engle             Software Juggler
Indiana University       Dept of Psychology
nengle@copper.ucs.indiana.edu
Technical Details
Message-ID: <1991May22.160613.9942@bronze.ucs.indiana.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!dali.cs.montana.edu!caen!sol.ctr.columbia.edu!bronze!copper!nengle
References: <1991May21.202043.24725@magnus.acs.ohio-state.edu> <1991May22.104513.22169@msuinfo.cl.msu.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!dali.cs.montana.edu!caen!sol.ctr.columbia.edu!bronze!copper!nengle
From: nengle@copper.ucs.indiana.edu (nathan engle)
Newsgroups: alt.msdos.programmer,comp.os.msdos.programmer
Subject: Re: Programming the printer port to read in data.
Message-ID: <1991May22.160613.9942@bronze.ucs.indiana.edu>
Date: 22 May 91 16:06:13 GMT
References: <1991May21.202043.24725@magnus.acs.ohio-state.edu> <1991May22.104513.22169@msuinfo.cl.msu.edu>
Sender: news@bronze.ucs.indiana.edu (USENET News System)
Distribution: usa
Organization: Indiana University, Bloomington
Lines: 96