How does the X-CUBE-MEMS1 Motion MC library know the difference between an LSM9DS1 and an LSM6DSO?
Deep in the STMicro Compass example in the STMicro's X-CUBE-MEMS1 code-package there is a call made to the STMicro Motion MC library to calibrate the LSM6DSO magnetometer. The STMicro compass code passes both the magnetometer values and the accelerometer values to the STMicro MC library. In return the library provides compensation values to be used on the magnetometer values. These compensated values are then passed to the Motion EC library. But before they are passed, the comments say that the X, Y & Z magnetometer axes values need to be changed to East-North-Up. Which appears to be simply switching the X and Y axis.
All that is fine and good. But I am using the LSM9DS1, not the LSM6DSO. The difference? Well the Y magnetometer axis is flipped! So, naturally I decided to "un-flip" the LSM9DS1's Y axis by multiplying it with -1. That did not work. The Motion MC library was never able to calculate working compensation values! Therefore the compass never worked!
What eventually work? Well, I found that if I gave STMicro's Motion MC library the un-flipped Y magnetometer value, -then- flipped the compensated Y magnetometer value before giving it to the STMicro's Motion EC library, the compass would work as expected.
But how?
How could the STMicro's Motion MC library properly calibrate the LSM9DS1 magnetometer values when the Y value on the LSM9DS1's magnetometer is backwards with respect to the Y value on the LSM6DSO???
Is there something in the STMicro's Motion MC library that knows what chip is being used??
Further, why does the compensated Y magnetometer value need to be flipped before giving it to the STMicro's EC library?? The question begging for an answer is - if the STMicro MC library knows what magnetometer chip is being used, then why is the STMicro EC library in need of "external corrections"??
-thanks
