-
Notifications
You must be signed in to change notification settings - Fork 255
Open
Description
Code now (bi-linear transform):
pid->differentiator = -(2.0f * pid->Kd * (measurement - pid->prevMeasurement)
+ (2.0f * pid->tau - pid->T) * pid->differentiator)
/ (2.0f * pid->tau + pid->T);
if you assume tau = 0, e[n] - e[n-1] = 0, then you'll get: D[n] = D[n-1], so it keeps always the previous value (and doesn't go to 0).
if you assume tau >>T, e[n] - e[n-1] = 0, then you'll get: D[n] = -1*D[n-1], so it keeps oscillating (and doesn't go to zero).
After reviewing other sources, I suggest using Backward-Euler transform s→(z-1)/z, then you'll get:
D[n] = K[d]/(tau + T)*(e[n] - e[n-1]) + tau/(tau + T)*D[n-1] // classical form
D[n] = K[d]/(tau + T)*(measurement[n-1] - measurement[n]) + tau/(tau + T)*D[n-1] // derivative on measurement
in this case it works as expected, for both "test cases" from above, if e[n] - e[n-1] = 0 then D[n] = 0
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels