From owner-freebsd-current Fri Jun 12 03:07:08 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id DAA00826 for freebsd-current-outgoing; Fri, 12 Jun 1998 03:07:08 -0700 (PDT) (envelope-from owner-freebsd-current@FreeBSD.ORG) Received: from hda.hda.com (hda-bicnet.bicnet.net [208.220.66.37]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id DAA00721 for ; Fri, 12 Jun 1998 03:06:43 -0700 (PDT) (envelope-from dufault@hda.hda.com) Received: (from dufault@localhost) by hda.hda.com (8.8.5/8.8.5) id FAA28604; Fri, 12 Jun 1998 05:38:34 -0400 (EDT) From: Peter Dufault Message-Id: <199806120938.FAA28604@hda.hda.com> Subject: Re: floating point usage within the kernel - howto ? In-Reply-To: <199806110745.JAA22102@labinfo.iet.unipi.it> from Luigi Rizzo at "Jun 11, 98 09:45:30 am" To: luigi@labinfo.iet.unipi.it (Luigi Rizzo) Date: Fri, 12 Jun 1998 05:38:33 -0400 (EDT) Cc: jb@cimlogic.com.au, mike@smith.net.au, current@FreeBSD.ORG X-Mailer: ELM [version 2.4ME+ PL25 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > > Luigi Rizzo wrote: > > > they want to run a P-I-D controller (and more generic controllers > > > if this goes well) to control a few motors, for didactical purposes. > > > > What update rate do they need that requires the code to run in the kernel? > > whenever i ask this question the answer is invariably "as fast as > possible". You have to get a better answer from them than that - they must know the bandwidth of the controllers and the number of control laws. The analog signal conditioning should match the design bandwidth. Alsi, in addition to the implementation of the control laws, the loading on the system has to be such that it can continue to run. The "as fast as possible" answer may mean the more horsepower the more complicated controllers they'll attempt, but it can mean ignoring the digitization aspects of the digital controller and not doing the analog filtering properly, not worrying about amplifying noise in the digital derivative in the D term, etc. > In any case, we don't have a real target application, it is just > a framework that must be adapted to different apps, so i would > expect a max rate of 1 KHz to cover all practical purposes, with > 100Hz being sufficient in many cases. I've done this in the 386BSD days by treating the PID controller like an embedded system not using any OS services, speeding up the clock tick by a factor of N, and calling the controller on each tick and the system every N ticks. You communicate between this controller and a kernel device driver through a mail box or queue scheme. I did it with fixed point controllers and avoided the floating point issue. In addition to implementing two control laws it was microstepping a digital throttle through the printer port, and you could telnet to it. This might look like a klooj compared to speeding up HZ, but it has its advantages. The controller is ready to move to an embedded system or board. You have a single point where you can save/restore floating point without worrying about other kernel facilities using floating point. The code that has to be validated for safety and that you must be sure is running properly is outside of the kernel, and you could potentially map and unmap it to avoid being stepped on, etc. > (and, last not least, robotics people tend to have a > lot of money just because their hardware costs so much :) Purchase orders for a contract cheerfully accepted at the e-mail address below. Peter -- Peter Dufault (dufault@hda.com) Realtime development, Machine control, HD Associates, Inc. Safety critical systems, Agency approval To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message