static bool calibrateMPU6500Gyro(void) { bool rcode = calibrateSensor(&gyroZero, MPU6500_GYRO_XOUT_H, 100); // 100 / 16.4 ~= 6.10 deg/s #if UART_DEBUG if (!rcode) UARTprintf("Gyro zero values: %d\t%d\t%d\n", gyroZero.axis.X, gyroZero.axis.Y, gyroZero.axis.Z); else UARTprintf("Gyro calibration error\n"); #endif return rcode; }
bool calibrateMPU6500Acc(mpu6500_t *mpu6500) { bool rcode = calibrateSensor(&cfg.accZero, MPU6500_ACCEL_XOUT_H, 100); // 100 / 4096 ~= 0.02g cfg.accZero.axis.Z -= mpu6500->accScaleFactor; // Z-axis is reading +1g when horizontal, so we subtract 1g from the value found if (!rcode) { #if UART_DEBUG UARTprintf("Accelerometer zero values: %d\t%d\t%d\n", cfg.accZero.axis.X, cfg.accZero.axis.Y, cfg.accZero.axis.Z); #endif updateConfig(); // Write new values to EEPROM } #if UART_DEBUG else UARTprintf("Accelerometer calibration error\n"); #endif return rcode; // No error }
void main(void) { /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/ PE_low_level_init(); /*** End of Processor Expert internal initialization. ***/ nLoop = 0; SCIcount=0; AD1_Start(); Puls1_Enable(); Puls2_Enable(); TI1_DisableEvent(); Cpu_Delay100US(10000); if(!AD_Flag) { calibrateSensor(); TI1_EnableEvent(); AD_Flag = 1; } //---------------------------------------------------------------- for(;;) { nLoop ++; if(nLoop >= LOOP_TIME) nLoop = 0; else continue; //---------------------------------------------------------------- if((g_fGyroscopeAngleIntegral < 50.0) && (g_fGyroscopeAngleIntegral > -50.0)) //ж╠а╒еп╤о standFlag = 1; else if((g_fGyroscopeAngleIntegral >= 50.0) || (g_fGyroscopeAngleIntegral <= -50.0)) standFlag = 0; //---------------------------------------------------------------- Cpu_Delay100US(100); if(UartFlag == 1) { sendData(); UartFlag = 0; } receiveData(); } }
void calibrateAcc() { calibrateSensor(MPU6050::ACC); }
void calibrateGyro() { calibrateSensor(MPU6050::GYRO); }
void onRecalibrate() { angleSetpoint = calibrateSensor(); cmdMessenger.sendCmd(kStatus, "Calibration done"); }