talking to my parallel port (LPT1)

Hi, I try to send a signal to the LPT1 using a 64 bit MATLAB on a 64 bit Windows 7. Unfortunately it doesn't work. I tried several methods:
Version 1:
if regexp(computer,'64')
lib = 'inpoutx64.dll';
libcall = 'inpoutx64';
else
lib = 'inpout32.dll';
libcall = 'inpout32';
end
if ~libisloaded(libcall)
loadlibrary(lib,'inpout32.h');
end
port_address = hex2dec('0378');
input = calllib(libcall, 'Inp32', port_address + 1);
calllib(libcall, 'Out32', port_address, 255);
unloadlibrary(libcall); %close library when finished
version 2:
ioObj = io64;
status = io64(ioObj)
address = hex2dec('378');
data_out=1;
io64(ioObj,address,data_out); % send a signal
data_out=0;
io64(ioObj,address,data_out); % stop sending a signal
clear io64;
Version 3:
loadlibrary('inpout32', 'inpout32.h');
calllib('inpout32', 'Out32', 888, 255);
unloadlibrary('input32');
Version 4:
config_io;
global cogent;
if( cogent.io.status ~= 0 )
error('inp/outp installation failed');
end
address = hex2dec('378');
byte = 99;
outp(address,byte);
%datum=inp(address);
I wrote a script that should send every second a signal to the LPT1 and measured the voltage on every contemplable pin. Nothing happend....what have I done wrong? Has anyone an idea? I would be reallly glad! Thanx!

6 Comments

Hi,
I'm sorry I'm asking another question on top of yours!
I wonder why you have used a library?
Can't you use digitalio? and perhaps why? what are the advantages of using a library?
digitalio('parallel','LPT1')
I did this ages ago to transfer files between to PCs via LPT1.
Thanks
Hey, you are right,
digitalio('parallel','LPT1')
would be the easiest way. Unfortunately a dont have the _data acquisition toolbox, so I have to work with other solutions. Sorry I should have mentioned...
Hi,
Thanks for your reply.
It's alright, at least now I know why you're using a library. Sorry I don't think if I can help with this. Libraries are very specific and I haven't used any for LPT1.
Good luck!
Actually, digitalio is not supported on Matlab latest version, so a work around has to be found no matter what. I'm wrestling with the same problem and haven't been able to find a solution either. Did you find one?
I found out how to make the "ioObj = io64" commands (version 2 above) in the original post) work on my machine. My problem was that my LPT port did not have the typical address (378) because Windows 10 assigns parallel port addresses differently now. Find out your LPT address range by going into device manager, "Multifunction Adapters" and double clicking your parallel port. the I/O range is listed there, and your ports address will be the first 4 characters following "0x". In my case it was 0xDFD8, so my address is DFD8, and I use the code "address = hex2dec('DFD8');" to set my address. Then my triggers worked.
Thank you, thank you, thank you Christopher Warren for posting your solution. Despite endless searching, I could not figure where the LPT address was on my Windows 10 machine. Now I can finally send triggers. Thanks!!

Sign in to comment.

Answers (1)

Hi, I am checking your code and maybe the problem is you are not giving enough time to your parallel port? LPT is very fast but whenever you try to write too fast you may have problems. So I would advice to use:
ioObj = io64;
status = io64(ioObj)
address = hex2dec('378');
data_out=1;
io64(ioObj,address,data_out); % send a signal
data_out=0;
pause(0.01); %10 miliseconds should be perfectly ok
io64(ioObj,address,data_out); % stop sending a signal
clear io64;
If this does not work, check that indeed your LPT output is 378 (should be, this is the standard). These are the things that come to my mind. Cheers!

Asked:

on 27 May 2015

Commented:

on 3 May 2019

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!