Bosch Sensortec Community

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

    BMX160 BSX Lite library integration problem

    Established Member

    Re: BMX160 BSX Lite library integration problem

    Hi neerajverma,

    if I'm not mistaken, all the sensors are asleep by default. You first have to initialize them and turn them on before you can fetch data. Maybe this is where the problem lies. This is the configuration that I use:

    a) initialization

     

    bmi.id = 0;
    bmi.interface = BMI160_SPI_INTF;
    bmi.read = spi_read_transfer;
    bmi.write = spi_write_transfer;
    bmi.delay_ms = delay;
    
    bmi160_init(&bmi);

     

     

    b) turning sensors on

     

    //Acc
    bmi.accel_cfg.power = BMI160_ACCEL_NORMAL_MODE;
    bmi.accel_cfg.bw = BMI160_ACCEL_BW_NORMAL_AVG4;
    bmi.accel_cfg.range = BMI160_ACCEL_RANGE_4G;
    bmi.accel_cfg.odr = BMI160_ACCEL_ODR_200HZ;
    
    //Gyro
    bmi.gyro_cfg.odr = BMI160_GYRO_ODR_200HZ;
    bmi.gyro_cfg.range = BMI160_GYRO_RANGE_1000_DPS;
    bmi.gyro_cfg.bw = BMI160_GYRO_BW_NORMAL_MODE;
    bmi.gyro_cfg.power = BMI160_GYRO_NORMAL_MODE;
    
    bmi160_set_sens_conf(&bmi);

     

     

    c) fetching data

     

    bmi160_get_sensor_data((BMI160_TIME_SEL | BMI160_ACCEL_SEL | BMI160_GYRO_SEL), &accel_data, &gyro_data, &bmi);

     

     

    To clarify, 'spi_read_transfer', 'spi_write_transfer' and 'delay' are master-chip specific functions for spi transfers and delay. 'bmi' is a structure of type bmi160_dev, 'accel_data' and 'gyro_data' are of type bmi160_sensor_data.

    In my project I also use the magnetometer, but I removed those parts of code to minimize confusion.

    Disclamer: I'm not a Bosch employee, so this is just a guess.

    Kind regards,

    Marko Njirjak

    Community Moderator
    Community Moderator

    Re: BMX160 BSX Lite library integration problem

    Hi neerajverma,

     

    If you are having issues getting started with BMX160, I would recommend to start your own thread and provide a link to this one in your description, and why the solution here does not work for you.

     

    Since this thread is marked as "solved" it is confusing to continue the discussion of more issues here.

    New Poster

    Re: BMX160 BSX Lite library integration problem

    Ok, sure. let me start new thread.

    Highlighted
    New Poster

    Re: BMX160 BSX Lite library integration problem

    Good day, 

    I am using the bmi160 and bmm150...I have used this post as a reference to develop my bsxLite fusion .

    I was hoping someone could shed some light on feeding the fusion library.  When using the struct "libraryinput_t" to feed the library, do i set the relevant variable i create to my sensor struct "bmi160_sensordata"? I have attached a screenshot of my code.

     

    Established Member

    Re: BMX160 BSX Lite library integration problem

    Hi Lashca_Pieterse,

    BSX fusion library is a standalone piece of software that accepts accelerometer, gyroscope and magnetometer measurements on one end and gives filtered data on the other end. With that in mind, you first need to fetch the data, preferably through Bosch drivers and than feed it to the library. The library accepts LSB format, which means that the data you fetch through Bosch drivers is pretty much tailored to your needs.

    Your code looks fine, the only thing that is missing is the data fetch before feeding it to the library. Here's an example for fetching accelerometer and gyroscope data:

     

    bmi160_get_sensor_data((BMI160_TIME_SEL | BMI160_ACCEL_SEL | BMI160_GYRO_SEL), &accel_data, &gyro_data, &bmi);

     

    P.S. You're missing magnetometer timestamp. For now, you can set is a gyroscope or accelerometer timestamp.

    Kind regards,

    Marko Njirjak

    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