Manually Tuning Motors

NI Motion Measurement & Automation Explorer

Manually Tuning Motors

Use the Control Loop tab to view and edit the PID parameters. Auto Tune provides a tuned system, but for an optimally tuned system, it is necessary to fine-tune the final PID parameters. It may also be necessary to alter the PID parameters, depending on your specific circumstances.

  • Proportional Gain (Kp)

    For each sample period, the PID loop calculates the position error and multiplies it by Kp to produce the proportional component of the 16-bit DAC command output. The position error is the difference between the instantaneous trajectory position and the primary feedback position.

    An axis with too small a value for Kp is unable to hold the motor in position and is very soft. Increasing Kp stiffens the axis and improves its disturbance torque rejection (its resistance to torque disturbances). However, too large a value for Kp could cause instability.

  • Derivative Gain (Kd)

    Every derivative sampling period, the PID loop computes the derivative of the position error. This derivative term is multiplied by Kd every PID sample period to produce the derivative component of 16-bit DAC command output. In order for the servo loop operation to be stable, a nonzero value for Kd is required for all systems that use torque or current amplifiers (where the command output is proportional to motor torque). Small Kd values result in oscillations and servo loop instability.

    With velocity or voltage amplifiers in which the command output is proportional to motor velocity, set Kd to 0 or to a very small positive value.

  • Integral Gain (Ki)

    For each sample period, the position error is added to the accumulation of previous position errors to form an integration sum. Integration sum is scaled by dividing it by 256 before multiplying it by Ki.

    Use the default value (0) for applications with small static torque loads. Static torque loads are those that apply torque to the shaft but are not moving. For systems with high static torque loads, tune this value to minimize position error when the axis is stopped. Ki has no effect when Integration Limit is equal to 0.

  • Derivative Sampling Period (Td)

    The derivative sampling period determines how often (in update samples) the derivative of position error is calculated. Adjust Td for greater flexibility in tuning the PID loop derivative term.

    As Td increases, you can use a proportionally lower Kd value for similar results. Start the Td parameter at its default value of 2, and make small adjustments as required by your motion system configuration.

    For low inertia systems, set Td to 0 or 1 so that the derivative is calculated often enough to provide adequate damping for servo loop stability.

    Systems with higher inertia can benefit from larger Td values. Because higher inertia means that the position error cannot change quickly, it is acceptable to calculate the derivative less often. As a result, you can use a lower Kd value and have the same effective amount of damping, and the system will be smoother with less torque noise from the derivative term. In higher inertia systems, using a Td of 0, and therefore a larger value for Kd, increases torque noise and motor heating without improving system stability.

Complete the following steps to manually tune a motor:

Note  This exercise assumes that Axis 1 is configured as a servo axis.
  1. Launch MAX.
  2. Expand Devices and Interfaces.
  3. Expand NI–Motion Devices, and then expand the item for the appropriate motion device.
  4. Expand Calibration in the configuration tree, and select Servo Tune.
  5. Auto tune the motor first.
  6. Click the Control Loop tab and note the values on the Kp, Kd, Ki, and Td controls. Write these values down for future reference.
  7. In the Control Loop tab, increase the proportional gain (Kp) by a factor 2, and click Save in the MAX toolbar. Increasing by a factor of 2 works for most systems, but if your system becomes unstable, reduce this factor appropriately.
  8. Click the Step Response tab to examine the Step Response plot. As you increase the proportional gain, the rise, peak, and settling times decrease, producing a stiffer, faster response. The maximum overshoot increases as well. Increasing by a factor of 2 typically results in a noticeably higher overshoot. If this is not true for your particular system, try increasing your gain again.
  9. Decrease the proportional gain (Kp) by a factor of 2 from its original value or a factor of 4 from its current value. Decreasing by a factor of 2 works for most systems, but if your system becomes too sluggish, reduce this factor appropriately.
  10. Click the Step Response tab to examine the Step Response plot. As you decrease the proportional gain, the rise, peak, and settling times increase, producing a smoother, slower response. As you decrease Kp, the maximum overshoot decreases as well. Decreasing by a factor of 2 typically results in a noticeably more damped system. If this is not true for your particular system, try decreasing the gain again.
  11. Reset the Proportional Gain (Kp) to the original value you noted in step 6.
  12. Increase the Derivative Gain (Kd) by a factor of 1.5. Increasing by a factor of 1.5 works for most systems, but if your system becomes too sluggish, reduce this factor appropriately.
  13. Click the Step Response tab to examine the Step Response plot. As you increase the derivative gain, the maximum overshoot decreases and the settling time increases. The number of visible oscillations decreases as well. Increasing by a factor of 2 typically results in a noticeably more damped system. If this is not true for your particular system, try increasing your gain again.
  14. Decrease the Derivative Gain (Kd) by a factor of 1.5 from the original value, or a factor of 2.25 from the current value. Decreasing by a factor of 1.5 works for most systems, but if your system becomes unstable, decrease this factor appropriately.
  15. Click the Step Response tab to examine the Step Response plot. As you decrease the derivative gain, the maximum overshoot increases while the settling time decreases. The number of visible oscillations increases as well. Decreasing by a factor of 1.5 typically results in a noticeably higher overshoot. If this is not true for your particular system, try decreasing your gain again.
  16. Reset the Derivative Gain (Kd) to the original value you noted in step 6.
    Note  There are subtle differences between the Kp and Kd values on your system. Increasing Kp increases the slope of the initial rise to the commanded position. As you increase Kp, you approach the commanded position faster, and thus overshoot by a greater amount. Kd reduces the oscillations over a period of time after the initial rise. When Kp decreases, Kd becomes dominant, and when Kd decreases, Kp becomes dominant. When tuning your system, the goal is to find a comfortable balance between Kp and Kd such that there is adequate response time, which is controlled primarily by Kp, and minimal overshoot, which is controlled primarily by Kd, without having to significantly increase or decrease the gains. Increasing or decreasing the gains too much can create an unstable system and possibly damage the motor.
  17. Decrease the Integral Gain (Ki) to 0.
  18. Click the Step Response tab to examine the Step Response plot. You may notice a steady state error position delta on the Step Response plot. This is the steady-state position error.
  19. Increase the Integral Gain (Ki), by increments of 1, beyond its original value. Be careful not to increase Ki too much.
  20. Click the Step Response tab to examine the Step Response plot. Increasing the Integral Gain beyond what is necessary to correct for a steady state position error can result in an unstable system.
    Tip  As you become familiar with the effects of Ki on your system, you will notice that it corrects steady-state position error. Some simple systems may not require Ki.
  21. Reset the Integral Gain (Ki) to the original value you noted in step 6.