1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-15 20:35:33 +03:00

Merge pull request #9724 from etracer65/gyro_scale_factor_correction

Correct gyro scaling factors
This commit is contained in:
Michael Keller 2020-06-22 00:30:34 +12:00 committed by GitHub
commit 312787e163
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 18 additions and 23 deletions

View file

@ -37,6 +37,9 @@
#pragma GCC diagnostic warning "-Wpadded"
#endif
#define GYRO_SCALE_2000DPS (2000.0f / (1 << 15)) // 16.384 dps/lsb scalefactor for 2000dps sensors
#define GYRO_SCALE_4000DPS (4000.0f / (1 << 15)) // 8.192 dps/lsb scalefactor for 4000dps sensors
typedef enum {
GYRO_NONE = 0,
GYRO_DEFAULT,

View file

@ -94,7 +94,7 @@ bool fakeGyroDetect(gyroDev_t *gyro)
gyro->readFn = fakeGyroRead;
gyro->temperatureFn = fakeGyroReadTemperature;
#if defined(SIMULATOR_BUILD)
gyro->scale = 1.0f / 16.4f;
gyro->scale = GYRO_SCALE_2000DPS;
#else
gyro->scale = 1.0f;
#endif

View file

@ -107,8 +107,7 @@ bool mpu3050Detect(gyroDev_t *gyro)
gyro->readFn = mpu3050GyroRead;
gyro->temperatureFn = mpu3050ReadTemperature;
// 16.4 dps/lsb scalefactor
gyro->scale = 1.0f / 16.4f;
gyro->scale = GYRO_SCALE_2000DPS;
return true;
}

View file

@ -107,8 +107,7 @@ bool mpu6050GyroDetect(gyroDev_t *gyro)
gyro->initFn = mpu6050GyroInit;
gyro->readFn = mpuGyroRead;
// 16.4 dps/lsb scalefactor
gyro->scale = 1.0f / 16.4f;
gyro->scale = GYRO_SCALE_2000DPS;
return true;
}

View file

@ -104,8 +104,7 @@ bool mpu6500GyroDetect(gyroDev_t *gyro)
gyro->initFn = mpu6500GyroInit;
gyro->readFn = mpuGyroRead;
// 16.4 dps/lsb scalefactor
gyro->scale = 1.0f / 16.4f;
gyro->scale = GYRO_SCALE_2000DPS;
return true;
}

View file

@ -350,7 +350,7 @@ bool bmi160SpiGyroDetect(gyroDev_t *gyro)
gyro->initFn = bmi160SpiGyroInit;
gyro->readFn = bmi160GyroRead;
gyro->scale = 1.0f / 16.4f;
gyro->scale = GYRO_SCALE_2000DPS;
return true;
}

View file

@ -440,7 +440,7 @@ bool bmi270SpiGyroDetect(gyroDev_t *gyro)
gyro->initFn = bmi270SpiGyroInit;
gyro->readFn = bmi270GyroRead;
gyro->scale = 1.0f / 16.4f;
gyro->scale = GYRO_SCALE_2000DPS;
return true;
}

View file

@ -166,9 +166,9 @@ bool icm20649SpiGyroDetect(gyroDev_t *gyro)
gyro->initFn = icm20649GyroInit;
gyro->readFn = icm20649GyroReadSPI;
// 16.4 dps/lsb 2kDps
// 8.2 dps/lsb 4kDps
gyro->scale = 1.0f / (gyro->gyro_high_fsr ? 8.2f : 16.4f);
// 16.384 dps/lsb scalefactor for 2000dps sensors
// 8.192 dps/lsb scalefactor for 4000dps sensors
gyro->scale = (gyro->gyro_high_fsr ? GYRO_SCALE_4000DPS : GYRO_SCALE_2000DPS);
return true;
}

View file

@ -166,8 +166,7 @@ bool icm20689SpiGyroDetect(gyroDev_t *gyro)
gyro->initFn = icm20689GyroInit;
gyro->readFn = mpuGyroReadSPI;
// 16.4 dps/lsb scalefactor
gyro->scale = 1.0f / 16.4f;
gyro->scale = GYRO_SCALE_2000DPS;
return true;
}

View file

@ -278,8 +278,7 @@ bool icm42605SpiGyroDetect(gyroDev_t *gyro)
gyro->initFn = icm42605GyroInit;
gyro->readFn = icm42605GyroReadSPI;
// 16.4 dps/lsb scalefactor
gyro->scale = 1.0f / 16.4f;
gyro->scale = GYRO_SCALE_2000DPS;
return true;
}

View file

@ -235,8 +235,7 @@ bool mpu6000SpiGyroDetect(gyroDev_t *gyro)
gyro->initFn = mpu6000SpiGyroInit;
gyro->readFn = mpuGyroReadSPI;
// 16.4 dps/lsb scalefactor
gyro->scale = 1.0f / 16.4f;
gyro->scale = GYRO_SCALE_2000DPS;
return true;
}

View file

@ -126,11 +126,10 @@ bool mpu6500SpiGyroDetect(gyroDev_t *gyro)
case MPU_9250_SPI:
case ICM_20608_SPI:
case ICM_20602_SPI:
// 16.4 dps/lsb scalefactor
gyro->scale = 1.0f / 16.4f;
gyro->scale = GYRO_SCALE_2000DPS;
break;
case ICM_20601_SPI:
gyro->scale = 1.0f / (gyro->gyro_high_fsr ? 8.2f : 16.4f);
gyro->scale = (gyro->gyro_high_fsr ? GYRO_SCALE_4000DPS : GYRO_SCALE_2000DPS);
break;
default:
return false;

View file

@ -186,8 +186,7 @@ bool mpu9250SpiGyroDetect(gyroDev_t *gyro)
gyro->initFn = mpu9250SpiGyroInit;
gyro->readFn = mpuGyroReadSPI;
// 16.4 dps/lsb scalefactor
gyro->scale = 1.0f / 16.4f;
gyro->scale = GYRO_SCALE_2000DPS;
return true;
}