From owner-freebsd-hackers Sun Sep 30 9: 2:41 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from srv1.cosmo-project.de (srv1.cosmo-project.de [213.83.6.106]) by hub.freebsd.org (Postfix) with ESMTP id 5F8BB37B409 for ; Sun, 30 Sep 2001 09:02:37 -0700 (PDT) Received: from mail.cicely.de (cicely20 [10.1.1.22]) by srv1.cosmo-project.de (8.11.0/8.11.0) with ESMTP id f8UG2Q634051; Sun, 30 Sep 2001 18:02:28 +0200 (CEST) Received: (from ticso@localhost) by mail.cicely.de (8.11.0/8.11.0) id f8UG33P19657; Sun, 30 Sep 2001 18:03:03 +0200 (CEST) Date: Sun, 30 Sep 2001 18:03:02 +0200 From: Bernd Walter To: Bart Kus Cc: hackers@FreeBSD.ORG Subject: Re: precise timing Message-ID: <20010930180302.A19621@cicely20.cicely.de> References: <200109301010.07784@EO> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <200109301010.07784@EO>; from bsd@shell-server.com on Sun, Sep 30, 2001 at 10:18:01AM -0500 X-Operating-System: NetBSD cicely20.cicely.de 1.5 sparc Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Sun, Sep 30, 2001 at 10:18:01AM -0500, Bart Kus wrote: > 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?). Is there any way to get at the system timers on the > motherboard? Those can provide precise timing, no? Controlling steppers via lpt is what I explained and showed last tuesday on the cosmo-project meeting. We used nanosleep() which worked fine for the demonstration and playing. As long as you don't have troubles with longer than requested periods this would fit your needs. Nevertheless in my opinion it's a job for a dedicated CPU/controller. Think about using an 68HC11 or something like that. If you can enshure not only minimum but also maximum step times you can even get the motor faster - well not with lowered drill of course. You can shorten the steps while the motor is rotating which you can't do at once. -- B.Walter COSMO-Project http://www.cosmo-project.de ticso@cicely.de Usergroup info@cosmo-project.de To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message