Re: [Emc-developers] PID musings
On 13 January 2012 06:05, Jon Elson el...@pico-systems.com wrote: I will have to try negative D values to see what they might do. D might want to be negative or positive, depending on what you are trying to achieve. You can use it to help catch a fast-moving setpoint (positive D) or to reject transients (negative D) -- atp The idea that there is no such thing as objective truth is, quite simply, wrong. -- RSA(R) Conference 2012 Mar 27 - Feb 2 Save $400 by Jan. 27 Register now! http://p.sf.net/sfu/rsa-sfdev2dev2 ___ Emc-developers mailing list Emc-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/emc-developers
Re: [Emc-developers] PID musings
On 01/12/2012 10:05 PM, Jon Elson wrote: I was just perusing some of the EMC docs, and wound up on the PID hal component docs and source. I have never quite understood the behavior of the D term. To (over) simplify: error = commanded - feedback errorD = error - previous error output = error * P + errorI * I + errorD * D Let's look at a couple cases : 1. commanded pos is 5.0, feedback is now 4.8, it was 4.8 last servo cycle. So, error is -0.1, previous error is -.2, so errorD is -0.1 - (-0.2) = +.1 I assume from your results there is a typo in the feedback -- it should have been 4.9 this cycle and 4.8 last cycle. So error = commanded - feedback = 5.0 - 4.9 = +0.1 previous error = previous_commanded - previous_feedback = 5.0 - 4.8 = +0.2 errorD = error - previous error = +0.1 - +0.2 = -0.1 errorD is negative, so with a positive D the D-term contribution is negative, which I think is what you want to avoid overshoot. Now, errorD is multiplied by the P term and adds a positive value to the output. This seems wrong, as the error is decreasing with movement in the positive direction, so you would actually want to add a negative adjustment to the output to avoid overshooting the commanded position. Here's another: commanded position is 5.0, and not changing. A disturbance has occurred, and the feedback is now 4.9, so the machine just bumped in the minus direction. error = 5.0 - 4.9 = +0.1 previous_error = 5.0 - 5.0 = 0 errorD = error - previous error = +0.1 - (0) = +0.1 when multiplied by a positive D, this adds a positive adjustment to the output, to bring it back to where it should be. error is -0.1, previous error was zero. errorD is -0.1 -(0) = -0.1 This adds a negative adjustment to the output, which is forcing it in the wrong direction. It should be moved to the positive to correct the disturbance. If I'm missing the boat, please let me know. Karl -- RSA(R) Conference 2012 Mar 27 - Feb 2 Save $400 by Jan. 27 Register now! http://p.sf.net/sfu/rsa-sfdev2dev2 ___ Emc-developers mailing list Emc-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/emc-developers
Re: [Emc-developers] PID musings
Karl Cunningham wrote: I assume from your results there is a typo in the feedback -- it should have been 4.9 this cycle and 4.8 last cycle. So Terribly sorry, YES, that is what I MEANT to type! If I'm missing the boat, please let me know. Maybe I'd better refrain from doing even SIMPLE arithmetic late at night! I'll have to go through all this again when I am more on the ball, but I think you are right. Thanks, Jon -- RSA(R) Conference 2012 Mar 27 - Feb 2 Save $400 by Jan. 27 Register now! http://p.sf.net/sfu/rsa-sfdev2dev2 ___ Emc-developers mailing list Emc-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/emc-developers
[Emc-developers] PID musings
I was just perusing some of the EMC docs, and wound up on the PID hal component docs and source. I have never quite understood the behavior of the D term. To (over) simplify: error = commanded - feedback errorD = error - previous error output = error * P + errorI * I + errorD * D Let's look at a couple cases : 1. commanded pos is 5.0, feedback is now 4.8, it was 4.8 last servo cycle. So, error is -0.1, previous error is -.2, so errorD is -0.1 - (-0.2) = +.1 Now, errorD is multiplied by the P term and adds a positive value to the output. This seems wrong, as the error is decreasing with movement in the positive direction, so you would actually want to add a negative adjustment to the output to avoid overshooting the commanded position. Here's another: commanded position is 5.0, and not changing. A disturbance has occurred, and the feedback is now 4.9, so the machine just bumped in the minus direction. error is -0.1, previous error was zero. errorD is -0.1 -(0) = -0.1 This adds a negative adjustment to the output, which is forcing it in the wrong direction. It should be moved to the positive to correct the disturbance. Any comments on this? This was mostly derived from the comments, as the actual code is a bit more complex, and seems to involve derivatives of both commanded and feedback, rather than looking at just error and previous error. I will have to try negative D values to see what they might do. Jon -- RSA(R) Conference 2012 Mar 27 - Feb 2 Save $400 by Jan. 27 Register now! http://p.sf.net/sfu/rsa-sfdev2dev2 ___ Emc-developers mailing list Emc-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/emc-developers