03-28-2023 10:30 PM
I could use some advice about how to code for the calibration of the BMI160. Consider that I will want to have the user hit a calibration button and initiate a gyro and accelerometer calibration process. Consider a button for each for simplicity of this question. What do I need to do in my functions tied to each of these buttons? I see that the API has some internal test capabilities. Are these related to the calibration process or is there some other command I haven't seen yet?
For the accelerometer calibration the user will have to put the product flat on a desk then hit the button which will start my routine. They then need to rotate the device in a 360 degree circle. Can you explain the necessary things my code needs to do to initiate the process, and to know when it is done, what it needs to read, what calculations or data it needs to do to write back to the calibration so that the device is 'calibrated'? I assume the same type of calling patterns would be needed for the gyro except that the user needs to rotate it 360 degrees in x, then y, then z axis. How can my code know that each of these stages is completed and to move on to the next one, or when the process is completed, how to lock that in?
Or am I thinking about calibration all wrong? Please suggest a more productive way of approaching this if I am not on the right track.
03-29-2023 07:33 PM
Hi,
Thanks for your inquiry.
BMI160 has built-in self-test feature for accelerometer and gyroscope. This is to check if the sensor is working properly or not after PCB assembly. It has nothing to do with calibration.
Gyro calibration is relatively simple. You can place your device stationary on a table at any orientation and then click "Gyro calibration" button. If you configure BMI160 gyro to 100Hz normal mode, then you can set up a counter for 1000 samples which is about 10 seconds long. After the counter reaches 1000, you can display "Gyro calibration is done". Then you can average these 1000 gyro data samples to get the offsets for x/y/z axes. In the future all gyro raw data should subtract these offsets to get calibrated values. This means that when your device is stationary gyro x/y/z data should be all around 0 dps (degree per second). If you also want to calibrate gyro x/y/z sensitivities, then you will need a turn table and this becomes complicated.
Accel calibration is to convert BMI160 accel x/y/z data to align with your device X/Y/Z axes, because BMI160 x/y/z axes will be invisible inside your device. Now you can click "Accel calibration" button and display "Please place device X axis pointing up". Then you can click "Start" button to collect BMI160 accel x/y/z data for 300 samples for example. If you configure BMI160 accel to 100Hz normal mode, then it will take about 3 seconds. When the counter reaches 300, you can click "Stop" button. Now you can average these 300 data samples to get accel x/y/z data at Z_up position. Then you can repeat the above process for Z_down, X_up, X_down, Y_up and Y_down the other 5 positions. Then you can search accelerometer calibration application note or code sample online about how to obtain accel 3 offsets and 3x3 sensitivity matrix calibration parameters from the above data sets you have collected. Then you can display "Accel calibration is done". In the future you need to apply these accel calibration parameters to all BMI160 accel raw data. Therefore, when you place any device axis X/Y/Z to up or down position, you should get +1g or -1g values after calibration.
Thanks.