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

Reply via email to