Skip to main content
Visitor II
January 2, 2019
Question

can we use the eCompass (MotionEC) and magnetometer calibration library with Lpc microcontroller.

  • January 2, 2019
  • 2 replies
  • 725 views

Hi ,

Can we use the libraries of  eCompass (MotionEC) and magnetometer calibration library (MotionMC) available in X-CUBE-MEMS1 package from the below path with lpc microcontroller.

 https://www.st.com/content/st_com/en/products/embedded-software/mcus-embedded-software/stm32-embedded-software/stm32cube-expansion-packages/x-cube-mems1.html

    This topic has been closed for replies.

    2 replies

    ST Employee
    January 2, 2019

    Unfortunately not, the libraries are intended for STM32 microcontrollers.

    PTadaAuthor
    Visitor II
    January 4, 2019

    Actually i am stuck in middle of something,

    I am using magnetometer LIS3MDL to work more like a E-Compass. We are measuring azimuth angle. I am not able to get tilt compensation right. Is there any reference design specific to this chip.

    This is the equation i am trying to use. Please let me know if there is something wrong. I am able to verify pitch and roll variations correctly.

    roll= atan(accData.fy/accData.fz);

    pitch= atan(-accData.fx/accData.fz);

    cosRoll = cos(roll);

    sinRoll = sin(roll);

    cosPitch = cos(pitch);

    sinPitch = sin(pitch);

    Xh = (magData.fx)*cosPitch + (magData.fy*sinPitch*sinRoll) + (magData.fz*sinPitch*cosRoll);

    Yh = (magData.fz)*sinRoll - (magData.fy)*cosRoll;

    magHeading = atan2(Yh, Xh);

    We will have to mount this on a metal structure, How can i compensate for soft iron.