[Fixed]: 强类型转换放错了地方

This commit is contained in:
but0n 2016-10-10 18:56:13 +08:00
parent e27d7c8e2f
commit 405a77a78a

View File

@ -16,15 +16,15 @@ void pid_SingleAxis(pid_pst temp, float setPoint) {
//Inner Loop PD
temp->p = temp->output + *temp->Gyro * 3.5f;
temp->d = *temp->Gyro - temp->InnerLast;
temp->output = INNER_LOOP_KP * temp->p + INNER_LOOP_KD * temp->d;
temp->output = (short)INNER_LOOP_KP * temp->p + INNER_LOOP_KD * temp->d;
if (*temp->Channel1 + temp->output > MOTOR_MAX) *temp->Channel1 = MOTOR_MAX;
else if (*temp->Channel1 + temp->output < MOTOR_LOW) *temp->Channel1 = MOTOR_LOW;
else *temp->Channel1 += (short)temp->output;
else *temp->Channel1 += temp->output;
if (*temp->Channel2 - temp->output > MOTOR_MAX) *temp->Channel2 = MOTOR_MAX;
else if (*temp->Channel2 - temp->output < MOTOR_LOW) *temp->Channel2 = MOTOR_LOW;
else *temp->Channel2 -= (short)temp->output;
else *temp->Channel2 -= temp->output;
temp->InnerLast = *temp->Gyro;
}