Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to 16G accelerometer config #3203

Merged
merged 2 commits into from
May 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/main/drivers/accgyro/accgyro_mpu6000.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ static void mpu6000AccAndGyroInit(gyroDev_t *gyro)
delayMicroseconds(15);

// Accel +/- 8 G Full Scale
busWrite(busDev, MPU_RA_ACCEL_CONFIG, INV_FSR_8G << 3);
busWrite(busDev, MPU_RA_ACCEL_CONFIG, INV_FSR_16G << 3);
delayMicroseconds(15);

busWrite(busDev, MPU_RA_INT_PIN_CFG, 0 << 7 | 0 << 6 | 0 << 5 | 1 << 4 | 0 << 3 | 0 << 2 | 0 << 1 | 0 << 0); // INT_ANYRD_2CLEAR
Expand All @@ -133,7 +133,7 @@ static void mpu6000AccAndGyroInit(gyroDev_t *gyro)

static void mpu6000AccInit(accDev_t *acc)
{
acc->acc_1G = 512 * 8;
acc->acc_1G = 512 * 4;
}

bool mpu6000AccDetect(accDev_t *acc)
Expand Down
6 changes: 3 additions & 3 deletions src/main/drivers/accgyro/accgyro_mpu6050.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ static void mpu6050AccAndGyroInit(gyroDev_t *gyro)
delayMicroseconds(15);

// Accel +/- 8 G Full Scale
busWrite(gyro->busDev, MPU_RA_ACCEL_CONFIG, INV_FSR_8G << 3);
busWrite(gyro->busDev, MPU_RA_ACCEL_CONFIG, INV_FSR_16G << 3);
delayMicroseconds(15);

busWrite(gyro->busDev, MPU_RA_INT_PIN_CFG, 0 << 7 | 0 << 6 | 0 << 5 | 0 << 4 | 0 << 3 | 0 << 2 | 1 << 1 | 0 << 0); // INT_PIN_CFG -- INT_LEVEL_HIGH, INT_OPEN_DIS, LATCH_INT_DIS, INT_RD_CLEAR_DIS, FSYNC_INT_LEVEL_HIGH, FSYNC_INT_DIS, I2C_BYPASS_EN, CLOCK_DIS
Expand All @@ -109,10 +109,10 @@ static void mpu6050AccInit(accDev_t *acc)
{
mpuContextData_t * ctx = busDeviceGetScratchpadMemory(acc->busDev);
if (ctx->chipMagicNumber == 0x6850) {
acc->acc_1G = 512 * 8;
acc->acc_1G = 512 * 4;
}
else {
acc->acc_1G = 256 * 8;
acc->acc_1G = 256 * 4;
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/drivers/accgyro/accgyro_mpu6500.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

static void mpu6500AccInit(accDev_t *acc)
{
acc->acc_1G = 512 * 8;
acc->acc_1G = 512 * 4;
}

bool mpu6500AccDetect(accDev_t *acc)
Expand Down Expand Up @@ -89,7 +89,7 @@ static void mpu6500AccAndGyroInit(gyroDev_t *gyro)
busWrite(dev, MPU_RA_GYRO_CONFIG, INV_FSR_2000DPS << 3 | FCB_DISABLED);
delay(15);

busWrite(dev, MPU_RA_ACCEL_CONFIG, INV_FSR_8G << 3);
busWrite(dev, MPU_RA_ACCEL_CONFIG, INV_FSR_16G << 3);
delay(15);

busWrite(dev, MPU_RA_CONFIG, config->gyroConfigValues[0]);
Expand Down
4 changes: 2 additions & 2 deletions src/main/drivers/accgyro/accgyro_mpu9250.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

static void mpu9250AccInit(accDev_t *acc)
{
acc->acc_1G = 512 * 8;
acc->acc_1G = 512 * 4;
}

bool mpu9250AccDetect(accDev_t *acc)
Expand Down Expand Up @@ -89,7 +89,7 @@ static void mpu9250AccAndGyroInit(gyroDev_t *gyro)
busWrite(dev, MPU_RA_GYRO_CONFIG, INV_FSR_2000DPS << 3 | FCB_DISABLED);
delay(15);

busWrite(dev, MPU_RA_ACCEL_CONFIG, INV_FSR_8G << 3);
busWrite(dev, MPU_RA_ACCEL_CONFIG, INV_FSR_16G << 3);
delay(15);

busWrite(dev, MPU_RA_CONFIG, config->gyroConfigValues[0]);
Expand Down
4 changes: 1 addition & 3 deletions src/main/fc/fc_msp.c
Original file line number Diff line number Diff line change
Expand Up @@ -427,10 +427,8 @@ static bool mspFcProcessOutCommand(uint16_t cmdMSP, sbuf_t *dst, mspPostProcessF

case MSP_RAW_IMU:
{
// Hack scale due to choice of units for sensor data in multiwii
const uint8_t scale = (acc.dev.acc_1G > 1024) ? 8 : 1;
for (int i = 0; i < 3; i++) {
sbufWriteU16(dst, (int16_t)lrintf(acc.accADCf[i] * acc.dev.acc_1G / scale));
sbufWriteU16(dst, (int16_t)lrintf(acc.accADCf[i] * 512));
}
for (int i = 0; i < 3; i++) {
sbufWriteU16(dst, gyroRateDps(i));
Expand Down
2 changes: 1 addition & 1 deletion src/main/sensors/acceleration.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ STATIC_FASTRAM filterApplyFnPtr accNotchFilterApplyFn;
STATIC_FASTRAM void *accNotchFilter[XYZ_AXIS_COUNT];
#endif

PG_REGISTER_WITH_RESET_FN(accelerometerConfig_t, accelerometerConfig, PG_ACCELEROMETER_CONFIG, 1);
PG_REGISTER_WITH_RESET_FN(accelerometerConfig_t, accelerometerConfig, PG_ACCELEROMETER_CONFIG, 2);

void pgResetFn_accelerometerConfig(accelerometerConfig_t *instance)
{
Expand Down