Skip to content

Issue with D component #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
maksoff opened this issue Apr 18, 2023 · 0 comments
Open

Issue with D component #9

maksoff opened this issue Apr 18, 2023 · 0 comments

Comments

@maksoff
Copy link

maksoff commented Apr 18, 2023

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

@maksoff maksoff mentioned this issue Apr 19, 2023
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant