Simple Servo Motor Tuning and finding PID gains

Updated Nov 17, 2023

Environment

Hardware

  • PXI-7350

Software

  • Measurement & Automation Explorer (MAX)

Driver

  • NI-Motion

I can't seem to get my servo motor tuned.  Is there a simple method to find PID gains that will give me something close to my desired response?

This document is intended to complement the Understanding Servo Tune document, which more thoroughly explores the concept of servo tuning.  There is no single proper way to do manual servo tuning, but the method outlined below provides a simple method to quickly determine gains that are in a reasonable range to provide a good response from the system.  

Tuning Features of Measurement & Automation Explorer

One way to tune an NI-Motion system is to open up the Step Response and Control Loop tabs as separate windows.  To do this, follow these steps:
  1. In Measurement & Automation Explorer (MAX), go to Calibration»Servo Tune for your motion controller.
  2. Click and hold the Step Response tab
  3. Drag the mouse until the Step Response tab appears as a separate window
  4. Click the push pin icon at the top right of the window to keep the Step Response window open.
  5. Repeat these steps for the Control Loop tab.  Arrange and resize the windows so that you can see them side by side as you tune your motor.  Images of the windows are shown below for your reference.


The Method of Tuning

Now that you have the windows arranged so that you can easily modify your control loop, and see the changes in the step response, take the following steps to tune your PID control system.
  1. Set all three PID parameters, Kp, Kd, and Ki to 0
  2. Start by tuning Kp.  Set it to a number that is much lower than needed.  If you are unsure, start with 1.
  3. Click the Step Response button to view a step response graph of your system.  Step response plots are described in further detail in the Understanding Servo Tune document mentioned earlier.
  4. If the graph shows the parameter is:
    • Too Low - Double the value of the parameter.
    • Too High - Set the parameter to halfway between the current value and the previous value.
  5. Repeat steps 3 and 4 until you achieve a reasonable value for Kp. For most systems, this will mean that the response will approach the input, and oscillate continually about the input with a small amount of dampening.  If the oscillation does not gradually decrease in amplitude as shown below, then the system is considered unstable.  If this occurs, you may need to add a small amount of Kd while you are repeating steps 3 and 4 to increase Kp.
  6. After you arrive at a reasonable value for Kd, move on to Ki.
  7. Repeat steps 3 and 4 for Kd until you achieve a reasonable value for Ki.  This parameter works on the integral of the position error therefore taking out offset error.  Please use this parameter conservatively as it can introduce instability into the system.
  8. After you arrive at a reasonable value for Kd, move on to Ki.
  9. Repeat steps 3 and 4 for Kd until you achieve a reasonable value for Ki.  This parameter works on the integral of the position error therefore taking out offset error.  Please use this parameter conservatively as it can introduce instability into the system.
See the  Understanding Servo Tune document for a tuning example.