Parallel port is a simple and inexpensive tool for building computer controlled devices and projects. The simplicity and ease of programming makes parallel port popular in electronics hobbyist world. The parallel port is often used in Computer controlled robots, Atmel/PIC programmers, home automation, ...etc. The primary use of parallel port is to connect printers to computer and is specifically designed for this purpose. Thus it is often called as printer Port or Centronics port (this name came from a popular printer manufacturing company 'Centronics' who devised some standards for parallel port). You can see the parallel port connector in the rear panel of your PC. It is a 25 pin female (DB25) connector (to which printer is connected). On almost all the PCs only one parallel port is present, but you can add more by buying and inserting ISA/PCI parallel port cards.

In addition, one input can also be used to create a processor interrupt. This interrupt can be enabled and disabled under program control. Reset from the power-on circuit is also Ored with a program output point, allowing a device to receive a power-on reset when the processor in reset. The input/output signals are made available at the back of the adapter through a right-angled, PCB-mounted, 25-pin, D-type female connector. This connector protrudes through the rear panel of the system, where a cable may be attached. When this adapter is used to attach a printer, data or printer commands are loaded into an 8-bit, latched, output port, and the strobe line is activated, writing data to the printer. The program then may read the input ports for printer status indicating when the next character can be written, or it may use the interrupt line to indicate "not busy" to the software. The output ports may also be read at the card's interface for diagnostic loop functions. This allows faults to be isolated between the adapter and the attached device.
Pin Assignment

| Pin No (DB25) | Signal name | Direction | Register - bit | Inverted |
1 | nStrobe | Out | Control-0 | Yes |
2 | Data0 | In/Out | Data-0 | No |
3 | Data1 | In/Out | Data-1 | No |
4 | Data2 | In/Out | Data-2 | No |
5 | Data3 | In/Out | Data-3 | No |
6 | Data4 | In/Out | Data-4 | No |
7 | Data5 | In/Out | Data-5 | No |
8 | Data6 | In/Out | Data-6 | No |
9 | Data7 | In/Out | Data-7 | No |
10 | nAck | In | Status-6 | No |
11 | Busy | In | Status-7 | Yes |
12 | Paper-Out | In | Status-5 | No |
13 | Select | In | Status-4 | No |
14 | Linefeed | Out | Control-1 | Yes |
15 | nError | In | Status-3 | No |
16 | nInitialize | Out | Control-2 | No |
17 | nSelect-Printer | Out | Control-3 | Yes |
18-25 | Ground | - | - | - |
Parallel port registers
The Data, Control and status lines are connected to there corresponding registers inside the computer. So by manipulating these registers in program , one can easily read or write to parallel port with programming languages like 'C' and BASIC.
1. Data register
2 . Status register
3. Control register
Data register is connected to Data lines, Control register is connected to control lines and Status register is connected to Status lines. So what ever you write to these registers , will appear in corresponding lines as voltages, Of course, you can measure it with a multimeter. And What ever you give to Parallel port as voltages can be read from these registers. For example , if we write '1' to Data register , the line Data0 will be driven to +5v. Just like this ,we can programmatically turn on and off any of the data lines and Control lines.
Program
This program was written by C language:
#include
#include
#include
#include
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;
}


No comments:
Post a Comment