Using matlab to control LPT port

28 sec read

Download the following 4 files:

  1. porttalk.sys, copy to C:\WINDOWS\system32\drivers
  2. lptread.m
  3. lptread.mexw32
  4. lptwrite.mexw32

Copy the last three files to a directory where your matlab can access.

Your LPT port number is probably 0x378 (or 888). Assume lptport is the port number, then we use lptread to read from the port:

val = lptread(lptport)

and use lptwrite to write to the port

lptwrite(lptport, val)

As a real example, we want to control the step motor Gary created to investigate motion artifact in fMRI. Here is a sample code:

lptport = hex2dec('378');
dir = hex2dec('40');
data = hex2dec('20');
for ii=1:30
lptwrite(lptport, data+dir);
pause(0.005)
lptwrite(lptport, dir)
pause(0.005)
end

Author of lptread.m: Erik Flister, UCSD, 2006. Adapted from Andreas Widmann.



写作助手,把中式英语变成专业英文


Want to receive new post notification? 有新文章通知我

xjview 10.0 released

xjView is a viewing program to visualize fMRI images. It can also be used to visualize fNIRS data if you convert the fNIRS activation data to a brain image. Today, we released version 10.0. The main updates are: The AAL version is updated to AAL3v1 I
Xu Cui
14 sec read

采用基于频率簇(Cluster)的置换检验(Permutation)方法选取感兴趣频段

作者:北京师范大学 龙宇航,[email protected]代码来源(见本页底部):周思远 在使用wtc计算脑间神经同步后,我们需要在多个频率段、多个通道组合上对神经同步值进行统计检验,因
Xu Cui
1 min read

Calculate phase difference between two general signals (e.g. HbO…

In a recent fNIRS journal club (vedio recorded here), Dr. Tong talked about their work on the phase difference between oxy and deoxy Hb, and its relationship with participants’ age. This article is a demo of how to use Hilbert transform to calc
Xu Cui
1 min read

5 Replies to “Using matlab to control LPT port”

  1. sorry, i couldnt access this command in matlab 7.you asked to download four file but it didnt work .there is a command error about lptread and lptwrite.

    if there are any solution different than this please re send

    thanx in advance
    sudip

  2. Undefined function or variable ‘lptwrite’.

    Error in lptdeneme (line 5)
    lptwrite(lptport, data+dir);

  3. I have Windows 64-bit, and the MATLAB cannot recognize the lptwrite function.
    I get the following error
    Undefined function or variable ‘lptwrite’.

    Does lptwrite only works on 32-bit? Could you please help me with this?

    Thanks,
    Nidhi

Leave a Reply

Your email address will not be published. Required fields are marked *