Kalman Filter 8 bit AVR - estimation and control

Go To Last Post
10 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,

I am just a newbie regarding the Kalman Filter, and was hoping to have some discussion from those with experience on implementing it on the 8 bit AVR platform or FPGAs. I know this question has been addressed before on this forum, but I need a more focused discussion.

Is it possible to do?
What are the limitations imposed by the AVR platform?
Why would someone choose to implement the Kalman Filter with FPGAs instead of the slower 8 bit AVR, especially for lower frequency < 1KHz signals?

Here is some webstuff I found...

Kalman Filtering
By Dan Simon
Embedded Systems Programming
Originally developed for use in spacecraft navigation, the Kalman filter turns out to be useful for many applications. It is mainly used to estimate system states that can only be observed indirectly or inaccurately by the system itself.
http://tinyurl.com/6dvkd

The Kalman Filter
Some tutorials, references, and research on the Kalman filter.
http://tinyurl.com/6e64l

Kalman C routine (seems easy for the AVR to do...)
cvs: autopilot/sim/src/mat/Kalman.h
http://tinyurl.com/4lyyo

Many thanks

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for posting these sites. The info will really help me with my Balancing Bot project.
~Mike

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

There are many variables to take into account to select how to implement a Kalman filter: the process to be measured, the (noisy) measuring process itself, and its noise.

For measures <1KHz and small number of dimensions of the state matrix (ie: 2) then probably would be better to use AVR than FPGA. For big matrices and samples per second better to do some DSP with FPGA, specially matrix works.

I wrote my own 'version' of a one dimension Kalman filter applied to a level measurement system, and that was really easy. Since my measurement process is noisy, and some times really wrong, I could reduce it to a single dimension (very easy to work with), and a different prediction system. That worked perfectly to me right now, since I setted up a fixed noise covariance in the measurement.

But this depends too much on the application you want to apply to.

Guillem.

Guillem.
"Common sense is the least common of the senses" Anonymous.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I posed this question to Dan Simon at UofCleveland and would like to share the response....and I also uploaded a terrific paper written by him (on his website) about implementing Kalman Filters with limited resources.

"Is it feasible to implement the Kalman Filter on an 8 bit microcontroller?"

Quote:

It depends on how you are modeling the signal. Basically you have to define a linear dynamic system that describes the behavior of whatever it is you are trying to estimate. You can do it several ways. If you are just trying to estimate the instantaneous magnitude of the sine, then you could model the sine as a 2-state, 3-state, 4-state (etc.) signal, depending on how much accuracy you want and how much computer power you have. The first state would be the magnitude, the second state would be the first derivative, the third state would be the second derivative, etc. At some point you have to assume that white noise is affecting the n-th derivative, where n is the number of states you are using. I did something like this in a project awhile ago: D. Simon and H. El-Sherief, “Hybrid Kalman / Minimax Filtering in Phase-Locked Loops,” Control Engineering Practice, vol. 4, pp. 615-623, October 1996.

Dan Simon
Cleveland State University
Dept. of Electrical Engineering
2121 Euclid Avenue, SH 332
Cleveland, OH 44115-2214

http://academic.csuohio.edu/simond/
216-687-5407

FWIW, if anyone has some Matlab Kalman Filter programs to share, I would like to learn from them. Dan Simon has alot on his page too.

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

One final reference:


Embedded Control Systems in C/C++: An Introduction for Software Developers Using Matlab

covers simulation of Kalman Filters in Matlab - CDROM included.

http://tinyurl.com/3t5xm

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Rotomotion has some stuff..

http://www.rotomotion.com/prd_RE...

tilt.c tilt.h C source code
Kalman filter with gyro bias tracking suitable for balancing a two wheeled robot.

Peter

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Can one of you folks try to explain to me the line of logic that would cause me to think I need a Kalman Filter to make a balancing type scooter.. Those two words seem to hold a Magic Quality as if they represent the Rosetta Stone of control systems... I'm just an old electrical engineer that taught himself to program back before computers were a 'science' and I was always awed by physicists and mathematicians that could read a page of heavy equations like a novel. But it must be way more complicated than 'measure the fwd rotation rate of the handle and drive the whells under the handle the way is falling'. What does the Kalman Filter do? What does it filter? The rotation rate? Where is the noise? Its tilting back and forth real fast? Does it obey the Nyquist criteion?

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

From my short experience and teorethical readings, the most common reason to apply a Kalman Filter is noise. When you want a greater accuracy than system's noise, and near (or beyond) Nyquist criterion, then you should use the Kalman Filter. The most commonly application is GPS positioning if you want accuracies of less than a meter. GPS gives an average error of 10m 50% of the time, less of 100m 90% of the time. In order to give an accuracy of about a meter with a 1SPS (the NMEA standar data rate) when the moving 'frequency' is about the same order of magnitude, the the Kalman Filter works very well. Specially if you use an inertial platform to calculate the estimation. This is ideal to use the short term accuracy of the inertial platform and the long term accuracy of the GPS systems.

I couldn't find any other reason than this. In fact, I'm using my own 'reduced order version' of the Kalman filter to keep a level in a tank with an ultrasonic transducer: It is noisy and has some artifacts that this filter helps to discart.

Guillem.

Guillem.
"Common sense is the least common of the senses" Anonymous.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

bobgardner wrote:
Can one of you folks try to explain to me the line of logic that would cause me to think I need a Kalman Filter to make a balancing type scooter..

I would feel more confident I wouldn't end up in the hospital if I knew the scooter was not going to flip me upside down with one or two spurious readings from the gyroscopes.

bobgardner wrote:
I was always awed by physicists and mathematicians that could read a page of heavy equations like a novel.

... and chess books too...

bobgardner wrote:
But it must be way more complicated than 'measure the fwd rotation rate of the handle and drive the whells under the handle the way is falling'.

I don't understand the mathmatical proofs behind the KF, so I am trusting others who do and present me with a practical application of the KF. It might be a case of the Emperor's Clothes http://tinyurl.com/654ln for all I know, and just makes me feel better!

It appears to me that the KF can be morphed into a filter of many applications. In my application, I am using to to serve as an expert opinion as to the likelihood of a certain state of my application being true or false as time passes rather than to control a system of some sort (like changing the tilt of the scooter). Sort of like a fuzzy logic, learning system. In fact KFs have been realized in neural network apps with good success.

But for a formal definition.... this is from the book quoted above...

The Kalman filter forms an optimal state estimate for a state-space plant model in the presence of process and measurement noise.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Hey guys. I made a small implementation of an Extended Kalman Filter Library intended for embedded use. Checkout https://github.com/dr-duplo/eekf. It's also usable for the standard Kalman Filter case.