Bosch Sensortec Community

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

    An issue at generate quaternion on BMX160

    An issue at generate quaternion on BMX160

    coder
    Member

    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

    11.jpg

    ...

    issue1.jpg

    2. void my_bsx_init() Functions achieve as follows:

    lib_init.png

     

     

     

     

     

     

     

     

     

     

     

     

     

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

    22.jpg

    My Bsx step process Functions achieve as below:

    33.jpg

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

    44.jpg

     Finally no changes with quaternion

     

     

     

    7 REPLIES 7

    mnjirjak
    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!

    Andy

    mnjirjak
    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;
    
    bsx_init(&s_input);

     

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

     

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

     

    c) Quaternion acquisition

     

    ts_dataquatf32 quaternion;
    bsx_get_orientdata_quat(&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.
    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