Arduino-PID-Library
Arduino-PID-Library copied to clipboard
output goes crazy as error approaches zero.
My PID output goes crazy as my error approaches zero. What am I doing wrong? Kp=2 Ki=0.1 Kd=0.3

Looks like too much derivative. Try kd=0 to confirm.
On Thu, Mar 22, 2018, 2:51 PM Phil D. [email protected] wrote:
My PID output goes crazy as my error approaches zero. What am I doing wrong? Kp=2 Ki=0.1 Kd=0.3
[image: 2_0 1_0 3] https://user-images.githubusercontent.com/3106132/37791782-51a3b742-2dc7-11e8-898b-238577ab4ed3.png
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/br3ttb/Arduino-PID-Library/issues/72, or mute the thread https://github.com/notifications/unsubscribe-auth/AAWL8tgNTAYAB9vKA5BY2Qv6JYxER4ioks5tg_K2gaJpZM4S3mwJ .
Yeah, the signal is a little noisy in that graph. But in general the Derivative works, EXCEPT when error is "too close" to zero. Then the whole system will suddenly "kick" (which of course pushes the error back up, and starts the whole thing over again).
It definitely DOES have something to do with kD, though. When kD is zero, the system oscillates, but doesn't have that weird "kick" at zero error.
There is more likelihood of quick back and forth near setpoint; when you're away it's clear which direction you have to go. So if your input jumps back and forth once, it creates a step slope which causes the d term to spike the output. If the system is pretty quick, that can cause a steep input slope in the other direction, and on and on.
That's what it looks like to me anyway. If you set kd to 0 you can confirm. If I'm right I see two pretty simple options: 1: don't use d. With a system this fast you can probably get the performance you need with just p and I 2: filter the signal a little to get rid of the spikes: pidInput = (rawInput + 9*pid Input)/10
On Mon, Mar 26, 2018, 5:42 PM Phil D. [email protected] wrote:
Yeah, the signal is a little noisy in that graph. But in general the Derivative works, EXCEPT when error is "too close" to zero. Then the whole system will suddenly "kick" (which of course pushes the error back up, and starts the whole thing over again).
— You are receiving this because you commented.
Reply to this email directly, view it on GitHub https://github.com/br3ttb/Arduino-PID-Library/issues/72#issuecomment-376321607, or mute the thread https://github.com/notifications/unsubscribe-auth/AAWL8pEJd334ziU07cb5lCOgCvEpj2ZEks5tiWCrgaJpZM4S3mwJ .
Thanks a ton for the helpful feedback, I'll definitely give this a try and report back!
A third option I didn't mention, which is similar to the first: use LESS d. Add a little to get the oscillation-dampening benefit, but not so much that you get twitchy.
On Mon, Mar 26, 2018, 9:22 PM Phil D. [email protected] wrote:
Thanks a ton for the helpful feedback, I'll definitely give this a try and report back!
— You are receiving this because you commented.
Reply to this email directly, view it on GitHub https://github.com/br3ttb/Arduino-PID-Library/issues/72#issuecomment-376364442, or mute the thread https://github.com/notifications/unsubscribe-auth/AAWL8sm1JqHAv7a0f38lBxmSzOACub4Iks5tiZRsgaJpZM4S3mwJ .