From 632cc783a19ad25452e7e8a1ebfbd377e7bdc4a9 Mon Sep 17 00:00:00 2001 From: Jason Short Date: Thu, 16 Feb 2012 22:07:35 -0800 Subject: [PATCH] cast D term to float just in case --- ArduCopter/Attitude.pde | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ArduCopter/Attitude.pde b/ArduCopter/Attitude.pde index c9506b91b3..6c5dbbd940 100644 --- a/ArduCopter/Attitude.pde +++ b/ArduCopter/Attitude.pde @@ -21,7 +21,7 @@ get_stabilize_roll(int32_t target_angle) // limit the error we're feeding to the PID target_angle = constrain(target_angle, -2500, 2500); - // conver to desired Rate: + // convert to desired Rate: int32_t target_rate = g.pi_stabilize_roll.get_p(target_angle); int16_t iterm = g.pi_stabilize_roll.get_i(target_angle, G_Dt); @@ -115,7 +115,8 @@ get_rate_roll(int32_t target_rate) target_rate = g.pid_rate_roll.get_pid(target_rate, G_Dt); // Dampening - target_rate -= constrain((current_rate - last_rate) * g.stabilize_d, -500, 500); + int16_t d_temp = (float)(current_rate - last_rate) * g.stabilize_d; + target_rate -= constrain(d_temp, -500, 500); last_rate = current_rate; // output control: @@ -133,7 +134,8 @@ get_rate_pitch(int32_t target_rate) target_rate = g.pid_rate_pitch.get_pid(target_rate, G_Dt); // Dampening - target_rate -= constrain((current_rate - last_rate) * g.stabilize_d, -500, 500); + int16_t d_temp = (float)(current_rate - last_rate) * g.stabilize_d; + target_rate -= constrain(d_temp, -500, 500); last_rate = current_rate; // output control: