cancel
Showing results for 
Search instead for 
Did you mean: 

Is E-Compass library platform independent?

AAYKA.1
Associate II

Hi

I will use ECompass library for my project. I downloaded X-CUBE-MEMS library in which it has ECompasss library and application projects. They were written for your sensor development boards like IKS01A2 which has LSM6DSL, LSM303AGR sensors. Is this means that i must use only these sensors with this library? I want to use LSM303AGR sensor which has acc. and mag. both. Is it possible with this library? Or should i use it with LSM6DSL as it was used in application? Also, they were tested on your Nucleo boards like NUCLEO-F401RE. Can i export this code on STM32G431 series by changing just HAL layer?

Best regards,

3 REPLIES 3
Miroslav BATEK
ST Employee

Hello @AAYKA.1​ 

the libraries are software agnostic, there is not problem to use only LSM303AGR.

The library is available for Cortex M0, M3, M4. STM32G431 is Cortex-M4 so no ptoblem to use it on this MCU.

Please be aware you have to perform also magnetometer calibration before passing the data to MotionEC, for that we have MotionMC library.

You can use the project in X-CUBE-MEMS1 as reference.

AAYKA.1
Associate II

Thanks for quick reply. We have used LIS3MDL before and read its raw magnetometer data. Then calculated its angle by using x and y values. But we have seen that rotation is not working linearly. For ex, when we rotate it 90 degree, it outputs 50 degree, another 90 degree yields 150 degree and so on. Our ground is flat. So no need for tilt compensation. I would like to ask, is this E-Compass library correct this value and give nearly accurate results for direction?

Rstua.1
Senior

Hi @AAYKA.1​ , I have used the Cube-MEMS library with an LSM9DS1 which is a magnetometer, accelerometer & gyroscope all in one package. So it is possible to use with other STMicro MEMS chips. However, I have not been able to use the Cube-MEMS library with the lis2mdl megnetometer. Which is currently a mystery to me.

Guessing, from your description, it does not sound like the library code is calibrating your magnetometer properly. Dive into the Cube-MEMS example code to see how this happens. Unfortunately, the Cube-MEMS example code is not written to use the ST.COM MEMS drivers found on the STMicro GitHub.com web sites. So you may find it difficult to merge the Cube-MEMS code with the GitHub.com STMicro drivers for any new STMicro MEMS chips.