Some applications in MATLAB environment need to communicate with external device either to send or receive signals. MATLAB provides a simple way to handle this task with PC parallel port.
Parallel port IDs and pin number:
Port ID |
Pins |
Description |
0 |
2 – 9 |
Eight I/O lines, MSB = pin 9 |
1 |
10 – 13 and 15 |
Five input lines used for status (output pins) |
2 |
1, 14, 16 and 17 |
Five I/O lines used for control (input pins) |
MATLAB has digital I/O (DIO) subsystems which are designed to transfer digital values to and from hardware. To send out data, follow the below procedures:
- To check the support of your system, type
daq=daqhwinfo(‘parallel’)
- Create a Digital I/O Object with the digitalio function
dio=digitalio(‘parallel’,’lpt1’);
- Add lines to a Digital I/O Object
addline(dio,0:7,0,’out’); % add the hardware lines 0 until 7 from port 0 to the
% digital object dio
- Send data to the lines
putvalue(dio.line(1),1); % send data ‘1’ to line 1
Before executing the program, of course you must have the parallel connection attached to your PC and some LED to indicate that the digital data have been sent.
Have a nice practice controlling your device via parallel port, and please give your comments!