Parallel Port (Printer port or LPT) Information
Understand in Parallel Port or Printer Port ,LPT
I thing,you know the printer port that after refer it again, I will be say the Parallel Port ,
May be you have not still understand it in control and access its for interfacing to another hardware.
We can interface hardware and device with parallel port in PC programming (such as VB,VC++,.NET,
So,This article help you know about information of using in Parallel port.
Most PC's have one Parallel ports. It has a 25 pin connector on the back of the computer.
Computer programs can send data (bytes) to Data pin (output) and receive bytes from the receive pin
(input). The other pins are for control purposes and ground. These are like the picture below.
The Parallel port is I/O(Input and Output) device. An I/O device is just a way to get data into and
out of a computer using. There are many types of I/O devices such as serial ports, parallel ports, disk drive
controllers, ethernet boards, universal serial buses, etc.
The Parallel Port is the most commonly used port for interfacing home made projects. This port will allow
the input of up to 9 bits or the output of 12 bits at any one given time, thus requiring minimal external circuitry
to implement many simpler tasks. The port is composed of 4 control lines, 5 status lines and 8 data lines.
It's found commonly on the back of your PC as a D-Type 25 Pin female connector.
There may also be a D-Type 25 pin male connector. This will be a serial RS-232 port and thus, is a totally
Newer Parallel Portís are standardized under the IEEE 1284 standard first released in 1994. This standard
defines 5 modes of operation which are as follows,
- Compatibility Mode.
- Nibble Mode. (Protocol not Described in this Document)
- Byte Mode. (Protocol not Described in this Document)
- EPP Mode (Enhanced Parallel Port).
- ECP Mode (Extended Capabilities Port).
Wring Pins and Wires Diagram for DB25 in Parallel Port connector
Teble below is show inforamtion of Pins and Wries including such as
DB25 pins compare with Printer port I/O address,Printer wring , wring etc.
On the picture below is a picture of the "Pin Outs" of the D-Type 25 Pin connector and the
Centronics 34 Pin connector.
The D-Type 25 pin connector is the most common connector found on the Parallel Port of
the computer, while the Centronics Connector is commonly found on printers. The IEEE 1284
standard however specifies 3 different connectors for use with the Parallel Port. The first one,
1284 Type A is the D-Type 25 connector found on the back of most computers. The 2nd is the
1284 Type B which is the 36 pin Centronics Connector found on most printers.
The output of the Parallel Port is normally TTL logic levels. The voltage levels are the easy part.
The current you can sink and source varies from port to port. Most Parallel Ports implemented in ASIC,
can sink and source around 12mA. However these are just some of the figures taken from Data sheets,
Sink/Source 6mA, Source 12mA/Sink 20mA, Sink 16mA/Source 4mA, Sink/Source 12mA.
As you can see they vary quite a bit. The best bet is to use a buffer, so the least current is drawn
from the Parallel Port.
Understand in Parallel Port Communication
Compatibility mode or "Centronics Mode" as it is commonly known, can only send data in the
forward direction at a typical speed of 50 kbytes per second but can be as high as 150+ kbytes a
second. In order to receive data, you must change the mode to either Nibble or Byte mode. Nibble
mode can input a nibble (4 bits) in the reverse direction. E.g. from device to computer. Byte mode
uses the Parallel's bi-directional feature (found only on some cards) to input a byte (8 bits) of data in
the reverse direction.
Extended and Enhanced Parallel Ports use additional hardware to generate and manage handshaking.
To output a byte to a printer (or anything in that matter) using compatibility mode, the software must.
This limits the speed at which the port can run at. The EPP & ECP ports get around this by letting
the hardware check to see if the printer is busy and generate a strobe and /or appropriate handshaking.
This means only one I/O instruction need to be performed, thus increasing the speed.
These ports can output at around 1-2 megabytes per second. The ECP port also has the advantage of using
DMA channels and FIFO buffers, thus data can be shifted around without using I/O
- Write the byte to the Data Port.
- Check to see is the printer is busy. If the printer is busy, it will not accept any data, thus any
data which is written will be lost.
- Take the Strobe (Pin 1) low. This tells the printer that there is the correct data on the data lines. (Pins 2-9)
- Put the strobe high again after waiting approximately 5 microseconds after putting the strobe low. (Step 3)
How to Parallel interfacing
Output Signal Control
We can control signal of the printer output in programming but we will be understand its process.
The non bi-directional ports were manufactured with the 74LS374's output enable tied
permanent low, thus the data port is always output only. When you read the Parallel Port's data
register, the data comes from the 74LS374 which is also connected to the data pins. Now if you can
overdrive the '374 you can effectively have a Bi-directional Port. (or a input only port, once you blow
up the latches output!)
What is very concerning is that people have actually done this. I've seen one circuit, a scope
connected to the Parallel Port distributed on the Internet. The author uses an ADC of some type, but
finds the ADC requires transistors on each data line, to make it work! No wonder why. Others have
had similar trouble, the 68HC11 cannot sink enough current (30 to 40mA!)
Bi-directional ports use Control Bit 5 connected to the 374's OE so that it's output drivers can
be turned off. This way you can read data present on the Parallel Port's Data Pins, without having bus
conflicts and excessive current drains.
Bit 5 of the Control Port enables or disables the bi-directional function of the Parallel Port.
This is only available on true bi-directional ports. When this bit is set to one, pins 2 to 9 go into high
impedance state. Once in this state you can enter data on these lines and retrieve it from the Data Port
(base address). Any data which is written to the data port will be stored but will not be available at the
data pins. To turn off bi-directional mode, set bit 5 of the Control Port to '0'.
However not all ports behave in the same way. Other ports may require setting bit 6 of the
Control Port to enable Bi-directional mode and setting of Bit 5 to dis-enable Bi-directional mode,
Different manufacturers implement their bi-directional ports in different ways. If you wish to use your
Bi-directional port to input data, test it with a logic probe or multimeter first to make sure it is in bi
Input Signal Control
This inforamtion is show how to using printer port to input signal 8 bits.
If your Parallel Port doesn't support bi-directional mode, don't despair.
You can input a maximum of 9 bits at any one given time.
To do this you can use the 5 input lines of the Status Port and the 4 inputs (open collector)
lines of the Control Port.
Input Signal 8 bit Diagram Picture
The inputs to the Parallel Port has be chosen as such, to make life easier for us.
Busy just happens to be the MSB (Bit 7) of the Status Port, then in ascending order comes Ack,
Paper Out and Select, making up the most significant nibble of the Control Port.
The Bars are used to represent which inputs are Hardware inverted, i.e. +5v will read 0 from the register,
while GND will read 1. The Status Port only has one inverted input.
The Control port is used to read the least significant nibble. As described before,
the control port has open collector outputs, i.e. two possible states, high impedance and GND.
If we connect our inputs directly to the port (For example an ADC0804 with totem pole outputs) ,
a conflict will result if the input is high and the port is trying to pull it down. Therefore we use open collector inverters.
However this is not always entirely necessary. If we were connecting single pole switches
to the port with a pull up resistor, then there is no need to bother with this protection.
Also if your software initializes the control port with xxxx0100 so that all the pins on the control port are high,
then it may be unnecessary. If however you donít bother and your device is connected to the Parallel Port
before your software has a chance to initialize then you may encounter problems.
Another problem to be aware of is the pull up resistors on the control port. The average pull-up resistor is 4.7k.
In order to pull the line low, your device will need to sink 1mA, which some low powered devices may struggle to do.
Now what happens if I suggest that some ports have 1K pull up resistors? Yes, there are such cards.
Your device now has to sink 5mA. More reason to use the open collector inverters.
Open collector inverters were chosen over open collector buffers as they are more popular,
and thus easier to obtain. There is no reason, however why you canít use them.
Another possibility is to use transistors.
The input, D3 is connected via the inverter to Select Printer. Select Printer just happens to be bit 3
of the control port. D2, D1 & D0 are connected to Init, Auto linefeed and strobe,
respectively to make up the lower nibble. Now this is done, all we have to do is assemble
the byte using software. The first thing we must do is to write xxxx0100 to the Control Port.
This places all the control port lines high, so they can be pulled down to input data.
outportb(CONTROL, inportb(CONTROL) & 0xF0 | 0x04);
Now that this is done, we can read the most significant nibble. This just happens to be
the most significant nibble of the status port. As we are only interested in the MSnibble
we will AND the results with 0xF0, so that the LSnibble is clear. Busy is hardware inverted,
but we wonít worry about it now. Once the two bytes are constructed, we can kill two birds
with one stone by toggling Busy and Init at the same time.
a = (inportb(STATUS) & 0xF0); /* Read MSnibble */
We can now read the LSnibble. This just happens to be LSnibble of the control port - How convenient!
This time we are not interested with the MSnibble of the port, thus we AND the result
with 0x0F to clear the MSnibble. Once this is done, it is time to combine the two bytes together.
This is done by ORíing the two bytes. This now leaves us with one byte, however we are not finished yet.
Bits 2 and 7 are inverted. This is overcome by XORíing the byte with 0x84, which toggles the two bits.
a = a |(inportb(CONTROL) & 0x0F); /* Read LSnibble */
a = a ^ 0x84; /* Toggle Bit 2 & 7 */
Note: Some control ports are not open collector, but have totem pole outputs.
This is also the case with EPP and ECP Ports. Normally when you place a Parallel Port in ECP or EPP mode,
the control port becomes totem pole outputs only. Now what happens if you connect your device
to the Parallel Port in this mode? Therefore, in the interest of portability I recommend using the next circuit,
reading a nibble at a time.
Using Nibble Mode
The Picture below is show diagram in using nibble mode with IC 74LS157.
Nible mode Diagram Picture
The Nibble mode is the preferred way of reading 8 bits of data without placing the port in reverse mode and
using the data lines. Nibble mode uses a Quad 2 line to 1 line multiplexer to read a nibble of data at a time.
Then it ďswitchesĒ to the other nibble and reads its. Software can then be used to construct the two nibbles
into a byte. The only disadvantage of this technique is that it is slower. It now requires a few I/O instructions
to read the one byte, and it requires the use of an external IC.
The operation of the 74LS157, Quad 2 line to 1 line multiplexer is quite simple. It simply acts as four switches.
When the A/B input is low, the A inputs are selected. E.g. 1A passes through to 1Y, 2A passes through to 2Y etc.
When the A/B is high, the B inputs are selected. The Y outputs are connected up to the Parallel Portís status port,
in such a manner that it represents the MSnibble of the status register. While this is not necessary,
it makes the software easier.
To use this circuit, first we must initialize the multiplexer to switch either inputs A or B. We will read
the LSnibble first, thus we must place A/B low. The strobe is hardware inverted, thus we must set Bit 0 of
the control port to get a low on Pin 1.
outportb(CONTROL, inportb(CONTROL) | 0x01); /* Select Low Nibble (A)*/
Once the low nibble is selected, we can read the LSnibble from the Status Port. Take note that the Busy Line
is inverted, however we wonít tackle it just yet. We are only interested in the MSnibble of the result,
thus we AND the result with 0xF0, to clear the LSnibble.
a = (inportb(STATUS) & 0xF0); /* Read Low Nibble */
Now itís time to shift the nibble we have just read to the LSnibble of variable a,
a = a >> 4; /* Shift Right 4 Bits */
We are now half way there. Itís time to get the MSnibble, thus we must switch the multiplexer to select inputs B.
Then we can read the MSnibble and put the two nibbles together to make a byte,
outportb(CONTROL, inportb(CONTROL) & 0xFE); /* Select High Nibble (B)*/
a = a |(inportb(STATUS) & 0xF0); /* Read High Nibble */
byte = byte ^ 0x88;
The last line toggles two inverted bits which were read in on the Busy line. It may be necessary to add delays
in the process, if the incorrect results are being returned.
You can learning more information about this thing with your project when try it that you can get idea and
improv your development .
English is not my first language, so please excuse any mistakes. This is my English article for thaiio.com,
so any suggestions and/or feedback will be appreciated. Thanks for reading till here.