I'm using a BHI260AB chip with an STM32 as the host processor.
To start I want to do something very simple now, which is basically taking the gravity vector measurement and with that vector figure out the inclination angle of my device.
So, I have the BHI chip with the following references (in red):
Then we have the gravity:
Then when the chip has a certain inclination:
In this picture, gravity has just two components (YZ) because the drawing shows a rotation around the X-axis (it's easier for me to draw this 2D scheme). But let's assume that the chip can have any orientation and the gravity is decomposed into the three axes.
On my project, I have an initial position of the device which is when the BHI chip is in the following orientation:
This orientation is considered to be the 0° inclination. And the inclination angle is calculated by doing the following:
alfa = arcsin(gz / g);
Where gz is the module of the Z component of the gravity and g is the module of the gravity.
So I do that calculation with my STM32 and I was surprised when I placed the device in the initial position (picture 4). My alfa angle was showing 6° of inclination. I was expecting the angle not to be 0°, but not to have such an error in the initial position.
Inspecting the g components got from the BHI chip in the initial position I got the following:
x = 0.017333984375 g
y = -0.992431640625 g
z = 0.120361328125 g
I'm very surprised by the Z component. It should be very low, but it's not.
As a comment, I didn't run any calibration on the chip or any offset correction before these calculations. I just connected the chip and used it as it was. But still, I'm concerned about the magnitude of the error.
Is there something that I should do before using the gravity vector?
I didn't try the same by using the accelerometer values instead of the gravity virtual sensor. But I guess the gravity virtual sensor is based on the accelerometer readings. So, It should be the same.
I hope anybody can help me.
Solved! Go to Solution.
xyz values for gravity is correct as root( x2 + y2 + z2) = 1. So, two things you can do for more accurate value.
If there is offset, the gavity value of root( x2 + y2 + z2) exceeds 1.
So, I think you need to calibrate BHI260 as below youtube clip. (It's BNO055, but same method as BHI260AB)
And also, please check whether you set BHI260 properly.
Thank you for your prompt reply.
In the Youtube video, I can see that they use the "Bosch Development Desktop" application for doing the calibration.
In my case, I use an STM32 as a host processor connected to the BHI260AB over SPI. I don't understand very well how should I do with my STM32 for calibrating the gravity virtual sensor.
Right now what I do with the STM32 is the following:
So, here are some questions: