Bosch Sensortec Community

    cancel
    Showing results for 
    Search instead for 
    Did you mean: 

    BMA4xy accelerometer series design guide

    Selecting the right part

    BMA456 is 16bit, digital, triaxial acceleration sensor with intelligent on-chip motion triggered interrupt features optimized for wearable and hearable applications. BMA456 support different advanced features via different configure file. Table 1 shows an overview of the features.

    Parameter

    BMA456

    Digital resolution

    16bit

    Range and sensitivity

    +/-2g: 16384LSB/g

    +/-4g: 8192LSB/g

    +/-8g: 4096LSB/g

    +/-4g: 2048LSB/g

    Zero-g offset(typ.)

    +/-20mg

    Noise density(typ.)

    120µg/√Hz

    Bandwidths

    5Hz …684Hz

    Interfaces

    SPI & I2C, 2 x digital interrupt pins

    Supply voltage

    VDD: 1.62 to 3.6V

    VDDIO: 1.2 to 3.6V

    LGA package(mm3)

    2.0 x 2.0 x 0.65

    Feature/Interrupts

    Step Counter/Step detector

    (optimized for wearables)

    Activity recognition: running, walking, still

    Tilt on wrist

    Tab/Double Tab

    Any-motion/No-motion

    High-g/ low-g

    Table 1: Overview BMA456 features

    Common characteristics
    The main characteristics of this product family are:

    Key features:

    • 2.0 x 2.0 mm² size
    • Pin to pin compatibility with all other 2.0 x 2.0 accelerometers from Bosch Sensortec
    • SPI or I²C interface
    • Configurable range from ±2G to ±16g
    • Configurable output data rate up to 1.6kHz
    • Integrated 1kB FIFO
    • Auxiliary I²C interface for connecting external magnetometer, including data synchronization
    • Built-in smart interrupt controller, with features such as step-counter which offers high performance for all wearing positions, including wrist-worn.


    BMA456 parameters
    BMA456 offers higher performance and stability in a smaller package. See the complete description in Table 2.

    Parameter

    BMA456

    Units

    Height

    0,65

    mm

    Digital resolution

    16

    bits

    Zero-g offset (typ.)

    ±20

    mg

    Noise density (typ.)

    120

    µg/√Hz

    TCO (X&Y axis)

    0.2

    mg/K

    TCO (Z axis)

    0.35

    mg/K

    TCS

    0.005

    %/K

    Cross Axis Sensitivity

    0.5

    %

    Table 2: BMA456 parameter value

    Available evaluation tools and software
    To best to evaluate the products from the BMA456 family, we recommend the following combination of evaluation tools:

    Layout recommendations

    Because the BMA4xy sensor family contains tiny mechanical structure inside the package, care must be taken during the layout phase to ensure the best performance. The complete handling and soldering guide can be found on the Bosch Sensortec's website.

    First power-on

    After powering the sensor for the first time, the initial specs would be to test for communication with the device. This can be done simply by reading the chip identification code in the register 0x00. See below for the expected values:

    Device

    Chip ID

    BMA456

    0x16

    Table 3: Chip IDs of the BMA4xy product family

    Here is some sample code on how to perform this test, based on BMA456, using the COINES software as the host.

    /*!

     * @brief This internal API is used to initializes the bma456 and verify the

     *communication by reading the chip id.

     *

     * @param[in] void

     * @return void

     *

     */

    static void init_comm_test_bma456(void)

    {

        int8_t rslt;

                  

        struct bma4_dev bma456dev = { 0 };  

        rslt = bma4_interface_init(&bma456dev, BMA4_I2C_INTF, BMA45X_VARIANT);

        rslt = bma456_init(&bma456devbma425dev);

        if (rslt == BMA4_OK)

        {

            printf("BMA456 Initialization Success!\n");

            printf("Test #1: Communication. PASSED. Chip ID 0x%x\n", bma456dev.chip_id);

        }

     

        else

        {

            char err_string[255];

            printf("BMA456 Initialization Failure!\n");

                                  

            if (BMA4_E_INVALID_SENSOR == rslt)

            {

                 sprintf(err_string, "Test #1: Communication. FAILED. Expected Chip ID: 0x%x. Received 0x%x\n",\

                                BMA456_CHIP_ID, bma456dev.chip_id);

            }

            else

            {

                 sprintf(err_string, "Test #1: Communication. FAILED. No response from the sensor.");

            }

                                  

            coines_exit_error(err_string);

        }

        coines_delay_msec(100);

    }

    How to test the sensor's functionality
    The BMA4xy series of accelerometers feature a fully integrated and motionless self-test procedure on the ASIC itself. When the self-test is triggered, the accelerometer uses electric fields to physically move the electrodes in all directions, senses the deflection and compares it with the expected output. Therefore, the built-in self-test features is the recommended way to test the sensor's functionality.

    Here is some sample code on how to perform this self-test, based on BMA456, using the COINES software as the host.

    /*!

     * @brief This internal API is used to test if the sensor is working by triggering the self-test.

     *

     * @param[in] void

     * @return void

     *

     */

    static void function_test_bma456(void)

    {

        uint16_t rslt;

        uint8_t testrslt;

     

        rslt = bma4_perform_accel_selftest(&testrslt, &bma456dev);

                  

        if ( 0 != rslt ) coines_exit_error("Test #2: Functionnality. FAILED. Unknown communication error\n");

                  

    if ( BMA4_SELFTEST_PASS == testrslt )

    {

            printf("Test #2: Functionnality. PASSED. Sensor self-test successful\n");

        }

    else

    {

            printf("Test #2: Functionnality. FAILED. Sensor self-test failed\n");

        }

                  

    }

    How to test the sensor's performance

    There are 2 performance parameters that can easily be tested with the device motionless: offset and noise. See below for the typical values of the sensors.

    Note: Typical values are defined as ±1σ, which means that we expect 68.3% of sensors to fall within these values. Min/Max values are defined as ±3σ, which means 99.7% of sensors shall be within these values.

    Parameter

    BMA456

    units

    Offset

    ±20

    mg

    Noise

    120

    µg/√Hz

    Table 4: Typical performance of BMA456

    For the offset, the test procedure is quite simple. With the device in a known position, such as a flat surface, calculate the average value for each axis, and substract the expected output (e.g. 0G, 0G, +1G) from the data. The result is the offset of the sensor.

    Here is some sample code on how to perform this test, based on BMA456, using the COINES software as the host.

    /*! Average value calculation */

    double x_avg_mg=0;

    double y_avg_mg=0;

    double z_avg_mg=0;

    for (int i=0; i<1000; ++i)

    {

        double xval, yval, zval;

        /* ( 'datapoint' * '4G' * '2' * '1000mg') / ('scaling factor for 16 bits') */

        xval = (((double)sens_data[i].x) * 4. * 2. * 1000) / pow(2,16);

        yval = (((double)sens_data[i].y) * 4. * 2. * 1000) / pow(2,16);

        zval = (((double)sens_data[i].z) * 4. * 2. * 1000) / pow(2,16);

                                  

        x_avg_mg += xval / 1000.;

        y_avg_mg += yval / 1000.;

        z_avg_mg += zval / 1000.;

    }

                  

    /*! Offset Calculation */

    double x_off_mg=x_avg_mg - X_REST_POSITION_MG;

    double y_off_mg=y_avg_mg - Y_REST_POSITION_MG;

    double z_off_mg=z_avg_mg - Z_REST_POSITION_MG;

                  

    if( OFFSET_THRESHOLD_MG > x_off_mg && OFFSET_THRESHOLD_MG > y_off_mg && \

                                   OFFSET_THRESHOLD_MG > z_off_mg )

    {

        printf("Test #3: Performance. Offset. PASSED: X=%4.1lfmg Y=%4.1lfmg Z=%4.1lfmg Threshold <\        %4.1lf\n",       x_off_mg, y_off_mg, z_off_mg, OFFSET_THRESHOLD_MG);

    }

    else

    {

        printf("Test #3: Performance. Offset. FAILED: X=%4.1lfmg Y=%4.1lfmg Z=%4.1lfmg Threshold <\ %4.1lf\n", x_off_mg, y_off_mg, z_off_mg, OFFSET_THRESHOLD_MG);

    }

    The noise calculation is a bit more complicated. First, subtract the offset from each datapoint. The RMS value can be calculated as the square root of the arithmetic mean of the squares of the noise values.

     x_rms = sqrt[1/n( x_1^2 + x_2^2 + .... + x_n^2)]

    Since the noise value is affected by the bandwidth of the digital filter, we need to convert it back to noise density with the following formula. Note: this applied only to a second order filter

    noise_density = noise_RMS/[sqrt(1.22 x bandwidth)]

    Here is some sample code on how to perform this test, based on BMA456, using the COINES software as the host.

    /*! RMS Noise Calculation */

    double x_rms_noise_mg=0;

    double y_rms_noise_mg=0;

    double z_rms_noise_mg=0;

    for (int i=0; i<1000; ++i)

    {

        double xval, yval, zval;

        /* ( 'datapoint' * '4G' * '2' * '1000mg') / ('scaling factor for 12 bits') */

        xval = (((double)sens_data[i].x) * 4. * 2. * 1000.) / pow(2,16);

        yval = (((double)sens_data[i].y) * 4. * 2. * 1000.) / pow(2,16);

        zval = (((double)sens_data[i].z) * 4. * 2. * 1000.) / pow(2,16);

                                  

        x_rms_noise_mg += pow(xval - x_avg_mg,2) / 1000.;

        y_rms_noise_mg += pow(yval - y_avg_mg,2) / 1000.;

        z_rms_noise_mg += pow(zval - z_avg_mg,2) / 1000.;

    }

                  

    /* rms noise is the square root of the arithmetic mean of the squares of the noise values */

    x_rms_noise_mg = sqrt(x_rms_noise_mg);

    y_rms_noise_mg = sqrt(y_rms_noise_mg);

    z_rms_noise_mg = sqrt(z_rms_noise_mg);

                  

    /*! RMS Noise to RMS noise density convertion */

    /* noise density = RMS noise  / sqrt ( 1.22 * bandwidth) */

    /* BMA456 has 40.5Hz bandwidth at 100Hz normal mode */

     

    double x_noise_dens_ug = 1000 * x_rms_noise_mg / sqrt(1.22 * 40.5);

    double y_noise_dens_ug = 1000 * y_rms_noise_mg / sqrt(1.22 * 40.5);

    double z_noise_dens_ug = 1000 * z_rms_noise_mg / sqrt(1.22 * 40.5);

     

    if( NOISE_THRESHOLD_MG > x_noise_dens_ug &&

                                   NOISE_THRESHOLD_MG > y_noise_dens_ug &&

                                   NOISE_THRESHOLD_MG > z_noise_dens_ug )

    {

        printf("Test #3: Performance. Noise. PASSED: X=%4.1lfug/sqrt(Hz) Y=%4.1lfug/sqrt(Hz) \ Z=%4.1lfug/sqrt(Hz) Threshold < %4.1lf\n", x_noise_dens_ug, y_noise_dens_ug, z_noise_dens_ug,\ NOISE_THRESHOLD_MG);

    }

    else

    {

        printf("Test #3: Performance. Noise. FAILED: X=%4.1lfug/sqrt(Hz) Y=%4.1lfug/sqrt(Hz) \   Z=%4.1lfug/sqrt(Hz) Threshold < %4.1lf\n", x_noise_dens_ug, y_noise_dens_ug,\ z_noise_dens_ug,NOISE_THRESHOLD_MG);

     

    }

    Calibrating the sensor

    The first question to ask concerning calibration is whether it is required for the intended application. Accelerometer calibration mainly consists of calibrating the accelerometer's offset. The main impact for this is in tilt-sensing application, where the offset will induce an error in the measurement of the horizon.

    The accelerometer comes from the factory pre-trimmed, but the soldering process and PCB bending due to assembly can vary the offset, therefore it is preferable to calibrate the accelerometer after assembling the device into the device housing.

    Pre- and post-calibration accuracy

    Saskia_0-1650888271792.png

     

    Saskia_1-1650888302316.png

     

    Sample code
    The calibration procedure is outlined in the inline calibration application note. Here is some sample code on how to perform this calibration, based on BMA456, using the COINES software as the host.

    Note : Although the concept is the same, the BMA4xy family of accelerometers does not include a built-in offset calculation on the ASIC. Since the offset are calculated inside of the Sensor API itself, it allows for a much more flexible target position.

     rslt = bma456_init(&bma456dev);

    if (rslt == BMA4_OK)

    {

        printf("BMA456 Initialization Success!\n");

    }

    else

    {             

        coines_exit_error("BMA456 Initialization Failure!\n");

    }

    coines_delay_msec(100);

    rslt = bma456_write_config_file(&bma456dev);

    /* Enable the accelerometer */

    rslt = bma4_set_accel_enable(BMA4_ENABLE, &bma456dev);

    /* Set the accel configurations */

    struct bma4_accel_config accel_conf = { 0 };

    accel_conf.odr = BMA4_OUTPUT_DATA_RATE_50HZ;

    accel_conf.bandwidth = BMA4_ACCEL_NORMAL_AVG4;

    accel_conf.perf_mode = BMA4_CIC_AVG_MODE;

    accel_conf.range = BMA4_ACCEL_RANGE_8G;

    rslt = bma4_set_accel_config(&accel_conf, &bma456dev);

    dev.delay_us(20000, dev.intf_ptr);         

                  

    if (rslt == BMA4_OK)

    {

        /* Set accel foc axis and it's sign (x, y, z, sign)*/

    struct bma4_accel_foc_g_value g_value_foc = { 0, 0, 0, 0 };

     

        rslt = bma4_perform_accel_foc( &g_value_foc, &bma456dev);          

                  

    if (rslt == BMA4_OK)

    {

            printf("BMA456 perform FOC successful!\n");

            /* Delay after performing Accel FOC */

            dev->delay_us(30000, bma456dev ->intf_ptr);

            /*! calculates the offset after compensation */

            rslt = bma4_read_regs(BMA4_OFFSET_0_ADDR, data_array, 3, & bma456dev);

            printf("Post-calibration offset : X=%4.1lfmg Y=%4.1lfmg Z=%4.1lfmg", data_array[0],\

                   data_array[1], data_array[3]);

        }

    else

    {         

            coines_exit_error("Unknown communication error. Exiting...\n");

        }

    }


    Once the offsets are determined, they can be written into the NVM so that the sensor automatically compensates for the soldering offset even after physically removing the power. Here is some sample code on how to save calibration data to NVM, based on BMA456, using the COINES software as the host.

    /*!

     * @brief This internal API is used to update the nvm content

     *

     * @param[in] void

     * @return void

     *

     */

    static void bma456_update_nvm(void)

    {

        uint16_t rslt;

        uint8_t data;

     

        /* unlocks the NVM for writing */

        data = 0x02;

        bma4_write_regs(0x6A, &data, 1, &bma456dev);

                  

        /* makes sure the BMA456 is not executing another command */

    do

    {

            rslt = bma4_read_regs(BMA4_STATUS_ADDR, &data, 1, &bma456dev);

            if ( 0 != rslt ) coines_exit_error("Unknown communication error. Exiting...\n");

        } while ( 0 == (data&0x10) );

                  

        /* performs the writing of the NVM */

        rslt = bma4_set_command_register( 0xA0,  &bma456dev);

        if ( 0 != rslt ) coines_exit_error("Unknown communication error. Exiting...\n");    

                  

        /* wait for the command to be completed */

    do

    {

            rslt = bma4_read_regs(BMA4_STATUS_ADDR, &data, 1, &bma456dev);

            if ( 0 != rslt ) coines_exit_error("Unknown communication error. Exiting...\n");

        } while ( 0 == (data&0x10) );

                  

        /* locks the NVM writing */

        data = 0x00;

        bma4_write_regs(0x6A, &data, 1, &bma456dev);

    }

     


    Further reads

    Datasheets:

    Application notes:

     

    Version history
    Revision #:
    4 of 4
    Last update:
    a month ago
    Updated by:
     
    Contributors
    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