From: Olivier Matz Date: Thu, 26 Jun 2014 18:38:09 +0000 (+0200) Subject: fix imu configuration X-Git-Url: http://git.droids-corp.org/?p=protos%2Fimu.git;a=commitdiff_plain;h=1efaecd600f90de4aa0f18d694355c52f2447b5a;hp=0a4bfd31b0b0b50659a6fbd8dfa283ba2603aabf fix imu configuration --- diff --git a/mpu6050.c b/mpu6050.c index 5ffa100..143d0e9 100644 --- a/mpu6050.c +++ b/mpu6050.c @@ -16,9 +16,9 @@ // fs_sel = 1 // 500°/s -#define gyro_x_resolution 66.5 -#define gyro_y_resolution 66.5 -#define gyro_z_resolution 66.5 +/* #define gyro_x_resolution 66.5 */ +/* #define gyro_y_resolution 66.5 */ +/* #define gyro_z_resolution 66.5 */ // fs_sel = 3 // 2000°/s @@ -26,9 +26,9 @@ #define gyro_y_resolution 16.4 #define gyro_z_resolution 16.4 -#define accel_x_resolution 8192.0 -#define accel_y_resolution 8192.0 -#define accel_z_resolution 8192.0 +#define accel_x_resolution 2048.0 +#define accel_y_resolution 2048.0 +#define accel_z_resolution 2048.0 @@ -37,8 +37,8 @@ #define MPU6050_OFF_LSB 0 -#define MPU6050_ADDRESS 0x68 -#define MPU6050_MAGNETO_ADDRESS 0x0C +#define MPU6050_ADDRESS 0x69 +#define MPU6050_MAGNETO_ADDRESS 0x0D #define SWAP_16(a) ((( (a) & 0xff)<<8) | (( (a) >> 8) & 0xff)) @@ -192,7 +192,7 @@ uint8_t mpu6050_init(void) while(1) { - err = read_reg(MPU6050_ADDRESS, 0x75, &id); + err = read_reg(MPU6050_ADDRESS, MPU6050_RA_WHO_AM_I, &id); if (err) continue; if (id == 0x68) @@ -210,9 +210,9 @@ uint8_t mpu6050_init(void) //Disable gyro self tests, scale of 2000 degrees/s send_mpu6050_cmd(MPU6050_ADDRESS, MPU6050_RA_GYRO_CONFIG, 0b00011000); + //Disable accel self tests, scale of +-16g, no DHPF + send_mpu6050_cmd(MPU6050_ADDRESS, MPU6050_RA_ACCEL_CONFIG, 0b00011000); - //Disable accel self tests, scale of +-4g, no DHPF - send_mpu6050_cmd(MPU6050_ADDRESS, MPU6050_RA_ACCEL_CONFIG, 0b00001000); //Freefall threshold of <|0mg| send_mpu6050_cmd(MPU6050_ADDRESS, MPU6050_RA_FF_THR, 0x00); //Freefall duration limit of 0