Article View: comp.sys.ibm.pc.misc
Article #7139PC parallel port input/output access
From: Murray Thessman
Date: Thu, 24 Jan 1991 06:53
Date: Thu, 24 Jan 1991 06:53
105 lines
4765 bytes
4765 bytes
FSC-Control: EID:d9a7 163896b5
From: Murray Thessman
Keywords: parallel port I/O
Organization: GenBOARD of Wellington New Zealand, INFN# (3:771/160)
In a msg from BonaFido (our UseNet gateway) 22-Jan-91, Winthrop Chan wrote ..
>WDC: Hi, I'm trying to find data on how to use the IBM-PC parallel port
for
>WDC: both output and INPUT. I know this can be done since quite a few
>WDC: transfer programs do this trick. I need port numbers and how they
do >WDC: it.
I repeat a msg I wrote to David Ingram in Zone3_Tech on Fido on 5-Jan-91. I
hope that this is what you were after....
In a message of <Jan 01 15:12>, David Ingram (3:770/110) writes:
>DI: Could somebody please tell me how I can control the printer port for
>DI: input and output (e.g. controlled a robot).
The standard parallel printer port found on most Herc, EGA or parallel
printer
port is made up of 3 separate ports: an 8 bit output, a 5 bit input and a 4
bit
quuasi bi-directional port.
The 8 bit is quite straight forward. The 8 bit data is sent to an Octal
latch
(74LS374) then directly to the D25 (bits 0-7 -> DB25 pins 2, 3, 4, 5, 6, 7,
8,
9). There is also an octal tristate buffer (74LS244) to provide feedback
which
allows some printer drivers to verify the integrity (ie no short circuits).
Both these ICs have the same address.
The 5 bit input port is via means of inverting tristate buffers but before
reaching the buffers SOME bits pass through additional inverters. These bits
have been inverted twice and will therefore be correct! (bits 3-7 -> DB25
pins
15, 13, 12, 10, 11). Only bit 7 needs inverting by software. Note that DB25
pin
10 (Bit 6) is also connected to interrupt IRQ7 and can be used to generate
interupts if these are enabled.
The 4 bit quasi bi-directional port use open collector output drivers with
4K7
pull-up resistors on board. By switching the output drivers off (ie logic 1
state) the port can be used as an input port. This means that to switch the
output drivers off the bit pattern 0100 (04 decimal) must be output to this
port. When inputting, the input buffer is itself an inverter so that the
line
that passes through a further inverter (bit b2) will be input in the correct
sense. This means that the remaining bits b0, b1, and b3 will need inverting
by
the software.
To save you working out the (almost complicated) logic <grin>
Constant
BasePort = $378 { change to $3BC if on EGA or Herc }
{ see table below }
Procedure InitInput; { init bi-direct port to input only}
Port[BasePort + 2]:= 04; { switch off drivers }
end;
Procedure InputIBM (var combined: byte);
{ Input from 4-bit and 5-bit ports, combine into a single 8-bit number
and corrects inverted bits }
var
hi,lo : byte;
begin
hi:=Port[BasePort + 1] and $F0; { input }
lo:=Port[BasePort + 2] and $0F { input }
combined := hi or lo; { combined nibbles }
combined := combined xor $8B; { invert bits 0, 1, 3, 7 }
end;
One last thing the port adresses
PARRALLEL EGA or
PORT PRINTER CARD HERCULES CARD
8 bit outport 378 Hex 3BC Hex
5 bit input 379 Hex 3BD Hex
4 bit bi-directional 37A Hex 3BE Hex
[ The above information was obtained from NEWelectronicS/March 1988
'Getting the best from a standard printer port - Jeff Broard' Pg 33]
>DI: I'm sure it can be done somehow.
Yes you where right! I plan to use the printer port it to switch the modem
off
and back on if I get a 'Modem not okay' (exit error 2) from OPUS to reset
everything. BTW LPT 2 & LPT 3 Will have different addresses.
[Just as a trailer I wouldn't mind a reply from you if you get this (always
suspicious of gateways - sorry John)]
regards Murray
--- msged 2.05
* Origin: GenBOARD, A genealogy BBS: Wgtn,NZ (64)(4)4990-490 (3:771/160)
SEEN-BY: 771/110 150 160 170 180 772/20
FSC-Control: PATH: 771/160 110
Technical Details
Message-ID:
<9101262155.AA35947@f170.n771.z3.fidonet.org>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!sdd.hp.com!spool2.mu.edu!uunet!munnari.oz.au!comp.vuw.ac.nz!actrix!fnet!Murray_ThessmanShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!sdd.hp.com!spool2.mu.edu!uunet!munnari.oz.au!comp.vuw.ac.nz!actrix!fnet!Murray_Thessman From: Murray_Thessman@f170.n771.z3.fidonet.org (Murray Thessman) Newsgroups: comp.sys.ibm.pc.misc Subject: PC parallel port input/output access Message-ID: <9101262155.AA35947@f170.n771.z3.fidonet.org> Date: 24 Jan 91 06:53:43 GMT Reply-To: Murray_Thessman@f160.n771.z3.fidonet.org (Murray Thessman) Lines: 105 Comment-To: Winthrop_D_Chan@f160.n771.z3.fidonet.org (Winthrop D Chan)