Pololu Robotics & Electronics
My account Comments or questions? About Pololu Contact Ordering information Distributors

Smoothing output from the MinIMU-9 (L3G4200D and LSM303D)


Hey guys,
Just wondering if anyone has implemented any kind of filter, or played around with smoothing the values off this device??
I’m using the AHRS Program that you guys wrote and it is extremely impressive.

I’ve got my MinIMU-9 hooked up to a head-tracking system I’m developing - the only problem is it works TOO good, haha :mrgreen:
The “camera” inside the game is linked to the Euler angle output almost exactly, so even when the device is just sitting on my desk there is still a very tiny amount of movement (like .05 to .1) “vibration” on each axis…

I’m not sure where (in the AHRS Code) I could change/average the output as it seems like it’s tied into those Matrix calculations… but I really have no idea, you guys are on a WAAAAY higher Math level than me, haha.

Thanks for any help/advice!



Could you just smooth the yaw, pitch, and roll angle outputs coming out of the AHRS? A running average would work, and that would probably be the easiest way to get the smoothing you are looking for.

- Kevin


Hi Kevin, thanks for the tips!
Is there any way to do it before the AHRS program outputs the yaw/roll/pitch? I’ve tried making a small loop inside my program that waits for 6 values to be accumulated, then divides by 6 to get the average, but it’s not working very well… I’ll keep at it!



Sure, you could do the averaging inside the AHRS program before it does the final angle calculations, but it would pretty much have the same effect if you use the same averaging method.

Does your program produce better results if you use more samples per average?

- Kevin



I haven’t thought about this too hard, and I haven’t looked at the AHRS code, so take my advice with a grain of salt, but it’s not obvious to me that it’s valid to average the Euler angle outputs (the three angles aren’t independent). If I were in your position, I think I would try to average the raw accelerometer, gyro, and magnetometer data and then pass those averages to the AHRS algorithm.

- Ben


Awesome guys, thank-you both for the excellent advice - When I have some time this weekend I’ll dive back in and see what I can do using your suggestions!
Had one question for Kevin though - how do you increase the number of samples? :slight_smile:


I just meant that instead of accumulating 6 values and dividing by 6, you could try accumulating and dividing by a larger number, which should have more of a smoothing effect.

It looks like burkleypatterson is working on some filtering on his own MinIMU-9 in this thread. You might be able to get some advice from him or work together on this.

- Kevin