How To Communicate With Parallel Port

Download as pdf or txt
Download as pdf or txt
You are on page 1of 24

How to Communicate Through

Parallel Port Using LabVIEW


The Parallel Port
• 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.

• Almost, all PCs contain one parallel port, but


you can add more by buying and inserting
ISA/PCI parallel port cards.
The Parallel Port
• 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.

• Parallel ports are easy to program and faster compared


to the serial ports.

• But main disadvantage is it needs more number of


transmission lines. Because of this reason parallel
ports are not used in long distance communications
The Parallel Port
The basic difference between working of parallel port and
serial port.

– In serial ports, there will be two data lines: One transmission


and one receive line.

– To send a data in serial port, it has to be sent one bit after


another with some extra bits like start bit, stop bit and parity
bit to detect errors (Look to previous serial port presentation).

– But in parallel port, all the 8 bits of a byte will be sent to the
port at a time and a indication will be sent in another line.
The Parallel Port
25 Contacts 36 Contacts

Pin
assignment

--Indicates active low signal


The Parallel Port
• Earlier parallel ports had only output enabled in data
pins since printers only inputs data. But latter, to
make parallel port capable of communicating with
other devices, bidirectional ports are introduced.

• By default, data port is output port.

• To enable the bidirectional property of the port, we


need to set the fifth bit (C5, count from C0) (of control
register).
The Parallel Port
Data Register
(output)

Status Register Control Register


input (output)
The Parallel Port

Set the fifth


Bit C5 to 1 for
Bidirectional
communication
The Parallel Port
• Now we can say that to communicate through parallel
port you should communicate with the following three
ports or registers:
Base address

1- The Data Port (278h/378h) which (input/output) 8 bits


(the input or output data).

2- The Status Port (279h/379h) which reads 8 bits for the


printer.

3- The Control Port (27Ah/37Ah) which transmit 8 bits


to select output or input operation.
The Parallel Port
• General Information:

- Pins 10,11,12,13 and 15 used to output 5V.

- Pins 18 to 25 are ground.

- The port names in the previous slide are in hex.


Like (378h) is 378 in hexadecimal
Parallel Port Base Address

4
378

3
Programming The Parallel Port with
LabVIEW
Programming The Parallel Port with
LabVIEW
In Port VI Out Port VI

address specifies the address to which you want to write an 16-bit signed integer.
This VI accepts only 16-bit addresses. Like (378), (379) or (37A) in hex or
its corresponding decimals (888). (889) or (890) respectively.
Programming The Parallel Port with
LabVIEW
• The data read can be I8 just to read the data port inputs
• The data read can be I16 just to read the data port and status
port inputs
• The data read can be I32 to read all the data port, the status
port and the control port inputs

• The write value can be I8 just to write to the data port outputs
• The write value can be I16 just to write to the data port and
status port outputs
• The write value can be I32 to write to all the data port, the
status port and the control port outputs
Example 1
To send high or low value to DATA 0 of the parallel port (pin 2)
Decimal Display Format

or Led control
hexadecimal Display Format
Example 2
To send high or low values to DATA 0..7 of the parallel port
Example 3
To read the inputs DATA 0..7 of the parallel port
Control Port address Data Port address

Should be low to read Should be high to read

Co
In hex but can be in decimal
If display format changed
Parallel port monitor
• Download the following program that
monitor the three ports of the parallel port

Parmon.exe
Example 4 Using VISA
• The main trick is to tie pins 11(Busy) and 12 (Paper
Error) to ground. Otherwise, the hardware driver will
think the printer it is talking to is busy or experiencing
an error and will not output any data.

• Remember that in LabVIEW all serial communication


needs to be sent as a string. Generally we will want to
send 8-bit numbers to the port. This will require
flattening the data to string so that the binary
representation of the data does not change. We can use
the Type Cast VI for the purpose.
Example 4 Using VISA
To send high or low values to DATA 0..7 of the parallel port

Or type ASRL10
Example 5 Using VISA
To send high or low values to DATA 0..7 of the parallel port
Continuous output
Example 6
How to read the
Status port getting
S7S6S5S4S3
Note
• To read the Control Port getting C3C2C1C0

You might also like