[olug] Parallel port interrupt

Daniel G. Linder dlinder at iprevolution.com
Fri May 16 16:02:32 UTC 2003


Eric Penne [mailto:epenne at olug.org] wrote:
> Has anybody used interrupts on the parallel port for data 
> logging in Linux?

No, but that never stopped me from throwing in my two cents... ;)

> The problem is simple.  We want to monitor the power used by 
> our facility.
>  We have a device that outputs a pulse at a time interval based on how
> much power we are using.  For example 1 pulse per second for 
> using 10kW
> and 2 pulses per second for 20kW.  Therefore each pulse corresponds to
> 2.7kWh.

Neet idea...simple but effective if resolution/accuracy is not the
paramount requirement.

> The pulse needs to be picked up by the computer and an 
> interrupt routine
> would get the time of day to the nearest millisecond (or second).  How
> fast are the pulses going to be coming in versus how fast the computer
> responds to the parallel interrupt?  We don't know that yet since the
> device hasn't been installed.  This can be done using RTLinux 
> but we would
> like to see if it can be done using a regular kernel.
> 
> The functions in time.h can do milli/microsecond accuracy but the big
> question is how fast can the kernel respond to the parallel port
> interrupt?

I don't know the stated accuracy, but in general a tight loop within
Linux on a Pentium-100 or higher should be able to poll the port quite
rapidly (100's of times per second at least).  A way to judge might be
to determine the theoretical maximum "pulses per second".  If you are
not getting 1000's or tens of thousands of pulses per second -- you're
not monitoring the output of a commercial power plant, are you? :) --
then a non-RT Linux system dedicated to this project should be
sufficient.  At worst case, if you see odd spikes/drops in what is
otherwise a smooth or linear graph before and after could be accounted
for in a missed pulse for a split second.

If you ARE monitoring something very critical (i.e. a power plant,
hospital generator/UPS, etc) then you might want to consider the real
time Linux solution -- better over-spend/-plan than have things go
massivly wrong just to save a few bucks... :O

Either way, a low-mid range Linux system running only the required
services (NO X11, NO Sendmail, NO FTP server, etc) should do this just
fine.

Dan


More information about the OLUG mailing list