restore _fCut that was lost in AP_Param development

This commit is contained in:
Andrew Tridgell 2012-02-12 20:32:03 +11:00
parent df77c462a4
commit c4b7a3116a
2 changed files with 8 additions and 1 deletions

View File

@ -30,7 +30,7 @@ PID::get_pid(int32_t error, uint16_t dt, float scaler)
// discrete low pass filter, cuts out the
// high frequency noise that can drive the controller crazy
float RC = 1/(2*M_PI*20);
float RC = 1/(2*M_PI*_fCut);
derivative = _last_derivative +
(delta_time / (RC + delta_time)) * (derivative - _last_derivative);

View File

@ -82,6 +82,13 @@ private:
float _integrator; ///< integrator value
int32_t _last_error; ///< last error for derivative
float _last_derivative; ///< last derivative for low-pass filter
/// Low pass filter cut frequency for derivative calculation.
///
/// 20 Hz becasue anything over that is probably noise, see
/// http://en.wikipedia.org/wiki/Low-pass_filter.
///
static const uint8_t _fCut = 20;
};
#endif