02-01-2021 07:57 PM
Hi everyone,
I worked on BMX160 IMU last few days, Till now i am able to get Raw readings of it like ACC(X,Y,Z),GYRO (X,Y,Z)and MAG(X,Y,Z) sensor.
I confirmed raw readings of ACC and GYRO are correct or not by placing sensor at rest state and then raw readings are came like acc: 0,0,-/+1 and
gyro: 0,0,0.(datasheet page no:106) but i didnot find any thing which is related to confirm Raw MAG readings are correct or not?
And also i converted Acc and Gyro raw readings in to gravity,m/s^2 by using below formulas,
//Here 2 is for 2g and 32768 for 16 bit value because ACC raw data is in 16 bit value
Ax = (acc_raw_x * 2)/32768;
Ay = (acc_raw_y * 2)/32768;
Az = (acc_raw_z * 2)/32768;
//Here 250 is for 250dps and 32768 for 16 bit value because Gyro raw data is in 16 bit value
Gx = (gyro_raw_x * 250)/32768;
Gy = (gyro_raw_y * 250)/32768;
Gz = (gyro_raw_z * 250)/32768;
1) Can you please help me to find MAG Raw data correct or not?
2) I am just reading raw data from six registers of MAG(0x04 -0x09)?is it correct?
3) In BMX160 Datasheet for reading MAG data procedure given like below attached imge
4) What is bmi160 API for doing above image task? i did not find any API in bmi160.c file like above image suggested ?
5) What king of fusion algorithm/filters can i use to find pitch,roll and yaw from above readings?
Please help me to come out of this issue.
Thank you,
Amarr
Solved! Go to Solution.
02-02-2021 06:49 PM
Hi,
Thanks for your inquiry.
BMX160 is a 9-axis sensor that includes BMI160 IMU (accel + gyro) and BMM150 (mag) inside, where BMM150 is connected to BMI160's secondary I2C interface internally as a slave. BMI160 API source code at https://github.com/BoschSensortec/BMI160_driver has all necessary functions to configure BMM150 mag and get mag raw data and convert raw data to final meaningful magnetic field values in the unit of uT.
Please see the answers to your questions.
1) Can you please help me to find MAG Raw data correct or not?
>>> There are two ways to check MAG data. The first way is to check the sign of each axis. If you are located in Northern Hemisphere such as USA or Canada, then the earth magnetic field vector will point downwards. So when you place your device with MAG any axis pointing down, then that axis output value should be positive in the unit of uT. If pointing upwards, then the output will be negative. The second way is that you can place your device on a flat table and then rotate it slowly with a full circle. It doesn't matter if you rotate the device clockwise or counterclockwise. If you rotate along Z axis, then you can plot X and Y axis data in 2D plane. You should be able to see a shifted circle or ellipse from the origin.
2) I am just reading raw data from six registers of MAG(0x04 -0x09)?is it correct?
>>> Yes, that is correct. MAG raw data from registers 0x04 to 0x09 don't give you anything. You need to use BMI160 API code to do temperature compensation on the raw data and then convert them to final meaningful values in the unit of uT.
3) In BMX160 Datasheet for reading MAG data procedure given like below attached image
4) What is bmi160 API for doing above image task? i did not find any API in bmi160.c file like above image suggested ?
>>> BMI160 API configures MAG, sets up MAG to work under forced mode, retrieves MAG raw data and places raw data into its data registers from 0x04 to 0x09 and converts raw data to final magnetic field values in the unit of uT.
5) What king of fusion algorithm/filters can i use to find pitch,roll and yaw from above readings?
>>> Please refer BSXLite SW at https://www.bosch-sensortec.com/software-tools/software/sensor-fusion-software/#bsxlite for more information. You should be able to get pitch/roll/heading Euler angles, quaternions, linear acceleration and gravity vector from BSXLite.
Thanks.
02-02-2021 07:17 PM
Hi FAE_CA1,
Thank you for reply,
As you told i downloaded BMI160 Driver code from your suggested link, but i did not find any MAG Data retrived API from BMI160 Driver code.
https://github.com/BoschSensortec/BMI160_driver
" >>> BMI160 API configures MAG, sets up MAG to work under forced mode, retrieves MAG raw data and places raw data into its data registers from 0x04 to 0x09 and converts raw data to final magnetic field values in the unit of uT"
Can you point it out from BMI160 Driver?
Thank you in advance,
amarr
02-02-2021 07:26 PM
Hi,
Sorry, the first page of the link of BMI160-API tells you that you need to include "bmm150.h" which is available at https://github.com/BoschSensortec/BMM150-Sensor-API.
Thanks.
02-02-2021 07:47 PM
Hi,
Till now i am able to read mag data by following below attached image by directly writing MAG registers of it, is it correct? because as you told for reading MAG Data from BMI160, can i definealtly use bmm150?
1) Can i make same functionality of bmm150 API did by indirect reg writing like below attached image?
2) Finally am i able to read correct MAG data, if i folllow the below attached image process?if not why?
Thank you,
amarr