MinIMU-9v5 Homing/Zeroing

Hello.

I’ve been testing the MinIMU-9v5 sensor and minimu-9 AHRS library examples with an ESP32, connected via I2C. For the application Im using, innitial position is not exactly flat/zero degrees, so I’m wondering if is possible to adjust the readings at some fixed angle as offset.

Currently using code based on the next repository:

Also, the code takes some readings before initializing, but each time the sensor starts on a different angle, even when the angle is phisically the same, Not sure if this is expected behavior or calibration may help with this issue

Is there a way to force the sensor to start at an specific angle?

Thanks in advance

Hello.

As long as your sensor always starts in a consistent position it should be possible to modify the code you are referencing to compensate for it starting in a position other than level. Essentially, in the same way that the program modifies the accelerometer’s Z offset to remove gravity from future sensor measurements, you will need to modify that line and add similar lines modifying the X axis and Y axis based on the angle that the sensor starts at.

- Patrick

Thanks a lot!

Here’s my approach, assuming rotation is only in X axis, and changing the offset inicialization just like you told me:

#define ROLL_OFFSET ToRad(-7.58)  //Initial roll offset in deg/radians

 AN_OFFSET[5]-=GRAVITY*SENSOR_SIGN[5]*cos(ROLL_OFFSET);
  AN_OFFSET[4]-=GRAVITY*SENSOR_SIGN[5]*sin(ROLL_OFFSET);

This approach seems to work fine most of the time, starting the measurements on the given roll angle. However, sometimes after a few readings (1 or two) the sensor sends some random angle, and starts to drift slowly towards the real angle.

I’m not sure what to expect since said drift doesn’t happens always and seems to be random. Is there any way to reduce said drift?

Please let me know if posting full code/some readings would help, and as always, thanks in advance

What axis or axes does the drift happen on? The simplest complete program that demonstrates the issue along with a sample output showing the sensor readings (as well as your calculations and timestamps) would be helpful.

- Patrick