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:
Philip Salmony
2020-05-27 20:49:12 +02:00
committed by Alekseev
parent 98ba591357
commit bd1a5902a1

2
PID.h
View File

@@ -6,7 +6,7 @@ typedef struct {
/* Controller gains */
float Kp;
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 */
float tau;