void PIT0_IRQHandler(void) { if(aa<1000) aa++; delayms(); mpu6050_read(); angle_calculate(); angle_calculate1(); if (flag==2||flag==1) set_gyro(); if (flag==3&&active==1) { set_gyro1_3(); set_gyro_3(); } // oledplay(); if(flag==1) { motor_control(); SetMotorVoltage(0.05,0); MotorSpeedOut(); } if(qd==0) { motor_control(); SetMotorVoltage(0.05,0); MotorSpeedOut(); } if (flag==3&&active==1) { motor_control_3(); // SetMotorVoltage(0,0.5); MotorSpeedOut_3(); } if (flag==4) { motor_control_4(); SetMotorVoltage(0.05,0); MotorSpeedOut(); } if(flag==5) { set_gyro1(); motor_control1(); SetMotorVoltage(0,0.05); MotorSpeedOut1(); angle_set1=16; } PIT_Flag_Clear(PIT0); //清中断标志位 }
/*******************最后的输出**************/ void MotorOutput(void) { float fLeft, fRight; fLeft = g_fAngleControlOut - g_fSpeedControlOut + g_DirectionControlOut; //速度角度 fRight = g_fAngleControlOut - g_fSpeedControlOut - g_DirectionControlOut; //速度角度之和 g_fLeftMotorOut = fLeft; g_fRightMotorOut= fRight; MotorSpeedOut(); }