Added minus sign to derivative-on-measurement expression.
Note on 'derivative-on-measurement': Since the 'error signal' effectively going into the differentiator does not depend on the setpoint: e[n] = 0 - measurement, and therefore (e[n] - e[n - 1]) = (0 - measurement) - (0 - prevMeasurement) = -Kd * (measurement - prevMeasurement). (Note the minus sign compared to derivative-on-error!)
This commit is contained in:
2
PID.h
2
PID.h
@@ -6,7 +6,7 @@ typedef struct {
|
|||||||
/* Controller gains */
|
/* Controller gains */
|
||||||
float Kp;
|
float Kp;
|
||||||
float Ki;
|
float Ki;
|
||||||
float Kd; /* Note: since using derivative-on-measurement, Kd needs to be negative (in contrast to conventional 'derivative-on'error') */
|
float Kd;
|
||||||
|
|
||||||
/* Derivative low-pass filter time constant */
|
/* Derivative low-pass filter time constant */
|
||||||
float tau;
|
float tau;
|
||||||
|
|||||||
Reference in New Issue
Block a user