MinIMU-9 with Arduino Uno

I have the minIMU-9 V2 and I have been using it with an Arduino Uno R3 and I have noticed that the code from there: github.com/pololu/MinIMU-9-Arduino-AHRS always zeros out(re-calibrates) upon power up (or using serial monitor. I was curious is there any way to remove that from the code? I am not very good at coding tbh and I can gladly upload what I do have. I have run the calibration program and used those values. Thank you for your time

-William
MinIMU9AHRS_ed.ino (12.3 KB)

Hello, William.

If you mean that you don’t want the AHRS program to assume that the MinIMU-9 board starts in a level orientation, you can make that change by editing this code (starting at line 224 of the file you posted, or line 171 of the original MinIMU9AHRS.ino):

  for(int i=0;i<32;i++)    // We take some readings...
  {
    Read_Gyro();
    Read_Accel();
    for(int y=0; y<3; y++)   // Cumulate values            <-- Change "y<6" to "y<3"
      AN_OFFSET[y] += AN[y];
    delay(20);
  }

  for(int y=0; y<3; y++)                                // <-- Change "y<6" to "y<3"
    AN_OFFSET[y] = AN_OFFSET[y]/32;

  //AN_OFFSET[5]-=GRAVITY*SENSOR_SIGN[5];                  <-- Comment out this line

(AN_OFFSET[3] through AN_OFFSET[5] are the accelerometer offsets. Normally, the program measures the accelerometer readings on startup, assuming the board is level, and uses those readings as offsets to zero the accelerometer.)

If you don’t want to zero the gyro either (which you might not want to do if the board might already be rotating when the program starts), you can comment out the entire block of code in the snippet above.

Please let us know how this works for you.

- Kevin

Kevin,

Thank you for the change in code. That was precisely what I needed. Thanks

-William