/** Power on and prepare for general usage. * This will activate the device and take it out of sleep mode (which must be done * after start-up). This function also sets both the accelerometer and the gyroscope * to their most sensitive settings, namely +/- 2g and +/- 250 degrees/sec, and sets * the clock source to use the X Gyro for reference, which is slightly better than * the default internal clock source. */ void MPU6050_Initialize(void) { MPU6050_SetClockSource(MPU6050_CLOCK_DIV_308); MPU6050_SetFullScaleGyroRange(MPU6050_GYRO_FS_2000); MPU6050_SetFullScaleAccelRange(MPU6050_ACCEL_FS_16); MPU6050_SetSleepModeStatus(DISABLE); }
/** Power on and prepare for general usage. * This will activate the device and take it out of sleep mode (which must be done * after start-up). This function also sets both the accelerometer and the gyroscope * to their most sensitive settings, namely +/- 2g and +/- 250 degrees/sec, and sets * the clock source to use the X Gyro for reference, which is slightly better than * the default internal clock source. */ void MPU6050_Initialize() { MPU6050_SetClockSource(MPU6050_CLOCK_PLL_XGYRO); MPU6050_SetFullScaleGyroRange(MPU6050_GYRO_FS_250); MPU6050_SetFullScaleAccelRange(MPU6050_ACCEL_FS_2); MPU6050_SetSleepModeStatus(DISABLE); }
/** Power on and prepare for general usage. * This will activate the device and take it out of sleep mode (which must be done * after start-up). This function also sets both the accelerometer and the gyroscope * to their most sensitive settings, namely +/- 2g and +/- 250 degrees/sec, and sets * the clock source to use the X Gyro for reference, which is slightly better than * the default internal clock source. */ void MPU6050_Initialize() { MPU6050_SetClockSource(MPU6050_CLOCK_PLL_XGYRO); //MPU6050_SetLowPassFilter(0x02); MPU6050_SetFullScaleGyroRange(MPU6050_GYRO_FS_500); MPU6050_SetFullScaleAccelRange(0x09); MPU6050_SetSleepModeStatus(DISABLE); }
/** Power on and prepare for general usage. * This will activate the device and take it out of sleep mode (which must be done * after start-up). This function also sets both the accelerometer and the gyroscope * to their most sensitive settings, namely +/- 2g and +/- 250 degrees/sec, and sets * the clock source to use the X Gyro for reference, which is slightly better than * the default internal clock source. */ void MPU6050_Initialize() { // GYRO AT 2000g AND ACC AT 2g MPU6050_SetClockSource(MPU6050_CLOCK_PLL_XGYRO); MPU6050_WriteBits(MPU6050_DEFAULT_ADDRESS, MPU6050_RA_CONFIG, MPU6050_CFG_DLPF_CFG_BIT, MPU6050_CFG_DLPF_CFG_LENGTH, MPU6050_DLPF_BW_42); //set DLPF bandwidth to 42Hz MPU6050_SetFullScaleGyroRange(MPU6050_GYRO_FS_2000); MPU6050_SetFullScaleAccelRange(MPU6050_ACCEL_FS_2); MPU6050_SetSleepModeStatus(DISABLE); }
/** Power on and prepare for general usage. * This will activate the device and take it out of sleep mode (which must be done * after start-up). This function also sets both the accelerometer and the gyroscope * to their most sensitive settings, namely +/- 2g and +/- 250 degrees/sec, and sets * the clock source to use the X Gyro for reference, which is slightly better than * the default internal clock source. */ void MPU6050_Initialize() { MPU6050_SetSleepModeStatus(DISABLE); //MPU6050_WriteBit(MPU6050_DEFAULT_ADDRESS, MPU6050_RA_PWR_MGMT_1, MPU6050_PWR1_DEVICE_RESET_BIT, DISABLE); delay(100); MPU6050_SetClockSource(MPU6050_CLOCK_PLL_XGYRO); delay(100); MPU6050_Config(0x01); delay(100); //MPU6050_WriteBits(MPU6050_DEFAULT_ADDRESS, MPU6050_RA_SMPLRT_DIV, 7, 8, 0x00); //delay(100); MPU6050_SetFullScaleGyroRange(MPU6050_GYRO_FS_2000); delay(100); MPU6050_SetFullScaleAccelRange(MPU6050_ACCEL_FS_16); delay(100); MPU6050_WriteBit(MPU6050_DEFAULT_ADDRESS, MPU6050_RA_INT_PIN_CFG, 4, ENABLE); //delay(100); MPU6050_WriteBit(MPU6050_DEFAULT_ADDRESS, MPU6050_RA_INT_ENABLE, 0, ENABLE); //delay(100); //MPU6050_WriteBits(MPU6050_DEFAULT_ADDRESS, MPU6050_RA_SIGNAL_PATH_RESET, 2, 3, 0x07); //delay(100); //MPU6050_enablemagnetometer(); //delay(100); // MPU6050_WriteByte(MPU6050_DEFAULT_ADDRESS, MPU6050_RA_PWR_MGMT_1, 1<<7);//reset the whole module first /* MPU6050_WriteBit(MPU6050_DEFAULT_ADDRESS, MPU6050_RA_PWR_MGMT_1, MPU6050_PWR1_DEVICE_RESET_BIT, DISABLE); delay(50); //wait for 50ms for the gyro to stable MPU6050_WriteByte(MPU6050_DEFAULT_ADDRESS, MPU6050_RA_PWR_MGMT_1, MPU6050_CLOCK_PLL_ZGYRO);//PLL with Z axis gyroscope reference MPU6050_WriteByte(MPU6050_DEFAULT_ADDRESS, MPU6050_RA_CONFIG, 0x00); //DLPF_CFG = 0: Fs=8khz; bandwidth=256hz MPU6050_WriteByte(MPU6050_DEFAULT_ADDRESS, MPU6050_RA_SMPLRT_DIV, 0x00); //1000Hz sample rate ~ 2ms MPU6050_WriteByte(MPU6050_DEFAULT_ADDRESS, MPU6050_RA_GYRO_CONFIG, MPU6050_GYRO_FS_2000); //Gyro full scale setting MPU6050_WriteByte(MPU6050_DEFAULT_ADDRESS, MPU6050_RA_ACCEL_CONFIG, MPU6050_ACCEL_FS_16); //Accel full scale setting MPU6050_WriteByte(MPU6050_DEFAULT_ADDRESS, MPU6050_RA_INT_PIN_CFG, 1<<4); //interrupt status bits are cleared on any read operation MPU6050_WriteByte(MPU6050_DEFAULT_ADDRESS, MPU6050_RA_INT_ENABLE, 1<<0); //interupt occurs when data is ready. The interupt routine is in the receiver.c file. MPU6050_WriteByte(MPU6050_DEFAULT_ADDRESS, MPU6050_RA_SIGNAL_PATH_RESET, 0x07);//reset gyro and accel sensor */ }
/** Power on and prepare for general usage. * This will activate the device and take it out of sleep mode (which must be done * after start-up). This function also sets both the accelerometer and the gyroscope * to their most sensitive settings, namely +/- 2g and +/- 250 degrees/sec, and sets * the clock source to use the X Gyro for reference, which is slightly better than * the default internal clock source. */ void MPU6050_Init() { DIS_SYSTICK(); MPU6050_I2C_Init(); if( !MPU6050_TestConnection() ) { printf( "init error\r\n" ); while( 1 ) ; } MPU6050_SetClockSource( MPU6050_CLOCK_PLL_XGYRO ); MPU6050_SetFullScaleGyroRange( MPU6050_GYRO_FS_2000 ); MPU6050_SetFullScaleAccelRange( MPU6050_ACCEL_FS_4 ); MPU6050_SetSleepModeStatus( DISABLE ); EN_SYSTICK(); }