Code covered by the BSD License  

Highlights from
parallel port counter

from parallel port counter by mohammad
this is an 8 bit counter using the standard parallel port

counter(vstart,vfinal,ton)
%% prepared by Mohammad A.Amayreh
% this m file is a binary counter that output the values on the parallel
% port input parameters are
% vstart start value of the couonter
% vfinal final value of the counter
% ton the on time interval
function counter(vstart,vfinal,ton)
%first defining the digital io object to be the parallel port
dio=digitalio('parallel','lpt1');
%selecting 8 output lines 
addline(dio,0:7,'out');
%setting the timer event parameters 
set(dio,'TimerPeriod',ton);
set(dio,'TimerFcn',{@seton,vfinal});
set(dio,'userdata',vstart);
%outputing the first number 
putvalue(dio,dio.userdata);
%starting the digital io object 
start(dio)
end
function seton(obj,event,vfinal)
%this function will be called each time period specified in the main
%function 
obj.userdata=obj.userdata+1;
putvalue(obj,obj.userdata)
if(obj.userdata==vfinal+1)
    obj.TimerFcn=' ';
    putvalue(obj,0)
    stop(obj)
end
end

Contact us at files@mathworks.com