LSM9DS1 and MPU9250 gyro dampening issue

I previously posted about a gyro error when attempting to integrate the values, I have fixed this issue with writing and offset calibration in the setup, however I have not fixed my integrated gyro values being very dampened.

void loop() 
{
  // dataReady() checks to see if new accel/gyro data
  if ( imu.dataReady() )
  {
    imu.update(UPDATE_ACCEL | UPDATE_GYRO | UPDATE_COMPASS);
    a_x = imu.ax;
    a_y = imu.ay;
    a_z = imu.az;
    g_x = -(imu.calcGyro(imu.gx)-g_offset_x);
    g_y = imu.calcGyro(imu.gy)-g_offset_y;
    g_z = imu.calcGyro(imu.gz)-g_offset_z;
    m_x = imu.calcMag(imu.mx);
    m_y = imu.calcMag(imu.my);
    m_z = imu.calcMag(imu.mz);
    
  }
  a_pitch = atan2(a_y,a_z)*180.0 / PI;
  a_roll = -(atan2(a_x, sqrt(a_y*a_y+(a_z*a_z))))*180.0 / PI;
  dt = (millis() - prev_millis)/1000;
  prev_millis = millis();
  g_x_angle = (g_x_angle + (g_x*dt));
  
 
  printvalues();
  
}

Here the main bulk of my code, the gyro sends data in d/s which registers great however when im integrating it with accurate time measurement, it comes out heavily dampened to the actual angle ( comparing it with the accelerometer roll values). There is obviously something im missing here. I have attempted to track down a built-in MPU or LSM calibration code however DSM calibration from Sparkfun is too large for my Arduino micro. Any suggestions?

pistonsoup:
however I have not fixed my integrated gyro values being very dampened.

What does that mean?

Here's a link to an image of the accelerometer data vs the integrated gyro data, it's very dampened.

I do not see anything wrong with the rate gyro's output. If you want you can change the scale and get mo sensitive gyro data but remember the important words "rate gyro".

Yes, the data is recorded in degrees per second, when integrating that you should be able to find the number of degrees moved given an accurate amount of seconds that have passed. If I multiply my current data by a scaling factor, the drift goes to unusable levels. How do I get reasonable usable gyro values to combine with the accelerometer for a complimentary filter?

Which library are you using?

Show the IMU setup code; setting like gyro range, accelerometer range, filters, and so on and so forth.

OK, so for starters why do you apply an offset to the gyros but not the accelerometers?

What kind of gyro thingy do you get when you remove the offsets? Where did you get an offset values?

You are not going to get big whooping numbers from a gyro that only outputs data during changes of angular momentum.

What calibration procedure did you do. Typically I run calibrations before regular IMU operations.

Idahowalker:
Which library are you using?

Im using the Sparkfun MPU9250 library

Show the IMU setup code; setting like gyro range, accelerometer range, filters, and so on and so forth.

void setup() 
{
  SerialPort.begin(115200);
  Wire.begin();
  // Call imu.begin() to verify communication with and
  // initialize the MPU-9250 to it's default values.
  // Most functions return an error code - INV_SUCCESS (0)
  // indicates the IMU was present and successfully set up
  if (imu.begin() != INV_SUCCESS)
  {
    while (1)
    {
      SerialPort.println("Unable to communicate with MPU-9250");
      SerialPort.println("Check connections, and try again.");
      SerialPort.println();
      delay(5000);
    }
  }
  // Use setSensors to turn on or off MPU-9250 sensors.
  // Any of the following defines can be combined:
  // INV_XYZ_GYRO, INV_XYZ_ACCEL, INV_XYZ_COMPASS,
  // INV_X_GYRO, INV_Y_GYRO, or INV_Z_GYRO
  // Enable all sensors:
  imu.setSensors(INV_XYZ_GYRO | INV_XYZ_ACCEL | INV_XYZ_COMPASS);
  // Use setGyroFSR() and setAccelFSR() to configure the
  // gyroscope and accelerometer full scale ranges.
  // Gyro options are +/- 250, 500, 1000, or 2000 dps
  imu.setGyroFSR(2000); // Set gyro to 2000 dps
  // Accel options are +/- 2, 4, 8, or 16 g
  imu.setAccelFSR(2); // Set accel to +/-2g
  // Note: the MPU-9250's magnetometer FSR is set at 
  // +/- 4912 uT (micro-tesla's)
  // Can be any of the following: 188, 98, 42, 20, 10, 5
  // (values are in Hz).
  imu.setLPF(5); // Set LPF corner frequency to 5Hz
  
  // setSampleRate. Acceptable values range from 4Hz to 1kHz
  imu.setSampleRate(200); // Set sample rate to 500Hz


  // This value can range between: 1-100Hz
  imu.setCompassSampleRate(100); // Set mag rate to 100Hz
  delay(2000);
  gyrocalibrate();
}

What kind of gyro thingy do you get when you remove the offsets? Where did you get an offset values?

The offset values are from my calibration shown here

void gyrocalibrate(){
 Serial.println("Gyro will now be forced into obedience, please keep the sensor still and wait 5 secounds");

 delay(5000);
while (i<=2000){
    if ( imu.dataReady() )
  {
    imu.update(UPDATE_ACCEL | UPDATE_GYRO | UPDATE_COMPASS);
    a_x = imu.ax;
    a_y = imu.ay;
    a_z = imu.az;
    g_x = imu.calcGyro(imu.gx)-g_offset_x;
    g_y = imu.calcGyro(imu.gy)-g_offset_y;
    g_z = imu.calcGyro(imu.gz)-g_offset_z;
   
  }
   g_store_x = g_store_x + g_x;
   g_store_y = g_store_y + g_y;
   g_store_z = g_store_z + g_z;
   a_store_pitch = a_store_pitch +a_pitch;
   a_store_roll = a_store_roll +a_roll;
   if (i==500){
    g_offset_x = g_offset_x+ g_store_x/i;
    g_store_x = 0;
    g_offset_y = g_offset_y+ g_store_y/i;
    g_store_y = 0;    
    g_offset_z = g_offset_z+ g_store_z/i;
    g_store_z = 0;     
     
   }
   if (i==1000){
     g_offset_x = g_offset_x+ g_store_x/i;
    g_store_x = 0;
    g_offset_y = g_offset_y+ g_store_y/i;
    g_store_y = 0;    
    g_offset_z = g_offset_z+ g_store_z/i;
    g_store_z = 0;          
   }
   if (i==1500){
    g_offset_x = g_offset_x+ g_store_x/i;
    g_store_x = 0;
    g_offset_y = g_offset_y+ g_store_y/i;
    g_store_y = 0;    
    g_offset_z = g_offset_z+ g_store_z/i;
    g_store_z = 0;     
   }
   if (i==2000){
    g_offset_x = g_offset_x+ g_store_x/i;
    g_store_x = 0;
    g_offset_y = g_offset_y+ g_store_y/i;
    g_store_y = 0;    
    g_offset_z = g_offset_z+ g_store_z/i;
    g_store_z = 0;     
   }
   i+=1;
  }
  i=0;
}

Without this offset, the gyro values are not set at 0d/s and continuously add errors to the integration. For now, no filtering has been applied, I will most likely add a moving average filter to accel values and a complimentary for sensor fusion.

I have not applied any offset to the accelerometers or any calibration because it seems to be giving generally good values that I can use to reference, for now, I will calibrate it later. I will so be using this accelerometer data shown as a_store_pitch to reference the gyro values one I can get a good amplitude from the gyro values.

Thank you again for continuing to reply, my ignorance is getting really frustrating and im just trying to get usable data so I can work on more entertaining things haha like actual controls.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.