diff --git a/flight/libraries/math/pid.c b/flight/libraries/math/pid.c index 6e962c306..dafff7b15 100644 --- a/flight/libraries/math/pid.c +++ b/flight/libraries/math/pid.c @@ -6,7 +6,8 @@ * @{ * * @file pid.c - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. + * @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2016. + * The OpenPilot Team, http://www.openpilot.org Copyright (C) 2015. * @brief Methods to work with PID structure * * @see The GNU Public License (GPL) Version 3 @@ -159,7 +160,7 @@ void pid_configure(struct pid *pid, float p, float i, float d, float iLim) * @param[in] kp proportional gain * @param[in] ki integral gain. Time constant Ti = kp/ki * @param[in] kd derivative gain. Time constant Td = kd/kp - * @param[in] Tf filtering time = (kd/k)/N, N is in the range of 2 to 20 + * @param[in] Tf filtering time = (kd/kp)/N, N is in the range of 2 to 20 * @param[in] kt tracking gain for anti-windup. Tt = √TiTd and Tt = (Ti + Td)/2 * @param[in] dt delta time increment * @param[in] beta setpoint weight on setpoint in P component. beta=1 error feedback. beta=0 smoothes out response to changes in setpoint diff --git a/flight/libraries/math/pid.h b/flight/libraries/math/pid.h index b6d9e2ae6..eba64a5f9 100644 --- a/flight/libraries/math/pid.h +++ b/flight/libraries/math/pid.h @@ -6,7 +6,9 @@ * @{ * * @file pid.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. + * + * @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2016. + * The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. * @brief Methods to work with PID structure * * @see The GNU Public License (GPL) Version 3 @@ -46,17 +48,17 @@ struct pid { // pid2 structure for a PID+setpoint weighting, anti-windup and filtered derivative control struct pid2 { - float u0; - float va; + float u0; // Initial value of r & y - for bumpless transfer + float va; // Actuator float vb; - float kp; - float bi; - float ad; - float bd; - float br; - float beta; - float yold; - float P; + float kp; // proportional gain + float bi; // Integral gain . dT + float ad; // Filtered factor for derivative calculation + float bd; // Constant for derivative calculation + float br; // Time constant for integral calculation + float beta; // Scalar for proportional factor + float yold; // t-1 y value for Integral calculation + float P; // Latest calculated P, I & D values float I; float D; uint8_t reconfigure;