Parallel Port

Here i will deal with parapllel ports in C,vb and MATLAB 7.0

Parallel ports are the 25 pin cute things that you will find behind your computer pannel. here is a picture below to show you the pin categories. Basically they are split into three categories.The control pins,status and data pins (as shown below).

parallel port pins

Now dataports and status ports (pins actually) can be used for input and oputput data and the status are used by the computer to find out the status of an external device and thus can serve a good input port. Actually speaking mostly all these can be used for input and output but you can't use output to status pins. (*If your ports don't work just check your BIOS there will be a option to elect ports as bidirectional so just enable that option).

If you are using any os of higher than 'Me' your ports are protected for security reasons and thus you need to open it.You can get port opennig software called userport.sys . just open it and execute it and you can see it show this.

userport image

To monitor you port pin status just download a software caller parmon with which you can monitor your ports status and it looks as shown below

pram

now in the above image you can see that all data pins are LOW(GREEN) and all HIGH(RED 5v). now you can see that all of the data port are all '0' and the status pins are '1' high. Note that the control pins donot indicate the actual number in the "DEC" column in the monitor screen since they are negative logic.

Here below shows that all data pins are high, a value 255 and the next having a value254

pram pram

Start with C

in c adressing the port is very simple. just use the syntax outportb(address,value). Firstly note that the value is in hex i,e 255 is "FF" and here is how you will fiond the addess. check the 'Device manager' and click properties of 'COM1' which will show you this:

device manager
Normally we can use use '0x03FB' in plave of address. So outport(0x03FB,0xff); will output value "FF" to the data pins.of the parallel port.

To get an input from the port use : b = inportb(address) ; where bwill be a user defined variable. now this ends the discussion about C.

PORT ADDRESSING IN VB

download this DLL file and put it in the 'system' folder in your computer. now open a VB project and open a module and type in the followingin the plain module region.
Declare Sub vbOut Lib "WIN95IO.DLL" (ByVal nPort As Integer, ByVal nData As Integer)
Declare Sub vbOutw Lib "WIN95IO.DLL" (ByVal nPort As Integer, ByVal nData As Integer)
Declare Function vbInp Lib "WIN95IO.DLL" (ByVal nPort As Integer) As Integer
Declare Function vbInpw Lib "WIN95IO.DLL" (ByVal nPort As Integer) As Integer

module

now open a form and make a command button 'command1' and a textbox 'text1' now the following will letyou outputthe value to port (NOTE IT IS IN DECIMAL VALUE).

vbOut 888,255 <– here 888 suggests Data port (890 for control) and 255 is the data [variable]=vbInp([port]) <-- here the data from specifid port will be read to the vriable.

command

That's there.. i gues you all got it.

NOW MATLAB

Now the sad part is this all will work onlt in MATLAB 7.0 of greater version. now it is very simple. the following four lines will work to give you output.

open = daqhwinfo('parallel')
DIO1 = digitalio('parallel','LPT1');
DIO2 = digitalio('parallel','LPT1');
outreg = addline(DIO1, 0:7, 0, 'out');
inreg = addline(DIO2, 0:4, 1, 'in');

outreg is the variable in which output value will be put into by MATLAB and sent to ports and inreg is port to which the input value will be saved. now the '0:7' represents 8 pins of dataport and '0:4' represents 5 pins of status port.

putvalue(DIO1.Line(2),1) puts the value to line number "2" of the DIO1 configured port and the poutput value is 1.

getvalue(OBJ) will get the input value. incase u need help for this also just hold on.. today i'm a bit too tired and i'l put it up later.

–Have a nice day controlling your Parallel Ports.!! and please give your comments

85 thoughts on “Parallel Port

  1. WoW!
    thank U very mUchchchchchch
    i finally read a bit from pin data.1 :)
    again thnx
    just a problem in yr page: i cant c images
    i use firefox 1.5
    very nice site
    good luck
    bye

  2. Useful site, if I am to conroll individual pins of the parallel port via Matlab does the “daqhwinfo(‘parallel’)” mean I must have the data acquisition toolbox?

  3. @adb : i guess that should be done by your program on runtime. make it out when u wnaa out a value. and “in” when u expect some data from external device or something. Simultaneously biderectional i’m not sure of. sorry

  4. I’m trying to use the data pins to input information to my computer. I’m using matlab and when I try to read the port I can only read the las value I assigned to it. The code I’m using is


    open = daqhwinfo('parallel')
    DIO1 = digitalio('parallel','LPT1');
    inreg = addline(DIO1, 0:7, 0, 'in');
    getvalue(DIO1)

    I have all ready configured my BIOS settings but i just can’t get it to work.

    Any suggestions?

  5. hi, thanks to provide usefull inforamation regardin PP.
    I want to aquire digital value using Parallel port, but i am getting only last value. it is possible save all descrete value and reuse it.

  6. Hey man if the time doesnt synchronise then you’l get odd values only. To help you better may i know from where are you acquiring the datas?

  7. HI..
    i have enjoyed explored programming MATLAB with PPI8255, but i confuse how to send configuration like mode, access port A,B,C. if other program like pascal, delphi, assembler. they send configuration through address 378 and 37A. i don’t how to do like that in MATLAB. i have though if port (0)/ port (1) and port(2) is adddressed to 378,379 and 37A so we can direct send configuration and data to its port. OK, hope for your helping. send your comment to my email..if you not feel weight
    [feriyonika, student at GAdjah Mada University, major Electrical Enginering.30march07]

  8. @FERI
    Well i think you are just asking about how to address 8255 from matlab when you can just control the line pins. let me know if this is what you want to ask or anything different.

    As far as i know the lines can only be individually controlled thus might not produce the required results witha 8255. I’l like to get into more detils with this question so i’l be happy if you can get ack here and put your ideas in.

    Thanks
    Madan

  9. To Asaf

    If you set the bit 5 of the control buffer by other program as vB of Labview you will reed by matlab the port 0

  10. Hi, this is great stuff.
    Although i’m stumped at trying to write a string or a character to the Parallel Port (matlab)
    Things i want to write are: eg. “F”, or more complicated “I -200 200 450 1000 54 54 68″
    Would appreciate any help with writing strings in Matlab OR C to the parallel port.

    Thanks!
    email: neo_skool@hotmail.com

  11. hey i downloaded user port and executed too and when i start it,it shows driver not installed.may i know which driver its talking about.

  12. i want to control stepper motor or a relay with paralell port but data write or read must be throuh web site.i mean to say taht data should be sent from anywhere and relay that is attached a pc should be controlled.plz i am worried about it help m efor my project.

  13. How i can send and recive 8 bits, because i use Simulink to control a system, I use a pin 2 to 9 to send y 10 to 17 to recive.

    Some people told me that I have to make a S-Function.

    Thanks for help me.

    Sorry my English is pure

  14. i want to store the data acquired through parallel port to a matrix. i am getting the data in a loop, but i need to store that data to a matrix and then to show that matrix as an image.
    kindly help me
    i am really stuck.

  15. @liyasa
    wow that was a god one… but thar shud be simple if u just put some thot to it….

    Read some sinal to say u are sending a 8 bit data.. read port ten and sequentially keep saving it in the matrix…

  16. hi.. gud day.
    im want connect a LED to parallel port pin number 1, i want to control LED on/off..
    please give some tips to do that.

  17. hi.. gud day.
    i want to connect a LED to parallel port pin number 1, i want to control LED on/off..
    please give some tips to do that.

    what is the output voltage coming from parallel port?

  18. Hello Sir,
    thanks for this trivial info. i have a problem that i want to recieve optical encoder data through parallel port and want to use it in Matlab .Length of data is more then 1 pulse (say 500 pulses per second).can you please guide me how to do it.

  19. Hello Sir,
    thanks for this trivial info. i have a problem that i want to recieve optical encoder data through parallel port and want to use it in Matlab .Length of data is more then 1 pulse (say 500 pulses per second).can you please guide me how to do it….. Tahir

  20. hello to all,
    i am working on my project in MATLAB and i want to give input through parallel port, and want to use them..

    how can i do it?
    please help

  21. please help ,i use matlab with my laptop which doesn,t have lpt port ,i got usb 2 lpt cable but windows recognise it as “usb printer support ” not as ordinary lpt port,matlab didn,t recognise any lpt port

  22. how to configure data lines of parallel port as ‘in’ and read data from it using matlab 6.5… plz reply soon….

  23. hi i have to control two stepping motor with PC via parallel port and i have the peogram source writen in boolean with C3.0. and i need the graohic software (DUALSTEP.EXE)to run my program.

  24. Hi. I am trying to get information from a Pulse Oximeter through a parallel port into matlab, but I am having difficulties reading the data off it. I get values from the getvalue(obj) command but it seems to be static, id est it doesnt matter if it is pluged in or not , and it doesn’t matter if i have it in an active state. The reading is [1 1 1 1 0] for the status pins, 0 being the busy signal, and the data pins all give ones’s. Does anybody have an explaination of this?

  25. Can you pls tell me the codes on how to transmit 5 volts using parallel ports/com port/usb port. thanks!

  26. Hi

    I have created a application that reads off a photocell sensor that is place on a race track, and records race car laptimes. The application work fine, but I have noticed that on certain desktop or laptop computer the Status pins S3, S4 and S5 are high, with out any parallel port pluged into the computer. My application reads off status pin S3 for the sensor, but doesnt work when the status pin is set high on certain computers.

    Any way I can set the status pins to be low when the application starts? And why is this happening?

    Thanks

  27. it’s really informative site…thanx madan!
    but plz checkout why in some pages there is no image
    i.e. the ckt diagrams don’t appear.

    bcoz of this i am not able to get the ckt of h-bridge what u gave in ur next page… plz if u can send it to my mail..

  28. HI
    I am allso doing proj on interfacing with matlab but i don`t no how to interfac it plz help me . i want to move the dc motor

  29. hi
    i used the paraller port for pulse generation for driving stepper motor.but from the parralel port of pc ,the maximum sample per second is about 35HZ.now i need much more frequency than it.
    can anyone help me that how can i reach the large frequency using MATLAB(paraller or serial or USB port).

  30. Please send me the matlab M-file to control the pc parallel port without using DAQ Hardware
    for parallel processing .

  31. Hi there,

    I just wondering,what if I use USB parallel port, can I still use matlab to control the parallel port? thanks.

  32. Hi there,

    I just wondering,what if I use USB parallel port, can I still use matlab to control the parallel port? thanks.
    Reply

  33. i want to convert the webcam video stream into frames per second,i need the code following process,please send me the code of matlab

  34. i am using matlab 7.4 and i m not able to send data through usb 2 parallel port with my laptop.
    the laptop treats usb 2 parallel port as a printer port n not a lpt port.n i am getting this :

    open = daqhwinfo(‘parallel’)

    open =

    AdaptorDllName: [1x69 char]
    AdaptorDllVersion: ‘2.10 (R2007a)’
    AdaptorName: ‘parallel’
    BoardNames: {1×0 cell}
    InstalledBoardIds: {1×0 cell}
    ObjectConstructorName: {0x3 cell}

    wich means dat it is not detecting any lpt port.
    can anyone tell me what to do to access the parallel port as earliest as possible????

    thanx in advance.
    reply 2 : shresthbhutani@gmail.com

  35. hello everyone.!!
    i’m facing the same problem that mentioned above. I need to use USB to parallel port converter for my project. I need the codes for interfacing it with matlab. Can any one give your idea pls…??

  36. It is really nice and working fine. I have rotated a unipolar stepper motor using parallel port and 74LS244, ULN2003
    IC , it is really Nice and cheap. Investment only 15 INR and done the job. Yeh Hoo!!

  37. i dont have parallel port on my laptop but i need to control wiper motor through matlab.Can it be possible through USB. i think i need to use microcontroller between laptop and the motor.. please i need some serious help quite fast ??????????

  38. hey dude,
    i am working on hand tracking system can u help me out in it.
    how to calculate the centroid of the hand movement in frony of cam.??????
    it’ll be really kind of you if help me out in this case

  39. hey dude,
    i am working on hand tracking system can u help me out in it.
    how to calculate the centroid of the hand movement in frony of cam.??????
    it’ll be really kind of you if help me out in this case……..plssssssssss do it as early as possible

  40. Hello!
    I am working with PC using XP operating system.
    I want to use the DATA PORT of LPT1 as Bi-directional in MATLAB
    Please tell me what to do?
    Rao

  41. i write all of command to sent data on lpt1 port but i havent voltage on pins i think this port should be close how i can open ports (in matlab)
    please send your answer to my email

  42. kuch ata bhi hy tum logo ko!!!!!!!!!!!!
    search karne betho tou aagy ye aa jaty hain besharm ,nae ata tou atleast hmara tou time waste mat kiya kro,mehrbani hogi !

  43. can someone please help me out in writing a MATLAB code for interfacing parallel port of PC. The coding will be to check the control register 037a and check if its direction pin is high. if no, then configure it in the EPP mode and check gain or else open files corresponding to each 8 input channels.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s