After a few more tests, I now have the final version of the ArduIMU. The main problem was the calibration of the gyros: converting the raw data to degrees/s. I had to change the source code, compile it, upload, and repeat it over and over again. Totally waste of time.

So i configured Arduino to externally adjust the gyros and the accelerometer jitter filter, using the nunchuck potentiometers (joystick axis). Now it’s working pretty well. =)

Please, in the source code, ignore all the lines marked with "//(kalman)", this lines are related to the kalman filter code, those marked by "//(nunchuck) are related to nunchuck accelerometer and axis control, and all marked by "//(gyro)" are code related to the control of the gyroscope.

Another tip, all the data is processed in radians, then is converted to degrees (radian*180/PI = radians*57.295779= degrees). If somebody needs any help, please feel free of asking me.


-Yellow color = Just Accelerometer read
-Red color= Accelerometer+Gyro+KalmanFIiter

Arduino Source Code:

Labview (ground station) source code:

To do: -Integrate another Gyro (to make it dual axis) . -Program the SPI altimeter.
-And put all the hardware together and make it work (GPS, Altimeter, IMU, Modem).

Done: -Servo control -Gps Waypoint navigation (I’ll post later about it).

The next article I'm going to post all the links to get started with Arduino environment. All you would need to learn: tutorials, examples, references, tips and tricks. If you already know C++ it’s going to be 99% easier. If not, you are going to discover why C/C++ is the most compressive and famous language ever ;-) Then jumping to any AVR, ARM, PIC microcontroller C/C++ language environment, is going to be a lot easier, because they’re all based on the same principles.

Views: 40662

Comment by Tx36 on April 24, 2011 at 5:50am

Hello sir,
i have been looking for Kalman filter to use on my Arduino, with 3-axis acclerometer (BMA-180) and 3-axis gyro (ITG-3200)...

Can you please tell me if your code here works for me?
Also what circuit connects i have to make?

I'm a beginner into this so please help..

thank you..

Comment by bprasanthmce on April 30, 2011 at 7:00am

how to convert this code for pitch roll and yaw axis with 6 dof razor imu


Comment by bprasanthmce on April 30, 2011 at 7:00am

how to convert this code for pitch roll and yaw axis with 6 dof razor imu

Comment by Anu Gunara on April 9, 2012 at 5:43pm

Hi Jordi, I have a question about your code. What is the difference between the q_m and q_bias? Is q_bias the voltage or the digital value the gyro outputs when it's not moving? I'm trying to combine a digital compass and a single axis gyro using a kalman filter, so any help that you can give me would be greatly appreciated.


You need to be a member of DIY Drones to add comments!

Join DIY Drones


Season Two of the Trust Time Trial (T3) Contest 
A list of all T3 contests is here. The current round, the Vertical Horizontal one, is here

© 2019   Created by Chris Anderson.   Powered by

Badges  |  Report an Issue  |  Terms of Service