# SparkFun Forums

### IMU acts weird

What are we doing right with Artemis? What are we doing wrong? Let us know here!

### IMU acts weird#235880

By FilipVukovic
#235880
Hi,

First of all, please let me know on what forum topic I should post this question if it does not belong here

I have an OpenLog Artemis with IMU (DEV-16832). I want to calculate absolute coordinates using that 9 DoF IMU. Now, I tried doing so using trigonometry and Euler angles but that exposes me to gimbal lock and who knows what other problems. So I research this topic further and found that people use Quaternions for such solutions (using Madgwick's Quaternion Update algorithm).

This approach does not work as I want it to since I got pretty much the same problem as before (with Euler angles).

Next, I found out that the DMP can calculate quaternions for me so I tried that out but weird things kept happening. For example, when the IMU is placed stationary on the table, quaternion (Q1, Q2, Q3) values kept increasing or decreasing and then after 15 seconds they would stop, then again when I would move it (for 90%) I would, again, have to wait for about 15s until those values "calmed down".

Also, the 9DoF values (aX, aY, aZ, gX, gY, gZ, mX, mY, mX) are not really stable when the IMU is stationary, but that's something I can solve using average values of n readings since that is just sensor noise I suppose.

Do I have to calibrate the IMU and if so, how? (I have not found any detailed description on how to calibrate it).

And I know its a long shot, but does anyone have any working solutions that calculate absolute coordinates using ICM-20948?

Thank You for Your help and time!
Best Regards
Filip V

### Re: IMU acts weird#235882

By PaulZC
#235882
Hi Filip,

You do need to calibrate the DMP, so the readings become stable. You need to rotate the IMU around all three axes. This allows the DMP to measure the 'scale' and 'offset' for each sensor channel.

Best wishes,
Paul

### Re: IMU acts weird#235883

By FilipVukovic
#235883
Hi Paul,

What does that mean exactly? Something like calibrating phone GPS?

Best Regards,
Filip

### Re: IMU acts weird#235885

By FilipVukovic
#235885
Hi Paul,

Thank You very much for the explanation! Now it's much better, but only after some time. It takes some time after powering on to get to starting point I guess

One last question. Di I have to do it every time I power it up?

Best Regards!
Filip

### Re: IMU acts weird#235887

By PaulZC
#235887
Hi Filip,

Yes, every time, sorry! It should be possible to save and restore the DMP calibration, but - at the moment - we do not know how to do that. You can read a long discussion about it here:

https://github.com/sparkfun/SparkFun_IC ... /issues/50

Best wishes,
Paul

### Re: IMU acts weird#235888

By FilipVukovic
#235888
Hi Paul,

Thank You for Your help and time!

Best Regards!
Filip

### Re: IMU acts weird#235894

By jremington
#235894
Do I have to calibrate the IMU and if so, how? (I have not found any detailed description on how to calibrate it).
Yes, if you are not using the DMP. The gyro and the magnetometer MUST be calibrated for the Mahony or Madgwick filters to work at all. There are plenty of tutorials posted on line, but to summarize:

1. Calibrate the gyro by collecting a few hundred readings with the sensor held still, average those and store them as offsets. Subtract the offsets from subsequent raw measurements.

2. Calibrate the magnetometer by following the procedure outlined in this forum post (and read the references linked in that post): https://forum.pololu.com/t/correcting-t ... eter/14315
Topic permissions

You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

###### long long title how many chars? lets see 123 ok more? yes 60

We have created lots of YouTube videos just so you can achieve [...]

###### Another post test yes yes yes or no, maybe ni? :-/

The best flat phpBB theme around. Period. Fine craftmanship and [...]

###### Do you need a super MOD? Well here it is. chew on this

All you need is right here. Content tag, SEO, listing, Pizza and spaghetti [...]

###### Lasagna on me this time ok? I got plenty of cash

this should be fantastic. but what about links,images, bbcodes etc etc? [...]