Bosch Sensortec Community

    Showing results for 
    Search instead for 
    Did you mean: 

    An issue at generate quaternion on BMX160

    An issue at generate quaternion on BMX160


    Dear moderators and engineers!

    I have encountered problems when using BSXLite to generate quaternions on BMX160, as described below. Previously considering BMI160+BMM150, the problem was the same. Later, because BOSCH sales staff suggested using BMX160, the problem also exists. I think it is a simple link that has a problem. Please help me check it out:

    Chip: BMX160, 

    MCU: Cortex M3, 

    Language: C programming, 

    Compiler Environment: MDK5

    System situation: BLE-Stack


    1. The main functions initialization




    2. void my_bsx_init() Functions achieve as follows:















    3. Operate Algorithm library, updataing value of sensors. Program will run to this function per 30mS


    My Bsx step process Functions achieve as below:


    4. Get quaternion,  Program will call follows functions to take quaternion


     Finally no changes with quaternion




    7 REPLIES 7

    Established Member

    Dear coder,

    I use BMX160 in one of my projects and I've had no problem retrieving quaternion data from the library. Have you considered using BMI160 and BMM150 drivers for communicating with the IMU (BMI160, BMM150)? I understand that this may not be your ultimate goal, but maybe it would be useful to pinpoint where the problem is. Additionally, here's the topic that cleared a thing or two for me.

    Disclamer: I am far from an expert and I'm also not a Bosch employee. Bosch engineers will certainly have better advice.

    Kind regards,

    Marko Njirjak

    Dear Marko Njirjak

    Yes, I have read the post you posted and checked the related program and found no similar problems. Are you using the Cortex MCU as well? I think the search for quaternions is not too complicated. If there is a comparison block, maybe I can find the reason. Can you show me the code you used to retrieve the quaternion?

    thank you very much!


    Established Member

    Dear coder,

    yes, I use Cortex M4F.

    Here are some sample codes:

    a) BSX Lib initialization


    initParam_t s_input;
    s_input.accelspec = (BSX_U8 *)&bsxLibConfAcc;
    s_input.magspec = (BSX_U8 *)&bsxLibConfMag;
    s_input.gyrospec = (BSX_U8 *)&bsxLibConfGyro;
    s_input.usecase = (BSX_U8 *)&bsxLibConf;


    b) Feeding data to BSX lib (this is done every 10ms)

  = accel_data.x; = accel_data.y; = accel_data.z;
    libraryInput_ts.acc.time_stamp = accel_data.sensortime*39; // BMX160 timestamp resolution is 39us, hence multiplying by 39 = gyro_data.x; = gyro_data.y; = gyro_data.z;
    libraryInput_ts.gyro.time_stamp = gyro_data.sensortime*39; =; =; =;
    libraryInput_ts.mag.time_stamp = accel_data.sensortime*39;


    c) Quaternion acquisition


    ts_dataquatf32 quaternion;


    I do use BMI160+BMM150 sensor APIs, i.e. I'm not fetching registers directly.


    Kind regards,

    Marko Njirjak

    Hi there,

    I would recommend to debug in steps, to help isolate the software issue.

    1- IMU raw data.
    Make sure that you integrate BMI160 API correctly and validate that you get raw data for Accel + Gyro that makes sense
    2- Magnetometer raw data
    Make integrate the BMM150 API and validate that you get raw mag data that makes sense
    3- BSX NDOF mode 50Hz test, virtual timestamps
    Sample the data at 50Hz and feed it to BSX library in IMU mode. Increment the timestamp artificially by 20ms each datapoint. Verify the output makes sense
    4- BSX NDOF mode 50Hz test, real timestamps
    Same as #3, but with real sensor timestamps

    Then you would have validated the entire hardware and software integration of the Bosch Sensor and Library.

    Note: BSXLite is limited to 50Hz in NDOF mode. If you would like to take advantage of the full BSX Library, consider BNO055 or BHI160.