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 name | Direction | Register – bit |
1 | nStrobe | Out | Control-0 |
2 | Data0 | In/Out | Data-0 |
3 | Data1 | In/Out | Data-1 |
4 | Data2 | In/Out | Data-2 |
5 | Data3 | In/Out | Data-3 |
6 | Data4 | In/Out | Data-4 |
7 | Data5 | In/Out | Data-5 |
8 | Data6 | In/Out | Data-6 |
9 | Data7 | In/Out | Data-7 |
10 | nAck | In | Status-6 |
11 | Busy | In | Status-7 |
12 | Paper-Out | In | Status-5 |
13 | Select | In | Status-4 |
14 | Linefeed | Out | Control-1 |
15 | nError | In | Status-3 |
16 | nInitialize | Out | Control-2 |
17 | nSelect-Printer | Out | Control-3 |
18-25 | Ground | – | – |
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 ID | Pins | Description |
0 | 2-9 | Eight I/O lines |
1 | 10-13 and 15 | Five inputs for status |
2 | 1,14,16,17 | Four 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));
Obecnie oprogramowanie do zdalnego sterowania jest używane głównie w biurze i oferuje podstawowe funkcje, takie jak zdalne przesyłanie plików i modyfikacja dokumentów.
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?