View Single Post
  #2   Spotlight this post!  
Unread 09-02-2003, 16:52
Don Reid Don Reid is offline
Registered User
#0997
Team Role: Mentor
 
Join Date: Jan 2003
Rookie Year: 2002
Location: Corvallis, Oregon
Posts: 45
Don Reid will become famous soon enough
The first point is that you have to accumulate (integrate) in small enough units that you don't lose precision. Then when you have accumulated enough, you can convert to degrees.

Each unit of sensor input is worth a fraction
of a degree, (~1/53).

Code:
//   27 mV * sec    1V       127    1 (loop)
//   -----------  * --     * ---- * ----
//      degree     1000 mV   2.5V   0.026 sec
So you can accumulate the numbers from the sensor (with 127 meaning zero), then if you have
more than +53, thats 1 degree....

Also multiply by "delta_t + 1" to account for possible added delay.

You could use many other forms of multi-byte math, they are all really doing fixed point math with some scale factor using integers.
__________________
Don Reid

Last edited by Don Reid : 09-02-2003 at 16:58.