From 484903fcdfccad34a8f2df013714a858033b3ef6 Mon Sep 17 00:00:00 2001 From: but0n Date: Mon, 10 Oct 2016 19:19:48 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=BA=E7=B1=BB=E5=9E=8B=E8=BD=AC=E6=8D=A2?= =?UTF-8?q?=E5=BF=98=E8=AE=B0=E5=8A=A0=E6=8B=AC=E5=8F=B7=E6=83=B9..?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pid.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pid.md b/pid.md index 563f4b3..29740d2 100644 --- a/pid.md +++ b/pid.md @@ -77,15 +77,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 = (short)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 += temp->output; + 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; - 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 -= 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; temp->InnerLast = *temp->Gyro; }