Bosch Sensortec Community

    cancel
    Showing results for 
    Search instead for 
    Did you mean: 
    SOLVED

    BMX160 PITCH,ROLL AND YAW

    BMX160 PITCH,ROLL AND YAW

    amar
    Established Member

    Hi everyone,

    I worked on BMX160 IMU last few days, Till now i am able to get Raw readings of it like ACC(X,Y,Z),GYRO (X,Y,Z)and MAG(X,Y,Z) sensor.

    I confirmed raw readings of ACC and GYRO are correct or not by placing sensor at rest state and then raw readings are came like acc: 0,0,-/+1 and

    gyro: 0,0,0.(datasheet page no:106) but i didnot find any thing which is related to confirm Raw MAG readings are correct or not?

    And also i converted Acc and Gyro raw readings in to gravity,m/s^2 by using below formulas,

    //Here 2 is for 2g and 32768 for 16 bit value because ACC raw data is in 16 bit value 

    Ax = (acc_raw_x * 2)/32768;

    Ay = (acc_raw_y * 2)/32768;

    Az = (acc_raw_z * 2)/32768;

    //Here 250 is for 250dps and 32768 for 16 bit value because Gyro  raw data is in 16 bit value 

    Gx = (gyro_raw_x * 250)/32768;

    Gy = (gyro_raw_y * 250)/32768;

    Gz = (gyro_raw_z * 250)/32768;

    1) Can you please help me to find MAG Raw data correct or not?

    2) I am just reading raw data from six registers of MAG(0x04 -0x09)?is it correct?

    3) In BMX160 Datasheet for reading MAG data procedure given like below attached imge

     

    bmx160_image_1.PNG

    4) What is bmi160 API for doing above image task? i did not find any API in bmi160.c file like above image suggested ?

    5)  What king of fusion algorithm/filters  can i use to find pitch,roll and yaw from above readings?

    Please help me to come out of this issue.

    Thank you,

    Amarr

     

     

     

    11 REPLIES 11

    FAE_CA1
    Community Moderator
    Community Moderator

    Hi,

    Thanks for your inquiry.

    BMX160 is a 9-axis sensor that includes BMI160 IMU (accel + gyro) and BMM150 (mag) inside, where BMM150 is connected to BMI160's secondary I2C interface internally as a slave. BMI160 API source code at https://github.com/BoschSensortec/BMI160_driver has all necessary functions to configure BMM150 mag and get mag raw data and convert raw data to final meaningful magnetic field values in the unit of uT.

    Please see the answers to your questions.

    1) Can you please help me to find MAG Raw data correct or not?

    >>> There are two ways to check MAG data. The first way is to check the sign of each axis. If you are located in Northern Hemisphere such as USA or Canada, then the earth magnetic field vector will point downwards. So when you place your device with MAG any axis pointing down, then that axis output value should be positive in the unit of uT. If pointing upwards, then the output will be negative. The second way is that you can place your device on a flat table and then rotate it slowly with a full circle. It doesn't matter if you rotate the device clockwise or counterclockwise. If you rotate along Z axis, then you can plot X and Y axis data in 2D plane. You should be able to see a shifted circle or ellipse from the origin.

    2) I am just reading raw data from six registers of MAG(0x04 -0x09)?is it correct?

    >>> Yes, that is correct. MAG raw data from registers 0x04 to 0x09 don't give you anything. You need to use BMI160 API code to do temperature compensation on the raw data and then convert them to final meaningful values in the unit of uT.

    3) In BMX160 Datasheet for reading MAG data procedure given like below attached image

    4) What is bmi160 API for doing above image task? i did not find any API in bmi160.c file like above image suggested ?

    >>> BMI160 API configures MAG, sets up MAG to work under forced mode, retrieves MAG raw data and places raw data into its data registers from 0x04 to 0x09 and converts raw data to final magnetic field values in the unit of uT.

    5) What king of fusion algorithm/filters can i use to find pitch,roll and yaw from above readings?

    >>> Please refer BSXLite SW at https://www.bosch-sensortec.com/software-tools/software/sensor-fusion-software/#bsxlite for more information. You should be able to get pitch/roll/heading Euler angles, quaternions, linear acceleration and gravity vector from BSXLite.

    Thanks.

    amar
    Established Member

    Hi FAE_CA1,

    Thank you for reply,

    As you told i downloaded BMI160 Driver code from your suggested link, but i did not find  any MAG Data retrived API from BMI160 Driver code.

    https://github.com/BoschSensortec/BMI160_driver 

    " >>> BMI160 API configures MAG, sets up MAG to work under forced mode, retrieves MAG raw data and places raw data into its data registers from 0x04 to 0x09 and converts raw data to final magnetic field values in the unit of uT"

    Can you point it out from BMI160 Driver?

    Thank you in advance,

    amarr

    FAE_CA1
    Community Moderator
    Community Moderator

    Hi,

    Sorry, the first page of the link of BMI160-API tells you that you need to include "bmm150.h" which is available at https://github.com/BoschSensortec/BMM150-Sensor-API.

    Thanks.

    amar
    Established Member

    Hi,

    Till now i am able to read mag data by following below attached image by directly writing MAG registers of it, is it correct? because as you told for reading MAG Data from BMI160, can i definealtly use bmm150?

    1) Can i make same functionality of bmm150 API did by indirect reg writing like below attached image?

    2) Finally am i able to read correct MAG data, if i folllow the below attached image process?if not why?

     

    Capture_2.PNG

    Thank you,

    amarr

    Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist