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
This commit is contained in:
DrZiplok@gmail.com 2010-11-26 04:36:43 +00:00
parent f04e58c6b3
commit 9a45c2babc
2 changed files with 12 additions and 9 deletions

View File

@ -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;

View File

@ -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;
};