[comp.sys.ibm.pc] Using the printer port for input

frisk@rhi.hi.is (Fridrik Skulason) (01/11/89)

I need to connect a set of eight switches to my PC. The most simple way 
to do it seems to be connecting them to the parallel port, and using it
as input port instead of output. 

My question is: Does anyone have a code fragment (in C, assembler or
whatever) for changing the port into an input port?

Thanks....
-- 
         Fridrik Skulason          University of Iceland
         UUCP  frisk@rhi.uucp      BIX  frisk

     This line intentionally left blank ...................

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

In article <704@krafla.rhi.hi.is>, frisk@rhi.hi.is (Fridrik Skulason) writes:
> I need to connect a set of eight switches to my PC. The most simple way 
> to do it seems to be connecting them to the parallel port, and using it
> as input port instead of output. 
> 
> My question is: Does anyone have a code fragment (in C, assembler or
> whatever) for changing the port into an input port?

Sorry, the standard PC parallel port hardware is not capable of being
used as an input port no matter how clever your code is.  

There was an article a few months ago in Steve Ciarcia's "Circuit Cellar
INK" magazine on a simple hardware modification to correct this
problem.  It requires cutting a trace, adding a wire, and is pretty
simple if you are good at tracing out paths on a circuit board.

-- 
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		

network@hgcvax.uucp (craig chaiken) (01/13/89)

In article <704@krafla.rhi.hi.is>, frisk@rhi.hi.is (Fridrik Skulason) writes:
> I need to connect a set of eight switches to my PC. The most simple way 
> to do it seems to be connecting them to the parallel port, and using it
> as input port instead of output. 
> 
> My question is: Does anyone have a code fragment (in C, assembler or
> whatever) for changing the port into an input port?
> 
(*** The following is an except of my, soon to be published book,    ***)
(*** _Blueprint of a Local Area Network_.  It soon be available from ***)
(*** M & T Publishing for $24.95 sometime around July.  The book     ***)
(*** provides the source code and details the hardware necessary to  ***)
(*** build an inexpensive, customized IBM PC Local Area network.     ***)
(*** Both hardware hackers an assembly language programmers, alike   ***)
(*** will find that it is chock full of useful information, and      ***)
(*** techniques.                                                     ***)

     The parallel port on the IBM PC was designed for use with a parallel
printer.  It provides 8 output-only lines, mapped to bits 0 through 7 of
I/O port 0378H, which are data bit 0 through data bit 7.  It provides 5
input-only lines. mapped to bits 3 through 7 of I/O port 0379H, which are
ERROR, SELECT, PAPER_END, ACKNOWLEDGE, and BUSY.  And it provides 4
input/output lines, mapped to bits 0 through 3 of I/O port 037AH, which
are STROBE, AUTO_LINE_FEED, INITIALIZE, and SELECT_IN (* Note -
in order to input from this port, you must first send 04H to I/O port
037AH *).  BUSY, AUTO_LINE_FEED, and STROBE input signals are inverted by
the hardware, and must be negated in software.

(*** End of Excerpt from Blueprint of a Local Area Network ***)

Craig Chaiken
Hartford Graduate Center
Computing Services

warren@psu-cs.UUCP (Warren Harrison) (01/14/89)

> In article <704@krafla.rhi.hi.is>, frisk@rhi.hi.is (Fridrik Skulason) writes:
> > I need to connect a set of eight switches to my PC. The most simple way 
> > to do it seems to be connecting them to the parallel port, and using it
> > as input port instead of output. 
> > 
> > My question is: Does anyone have a code fragment (in C, assembler or
> > whatever) for changing the port into an input port?
> 
> Sorry, the standard PC parallel port hardware is not capable of being
> used as an input port no matter how clever your code is.  
> 
> There was an article a few months ago in Steve Ciarcia's "Circuit Cellar
> INK" magazine on a simple hardware modification to correct this
> problem.  It requires cutting a trace, adding a wire, and is pretty
> simple if you are good at tracing out paths on a circuit board.
> 
> -- 
> 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		


It would seem this is the case, and I would believe it, except many
of the laptop to desktop data transfer utilities use the parallel port
to transfer data (ie, one parallel port sends it and one receives it).
For example, my copy of "The Interchange" (SMT, Inc.) includes a cable
which you connect to the parallel ports of the laptop and the desktop
to transfer files (in the event you don't have a 3.5" disk on the desktop).
This results in *VERY* fast data transfer (obviously faster than is
possible with a serial line).

The product specs do not mention anything about hardware modifications,
and it seems to work OK on my Amstrad laptop and my 286 clone (which are
about as plain vanilla as you can get).  This leads me to believe that
in fact you can use the parallel port as an I/O device (albeit, the cable
can't be more than 10' long) if you know what you're doing and are willing
to write the appropriate software.

Warren

-- 
-------------------------------------------------------------------------------
Warren Harrison                 CSNET: warren@pdx.edu
Department of Computer Science  UUCP:  {ucbvax,decvax}!tektronix!psu-cs!warren
Portland State University       Internet: warren%pdx.edu@relay.cs.net
Portland, OR 97207-0751

ralf@b.gp.cs.cmu.edu (Ralf Brown) (01/14/89)

In article <1502@psu-cs.UUCP> warren@psu-cs.UUCP (Warren Harrison) writes:
}It would seem this is the case, and I would believe it, except many
}of the laptop to desktop data transfer utilities use the parallel port
}to transfer data (ie, one parallel port sends it and one receives it).
...
}The product specs do not mention anything about hardware modifications,

These products probably use the five status lines which are usable as inputs.
I'm sure that the cables are specially wired to connect the data lines from
one port with the status lines of the other.

-- 
{harvard,uunet,ucbvax}!b.gp.cs.cmu.edu!ralf -=-=- AT&T: (412)268-3053 (school) 
ARPA: RALF@B.GP.CS.CMU.EDU |"Tolerance means excusing the mistakes others make.
FIDO: Ralf Brown at 129/31 | Tact means not noticing them." --Arthur Schnitzler
BITnet: RALF%B.GP.CS.CMU.EDU@CMUCCVMA -=-=- DISCLAIMER? I claimed something?
-- 

nather@ut-emx.UUCP (Ed Nather) (01/15/89)

In article <816@ttrde.UUCP>, pfales@ttrde.UUCP (Peter Fales) writes:
> In article <704@krafla.rhi.hi.is>, frisk@rhi.hi.is (Fridrik Skulason) writes:
> > I need to connect a set of eight switches to my PC. The most simple way 
> > to do it seems to be connecting them to the parallel port, and using it
> > as input port instead of output. 
> > 
> 
> Sorry, the standard PC parallel port hardware is not capable of being
> used as an input port no matter how clever your code is.  
> 

I'm glad I didn't know this when I wrote my "portfinder" routine, which
finds the port name of the printer port -- you have to put a dummy plug
in, which the program looks for.  It does this by sending out 4-bit
codes, then reading the various possible ports to see if it can find the
code -- by using lines in the output port as input bits.  As I recall
(it's been several years) I could only input 4 bit codes, not 8 bit --
there weren't enough input lines for 8 of them.  I did the input in
two-nibble bytes.


"`Impossible' is a challenge, not a truth."

-- 
Ed Nather
Astronomy Dept, U of Texas @ Austin

akm@uoregon.uoregon.edu (Anant Kartik Mithal) (01/15/89)

It certainly is possible to use the printer port for input. Lanlink is a
software based network that uses printer ports to obtain up to .5 Mbit/S
data transfer.

If I remember correctly, the hardware for the printer port is set up as
an I/O port, and there is nothing to stop anyone from inputting data on
the ports.

cas@hoptoad.uucp (Curtis Spangler) (01/15/89)

>  In article <704@krafla.rhi.hi.is>, frisk@rhi.hi.is (Fridrik Skulason) writes:
>> In article <816@ttrde.UUCP>, pfales@ttrde.UUCP (Peter Fales) writes:
>  [ text elided ] 
>  My question is: Does anyone have a code fragment (in C, assembler or
>  whatever) for changing the port into an input port?
>> Sorry, the standard PC parallel port hardware is not capable of being
>> used as an input port no matter how clever your code is.  
>> [ text elided ]

Reference:   The C Users Journal, Dec./Jan. 1989, Volume 7, Number 1
Address:     2120 W. 25th Street Suite B, Lawrence, KS 66046-9972
Telephone:   (913) 841-1631
Article:     High Speed, Real Time Data Acquisition In C
By:          J.F. Vibert & B. Cointot, page 39

Quoted without permission from page 48 of the above article:

"   Unfortunately, it appears from the available manuals that the printer
parallel interface is limited to solely output data.  When we checked the
ROM BIOS listing in the IBM PC/XT Technical Reference Manual we found that
the PPI chip which controls this port "can be read as well as written."
This led us to think that it was possible to use it as input, too.  This
proved to be true when we tested it (see Listing 8). "

"Listing 8" is a fragment in C titled sic "Function to demonstrate acquisition
with the parallele printer interface."


-- 
Curtis Spangler  {sun,pacbell,uunet,pyramid,amdahl}!hoptoad!cas  cas@toad.com

hundt@paul.rutgers.edu (Thomas M. Hundt) (01/16/89)

>many of the laptop ... transfer utilities use the parallel port to
>transfer data

Well, perhaps they are using the status lines, eg. "paper out", and
shoving it through at high speed this way.  So probably you can hook
up maybe 3 switches and be able to read their input.  I suspect the
transfer programs are using two lines, one for clock and one for data,
which would be sufficient.
-- 
RRRRRR    Thomas M. Hundt (aka hundt@occlusal.rutgers.edu)
 RR  RR   Gradual Student --- Electrical & Computer Engineering
 RR  RR   Rutgers University         201/932-5843(Lab)
 RRRRR    272 Hamilton St. #96       201/247-6723(H)
 RR  RR   New Brunswick, NJ  08901
RRR  RRR  Famous last words: "The virus ate it."

matthieu@laas.laas.fr (Matthieu Herrb) (01/16/89)

	I've seen many authors saying that it is impossible to
use // port as input.
	I don't have my technical reference manual here at work,
but all they say is that this is not recommended.
	I wrote a few years ago a program to grab byte from a silly
voltmeter, it uses 8 bit input and the // card used is still alive.

	
-- 
\  /  | Matthieu Herrb             LAAS - RIA
|\/|--| matthieu@idefix.laas.fr    7, avenue du Colonel Roche
|  |  |                            31077 Toulouse Cedex - France

pete@octopus.UUCP (Pete Holzmann) (01/21/89)

A couple of years ago I was interested in doing high-speed data transfer
between PC's. I checked the schematics and sure enough, as someone else
mentioned, there are 8 data out lines (normal data to printer), 5 input
status lines, and 4 lines normally for control output, but you can make
them input lines (sometimes by flipping a bit, but more reliably in my
experience by making the output float. Send a zero, I think, and you
can read whatever is out there...).

I had a set of test software running, and could do 70+KB/sec between two
PC's... never got around to turning it into a product. I wonder if it was
patentable?

Anyway, I'll probably never get around to doing anything useful with it.
As soon as I can rummage a little, I'll post some code to the net. Maybe
somebody can have some fun with it...

Pete

-- 
  OOO   __| ___      Peter Holzmann, Octopus Enterprises
 OOOOOOO___/ _______ USPS: 19611 La Mar Court, Cupertino, CA 95014
  OOOOO \___/        UUCP: {hpda,pyramid}!octopus!pete
___| \_____          Phone: 408/996-7746

james@bigtex.cactus.org (James Van Artsdalen) (01/22/89)

In <485@octopus.UUCP>, pete@octopus.UUCP (Pete Holzmann) wrote:
> A couple of years ago I was interested in doing high-speed data transfer
> between PC's. [...]

> I had a set of test software running, and could do 70+KB/sec between two
> PC's... never got around to turning it into a product. I wonder if it was
> patentable?

Well, not any more.  You have to file those patent papers within a
year.

In any case, there is an excellent commercial product called FastWire
that does just this (it can also use one or more serial ports for
transfers).  It is so fast that we use it to make backups of entire
hard disks at a time: a 30meg partition goes in a few minutes.
-- 
James R. Van Artsdalen          james@bigtex.cactus.org   "Live Free or Die"
DCC Corporation     9505 Arboretum Blvd Austin TX 78759         512-338-8789

chris@zorin.UUCP (Christopher Nielsen) (01/22/89)

In article <274@laas.laas.fr>, matthieu@laas.laas.fr (Matthieu Herrb) writes:
> 
> 	I've seen many authors saying that it is impossible to
> use // port as input.

I have an article in front of me:
	"A programmer's guide to the parallel port" by Bruce Eckel, that
appeared in "Turbo Technix". It describes using it in real world
applications. It's short (6 pages) but describes (with listings) of how to
programm the PC parallel port for input & output. He also mentions that 
the listings are available on compuserve as parallel.arc. Contact
information...

	Bruce Eckel
	Eisys
	1009 N 36th Street
	Seattle WA 98103

Christopher A. Nielsen
//////////////////            Zorin Data Systems, Inc
           ////      P.O. Box 5669 Santa Monica, CA 90405-0669  
        ////                      (213) 399-3804
     ////		  UUCP: hplabs!sdcrdcf!zorin!info
  ////
<<<<<<<<<<<<<<<<<<<<<<<<<<  Zorin... "The Future OnLine"  >>>>>>>>>>>>>>>>>>>>>
< Online Product Information and other services - Call or write for free demo >

oferf@shum.huji.AC.IL (ofer faigon) (01/26/89)

There waere several queries recently about reading input through
the parallel printer port, but I don't recall seeing any definitive
reply.

The following is quoted from Steve Ciarcia's Circuit Cellar that
appeared in BYTE, vol 13, No.9 (September 1988), page 305:

    Unfortunately, an irritating problem with the design of the PC
    is that its standard parallel printer port is output only.
    All the hardware needed to read or write 8 bits of data is
    already in place, but it lacks a connection to enable that
    function.  While you can buy a custom parallel I/O board, I think
    changing a single trace on the existing board might be worth it
    to some readers.  Figure 5 shows the single cut and addition to
    convert a standard paraller printer port to bidirectional operation.
    Of course, all the clone boards (even the IBM boards) seem to use
    different IC numbers and assign the bits to different pins on the
    ICs, so this modification can be a real mystery.  If you are unwilling
    to chop up your printer port card, buy a $50 clone printer port card.
    They are usually bidirectional.  Some clone boards also omit the input
    connection between the data bus and pin 14 of the LS174.
    ...[some text deleted]...
    ...(a modified port will stil work correctly with all your other
    software, simply because the code doesn't know about the change
    and won't take advantage of it).

Figure 5 appears on page 310, and is a bit hard to reproduce here.
What it shows is the three chips involved (74LS374, 74LS244 and 74LS174),
and the one (or two) modifications needed:

- Disconnecting the output-enable pin (1) of the 374 from ground,
  and connecting it to the unused output pin on the 174 (the figure
  shows a connection to pin 15 - Q6, assuming Q1-Q5 are in use).

- If the connection between BDATA5 ant the input side of the 174
  is missing, then connect them (the figure shown connection to
  pin 14 - 6D, assuming 1D-5D are connected to BDATA0-4).

And a final quotation: "Actual pin numbers on your board will vary;
Trace the wiring from the DB25 connector to identify the right traces
and pins".

Have fun.

- Ofer Faigon                                         TEL: +972-2-669-834
  MAIL: P.O.B 7347, Jerusalem 91072, ISRAEL
  BITNET: oferf@HUJINIX         CSNET & INTERNET: oferf@shum.huji.ac.il