From 9a45c2babccb89b11c20b9b6172f5e8c10f1e8b8 Mon Sep 17 00:00:00 2001 From: "DrZiplok@gmail.com" Date: Fri, 26 Nov 2010 04:36:43 +0000 Subject: [PATCH] Re-type delta t, explicitly size error args to get_pid. git-svn-id: https://arducopter.googlecode.com/svn/trunk@936 f9c3cf11-9bcb-44bc-f272-b75c42450872 --- libraries/PID/PID.cpp | 2 +- libraries/PID/PID.h | 19 +++++++++++-------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/libraries/PID/PID.cpp b/libraries/PID/PID.cpp index b64d3984cd..8eb65da747 100644 --- a/libraries/PID/PID.cpp +++ b/libraries/PID/PID.cpp @@ -9,7 +9,7 @@ #include "PID.h" long -PID::get_pid(long error, long dt, float scaler) +PID::get_pid(int32_t error, uint16_t dt, float scaler) { float output = 0; float delta_time = (float)dt / 1000; diff --git a/libraries/PID/PID.h b/libraries/PID/PID.h index 5adb8c11a8..f9425c80b3 100644 --- a/libraries/PID/PID.h +++ b/libraries/PID/PID.h @@ -44,13 +44,16 @@ public: /// /// Positive error produces positive output. /// - /// @param err The measured error value - /// @param dt The time delta in milliseconds + /// @param error The measured error value + /// @param dt The time delta in milliseconds (note + /// that update interval cannot be more + /// than 65.535 seconds due to limited range + /// of the data type). /// @param scaler An arbitrary scale factor /// /// @returns The updated control output. /// - long get_pid(long err, long dt, float scaler=1); + long get_pid(int32_t error, uint16_t dt, float scaler = 1.0); /// Reset the PID integrator /// @@ -94,11 +97,11 @@ private: 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, - /// set to 20 Hz becasue anything over that - /// is probably noise, see - /// http://en.wikipedia.org/wiki/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 _RC = 20; };