Introduction To Parallel Port



What is a port?
A port contains a set of signal lines that the CPU sends or receives data with other components. We use ports to communicate via modem, printer, keyboard, mouse etc. In signaling, open signals are "1" and close signals are "0" so it is like binary system. A Standard Parallel Port sends 8 bits and receives 5 bits at a time. The serial port RS-232 sends and receive 1 bit at a time.


About Parallel Port
The Parallel Port is the easiest way to control devices outside the PC, like LEDs, lights and even home appliances. In fact the idea behind parallel port is really simple. It is an 8-bit parallel interface, so we have eight bits available there. Simple put, since each data bit can be set as either “0” (“turned off”) or “1” (“turned on”), we can directly turn on or off up to eight devices.

Parallel Port has mainly 3 modes of operation :-

  1. SPP - Standard Parallel Port (Discussed in this article).
  2. EPP - Enhanced Parallel Port (Not discussed in this article).For more info on EPP click here.
  3. ECP - Extended Capabilities Port (Not discussed in this article).For more info on ECP click here.


How it looks?
On the PC the parallel port uses a 25-pin connector (called DB-25, 25-pin D-sub or 25-pin D-shell), as you can see in figure shown below.


Parallel Port


Pin Configuration
The Parallel Port actually has 32 pins.

  • 8 - Data Pins (shown in yellow)
  • 8 - Control Pins (shown in red)
  • 8 - Status Pins (shown in blue)
  • 8 - Ground Pins (shown in green)

Parallel Port PinoutBut only 25 pins were required to run a printer through it, so rest of the pins (not shown in above picture) were not made available outside the mother board.
So, we have in total 25 pins.

  • 8 - Data Pins
  • 4 - Control Pins
  • 5 - Status Pins
  • 8 - Ground Pins


Data Pins
Data pins are used to send 8-bits of data. Pins 2 to 9 are data pins or we can call them as an 8-bit data bus (D0 – D7). This data bus carries 8-bit data at any instant of time as shown below.

Parallel Port Data Transfer

The type of data it carries is in digital form, i.e. either 0 or 1.

  • ‘0’ means OFF or 0 volts.
  • ‘1’ means ON or 5 volts.

For example, if pin 2 is carrying ‘0’, then it will give 0 volts at output. And if it is carrying ‘1’, then it will give 5 volts at its output. Similarly we get output as 0 volts or 5 volts from other data pins.

Now a question arises, how can we send data?

Answer to this is pretty simple. Every port on our computer has got some unique hexadecimal address. Parallel Port also has got a specific address. Generally this address is 0x378H.

To find out the address of the parallel port on your computer follow the steps written below:-

  1. Open Device Manager.

  2. Go to Ports (COM & LPT) item in it.

  3. Double click ECP Printer Port (LPT1).

  4. A new window will pop up.

  5. In that window click Resources tab.

  6. Now see the I/O Range. Mine is 0378–037F.

  7. Here 0378 is the starting address of the Parallel Port.

Now we can send data using software programs (discussed later) to this address.

Now we know where to send data, but what data we have to send?

We have to send ‘0’ or ‘1’ to each pin (D0-D7) simultaneously.

Each Data Pin has been assigned a bit value as shown below.


Parallel Port Data Table

Here, D7 is the most significant bit and D0 is the least significant bit.

This means, if we send any data say ‘16’ , then ‘1’ will be sent to D4 and ‘0’ to rest of the pins. Similarly ‘255’ will send ‘1’ to each pin.

We can also view it like this:-

  • Binary representation of 16 is 00010000.

  • Binary representation of 255 is 11111111.

See the table below for other decimal numbers.

Parallel Port Binary Table

So, every data is converted to 8-bit binary form and pins are send data accordingly.


Status Pins
These ports are made for reading signals. The range is like in data ports which are S0-S7. But S0, S1, S2 are invisible in the connector. And the address for this is 0x379.

Note- Address of data bus is same as that of parallel port. But address of Status Bus is 0x378 + 1, i.e. 0x379 (Address of Data Bus + 1).

Bit value for these is shown below.


Parallel Port Status Table


Control Pins
This port usually used for sending as well as recieving data. The range is like in data ports C0-C7 but C4, C5, C6, C7 are invisible in connector. And the address for this is 0x37A.

Note- Address of Control Bus is 0x378 + 2, i.e. 0x37A (Address of Data Bus + 2).


Ground Pins
These pins are just used to complete the circuit attached to the parallel port.


In The End
This article was just an introduction to the parallel port.

Now you are ready to make your first parallel port controlled device. Read my next article on Interfacing LEDs using the Parallel Port.


24 comments:

Supreet Sharma said...

nice stuff .. post more

Hijo de la Luz said...

Nice job, man... thanks, it has been very good, keep posting;

DM7 said...

Tanks for your informations.
Be bless.
Daniel - Romania

Anonymous said...

Exactly what i was looking for, thanks!

Unknown said...

Thanks a lot dude...some easy to understand basic information.

Keerthi Bandara said...

Thanks a lot. Good job.

Unknown said...

oooo paji tusi bada acha kaam kar rahe ho....
it was so easy to understand...
post something more jasprit. and ya can u help me please.. i want to program an eeprom through parallel port. the ic is 28c64.
please let me know how to connect the parallel port with the ic.
please sent me some useful site on the same......
thanks a lot

Jaspreet Singh said...

thanx nirav...
search "parallel port complete" on 4shared.com and u will find everything related to parallel port in the search result that would follow...

Anonymous said...

amazing.... this helped a lot... i hope you can help me interface a circuit using VB6...

jayant sharma said...

nice work jaspreet i really need ur help in one of my project man please help me out man please
i 'm waiting for ur reply
my project is regarding parallel port "rs232"
email:

jayant sharma said...

nice work jaspreet i really need ur help in one of my project man please help me out man please
i 'm waiting for ur reply
my project is regarding parallel port "rs232"
email:
jayant_sharma123@yahoo.com

pesa09 said...

Helo,how can i use parallel port for input..let say..i have a device that switch off or switch on for 30 ms/50 ms and 100 ms..this miliseconds determine the program what to do..So how can i do that by using the pins?

thank you.

Jaspreet Singh said...

Use STATUS Pins for input.

Say your device switches ON and OFF after 100ms. When it swithes ON send +5V to one of the status pins and when it switches OFF send 0V to that status pin. For +5V either you can use external supply or directly use one of the DATA pins with HIGH output. For 0V use one of the GROUND pins.

Unknown said...

my computer is not detecting parallel port when i star control software

Jaspreet Singh said...

@Riasat
You must be having an external Parallel Ports Card on your computer.

My Parallel Port Control software works with in-built PARALLEL PORTs only.

It won't work with external Parallel Ports Cards or with USB to parallel convertors.

Anonymous said...

thanks for reply,but first time i install it works properly.

Sharique Hasan said...

hi jaspirit i can i have the source code or a sample program in C language.. not in C# or any other lang.. as C is the requirment in my project... i wana control lights of a handmade house. please help.

Jaspreet Singh said...

@Sharique Hasan

'C' source code can control the Parallel Port in Windows 98 or in previous versions of Windows only.

In Windows XP we need to use C# or any other language but not 'C'.

nirupom said...

Hi! Sir. How are you? I have a code for controlling two stepper motors in C language. But I do not have any parallel port except a usb to parallel converter. I am using XP os. Is there any way to use this converter using C language in XP?
Waiting for your reply.

Jaspreet Singh said...

@nirupom

You need drivers to do so.

See this link:-

http://www.jungo.com/st/windriver_usb_pci_driver_development_software.html

Aditya Medhe said...

Hello sir what to do if i want to run this on a laptop which does not have a lpt port?
will a converter work??
pls help

Aditya Medhe said...

hello sir how do i make it work on a laptop without a lpt port?
will a usb converter do?
pls help

Jaspreet Singh said...

@Aditya Medhe

It can run on a laptop having onboard lpt port only.
USB converter will not work either.

Unknown said...

Hi. In school we are ask to make a project using a parallel port using Assembly language. We use Tasm as the assembler. Ahm, could you please make a tutorial of like that using tasm or assmbly lang. Thank you so much for the help.