Project Basics

Parallel Port

Computers parallel port is generally used to send or receive binary signals while interfacing with the external devices.

We can use switches, micro-controller pins or some IC pins to connect to parallel port.

Pin-out of Parallel port: The parallel port consists of 8 data pins and 4 status pins .We can use data pins as output ports and status as input port.

The data and status pins are normally high. Data pins are latched outputs while status pins are always high, except when a low input is applied and retained.

Pin No (DB25)Signal nameDirectionRegister – bit
1nStrobeOutControl-0
2Data0In/OutData-0
3Data1In/OutData-1
4Data2In/OutData-2
5Data3In/OutData-3
6Data4In/OutData-4
7Data5In/OutData-5
8Data6In/OutData-6
9Data7In/OutData-7
10nAckInStatus-6
11BusyInStatus-7
12Paper-OutInStatus-5
13SelectInStatus-4
14LinefeedOutControl-1
15nErrorInStatus-3
16nInitializeOutControl-2
17nSelect-PrinterOutControl-3
18-25Ground

Accessing parallel port in MATLAB:

Matlab provides port ID’s to the 3 registers of parallel port namely Data, Status and Control as shown in the following table:

Port IDPinsDescription
02-9Eight I/O lines
110-13 and 15Five inputs for status
21,14,16,17Four I/O lines used for control

The PC supports up to three parallel ports that are assigned the labels LPT1, LPT2, and LPT3. We can use any of these standard ports as long as they use the usual base addresses, which are (in hex) 378, 278, and 3BC, respectively. The port labels and addresses are typically configured through the PC s BIOS. Additional ports, or standard ports not assigned the usual base addresses, are not accessible by the toolbox.

Most PCs that support the MATLAB software will include a single parallel port with label LPT1 and base address 378. There are few steps to access parallel port using matlab:

  • Firstly we need to create a digital Input Output object.

To create a DIO (digital IO) object for parallel port following code is written,

   dio = digitalio('parallel','LPT1'); or dio = digitalio('parallel', 1)
  • Next we add pins which are to be used as output lines, in the above created object.

We add lines to a digital I/O object with the addline function. The function addline requires the device object, at least one hardware line ID, and the direction (input or output) of each added line as input arguments. . For example, to add eight output lines from port 0 to the device object dio created in the preceding section:

        hwlines = addline(dio,0:7,'out');

Sending data to the port:

  • Send the data at the output lines

We have already configured eight data lines as output pins and the data to be sent is stored in the variable named data. Now data can be written as follows

putvalue(dio.Line(1:8),data)

      OR

Receiving data from the port:

  • Receive the data from the pins If we configure the eight data lines as input lines                   hwlines = addline(dio,0:7,’in’); and we receive the data as                                       ram = getvalue(dio2.line(1:8));Now the data received gets stored in the variable named ram.
  • Creating a digital Input Output object.

dio2 = digitalio(‘parallel’,’LPT1′);

  • Add pins of status lines, in the above created object inreg = addline(dio2, 0:1, 1, ‘in’);
  • Reading values from status pins.ram=getvalue(dio2.line(1:2));

17 Replies to “Parallel Port

  1. Pingback: celeb deepfakes
  2. Thank you for your sharing. I am worried that I lack creative ideas. It is your article that makes me full of hope. Thank you. But, I have a question, can you help me?

  3. Pingback: betflix allstar
  4. Pingback: altogel

Leave a Reply

Your email address will not be published. Required fields are marked *