Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 30 Sep 2001 10:47:53 -0700
From:      Greg Shenaut <greg@bogslab.ucdavis.edu>
To:        hackers@FreeBSD.ORG
Subject:   Re: precise timing 
Message-ID:  <200109301747.f8UHlsA35003@thistle.bogs.org>
In-Reply-To: Your message of "Sun, 30 Sep 2001 10:18:01 CDT." <200109301010.07784@EO> 

next in thread | previous in thread | raw e-mail | index | archive | help
In message <200109301010.07784@EO>, Bart Kus cleopede:
>	On a totally unrelated subject to my sio.c message, I have a second problem. 
> I've built a computer-controlled drill, that is controlled via the parallel 
>port.  This drill uses stepper motors, at 1/2 step.  My driver software 
>implements a maximum-acceleration control algorithm that ensures that at any 
>point in time, any axis will not experience more than X m/s/s of 
>acceleration.  This keeps the drill from self-destructing. :)  Unfortunately, 
>it means I need access to a very precise timing source to issue the step 
>instructions to the motor control board.
>
>	Right now, I use for() as a timing loop.  I calibrate it on program start 
>and can then get very precise timing.  There are, of course, the intermittent 
>interruptions of the multitasker.  So this solution is not ideal by any 
>means.  In fact, the for() loop approach is really meant for the DOS port of 
>this software.  I'm wondering if there is any way I can access a more precise 
>interrupt-driven (or blocking) timing source.  I know I can do a select() 
>with supposedly microsecond accuracy, but I doubt that it is in fact that 
>accurate in practice (doesn't the kernel only use a 100Hz clock or 
>something?).

Well, setitimer has a maximum rate of 100 Hz, with a slop factor
sometimes much greater than 10 ms.  This was the result of some
recent testing on a lightly-loaded standard 4.3 system.

>Is there any way to get at the system timers on the 
>motherboard?  Those can provide precise timing, no?

But not necessarily realtime response if you are generating the
stepper pulses yourself.

How many stepper motors are you driving?  If it's only one at a time, then
maybe the speaker port on the motherboard (a programmable counter-timer)
would be more reliable.  Another idea is to use a fifo'ed UART's data out
line and fiddle with the baud rate to vary the speed of the pulses.  And
one final idea is to use a (possibly port-powered) MCU as an independent
timer generator.

Greg Shenaut

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200109301747.f8UHlsA35003>