Section 4: Flight-Control-Functions.

........ MPU6050 Calibration Data Source Code .........

====== File-Name: 7_Calibration_Data_MPU6050.ino =======



//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+ Begin of function to load MPU6050 Accel.Calibration Matrix +
//                  Last Update: 15-08-2021  
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

void MPU6050_CaliMatrix()
  {
if (Calib_Serie==1)
  {
//+++++++++ Series-1 Calibrated MPU6050-1 ++++++++++++++++++++++++++++
//+++++++++ Load MPU6050 Accel.Calibration Matrix ++++++++++++++++++++
//Accel.Calibration made on 30-11-2020
//Calib.file: MPU6050-1 acc Coolterm Capture 2020-11-30 00-19-08.txt 

  //matrix [m]x[p] (m=rows,p=columns)
  //  First column
  CaliMatrix[0][0] =   0.995188;
  CaliMatrix[1][0] =  -0.005385; 
  CaliMatrix[2][0] =  -0.072709;  

  // Second column
  CaliMatrix[0][1] =   0.015502;
  CaliMatrix[1][1] =   1.001722;
  CaliMatrix[2][1] =   -0.000345;

  // Third column
  CaliMatrix[0][2] =   0.070613;
  CaliMatrix[1][2] =   0.004181;
  CaliMatrix[2][2] =   0.965597;
  
  // Calibratie shift Vector
  CaliVec[0] =  0.068628;
  CaliVec[1] = -0.009862;
  CaliVec[2] = -0.064153;

  // Calibration quality door kwadraat residu vector x,y,z:
  //0.002030  
  //0.004776  
  //0.001229  

//  Serial.println("Accel Calibration Matix is loaded...");
//  delay(2000);

    Gvalue = 1.05;    //G-measured in rest 

//*************************************************************
   Pitch_Correction =  0.0;    //degrees worden afgetrokken
   Roll_Correction  =  0.0;    //degrees
//*************************************************************

//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
//*************************************************************
  Serial.println("Series-1 Accel.Calibration Matrices have been loaded.");
//*************************************************************
  }


//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx


if (Calib_Serie==2)
  {
//+++++++++ Series-2 Calibrated MPU6050-2 +++++++++++++++++++++++
//+++++++++ Load MPU6050 Accel.Calibration Matrix +++++++++++++++
//Accel.Calibration made on 29-11-2020
//Calib.file: MPU6050-2 acc Coolterm Capture 2020-11-29 16-35-51.txt 

  //matrix [m]x[p] (m=rows,p=columns)
  //  First column
  CaliMatrix[0][0] =  0.991630;
  CaliMatrix[1][0] =  0.016956; 
  CaliMatrix[2][0] = -0.069229;  

  // Second column
  CaliMatrix[0][1] =  -0.013950;
  CaliMatrix[1][1] =   0.988744;
  CaliMatrix[2][1] =  -0.000596;

  // Third column
  CaliMatrix[0][2] =  0.067295;
  CaliMatrix[1][2] =  0.001589;
  CaliMatrix[2][2] =  0.978748;
  
  // Calibratie shift Vector
  CaliVec[0] =  0.031197;
  CaliVec[1] =  0.004587;
  CaliVec[2] =  -0.049454;

  // Calibration quality door kwadraat residu vector x,y,z:
  //0.003567  
  //0.005483  
  //0.005087

   Gvalue = 1.05; //G-measured in rest 

//*************************************************************
   Pitch_Correction =  0.0;    //degrees worden afgetrokken
   Roll_Correction  =  0.0;    //degrees
//*************************************************************

//*************************************************************
  Serial.println("Series-2 Accel.Calibration Matrices have been loaded.");
  delay(1000);
//*************************************************************
  }

//************************************************************
// *** Factors to convert Bitvalues to Physical Quantities ***
// Convert MPU6050 Accel Bitvlues to g:
   AccSensitivity = 4096; //LSB/g bij +/-8g Full Scale Range
// Convert MPU6050 GyroBitvalues to deg/sec: 
   DigitPerdps = 131;           //Gyro-Rate: 250 deg/s => 131, 500 deg/s => 65.5
//*************************************************************
 
}

//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//++ End of function to load MPU6050 Accel.Calibration Matrix +
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Free-Drones Company 2022