You are on page 1of 10

Basic and Advanced Parallel Port Interfacing

PARALLEL PORT INTERFACING PART 1


Parallel
Parallel communication requires as much wires as the no. of bits in a word for its transmission. Word may be a combination of
4,8,16,32 or 64 bits etc.
Parallel port identification on IBM PC

Usually ports are found on the rear of computer and are of the following two types;
1)
Male ports
having pins coming out of port.
2)
Female ports
having holes for pins.
Parallel port is generally a 25 pin female connector with which a printer is usually attached.

Pin configuration of parallel port

Data port:
It includes pin 2 to pin 9 with pin names Data-0 to Data- 9
It is usually for data output according to old standard parallel port standard.
Status Port
Status port is an input only port i.e. Data cant be output on this port but it can only be read.
Control port
Control port is a read / writes port. For printer purposes it is write only port.
How to access parallel port pins in the software.
Parallel port is assigned a unique I/O address which is generally among the following:
i) 378h
(mostly used in output)
ii) 278h
(normally found when there are more than one parallel ports)
iii)379h
(for the input)
Prepared By: Engr. Policarpio Tena II, MEng

1/9

Basic and Advanced Parallel Port Interfacing

iv) 37ah (for the CONTROL PORT outputs)


How to know the port address on your pc
Restart your computer go into BIOS. Then see the address of the port there.
If it is set auto hen there are two options:
i) Explicitly assign an address in the BIOS.
ii) Check the address in Windows by going to
Control panel >System >Device Manager > PortsPrinter port > Properties > Resources > Input/Output Range.
Difference between memory address space and I/O address space
In Intel family of x86 processors the memory addresses and I/O addresses are separate
Memory addresses
They depend upon the RAM/ROM present in your PC & Address lines.
I/O
This address space is dependent upon no. of address lines available for accessing I/O devices.
How to address above two type of addresses in Assembly Language
Memory addresses are ,generally, not known to a Assembly programmer the programmer can refer to an address by using pointer
notation.
I/O addresses are accessed in Assembly environment by using following commands
i) in
ii) out
How to address above two type of addresses in C/C++
I/O addresses are accessed in Turbo C/C++ environment by using following Library functions
i) Inport
ii) Inportb
iii) Outport
iv) Outportb
How to address above two type of addresses in Basic/Visual Basic
I/O addresses are accessed in Assembly environment by using following commands
i) Out
ii) In
Relation between bits present at the port address and voltage levels on port pins.
Each bit present at base address of the port has direct link with the voltage level on corresponding port pin.
i.e. a 1 in register at I/O address corresponds to logic high at port pin.
OUTPORT (Data/Control)
A brief overview of logic high and logic Low levels of parallel port.
In parallel port
Logic high means a voltage of +5V w.r.t ground.
Logic low means a voltage of 0V w.r.t ground.

Prepared By: Engr. Policarpio Tena II, MEng

2/9

Basic and Advanced Parallel Port Interfacing

Deviation from above bit-logic level relation


In case of hardware-inverted pins the above described relation of bit and logic level is reversed
i.e. 1 corresponds to 0V on port pin. Examples are busy and strobe.
Some considerations of control port
Control port can be used both for input or out put. However there are some deviations Open Collector Output
In some hard wares control port pins are open collector. Its equivalent circuit is as follows:
Logic States of Open Collector Pin
i) Logic low (0V).
It is actually a short circuit to ground as transistor is conducting.
ii)Logical high ( Open Circuit)

Prepared By: Engr. Policarpio Tena II, MEng

3/9

Basic and Advanced Parallel Port Interfacing

SAMPLE APPLICATION
1.) Demonstration of control of light Bulb through parallel port

The Software controlling part


.model small
.stack
.code
start:
mov dx,378h
mov al,1
out dx,al
mov ah,4ch
int 21h
end start
(Using Assembly in TASM 4.0)
#include<dos.h>
Delay(time_ms);
Outportb(port,data);
a=inportb(port);
Printf(%x,a);
(Using Turbo C)
Out &H378,1
(Using Basic or Visual Basic 6.0 w/ Dllport.dll)

Prepared By: Engr. Policarpio Tena II, MEng

4/9

Basic and Advanced Parallel Port Interfacing

Sample program in VC++


Writing a parallel port interfacing program in VC++ is very easy. Here is the steps to write your first parallel port interfacing
application in VC++.
Start VC++ IDE , Select 'New' from File menu. Then select Win32 Console Application from Projects tab(picture-3). enter
project name as partest1 , then click OK button.

Picture-3
Now you can see a dialog box with caption Win32 Console Application - step 1 of 1 (picture-4).

Picture-4
Prepared By: Engr. Policarpio Tena II, MEng

5/9

Basic and Advanced Parallel Port Interfacing

Select a simple Application and click Finish. Now open example1.cpp from fileview and replace the existing code with the code given
below.

#include "stdafx.h"
#include "conio.h"
#include "stdio.h"
#include "string.h"
#include "stdlib.h"
int main(int argc, char* argv[])
{
short data;
if(argc<2)
{
printf("Usage\n\n");
printf("partest1.exe ,,\n\n\n");
return 0;
}
if(!strcmp(argv[1],"read"))
{
data = _inp(atoi(argv[2]));
printf("Data read from parallel port is ");
printf("%d\n\n\n\n",data);
}
if(!strcmp(argv[1],"write"))
{
_outp(atoi(argv[2]),atoi(argv[3]));
printf("Data written to parallel port is ");
printf("%s\n\n\n\n\n",argv[3]);
}
return 0;
}

Build the project and copy partest1.exe to "c:\".

Prepared By: Engr. Policarpio Tena II, MEng

6/9

Basic and Advanced Parallel Port Interfacing

IN PORT (Status)
Range of voltage for logic high and logic low
But it will give you incorrect results. The reason is the range of voltage levels that are considered high or low.
Parallel port is TTL(transistor transistor logic) compatible in which
Logic high is a voltage between 0 to 0.8 V
Logic low is a voltage between 2.0 to 5V
Any voltage in between the above rage is undefined.
A voltage higher than the logic high or lower than the logic low can damage your port or any other TTL circuit.

How to set a Logic High Voltage level on Open Collector

You should connect an external resistor with pin to get logic high voltage which depends upon the supply voltage you
use.

In case of parallel port dont use Vcc greater than +5V.

INTRODUCTION TO BUFFERING FOR PARALLEL INTERFACING

Buffers are normally used for purpose of load isolation.


For digital interfacing we use digital buffers or inverters like
CD4050 (buffer)
CD4049 (inverter)
OR
74 LS245
74 LS244 TTL

Prepared By: Engr. Policarpio Tena II, MEng

7/9

Basic and Advanced Parallel Port Interfacing

Why we need Buffer? Introduction to Source & Sink Currents


Source current
In high output level the port pin or any TTL circuit can provide a certain maximum amount of output current while maintaining logic high
level. This current is called source current.
For parallel port this may be up to a minimum of 1mA among various ratings.
Beyond this current, your voltage level decreases. This must be avoided.
Sink current
In case of a pin being in logic low state there is a minimum amount of current that the pin can absorb called sink current.
A current larger than sink current can result in severe damage to the logic device.
The amount of the sink current is usually higher than corresponding source current for the same device.
The usual range is about 10mA for parallel port.
Advantage of buffers
Buffers have better ratings of the source and sink currents.
They provide protection to your costly circuits in the event a pin is over loaded by excessive source/sink Current or
an over voltage applied.
It is always a good practice to use buffers for your costly logic devices for both data in and out.
Demonstration of use of Buffers in Data Output

Prepared By: Engr. Policarpio Tena II, MEng

8/9

Basic and Advanced Parallel Port Interfacing

PARALLEL PORT INTERFACING PART 2


Advanced techniques in parallel port interfacing
Bi-directional Parallel Port

These days starting from PCs equipped with Pentium processors, the parallel ports have Bi-directional read/write
facility.
Bi-directional means that you can read byte (8 bits) from parallel port which traditionally was an output only port in the
old PCs.
In order to check whether your port is configured for it, restart your PC and go into BIOS see the portion related to the
parts. You will find port address as well as its type, usually the options are as follows

SPP - standard parallel port not bi-directional


Bi-directional - standard parallel port with bi-directional facility
EPP - Enhanced Parallel port
ECP - Extended Capabilities parallel port
EPP and ECP
Printer Hand shake used in standard parallel port (Centronics Standard) According to this standard , following hand shake was used:

All above signaling was done by software in which PC had to wait for a response from printer before outputting the next signal. It was a
slow process with data rate of 50KB/sec to 150KB/sec.
EPP Handshake
EPP was designed to do, the above described, handshaking by a separate hardware chip instead of main processor. It is described as
follows:
EPP Data Write Cycle

Prepared By: Engr. Policarpio Tena II, MEng

9/9

Basic and Advanced Parallel Port Interfacing

Prepared By: Engr. Policarpio Tena II, MEng

10/9

You might also like