Qwiic tilt-compensation: ICM-20948 / MLX90393?

Hi there,

I’m curious know if either the [SparkFun 9DoF IMU Breakout - ICM-20948 (Qwiic) or [SparkFun Triple Axis Magnetometer Breakout - MLX90393 can be employed as a tilt-compensated compass? I’ve been digging through their respective datasheets, but haven’t found any examples of how to accomplish tilt-compensation. Ideally, I’d like to achieve this using a Qwiic product, but I’d be keen to know if any of SparkFun’s IMUs/magnetometers can be used for tilt-compensation (aside from the $$$ HMC6343).

I’ve had good success with the LSM303D/LSM303DLHC in the past, but it looks like SparkFun only has the LSM303C.

Cheers,

Adam](https://www.sparkfun.com/products/14571)](https://www.sparkfun.com/products/15335)

Hi Adam,

I am afraid I do not believe either of those will work very well as a tilt-compensated compass. The ICM-20948 might be able to have tilt compensation since it uses the InvenSense Digital Motion Processor (DMP) and it does allow tilt readings through that software but our library does not have any functions that would allow you to use the ICM-20948 as a tilt-compensated compass.

Unfortunately, the only breakout we carry that I know can act as a tilt-compensated compass is the HMC6343. You might want to check [this list of devices from the folks over at I2Cdevlib for alternatives to the Honeywell Magnetometer.](Devices | I2C Device Library)

What is a tilt-compensated compass? A brief internet search only gave me guides for how to make one rather than what it is supposed to accomplish. Does this involve the declination of the Earth’s magnetic field?

Hi there,

A tilt-compensated compass is able to provide accurate heading values irrespective (for the most part) of the pitch and roll experienced by the sensor. For example, if the board is pointed at a heading of 180°, it will be able to maintain this heading even when pitched up or down or rolled to either side. There are different methods of calibrating the sensor, with some taking into account the hard-iron and soft-iron effects and others that simply use the minimum and maximum values of the sensor.

For more information see:

https://www.pololu.com/file/0J434/LSM30 … p-note.pdf

https://forum.pololu.com/t/lsm303d-tilt … em/11611/5

Cheers,

Adam

Thanks for that - so if I understand correctly you need to get the heading no matter what orientation the sensor is in…

I did something like that once when making a drag-tilt (water) current sensor. We wanted the heading to know which direction water was flowing but the sensor was expected to tilt through a range of orientations. https://spacegrant.colorado.edu/images/ … LOCATS.pdf

You should be able to do this with the ICM-20948 (either with DMP - which I have not used - or with your own sensor fusion). If you assume static conditions then the measured acceleration points in the direction of gravity and can be used to define the horizon plane in your coordinate system. Then projecting the measured magnetic vector onto that plane gives a compass heading (you will need another vector in that plane to measure the angle against - I used the projection of the Z-axis into the horizon plane for mine but that is numerically unstable when the sensor is near vertical so you might have to choose another way depending on your use case)

I drew an ugly picture in case you want to see it.

File upload tool is not working right now so the stick figure drawing will have to wait :frowning:

Hi liquid.soulder,

Thanks for your reply. I enjoyed looking over your poster.

My primary application is for iceberg tracking beacons deployed in the Canadian Arctic (https://cryologger.org/wp-content/uploa … t_2018.pdf). I typically employ a 6DOF sensor in my design in order to measure the iceberg’s orientation/rotation. Because the beacon enclosure can ablate (melt) into the ice or the orientation of the iceberg itself can change due to deterioration, the tilt-compensation helps to ensure that I’ll have a relatively good idea of its heading. The effects of magnetic declination also come into play, but this is usually accounted for later in post-processing.

While the The LSM303D has proven to be a cheap and simple solution, I’m in the process of trying to design a new tracking beacon based on the SparkFun Qwiic ecosystem. Hence, the interest in the ICM-20948. I haven’t worked too much with sensor fusion yet, but I’ll look more into it!

It’s also funny you should mention water current tilt sensors, as that’s also something I have on my list of things to do! Our lab is looking to build some inexpensive tilt sensors mounted to a mooring installed on the surface of the ice in the Arctic. I’ll be sure to pick your brain when I get to that project!

Cheers,

Adam

Oh cool! (pun intended?) Sounds like the kind of application that I am interested in so what a nice coincidence!

If you’d like to discuss the ICM-20948 more in terms of your requirements on precision/accuracy I’d be pleased to help.

And of course the same goes for your future drag-tilt application. That was a fun one.

Best, Owen