# IMU sensor and compensation

Hi I'm using "minImu 9" 9 DOF IMU (gyro, accelerometer and compass) sensor and it gives pitch roll and yaw values with a slope on desktop (no touch, no vibration, steady). Y axis is angle in degree and X axis is time in second. X axis length is 60 seconds. How can fix this?

Pitch

Roll

Yaw

Note1: minIMU code

• what do the raw measurements look like when it's sitting on the table? – holmeski Dec 8 '15 at 18:39

MEMS gyros all have a problem with drift due to temperature. This can be worked around using several techniques, and higher cost parts generally have some amount of compensation built in. However, in my experience even the most expensive gyros need some individual calibration or sensor fusion techniques to deal with drift.

Taking a look at this sensor package, the 3 axis gyro is not calibrated for temperature, but does include a temperature sensor. This is pretty common in low cost gyros.

As an aside, I would not consider this part an IMU since it does no sensor fusion or calibration between the gyro, temperature sensor, accelerometer and magnetometer. This is reflected in its price.

Anyway, what that means is you will need to come up with a way to deal with the gyro drift yourself.

The best technique is going to depend on your application and budget, but here are some approaches to look at:

1. Buy a better IMU: Depending on your budget, this may be the simplest solution. Expect to spend between $50-$100.00 for such a device.
2. Have an operational calibration process: In this case, you would measure the drift rate of each axis every time you knew it was not in motion, keeping it updated in a moving average and apply that as an offset to the measured rate. This is a simple solution if you have a way of knowing that the sensor is not moving and that will happen regularly during operation.
3. Calibrate the offset for temperature: If you have access to a precision thermal chamber, you can pre-calculate the drift rate vs temperature function and update it on the fly. This works best if combined with an occasional stopped calibration.
4. Implement a Complementary or Kalman filter to process the data. This is described in the answers to https://stackoverflow.com/questions/1586658/combine-gyroscope-and-accelerometer-data and can be combined with 2 and 3.
• it looks like he's already using a complimentary filter, you won't get that kind of drift using any sort of kalman filter. – holmeski Dec 7 '15 at 20:55
• @holmeski understands the problem: yes there is a filter. A filter just estimates new sensor reading and eleminates noise. In this measurement the sensor values increases/decreases monotonically filter is not a sollution. – acs Dec 8 '15 at 6:41

if you're using a complementary filter, it's likely you have a bias in your gyroscope. take an average of 100 measurements when the imu isn't moving and subtract that from future measurements.

How does removing the average change the behavior of the complimentary filter?

What do the measurements look like before and after the biases have been removed?

• subtracting avarage of first 100 not working. – acs Dec 8 '15 at 6:43