Friday, July 18, 2008

Interfacing with Parallel Port using MATLAB

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:

  1. To check the support of your system, type

daq=daqhwinfo(‘parallel’)

  1. Create a Digital I/O Object with the digitalio function

dio=digitalio(‘parallel’,’lpt1’);

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

  1. 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!

28 comments:

Anonymous said...

simple but clear tutorial, friend..
i've tried n successful...

Sri Atmaja P. Rosyidi said...

Mas, one simple question. Is it possible to transfer data from ADC device directly to PC using matlab ? If possible maybe we can propose ADC device of multi-channel detectors for surface waves, and matlab for system of spectrum analyser.

masimet said...

Basically, using Matlab, parallel port (or other Data Acquisition Card attached to PC) can be used to receive/send digital data from/to external device, such as ADC, motor, etc. Interesting idea mas..., I'm opened for further discussion.

Anonymous said...

Is MATLAB able to read data from Port 0? I'm looking for a way to monitor 8 data lines, and am hoping to not have to learn another language to do it.

Unknown said...

Hi
can someone please tell me which toolbox is required for programming the LPT1 parallel port in MATLAB? im guessing its the Data Acquisition Toolbox.. can smbdy plz confirm this?

masimet said...

to bobafide,

yes ur right, needs Data Acquisition Toolbox.

Unknown said...

duude.. its Bonafide.. not bobafide :/

well thx neways..

shyam said...

hlo sir,
I am making a simple autonmous robot using PC.For this i m using parallel port, as i m using two stepper motor so all the 8-data pins are used,now for further i/p-o/p what we should do...hw can we progg. it in matlab.....plz reply as soon as possible...

Unknown said...
This comment has been removed by the author.
Unknown said...

hello sir,
I m trying for interfacing ADC with PC using MATLAB. actually as far as i know there are five input pins(10,11,12,13,15) are available on parallel port... can u tell me where should i connect my output of ADC with parallel port?? i mean at which pins of port??? or how to read control port in MATLAB??? because i found that it can also be used as an input???

Unknown said...

hello sir ,
i m trying to control DC motor through Matlab . what is the code required in matlab to take in and give away data through parallel port of PC?

Dimitris said...

Very nice all the above and good explanation.

But what about if I don't have the data acquisition toolbox in Matlab.

Is there any other way to read signal from parallel port?

Anonymous said...

is there any technique that we can send data to the parallel port after some delays???????

Mohammad Saad Yaseen said...

How do I use MATLAB to:

1. Configure Parallel Port 12 bit as output port (write mode)

2. Configure Parallel Port 10 bit output and 4 bit input port (10 bit write and 4 bit read )

Anonymous said...

how can I back emf of a motor using matlab interfacing....please let me know ....i have a project on this

Anonymous said...

nice it helped me thank u sir.

Anonymous said...

but there is some problem in matlab 2010
that is:
Warning: This Parallel adaptor ('parallel') will not be provided in future releases
of Data Acquisition Toolbox. Instead, it will be available as a separate download.
See Solution 1-5LI9OA for details.
please help me

MUHAMMAD SALEH said...

SIR, i want to do interfacing threw matlab using parallel port. this is my small project. but i don 't know how i can interface. i have no any basic idea. sir plz tell me how matlab is connect with the parallel port, which progaming is used. i m waiting for u reply...

JJ said...

I too would like to know how to do this without the Data Acquisition Toolbox. Maybe through a piece of C code and mex file?

JJ

Anonymous said...

how to check status of a single pin of parallel port using matlab

Anonymous said...

simple nd sweet .... worked successfully :)

Anonymous said...

hi there,
i hav designed a 6 channel EMG extraction unit and i want to read the data in matlab via parallel port. I hav used PIC for A2D conversion can anyone help me in reading the pic output on matlab via parralel port pls.

Unknown said...

sir,

i want to transmit a desired bit pattern through parallel port using matlab.How can it be done?.pls reply
jobinvarghese1987@gmail.com

Unknown said...

sir,
i want to sent a desired bit pattern through parallel port using matlab.how can it be done?.pls help.
reply
jobinvarghese1987@gmail.com

Unknown said...

sir,
i want to sent a desired bit pattern through parallel port using matlab.how can it be done?.pls help.
reply
jobinvarghese1987@gmail.com

Ferreira said...

I need to develop an application that could control dc motor through parallel port with Matlab using Windows XP 32bit, I can generate the pulses to the drivers with Matlab / Simulink?

Anonymous said...

hello sir,

pleas hep meout on this.
how to interface parallel port in MATLAB and configure it in EPP mode? how do we check the control register 037a and the direction pin whether it is high or not?

Anonymous said...

this procedure is not working with parallel port of laptop db15 connector.. so how to interface it with laptop....