Bosch Sensortec Community

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

    wrong read out accelerometer BMA280

    wrong read out accelerometer BMA280

    NickDR92
    New Poster

    Hi

    For a research project, I am currently trying to read the acceleration data from the BMA280. This chip is used by silabs on there WSTK expansion board. At this moment I'm following a complete procedure to initialize the accelerometer.

    1. Perform self test
      1. Check if difference from read out of +X en -X is bigger than 800mg (answer: check)
      2. Check if difference from read out of +Y en -Y is bigger than 800mg (answer: check)
      3. Check if difference from read out of +Z en -Z is bigger than 400mg (answer: check)
    2. Soft reset the accelerometer
      1. wait 1,5 sec
    3. Initialize the accelerometer to my preferences
    4. Perform Fast compensation
      1. Clear offset register
      2. Set offset compensation to X: 0g, Y: 0g, Z:+1g, BW 1%
      3. X-axis calibration
      4. Y-axis calibration
      5. Z-axis calibration
      6. Read offset X              my answer: x = -31 mg
      7. Read offset Y              my answer:  y = -15 mg
      8. Read offset Z             my answer:  z = 0 mg
    5. init done

    The values afterwards are x=+-20mg, y=+-2mg en z=+- -19mg. I expected the values would be x=+-0g, y=+-0g en z=+- -1g when the chip is laying flat on my desk.

    I convert the acceleration data in this way.

     

     

    volatile float factor = 0.488; // 8000/2^14 mg/LSB
    // X-Axis in 0x02-0x03
    LSBx = BMA280_read_register(USART1, BMA280_ACCD_X_LSB);
    LSBx = LSBx >> 2;
    MSBx = BMA280_read_register(USART1, BMA280_ACCD_X_MSB);
    tmpx = (uint16_t)((MSBx << 6) | LSBx);
    acceleration[0] = (float) tmpx * factor;

     

    Can somebody confirm me If this is correct? Or give me the correct init from the accelerometer?

    Thank you in advance

    Best Regards

    Nick

    3 REPLIES 3

    FAE_CA1
    Community Moderator
    Community Moderator

    Hi,

    Thanks for your inquiry. Please see the attached "How to perform BMA253 self-test.pdf" and "How to do BMA253 inline calibration.pdf" which can be applied to BMA280 as well.

    Due to the noise of intenral ADC, after inline calibration BMA280 x/y/z measurements or outputs will not be exactly at 0g and +1g when it is stationary and flat on your table. Instead, they should be very close to 0g and +1g. For example, if you select BMA280 BW to 125Hz which is 250Hz output data rate, then you should see the x/y/z outputs within +/-5mg with regrad to 0g and +1g.

    Thanks.

    Hi

    Thanks for the reply.

    I checked both PDF and adjusted my code. When I perform the self test I get values (x=12599LSB, y=13235LSB, z=13589LSB) So the self test passes. The calibartion (fast compensation +-2G) gave me (x=-5LSB, y=1LSB, z=-2LSB).  But when the chip is flat on my desk with a refresh rate of 125Hz I get these values:

    x: 16,0 mg y: 51,172 mg z: -25,252 mg
    x: 15,0 mg y: 53,216 mg z: -21,240 mg
    x: 17,0 mg y: 54,116 mg z: -19,240 mg
    x: 18,0 mg y: 54,16 mg z: -23,252 mg
    x: 20,0 mg y: 50,184 mg z: -20,96 mg

    So I think, I do something wrong with the conversion of LSB to g or mg.

     

     

     

    volatile uint16_t tmpx = 0, tmpy = 0, tmpz = 0;
    volatile uint8_t MSBx = 0, LSBx = 0, MSBy = 0, LSBy = 0, MSBz = 0, LSBz = 0;
    volatile float factor = 0.488; //mg/LSB 8000/2^14 for range of +-4G
    
    // X-Axis in 0x02-0x03
    LSBx = BMA280_read_register(USART1, BMA280_ACCD_X_LSB);
    MSBx = BMA280_read_register(USART1, BMA280_ACCD_X_MSB);
    tmpx = (uint16_t)(((MSBx <<  | LSBx) >> 2);
    acceleration[0] = (float) tmpx * factor;

     

     

     

    Is this the correct way?

    Thx for the previous help!!

    Best regards

    Nick

    I found the solution.

    // X-Axis in 0x02-0x03
    LSB = BMA280_read_register(USART1, BMA280_ACCD_X_LSB);
    MSB = BMA280_read_register(USART1, BMA280_ACCD_X_MSB);
    Ax = (int16_t) ((MSB << 😎 | LSB);
    Ax = Ax >> 2;
    Acceleration[0] = ((float) Ax) * factor; //0,244mg/LSB

    Thx for the help

    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