05 January 2008

Not enough resolution with integers

Finished code to use Kalman filter. Bot working a lot better than before. Not balancing, but no where near as ill behaved.

Problem: As Self balancing needs moderate power when small angular changes occur I need to have large PID control loop K values. Which means VERY granular changes in speed. For example with Kp=100, we go from speed 0 to speed 100 to speed 200.

Need to either use fixed point or floating point. Some of my old code uses a form of fixed point arithmetic. For example by using milli-gravities and milli-volts rather than gravities and volts. Would be great to use floating point, but I've no idea of the performance issues. In fact, I have no idea of the performance characteristics of the Atmega186 at all.

Solution: I just wrote the sketch Benchmarks/IntLongFloatMult to find out the speed of multiplying int/long/floats. Results: 4M int mults/sec. 2M long mults/sec. 2M float mults/sec.

Floating point is plenty fast. Not much sense in using fixed point. Will rewrite PID, Kalman, and other libraries to use floating point. Much of af the Kalman code already uses floating point so that should be easy ...

No comments:

Post a Comment