24
How to Communicate Through Parallel Port Using LabVIEW

How to Communicate With Parallel Port

Embed Size (px)

DESCRIPTION

labview

Citation preview

Page 1: How to Communicate With Parallel Port

How to Communicate ThroughParallel Port Using LabVIEW

Page 2: How to Communicate With Parallel Port

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.

Page 3: How to Communicate With Parallel Port

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

Page 4: How to Communicate With Parallel Port

The Parallel PortThe 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 afteranother with some extra bits like start bit, stop bit and paritybit 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.

Page 6: How to Communicate With Parallel Port

25 Contacts 36 Contacts

--Indicates active low signal

Pinassignment

Page 7: How to Communicate With Parallel Port

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).

Page 8: How to Communicate With Parallel Port

The Parallel Port

Data Register(output)

Control Register(output)

Status Registerinput

Page 9: How to Communicate With Parallel Port

The Parallel Port

Set the fifthBit C5 to 1 forBidirectionalcommunication

Page 10: How to Communicate With Parallel Port

The Parallel Port• Now we can say that to communicate through parallel

port you should communicate with the following three ports or registers:

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.

Base address

Page 11: How to Communicate With Parallel Port

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

Page 12: How to Communicate With Parallel Port

Parallel Port Base Address

2

3

4378

1

Page 13: How to Communicate With Parallel Port

Programming The Parallel Port withLabVIEW

Page 14: How to Communicate With Parallel Port

Programming The Parallel Port withLabVIEW

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 orits corresponding decimals (888). (889) or (890) respectively.

Page 15: How to Communicate With Parallel Port

Programming The Parallel Port withLabVIEW

• 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

Page 16: How to Communicate With Parallel Port

Example 1

To send high or low value to DATA 0 of the parallel port (pin 2)

or Led control

Decimal Display Format

hexadecimal Display Format

Page 17: How to Communicate With Parallel Port

Example 2

To send high or low values to DATA 0..7 of the parallel port

Page 18: How to Communicate With Parallel Port

Example 3

To read the inputs DATA 0..7 of the parallel portControl Port address Data Port address

In hex but can be in decimalIf display format changed

Should be high to readShould be low to read

Co

Page 19: How to Communicate With Parallel Port

Parallel port monitor

• Download the following program that monitor the three ports of the parallel port

Parmon.exe

Page 20: How to Communicate With Parallel Port

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.

Page 21: How to Communicate With Parallel Port

Example 4 Using VISATo send high or low values to DATA 0..7 of the parallel port

Or type ASRL10

Page 22: How to Communicate With Parallel Port

Example 5 Using VISATo send high or low values to DATA 0..7 of the parallel port

Continuous output

Page 23: How to Communicate With Parallel Port

Example 6

How to read theStatus port getting

S7S6S5S4S3

Page 24: How to Communicate With Parallel Port

Note • To read the Control Port getting C3C2C1C0