Rotomotion's Kalman filter tilt.c by Tom Hudson

Have you got the greatest 48 bit multiplier ever conceived? Prove it - post your code here.

Moderator: phalanx

Post Reply
rp181
Posts: 47
Joined: Mon Jan 04, 2010 5:45 pm

Rotomotion's Kalman filter tilt.c by Tom Hudson

Post by rp181 » Tue Sep 07, 2010 6:09 pm

I recently found Tom's kalman code:
http://www.rotomotion.com/downloads/tilt.c

What kind of values does this take in? Should the input be offset by the zero value?
I tried offsetting the zero value and giving it the raw ADC data (8000 is gyro flat), so Sensor value - offset value.

I get results from the kalman filter, but they do not look right at all. It jumps all over the place, and kind of acts like a out of tune PID loop, but worse.

Code: Select all

for (i = 0;i<100;i++) {
		averageSumg += getValue(7);
		averageSumy += getValue(2);
		averageSumz += getValue(3);
		delay(10);

	}
	averageSumg = averageSumg/100;
	averageSumy = averageSumy/100;
	averageSumz = averageSumz/100;
averageSumy, averageSumz);
	while (1){
	for (i = 0; i < 1000; i++) {

		pitchgyro = getValue(7)-averageSumg;
		accely = getValue(2) - averageSumy;
		accelz = getValue(3) - averageSumz;

stateup(pitchgyro);
anglenew = kalmanup(accely,accelz);

Post Reply