본문 바로가기

하드웨어

드론, 쿼드콥터 아두이노 미니 + multiwii + mpu 92/65 로 자세제어 및 날리기









 

 

설정관련 이미지

 

 


 

multiwii에서 mpu 92/65를 사용하기 위해 다음 코드를 사용했다.


http://hnegi38.tumblr.com/post/137093033046/mpu-9250-is-nine-axis-gyro-accelerometer

에서 코드를 가져왔다.


MPU-9250 is Nine-Axis (Gyro + Accelerometer + Compass) MEMS MotionTracking™ Device. I tried it with arduino.

MPU-9250 + ArduinoProMini + MultiWii

Add some code for MPU-9250

def.h
#if defined(MPU9250)
#define MPU6050
#define AK8963
#define ACC_ORIENTATION(X, Y, Z) {imu.accADC[ROLL] = -X; imu.accADC[PITCH] = -Y; imu.accADC[YAW] = Z;}
#define GYRO_ORIENTATION(X, Y, Z) {imu.gyroADC[ROLL] = Y; imu.gyroADC[PITCH] = -X; imu.gyroADC[YAW] = -Z;}
#define MAG_ORIENTATION(X, Y, Z) {imu.magADC[ROLL] = Y; imu.magADC[PITCH] = X; imu.magADC[YAW] = -Z;}
#undef INTERNAL_I2C_PULLUPS
#endif

config.h
#define MPU9250

[2016.3.20] change the sensitivity…
AK8975: 0.3 μT/LSB (13-bit)
AK8963: 0.15 µT/LSB (16-bit)
The Quadcopter shake sometimes when flew in the HEADFREE mode. Therefore I changed the sensitivity of AK8963 down to AK8975 same.

Sensors.cpp
// ***************************************
// I2C Compass AK8963
// ***************************************
// I2C adress: 0x0C (7bit)
// ***************************************
#if defined(AK8963)
#define MAG_ADDRESS 0x0C
#define MAG_DATA_REGISTER 0x03

void Mag_init() {
delay(100);
i2c_writeReg(MAG_ADDRESS,0x0a,0x11); //0x01=AK8975,0x11=AK8963
delay(100);
}

void Device_Mag_getADC() {
i2c_getSixRawADC(MAG_ADDRESS,MAG_DATA_REGISTER);
MAG_ORIENTATION( ((rawADC[1]<<8) | rawADC[0]) /2,
((rawADC[3]<<8) | rawADC[2]) /2,
((rawADC[5]<<8) | rawADC[4]) /2);
//Start another meassurement
i2c_writeReg(MAG_ADDRESS,0x0a,0x11);
}
#endif