For simple, byte-world or analogue I/O, PC expansion slots offer a far from cost-effective solution. But there is a very low-cost and easy to implement alternative path to simple i/o in the guise of the standard Centronics printer port, as we will explain.
On PC compatibles, the printer port is complies with the Centronics standard, which involves transfer of eight parallel bits of date at a time. To control data flow, a number of handshaking bits are needed, bringing the total number of lines to 17. These comprise 12 outputs and 5 inputs. All the lines are TTL compatible, simplifying interfacing. Table 1 summarises connections at the PC end.
For controlling printer data flow, there are three bytes in the PC I/O map. Addresses of these bytes depend on which of the four LPT printer ports is being accessed. Generally, LPT1 address is at 37816 and LPT2 is at 27816 but these addressees may vary, Table 2.
Table 1. Pin-out of the almost universal Centronics printer port. |
|||||
Pin |
I/o |
Centronics signal |
Pin |
I/O |
Centronics signal |
1 |
O |
Data strobe |
14 |
O |
Auto line feed |
2 |
O |
Data bit 0 |
15 |
I |
Error status |
3 |
O |
Data bit 1 |
16 |
O |
Initialise |
4 |
O |
Data bit 2 |
17 |
O |
Select |
5 |
O |
Data bit 3 |
18 |
- |
0V line |
6 |
O |
Data bit 4 |
19 |
- |
0V line |
7 |
O |
Data bit 5 |
20 |
- |
0V line |
8 |
O |
Data bit 6 |
21 |
- |
0V line |
9 |
O |
Data bit 7 |
22 |
- |
0V line |
10 |
I |
Data acknowledge |
23 |
- |
0V line |
11 |
I |
Busy |
24 |
- |
0V line |
12 |
I |
Out of paper |
25 |
- |
0V line |
13 |
I |
Selected |
|||
| Table 2. Within the PC I/O map, these three bytes are available for controlling the printer port. Their position on the map depend on whether they relate to LPT1,2,3 or 4. | |||
Bit |
Base |
Base+1 |
Base+2 |
0 |
Data bit 0 |
Unused |
Data strobe |
1 |
Data bit 1 |
Unused |
Auto linefeed |
2 |
Data bit 2 |
Unused |
Initialise |
3 |
Data bit 3 |
Error status |
Select |
4 |
Data bit 4 |
Selected |
Interrupt enable |
5 |
Data bit 5 |
Out of paper |
Not used |
6 |
Data bit 6 |
Data acknowledge |
Not used |
7 |
Data bit 7 |
Busy |
Not used |
| Notes: Bit 0 is the least significant bit. Base is 37816 for LPT1, 27816 for LPT2. Base and base+2 are write only, base+1 is read only. Bit 4 of base+2 is not available on the port but is an internal line used to enable printer port interrupts. | |||
In summery the pines available are:
Address |
Port |
Lines |
Base |
0 |
8 outputs |
Base+1 |
1 |
5 inputs (1 interrupt) |
Base+2 |
2 |
5 outputs |
In our project the interface is simpler than that, the device we are doing the interface for accepts digital output, so no need for D-to-A and A-to-D conversion and sampling.
Our part in the project was to write the software for an already built hardware.
The hardware is a machine that is built in the LAB and used to make a Printed Circuit Board. It consist of three stepper motors one for each X, Y, Z directions, each motor needs four inputs to operate, and they are all pulses in specific sequence that will move the motor one step forward or backward. So we need four bits output for the X motor and four bits output for Y motor and four bits output for Z motor. The interface was just driver consists of two 74374 TTL chips ( ) as in the figure 2-1.
For the system to be practical it must read an "NC Drill File", which is generated after the design of a circuit in a standard PCB software such as "PSpice". So software must understand the format of the NC Drill File and convert it to commands to the PCB machine. As expected the software have to be written in the Intel assembly, but because of the power of C++ and its low level language capabilities I wrote it in C++.[Home] [Articles] [Resume] [DSP & ES] [Wavelet Shopping] [Wavelet Resources] [Links] [Contact Us]
Send
mail to madani@ieee.org with questions or comments
about this web site.
Copyright © 1999 by Salem AL-Madani. All rights reserved.