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).
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.
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
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
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:
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
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.
That's there.. i gues you all got it.
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