Category : Printer Utilities
Archive   : PARALLEL.ZIP
Filename : PARALLEL.DOC

 
Output of file : PARALLEL.DOC contained in archive : PARALLEL.ZIP





This document details the RS232 parallel printer ports of the IBM-PC
Each of the printer ports conforms to a modified Centronics Parallel
Interface. The connection to the PC is through a DB25 25 pin connector.
The IBM-PC will support up to three parallel ports. Each port provides
12 TTL outputs and 5 TTL inputs. This document contains the following
data:
a. DB25 PINOUT, and signal names where known.
b. PORT addresses of each parallel port.
c. DATA, CONTROL, and INPUT PORTS pinouts w/bit positions
within each byte.
d. Example programs written in C highlighting input and
output to the ports.
e. Clock display circuit diagram w/parts list.
f. Closing comment.

DB25 PINOUT

ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
-STROBE ---> º 1 º
º 14 º <------ -AUTO FEED
D0 -------> º 2 º
º 15 º ------> ?
D1 -------> º 3 º
º 16 º <------ INITIAL
D2 -------> º 4 º
º 17 º <------ -?
D3 -------> º 5 º
º 18 º <------+
D4 -------> º 6 º |
º 19 º G |
D5 -------> º 7 º |
º 20 º R | ÉÍÍ»
D6 -------> º 8 º | Output Signal ----> º º
º 21 º O | (From Computer) ÈÍͼ
D7 -------> º 9 º |
º 22 º U |
ACK <------ º 10 º |
º 23 º N |
-BUSY <----- º 11 º | ÉÍÍ»
º 24 º D | Input Signal <---- º º
PE <------- º 12 º | (To Computer) ÈÍͼ
º 25 º <------+
SEL <------ º 13 º
ÈÍÍÍÍÍÍÍÍÍÍÍÍÍͼ


Pins 1, 11, 14, 17 are negative TTL, meaning

0 is ON & 1 is OFF



PARALLEL Port Addresses DATA PORT (Output from computer)


LPT1: 956 3BC Hex
LPT2: 888 378 Hex
LPT3: 632 278 Hex


ÉÍÍÍÍÍÍÑÍÍÍÍÍÍÑÍÍÍÍÍÍÑÍÍÍÍÍÍÑÍÍÍÍÍÍÑÍÍÍÍÍÍÑÍÍÍÍÍÍÑÍÍÍÍÍÍ»
º ³ ³ ³ ³ ³ ³ ³ º
º ³ ³ ³ ³ ³ ³ ³ º
º D7 ³ D6 ³ D5 ³ D4 ³ D3 ³ D2 ³ D1 ³ D0 º
º ³ ³ ³ ³ ³ ³ ³ º
º ³ ³ ³ ³ ³ ³ ³ º
ÈÍÍÍÍÍÍÏÍÍÍÍÍÍÏÍÍÍÍÍÍÏÍÍÍÍÍÍÏÍÍÍÍÍÍÏÍÍÍÍÍÍÏÍÍÍÍÍÍÏÍÍÍÍÍͼ


PIN # 9 8 7 6 5 4 3 2
BIT # 7 6 5 4 3 2 1 0
VALUE 128 64 32 16 8 4 2 1



PARALLEL Port Addresses CONTROL PORT (Output from computer)


LPT1: 958 3BE Hex
LPT2: 890 37A Hex
LPT3: 634 27A Hex



ÉÍÍÍÍÍÍÑÍÍÍÍÍÍÑÍÍÍÍÍÍÑÍÍÍÍÍÍÑÍÍÍÍÍÍÑÍÍÍÍÍÍÑÍÍÍÍÍÍÑÍÍÍÍÍÍ»
º ³ ³ ³ ³ ³ ³ ³ º
º ³ ³ ³ ³ ³ ³ ³ º
º NA ³ NA ³ NA ³ NA ³ -? ³ INIT ³ -AF ³ -ST º
º ³ ³ ³ ³ ³ ³ ³ º
º ³ ³ ³ ³ ³ ³ ³ º
ÈÍÍÍÍÍÍÏÍÍÍÍÍÍÏÍÍÍÍÍÍÏÍÍÍÍÍÍÏÍÍÍÍÍÍÏÍÍÍÍÍÍÏÍÍÍÍÍÍÏÍÍÍÍÍͼ


PIN # - - - - 17 16 14 1
BIT # - - - - 3 2 1 0
VALUE - - - - 8 4 2 1


Notes:

1. -? denotes negative TTL signal, name unknown.
2. INIT is INITIAL.
3. -AF is negative TTL signal, AUTOFEED is signal name.
4. -ST is negative TTL siganl, STROBE is signal name.
5. NA not applicable.




PARALLEL Port Addresses INPUT PORT (Input to computer)


LPT1: 957 3BD Hex
LPT2: 889 379 Hex
LPT3: 633 279 Hex



ÉÍÍÍÍÍÍÑÍÍÍÍÍÍÑÍÍÍÍÍÍÑÍÍÍÍÍÍÑÍÍÍÍÍÍÑÍÍÍÍÍÍÑÍÍÍÍÍÍÑÍÍÍÍÍÍ»
º ³ ³ ³ ³ ³ ³ ³ º
º ³ ³ ³ ³ ³ ³ ³ º
º -BUSY³ ACK ³ PE ³ SEL ³ ? ³ NA ³ NA ³ NA º
º ³ ³ ³ ³ ³ ³ ³ º
º ³ ³ ³ ³ ³ ³ ³ º
ÈÍÍÍÍÍÍÏÍÍÍÍÍÍÏÍÍÍÍÍÍÏÍÍÍÍÍÍÏÍÍÍÍÍÍÏÍÍÍÍÍÍÏÍÍÍÍÍÍÏÍÍÍÍÍͼ


PIN # 11 10 12 13 15 - - -
BIT # 7 6 5 4 3 - - -
VALUE 128 64 32 16 8 - - -


Notes:

1. ? signal name unknown.
2. NA not applicable.
3. -BUSY is negative TTL signal.




Example of Negative TTL logic


PIN # 6 5 4 3 2
BIT # 4 3 2 1 0
VALUE 16 8 4 2 1


ÉÍÍÍÍÍÑÍÍÍÍÍÑÍÍÍÍÍÑÍÍÍÍÍÑÍÍÍÍÍÑÍÍÍÍÍÑÍÍÍÍÍÑÍÍÍÍÍ»
º ³ ³ ³ ³ ³ ³ ³ º
º - ³ - ³ - ³ 1 ³ 0 ³ 0 ³ 0 ³ 0 º DATA PORT
º ³ ³ ³ ³ ³ ³ ³ º
ÈÍÍÍÍÍÏÍÍÍÍÍÏÍÍÍÍÍÏÍÍÍÍÍÏÍÍÍÍÍÏÍÍÍÍÍÏÍÍÍÍÍÏÍÍÍÍͼ

| | | | |
| | | | |

ÉÍÍÍÍÍÑÍÍÍÍÍÑÍÍÍÍÍÑÍÍÍÍÍÑÍÍÍÍÍÑÍÍÍÍÍÑÍÍÍÍÍÑÍÍÍÍÍ»
º ³ ³ ³ ³ ³ ³ ³ º
INPUT PORT º 0 ³ 0 ³ 0 ³ 0 ³ 0 ³ - ³ - ³ - º
º ³ ³ ³ ³ ³ ³ ³ º
ÈÍÍÍÍÍÏÍÍÍÍÍÏÍÍÍÍÍÏÍÍÍÍÍÏÍÍÍÍÍÏÍÍÍÍÍÏÍÍÍÍÍÏÍÍÍÍͼ

PIN # 11 10 12 13 15
BIT # 7 6 5 4 3
VALUE 128 64 32 16 8


Notes:

1. A 1 bit in the DATA port causes 2.5 to 5.0 volts
to appear on the cooresponding pin on the DB25 connector.
In the example above PIN # 6 is on.

2. BIT # 7 of the INPUT port has negative TTL logic, where
2.5 to 5.0 volts on PIN # 11 is logic level zero. The other
bits of the INPUT port are normal TTL logic.


/* CLOCKC.C ==> This program runs the binary clock */

#include "conio.h"
#define PORT_HR 634
#define PORT_MIN 632
#define OFF_MIN 0
#define OFF_HRS 0x0b
#define WINK 64 /* bit 7 of minute byte used for seconds */

main()
{
unsigned char ctr_min, ctr_hr, status, hours, minutes, seconds,
hundrds, lastsec, second_on();
void time(), turn_on(), turn_off();

/* start by turning off all circuits */

ctr_min = OFF_MIN;
ctr_hr = OFF_HRS;

outp (PORT_HR, ctr_hr);
outp (PORT_MIN, ctr_min);

/* the clock will run indefinately */

for (;;) {

/* get the time */
time(&hours, &minutes, &seconds, &hundrds);

/* the hours require special handling, DOS returns hours in 24 */
/* hour format. Convert to 12 hr format. Next XOR hours against */
/* OFF_HRS to get the proper bit pattern for the hours. */

ctr_hr = ((hours = hours % 12) ? hours : 12) ^ OFF_HRS;

/* the minutes are easy, output ASIS */

ctr_min = minutes;

/* Display the hours and minutes */

outp (PORT_HR, ctr_hr);
outp (PORT_MIN, ctr_min);

/* wink the seconds, up to the next minute */




for (lastsec = seconds; seconds <= 59; ) {

time (&hours, &minutes, &seconds, &hundrds);

if (lastsec != seconds) { /* seconds has changed */

lastsec = seconds;

/* if second is on turn off, else turn on */

if (!second_on(ctr_min, WINK))

turn_on (PORT_MIN, &ctr_min);
else

turn_off (PORT_MIN, &ctr_min);

}

/* seconds up to 59, exit loop */

if (seconds == 59)
break;


}
}

}

unsigned char second_on(control, sec)
unsigned char control, sec;
{
return (control & sec);

}

void turn_on (port, control)
unsigned char *control;
int port;
{
*control = *control | WINK;

outp (port, *control);

}

void turn_off (port, control)
unsigned char *control;
int port;
{
*control = *control & ~WINK;

outp (port, *control);

}



/* PORTTST.C -- This program is used to determine if the info */
/* I have gathered about Input Ports is correct. The program */
/* is to send pre-determined values to PORT 632 bits 0-4 */
/* the bits coorespond to pins 2-6 of a printer parallel port. */
/* Pins 2-6 are then connected to Pins 15,13,12,10,11 respec- */
/* tively. Pins 10-13,15 coorespond to Bits 7-3 of Input PORT */
/* 633. For a given input a pre-determined set of values will */
/* be returned. Pin 11 of the Input port is negative TTL */

#define PORTE 633
#define PORTD 632
#include "conio.h"

main()
{
static char test_values [] = {16, 17, 18, 20, 24, 0};

/* test_value => 16 return 0 */
/* test_value => 17 return 1 */
/* test_value => 18 return 2 */
/* test_value => 20 return 4 */
/* test_value => 24 return 8 */
/* test_value => 0 return 16 */

unsigned char bit, send;
void porttst();

/* turn off all bits in send */

for (bit = 0; bit < sizeof(test_values); bit++) {

porttst (PORTD, PORTE, *(test_values + bit));

}

}
void porttst (pd, pe, send)
int pd, pe;
unsigned char send;
{
unsigned char result;
int bits();

outp (pd, send);

result = inp(pe);

/* display the bit patterns sent and recieved */

printf ("\nOut Value ");
bits (4, 0, send);
printf (" In Value ");
bits (7, 3, result);

}



OUTPUT from PORTTST.C


C>porttst

Out Value 10000 In Value 00000
Out Value 10001 In Value 00001
Out Value 10010 In Value 00010
Out Value 10100 In Value 00100
Out Value 11000 In Value 01000
Out Value 00000 In Value 10000




/* DTIME.C ==> This program generates binary code representing */
/* 0 to 12, which are then output from the computers control port */
/* (actually part of the parallel printer port) to 4 LED's that */
/* are connected to pins 1, 14, 16 & 17 of the parallel port */
/* with the first being binary digit 0 and the latter being digit */
/* 3. */
/* See diagram of the Control Port for more data. */

#define CONTROL_PORT 634
#define XOR 0xb

main()
{
char count, send;
int bits();

printf("\nCOUNT\tHOUR\t\tXOR\t ACTUAL BITS\n");

for (count = 0; count <= 12; count++) {

send = count ^ XOR;
outp(CONTROL_PORT, send);

/* in practice the following is not used. it exists */
/* for illustration purposes only. */

printf ("\n%4d\t", count);
bits (3, 0, count);

printf ("\t\t");
bits (3, 0, XOR);

printf ("\t\t");
bits (3, 0, send);

}

}

COUNT HOUR XOR ACTUAL BITS

0 0000 1011 1011
1 0001 1011 1010
2 0010 1011 1001
3 0011 1011 1000
4 0100 1011 1111
5 0101 1011 1110
6 0110 1011 1101
7 0111 1011 1100
8 1000 1011 0011
9 1001 1011 0010
10 1010 1011 0001
11 1011 1011 0000
12 1100 1011 0111


CLOCK CIRCUIT

Minutes Display (uses DATA PORT)


PIN # R1 D1

2 o----/\/\/-------|<-------+
| <--- Ground uses pins
R2 D2 | 18 - 25.
|
3 o----/\/\/-------|<-------|
|
R3 D3 |
| Parts List:
4 o----/\/\/-------|<-------|
| R1 - R10: 220æ «w resistors
R4 D4 | D1 - D10: 2.5vdc @20ma LED's
|
5 o----/\/\/-------|<-------| Misc:
|
R5 D5 | 1 - DB25 male connector
| snap on is best.
6 o----/\/\/-------|<-------|
| 1 - 25 line ribbon cable
R6 D6 |
|
7 o----/\/\/-------|<-------|
ð


Hours Display (uses CONTROL PORT)



PIN # R7 D7

1 o----/\/\/-------|<-------+
| <--- Ground uses pins
R8 D8 | 18 - 25.
|
14 o----/\/\/-------|<-------|
|
R9 D9 |
|
16 o----/\/\/-------|<-------|
|
R10 D10 |
|
17 o----/\/\/-------|<-------|
ð



Closing comment.

I hope that the information contained within this document is usefull,
although usefullness depends upon who is doing the looking.

The programs listed are very simple in terms of capabilities. If there
is anyone in BBS Land who is capable (read willing) of writing a TSR
that can drive the clock circuit, Please contact me:

Michael N. White, President
MNW Consulting
6715 Red Top Rd
Takoma Park, Md. 20912
(301)559-5585

The TSR should come with theory of operation and source code. The
program is to be used for demonstration purposes only, and to further
my knowledge of TSR.




  3 Responses to “Category : Printer Utilities
Archive   : PARALLEL.ZIP
Filename : PARALLEL.DOC

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/