:Hi,
:
:I am in the process of developing a device driver for the purpose of
:stepper motor control. The timing of each pulse is determined by
:external timing hardware on an I/O board, which will fire an interrupt
:after the time requested. Using this method, I am able to generate
:streams of pulses at approximately 5000Hz on a Pentium II 400MHz system.
:
:Everything seems to be working well, but I'd really like to gather some
:accurate timing data in order to derive some statistics to from the
:system. Intuition tells me I'll need a clock with a tick rate of at
:least 20000 Hz to derive this.
:
:So, is such a thing available in the kernel? I've searched through
:various mailing list archives and have found reference to the "HZ"
:option to the kernel, which works to a point. However, it is not ideal
:as setting HZ to high values generates far too much kernel overhead.
:Also being considered is additional external timing hardware, but this
:is something I'd rather avoid for many reasons.
:
:What I am after is not a "timer" as such - all I need to do is derive a
:time value at an initial time, and a subsequent value at a later time.
:I've used "getmicrouptime", but this appears dependent on the "Hz"
:option, and as such is of limited use.
:
:I've just had some input from a colleauge who has suggested using the
:Pentium profiling registers, which we are currently investigating...
:
:Any advice gratefully received,
:
:--
:Jennifer Clark
Hmm. FreeBSD does not guarentee interrupt timing. If the system
is busy doing other things your interrupts can be significantly
delays (by microseconds, even milliseconds). I would definitely
not try to control a stepper motor from an interrupt!
What I recommend instead is that you put a microcontroller on
the I/O board and have it do all the sensitive stepper motor
timing, then write a device driver that does supervisory
management of the microcontroller. For example, a small 68HC11F1
or an 8xC51 type of microcontrollor would work well. I prefer
the 68HC11F1 myself because it has automatically timed output
registers that make it easy to generate perfect waveforms.
In regards to your question on accumulating statistics... that's
a hard one. An external interrupt pulse is probably the easiest
way to do it even though you do not like the idea. It may also
be sufficient to call getmicrouptime from the interrupt you are
already getting from the I/O board. Another possibility would be
to write a user-level process with access to the I/O space (via
/dev/mem or /dev/io) to poll in a tight loop and collect
statistics that way.
-Matt
Matthew Dillon
<[EMAIL PROTECTED]>
To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message