Have you ever wondered how you can use and access parallel port using Matlab. This post give a very easy and basic method of accessing and using Parallel port using Matlab. But first of all lets learn a bit about Parallel port.
This is a typical type of port you usually find in the back of your PC. Other external port such as USB or serial port requires more complex sending and data receiving algorithms. But by using 8 data pins in parallel port you can easily send a byte of data. That's why Parallel Port is the most commonly used port for interfacing home made projects. Here is a good tutorial about parallel port configurations.
Now lets learn to access Parallel port using Matlab for your project.
You can easily access parallel port in Matlab
paraport=digitalio('parallel','LPT1');
by this u create a digital i/o object
line1=addline(paraport,0:3,'out');
this tells matlab to use first 4 data pins as output pin
pval=[0 0 0 1];
putvalue(paraport,pval);
this sends 1 value 2 pinno- 2.
Parallel port configuration
A typical Parallel port
Now lets learn to access Parallel port using Matlab for your project.
You can easily access parallel port in Matlab
paraport=digitalio('parallel','LPT1');
by this u create a digital i/o object
line1=addline(paraport,0:3,'out');
this tells matlab to use first 4 data pins as output pin
pval=[0 0 0 1];
putvalue(paraport,pval);
this sends 1 value 2 pinno- 2.
i tried this code its very easy and helpfull,thanx
ReplyDeletebut i need to know that can it be possible that for some time like 100msec the pin 1 high and after that pin 2 will be high???
plz plz send me idea or any help
thanx in advance
Thanks Usman ... yes it is possible. You need to use 'clock' function. this function return your computer's time
ReplyDeletec = clock
c = [year month day hour minute seconds]
c =
1.0e+003 *
2.0090 0.0100 0.0040 0.0020 0.0110 0.0485
This comment has been removed by the author.
ReplyDeleteplease help ,i use matlab with my laptop which doesn,t have lpt port ,i got usb 2 lpt cable(db25 connector) but windows recognise it as “usb printer support ” not as ordinary lpt port,matlab didn,t recognise any lpt port
ReplyDeleteHi Rajat,
ReplyDeleteThe newer versions of windows doesn't recognizes the parallel port via adapter. You can try other adapter or better you should go for serial port.
can ne1 tell hw to write a program for 6 gate pulses at 100msec gap using parallel port programming in matlab
ReplyDeleteplease its kinda urgent........nyd help
ReplyDeleteputvalue(paraport,pval);
ReplyDeletethis sends 1 value 2 pinno- 2. i didnt get that how this data is going to pin no 2 only ? what if we want to send data to pin no 1?
" Warning: This Parallel adaptor ('parallel') will not be provided in future releases
ReplyDeleteof Data Acquisition Toolbox. Instead, it will be available as a separate download.
See Solution 1-5LI9OA for details.
??? Error using ==> digitalio.digitalio at 115
Failure to find requested data acquisition device: parallel.
Error in ==> testport at 1
paraport=digitalio('parallel','LPT1');
>> "
Why am i getting this error message? My hardware works perfectly fine with a C program that I built. Can I please expect a solution to this? My email address is taufique.zaman1@gmail.com
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?
ReplyDelete??? Error using ==> digitalio.digitalio at 115
ReplyDeleteFailure to find requested data acquisition device: parallel.
Error in ==> testport at 1
paraport=digitalio('parallel','LPT1');
why i get the above error , could you send for me using email: tedysal2001@gmail.com