本帖最后由 greenHands 于 2016-6-15 17:40 编辑
//这下面的函数看不懂
void engineProcess(void)
{
LEDon;
DEBUG_LEDoff;
while(ConfigMode==1){TimerOff();}//Configuration loop
MPU6050_ACC_get(); //Getting Accelerometer data
acc_roll_angle = -(atan2(accADC_x, accADC_z))+(configData[11]-50.00)*0.0035;
acc_pitch_angle= +(atan2(accADC_y, accADC_z));
MPU6050_Gyro_get();
acc_roll_angle_vid = ((acc_roll_angle_vid * 99.00)+ acc_roll_angle ) / 100.00; <--这样做的用途是什么?
acc_pitch_angle_vid= ((acc_pitch_angle_vid * 99.00)+ acc_pitch_angle) / 100.00;
sinus = sinusas[(int)(rc4)];
cosinus = sinusas[90-(int)(rc4)];
ROLL =- gyroADC_z * sinus + gyroADC_y * cosinus;
roll_angle = (roll_angle + ROLL * dt) + 0.0002 * (acc_roll_angle_vid-roll_angle);
//ROLL=-gyroADC_z*sinus+gyroADC_y*cosinus;
pitch_angle_true = ((pitch_angle_true + gyroADC_x * dt) + 0.0002 * (acc_pitch_angle_vid - pitch_angle_true)); //Pitch Horizon
sukimas = sukimas + gyroADC_x * dt;
rc4_avg = ((rc4_avg * 499.00) + (rc4)) / 500.00;
pitch_angle = pitch_angle_true - rc4_avg / 57.3;
pitch_angle_correction = pitch_angle * 50.0;
if(pitch_angle_correction > 1.0){ pitch_angle_correction = 1.0; }
if(pitch_angle_correction < -1.0){ pitch_angle_correction = -1.0; }
pitch_setpoint = pitch_setpoint + pitch_angle_correction;
roll_angle_correction = roll_angle * 50.0; //roll
if(roll_angle_correction > 1.0){ roll_angle_correction = 1.0; }
if(roll_angle_correction < -1.0){ roll_angle_correction = -1.0; }
roll_setpoint = roll_setpoint + roll_angle_correction;
if(tim_conf == 0)
{
//rewrite that thing;
Timer1_Config();
Timer8_Config();
Timer5_Config();
Timer4_Config();
tim_conf = 1;
TIM_Cmd(TIM5, ENABLE);
TIM_CtrlPWMOutputs(TIM5, ENABLE);
for (n=1 ; n<4 ; n++);
TIM_Cmd(TIM4, ENABLE);
TIM_CtrlPWMOutputs(TIM4, ENABLE);
}
pitch_PID();//Pitch axis pid
roll_PID(); //Roll axis pid
printcounter++; //Print data to UART
if (printcounter>=50)
{
printcounter=0;
}
stop=0;
LEDoff;
watchcounter=0;
}
------
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
程序不想抄
一周热门 更多>