Important Cookie Information

This website uses absolutely necessary cookies. If you consent to the use of convenience cookies, please click “Yes, I agree.” By clicking on “Privacy Settings.” you can change this setting at any time and withdraw your given consent. Icon down see more You can find detailled information in our Privacy Policy Icon forward-right
Icon up see less

Bosch Sensortec Community

    cancel
    Showing results for 
    Search instead for 
    Did you mean: 

    Introduction about BHA250 / BHI160 host side Axes remapping

    Introduction

    Accelerometer (Acc), Gyroscope (Gyro) and Magnetometer (Mag) sensors (components) have their own coordinates. By default BHA and BHI are configured to ENU axis convention (East-North-Up), as commonly used in consumer electronic devices. It is usually obtained by the integration of Accelerometer (Acc), Gyroscope (Gyro) and Magnetometer (Mag) sensors readings.

    The ENU coordinate system is defined as a direct orthonormal basis where:

        x points east and is tangential to the ground.

        y points north and is tangential to the ground.

        z points towards the sky and is perpendicular to the ground.

    8.png

     Users can download the BHI/BHA firmware from Bosch Sensortec Website. All firmware’s coordinates are the same. Figure 2(left) shows the coordinate of the BHI/BHA shuttle board. Cares must be taken that the direction of BHI/BHA and Magnetometer sensor must follow the BHI/BHA shuttle board when customer do the PCB placement. Figure 2(right) shows the direction of BHI/BHA and Magnetometer on the shuttle board.

    It is the easiest and best way that customer can reuse the same coordinate of BHI/BHA shuttle board on their product. It is possible to change the coordinate based on customer definition. This document is to tell the customer the way how to do the axis-remapping on their products.

    Axes definition

    1. Define the coordination of your board (XBOARD, YBOARD, ZBOARD). Normally this is the default coordination system of your final application (i.e. your system coordination).
    2. In standard Android system the ENU (east north up) orientation is required.
      For other applications, the ZBOARD is normally pointing to the sky or ground
      when the board is placed on a horizontal surface.
    3. Find the coordinates of the sensors mounted on the board in their datasheets.

    Draw all the coordinates on the paper. Figure 3 shows an example.10.pngIn Figure 3, it is highly recommended to follow the placement on the BHI160 shuttle board, if the user do not want to pay more effort on it.11.png

     If you are using a standard Bosch sensor, their coordinates follow the right-handed coordinate principle (Figure 4). You can apply it to find the sensor axes when it placed on the board.

     

    Orientation matrix

    When the sensors axes orientation are different to the board, we need to convert it to the board coordinate by following formula:12.png

    [X Y Z] is the board coordinate

    [Xs Ys Zs] is the sensor coordinate

    (C0… C8) is the orientation matrix.

    The coefficient has three possible value: 1, 0 and -1.

    1 --- Two axes are paralleled and have same direction

    -1 --- Two axes are paralleled and have opposite direction

    0 --- Two axes are perpendicular

    Example

    If we have a board shown in Figure 3. On this board, there are a BHI160 and a BMM150. The dots on the sensor indicate their coordinates. You can try to find the coordinates and write the orientation matrix. Table 1shows the result.
    15.png

    Orientation matrix:

    Cs = (0 -1 0 1 0 0 0 0 1),

    Updating via product API (Host side)

    Basic configuration

    When customer follow the requirement (components placement), so only one matrix is needed for the sensor(A,M,G). Users can configure the axes before enable the BHI160/BHA250 by editting the remapping matrix in its .c file.

    The following code is content of the accelerometer_remapping_example.c in the API. Use this as a reference to update your matrix accordingly.

    The matrix can also be edited within the product API which is available on GitHub:

    https://github.com/BoschSensortec/BHy1_driver_and_MCU_solution

    int main(void)
    {
    	u8 array[ARRAYSIZE], *fifoptr, bytes_left_in_fifo=0;
    	u16 bytes_remaining, bytes_read;
    	bhy_data_generic_t	fifo_packet;
    	bhy_data_type_t		packet_type;
    	BHY_RETURN_FUNCTION_TYPE result;
        s8 mapping[9] = {0};
        s8 mapping_all[9] = {0 -1 0 1 0 0 0 0 1}; // new mapping matrix, example on Figure3
    
       … …
    
        /* config mapping matrix, it is not necessary to change mapping matrix if its orientation is aligned with the board */
        bhy_get_mapping_matrix(PHYSICAL_SENSOR_INDEX_ACC,mapping); // get current ACC mapping matrix
        bhy_set_mapping_matrix (PHYSICAL_SENSOR_INDEX_ACC,mapping_all); // set new mapping matrix in the fw
     bhy_get_mapping_matrix(PHYSICAL_SENSOR_INDEX_ACC,mapping); // check if the matrix is set successfully 
    … …
     bhy_get_mapping_matrix(PHYSICAL_SENSOR_INDEX_GYRO,mapping); // get current GYRO mapping matrix
        bhy_set_mapping_matrix (PHYSICAL_SENSOR_INDEX_GYRO,mapping_all); // set new mapping matrix in the fw
     bhy_get_mapping_matrix(PHYSICAL_SENSOR_INDEX_GYRO,mapping); // check if the matrix is set successfully 
    … …
     bhy_get_mapping_matrix(PHYSICAL_SENSOR_INDEX_MAG,mapping); // get current MAG mapping matrix
        bhy_set_mapping_matrix (PHYSICAL_SENSOR_INDEX_MAG,mapping_all); // set new mapping matrix in the fw
     bhy_get_mapping_matrix(PHYSICAL_SENSOR_INDEX_MAG,mapping); // check if the matrix is set successfully 
    
    ​

    Advanced configuration

    If the sensor placement is not followed the Shuttle Board, the user can configure matrix for each sensor.

    In this configuration, customer can place the sensor on the board as they need(no need to follow the chip placement on shuttle board).

    int main(void)
    {
    	u8 array[ARRAYSIZE], *fifoptr, bytes_left_in_fifo=0;
    	u16 bytes_remaining, bytes_read;
    	bhy_data_generic_t	fifo_packet;
    	bhy_data_type_t		packet_type;
    	BHY_RETURN_FUNCTION_TYPE result;
        s8 mapping[9] = {0};
        s8 mapping_ACC[9] = {0 -1 0 1 0 0 0 0 1}; // new mapping matrix, example on Figure3
     s8 mapping_GYRO[9] = {0 -1 0 1 0 0 0 0 1}; // 
        s8 mapping_MAG[9] = {0 -1 0 1 0 0 0 0 1}; // can be different
    
       … …
    
        /* config mapping matrix, it is not necessary to change mapping matrix if its orientation is aligned with the board */
        bhy_get_mapping_matrix(PHYSICAL_SENSOR_INDEX_ACC,mapping); // get current ACC mapping matrix
        bhy_set_mapping_matrix (PHYSICAL_SENSOR_INDEX_ACC,mapping_ACC); // set new mapping matrix in the fw
     bhy_get_mapping_matrix(PHYSICAL_SENSOR_INDEX_ACC,mapping); // check if the matrix is set successfully 
    … …
     bhy_get_mapping_matrix(PHYSICAL_SENSOR_INDEX_GYRO,mapping); // get current GYRO mapping matrix
        bhy_set_mapping_matrix (PHYSICAL_SENSOR_INDEX_GYRO,mapping_GYRO); // set new mapping matrix in the fw
     bhy_get_mapping_matrix(PHYSICAL_SENSOR_INDEX_GYRO,mapping); // check if the matrix is set successfully 
    … …
     bhy_get_mapping_matrix(PHYSICAL_SENSOR_INDEX_MAG,mapping); // get current MAG mapping matrix
        bhy_set_mapping_matrix (PHYSICAL_SENSOR_INDEX_MAG,mapping_MAG); // set new mapping matrix in the fw
     bhy_get_mapping_matrix(PHYSICAL_SENSOR_INDEX_MAG,mapping); // check if the matrix is set successfully 
    

     

    For more details and technical support with respect to the product API the *.h file and the MCU porting please refer to the Bosch Sensortec documents “MCU Driver Porting Guide” and “Interfacing Reference Code from Generic Driver” for BHA and/or BHI placed within the section “Application notes”, available onhttps://www.bosch-sensortec.com/bst/support_tools/downloads/overview_downloads

    Check the orientation

    After the orientation matrix has been updated, you need to check whether the remapping is successful.

    You can read the uncalibrated data of the sensors to check if the remapping is successful. Please define the coordination of the board (XBOARD, YBOARD, ZBOARD) first.

    Check the Acc axes (XA, YA, ZA)

    • Enable Acc uncalibrated data;
    • Place the board on a horizontal surface and make sure ZBOARD is pointing to the sky. Z-axis should output 1g.
    • Turn the board at perpendicular position and make sure XBOARD is pointing to the sky. X-axis should output 1g.
    • Turn the board at perpendicular position and make sure YBOARD is pointing to the sky. Y-axis should output 1g.

    16.png Check the Gyro axes (XG, YG, ZG)

    If you use BHI160, the axes of Acc and Gyro are same.

    In Bosch product, a Gyro axis direction can be found by your right hand. Move your four fingers follow the rotation direction to make a fist and the thumb will be pointing to the positive axis like Figure 5 (This is similar to right-hand crew rule).

    • Enable Gyro uncalibrated data;
    • Place the board on a horizontal surface and make sure ZBOARD is pointing to the sky. Quickly rotate left 180 degree. The output has significant change is the rotation axis. It should be z-axis and output positive data.
    • Rotate the board according to XBOARD and YBOARD. Check the output with right-hand crew rule respectively.

    Check the Mag axes (XM, YM, ZM)

    Method 1

    • Enable Mag uncalibrated data and only log the first three data, which is the original data;
    • Place the board on the table and make sure the XBOARD is pointing to the planet's North Pole by using a reference compass. Record the (XM, YM, ZM) stable output below.
    • Then Point XBOARD to planet's South Pole and record the stable output.

    17.png

    • The axis output has the maximum difference is parallel to XBOARD Here |X1 - X2| should be the largest, and X1 > X2. Then the remapping is correct.  
    • Apply same method to YBOARD, ZBOARD to find if the orientation of other two axes are correct.

     Method 2

    1.Enable Mag uncalibrated data and only log the first three data;

    2.Rotate the board in following steps and record the output data:

    18.pngIf

    1. X1>X2 & X4>X3, min(X1,X2,X3,X4)=X2, and max(X1,X2,X3,X4)=X4;
    2. Y1>Y2 & Y4>Y3, min(Y1,Y2,Y3,Y4)=Y3, and max(Y1,Y2,Y3,Y4)=Y1;
    3. Z2>Z1.

    Then the remapping is correct.

     

    Version history
    Revision #:
    7 of 9
    Last update:
    4 weeks 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