Get the latest updates on the Coronavirus impact on engineers.Click Here
Process Manufacturing

How to tune servo systems (Part 1): Questions and answers

Inside Machines: More answers regarding servo system tuning follow the March 11 webcast on the same topic.

By Joseph Profeta April 22, 2020
The red curve is the phase of the loop gain before adding a notch filter in the loop. The green curve is the phase of the notch filter being added to the loop (with center frequency of five rad/sec). The black curve is the resulting phase of plant loop gain, which is found by adding the phase at each frequency of the red and green curve. At four rad/sec, the phase of the red curve phase (-140 degrees) plus the green curve phase (-40 degrees) is -180 degrees, which is shown on the black curve. Courtesy: Aerotech

Tuning a servo system can be among the most difficult tasks in machine building, offering a proportional-integrated-derivative (PID) control challenge. Tuning is not always about the PID gains, because other factors can be changed to improve the machine performance.  

The webcast “How to tune servo systems (Part 1)” covered controller design, including control loop structures, controller characteristics and using frequency-based tools for gain selection and machine characterization. A question-and-answer session after the webcast addressed some audience issues. The webcast is available for archived viewing until March 11, 2021.  

Joseph Profeta, Ph.D., director, control systems group, Aerotech, and speaker in the webcast, answers additional questions about servo system tuning. 

Servo tuning tips 

Q: You’ve mentioned using as few filters as possible. What are your thoughts on applying filtering when the PID values also could be fine-tuned to remove a resonance? Is there a benefit to translating a filter into changes in PID values? 

A: Changing PID values will not remove a system resonance, but they can be decreased so the resonance is dampened out and not excited. However, lowering these PID gains will decrease the bandwidth of your system. Adding a filter in will suppress the resonance, and the PID gains will likely be able to be increased. This raises the system bandwidth, resulting in higher throughput. 

Q: What does rise time mean? 

A: Rise time is the time it takes a system to move from 10% to 90% of the final value due to a step input. 

Q: Why does your phase response black trace occur at 4 rad/sec instead of 5 in your last slide? 

A: The red curve is the phase of the loop gain before adding a notch filter in the loop. The green curve is the phase of the notch filter being added to the loop (with center frequency of five rad/sec). The black curve is the resulting phase of plant loop gain, which is found by adding the phase at each frequency of the red and green curve. At four rad/sec, the phase of the red curve phase (-140 degrees) plus the green curve phase (-40 degrees) is -180 degrees, which is shown on the black curve. 

Q: Does the order of operations matter for applying notch and low-pass filters? When using notch and low-pass filtering, what sample time and hardware communication considerations should be taken? 

A: When considering the total loop gain for stability, the order does not matter. However, other practical considerations can affect the order and placement of filters. Typically, the notch filters are placed before the low-pass filters. Depending on the physical architecture, the order may matter more. For instance, in an analog system, placing the notch filter first allows the notch filters to operate on a larger signal than if placed after the low-pass filter. If all the loops are implemented digitally in one box using double precision floating point arithmetic, then the order is not as important. The control architecture also impacts the placement and order of filters. For instance, if you are using feedforward in the system, you should likely insert the feedforward after the filters. Finally, in most commercially available controllers, this is not usually a configurable item.  

Q: How does Aerotech’s A3200 EasyTune work in principle? Why does EasyTune sometimes fail on certain applications? 

A: EasyTune does an open-loop test to determine the load mass, which is used to set initial gains. Then a series of loop transmissions are run to characterize the system. Based on one user input setting, robustness, the algorithm determines the “best” gains for the system. The software continues to be improved. For instance, in release 5.0, loads with a shaft-to-load inertia ratio of 15:1 or higher did not tune well. In Release 6.0, improvements were made, and these systems now tune more easily. 

Q: Any good, practical books on tuning to recommend for reference? Is there a good resource or book for tuning a servo drive? 

A: Most mechanical and electrical undergraduate programs teaching Introduction to controls will cover the basics on PID, lead-lag and low pass filters with textbooks like Feedback Control of Dynamic Systems by Franklin, Powell, and Emami-Naeini, Pearson, 2018. A thorough treatment in the frequency domain can be found in Principles of Feedback Control by George Biernson (two volume set), Wiley, 1988. 

Q: If I have two identical systems and one of them is a stable system, can I have and apply the same values on the second system? Regarding integrated X-Y and vertical Z stage tuning issues, how can I get the same tuning performance from different systems? 

A: If they are identical, then the same gains for both systems should give you the same performance. Typically, a single set of gains can be used across multiple identical systems. When performance is different, it can point to an issue in the system build that needs to be resolved. Most original equipment manufacturers (OEMs) use this practice. 

Q: When you say sufficient margin at the crossover points, what is really going on there? Can you explain what the target margins are again and why? 

A: In practice, the gain margin should be ≥6 dB and the phase margin should be ≥30 degrees. This allows for the gain variations and nonlinearities in the system that are present. For instance, when moving the system, the resonance frequency may move or the orientation of the load may change the loop gain. 

Q: Can you extend loop shaping to nonlinear controllers well? 

A: The frequency response is a linear tool. It can be used with nonlinear systems by evaluating the system at different orientations, input magnitudes and other variations that expose the nonlinearities. Then, by plotting a family of curves and choosing the most robust tuning parameters, the system can be stabilized. There are other control strategies, such as sliding mode control, that target designing controllers for nonlinear systems. Depending on the extent of the nonlinearities or the optimality to be achieved, this and others may be a better approach. 

Q: Thanks for the webinar. It definitely gives me something to think about. What is the software you are using? 

A: The demonstration of loop shaping was done in Aerotech A3200 standard tuning tools. 

Q: How do you tune a current loop? 

A: For a servo motor, a proportional-integral (PI) control law is appropriate. It is usually sufficient to determine the Kp and Ki using a simple motor model with parameters that include the line-to-line resistance, motor inductance, amplifier bus voltage, amplifier peak current and desired current loop bandwidth. For Aerotech digital drives, the current loop is set up by selecting the motor and the parameters are calculated for the user based on the bandwidth and phase margin input. In addition, the user can tune the current loop with the same frequency response and loop shaping tools as shown for the servo loop in the webinar.  

Q: What is the best way to optimize control of a system feeding back on two encoders? Tuning inner velocity loop vs. outer position loop for servo actuator? How does the use of dual encoder feedback affect ballscrew-driven systems? How to deal with multiple loops of PID controllers? Tuning with backlash in the system? 

A: In general, when dealing with multiple loops that use different sensors as feedback, start by stabilizing and setting the control law for the innermost loop. After this inner loop response is as desired, move to compensating the next most outer loop. The inner loop is now the “plant” for the loop being compensated. Generally, the bandwidth of the inner loop will be the highest and the outermost loop bandwidth will be the lowest. 

In the example mentioned, a ballscrew with encoder feedback on the motor and a linear encoder are used to measure the movement of the carriage. The key problem here is that the ballscrew introduces a nonlinearity into the system due to the mass separation during reversals. The amount of backlash depends on the quality of the ballscrew. Generally, the bandwidth of a system with backlash will have to be set lower than a system without backlash. As always, first tune the current loop using the motor encoder for commutation (after initialization, many controllers use position to commutate). Then, stabilize the velocity loop using the motor encoder with a proportional-derivative control law. The input to the velocity loop is the velocity command based on the trajectory. Finally, stabilize the position loop using the linear encoder and an integral control law that is a parallel loop to the velocity loop (not cascaded). This will integrate out the error due to the backlash.  

The output of the velocity loop and position loop control laws should be added together and input to the notch filter (if necessary) and low-pass filter. With backlash in the system, often it is necessary to push the low-pass filter lower in frequency than in systems without backlash to smooth out the response. The output of the low-pass filter is the command to the current loop. 

Q: What technical information is available so users can implement the products? 

A: Besides this webinar, each controller has a software help file that explains these details. The file also has information on parameter setup and programming. Additionally, the EasyTune utility will take care of the majority of your tuning issues. Aerotech offers free global technical support. 

Q: Are there manual tuning estimates that can be used? 

A: When starting out, you want a stable system. Keeping the gains very low will allow you to have some stability while you identify the system. What very low means from system to system could be different, based on the scaling factors used by the system. Aerotech EasyTune or an open-loop autotune can inject current into the system for a few milliseconds to try and identify the plant of the system and set very low gains for that.  

Each Aerotech controller has a software help file that explains details. The file also has information on parameter setup and programming. The EasyTune utility will take care of the majority of tuning issues. Aerotech offers free global technical support. Courtesy: Aerotech

Each Aerotech controller has a software help file that explains details. The file also has information on parameter setup and programming. The EasyTune utility will take care of the majority of tuning issues. Aerotech offers free global technical support. Courtesy: Aerotech

Q: With load-based servo tuning, can you program a script to perform a pointwise scan for XYZ axes? 

A: Dynamic gain scheduling is a function that some controllers use to change gains on the fly between two sets (or more) of values based on position, velocity or current draw of the motor. Alternatively, a program can be written to change gain values based on some condition of your choosing. Each set of gains would need to be the result of a tuning process with the system in the position and load where that gain set is to be used. All the gains in the loop should be changed at the same time to prevent instabilities. 

Q: Is there room for improvement on my Vasculathe, namely reaching the overcurrent limit on the rotary when cutting small-diameter tubes with a lot of rapid back-and-forth rotary motion? 

A: From a tuning perspective, maybe it could be improved. But, probably the issue has more to do with trajectory generation. Modifying the trajectory to limit accelerations during reversals in motion would be the first step in improving your throughput and eliminating the overcurrent errors.  

Q: How do I tune a servo system with Aerotech? 

A: The majority of systems can be tuned using Aerotech’s EasyTune feature. This will supply PID gains, feedforward gains and filters to the system. Alternatively, you can also use Aerotech’s frequency domain tool, Loop Shaping, to tune the system as well.  

Q: How can I synchronize two axis controllers for a motion profile? 

A: This is a trajectory generation concern rather than a tuning issue. Assuming you have two axes tuned as required, a multi-axis controller that generates a coordinated trajectory for all axes given a move vector in XY space is needed. Aerotech’s A3200 and Ensemble lines of controllers are multi-axis controllers. The A3200 uses the G-Code language for contouring applications. 

Q: How can I remove low-level frequency disturbance? 

A: Assuming low frequency means less than the loop gain crossover frequency, the more lowfrequency gain that the system has at the frequency of the disturbance, the more the effect of the disturbances on the output will be dampened. 

Q: How do I set up non-Aerotech motors? 

A: Aerotech controllers support using any servo motor. There are utilities in the configuration manager that allow you to enter motor and stage data to generate a parameter file. Setting up a non-Aerotech motor requires some basic information about the motor, such as line-to-line resistance, inductance and bus voltage. 

Q: How can this technique be applied to systems combining a coarse and fine motor, like a piezo mounted on a linear servo? 

A: In a case like this, either via a program or firmware file, a routine would be written that takes the position command and sends it to both stages. The “coarse” stage feedback would be sent to the “fine” stage. This feedback would look like an error signal at the “fine” stage when in position, and at this point the control loop bandwidth would dictate the responsiveness of the system to counteract the errors. This concept is used in many galvanometer applications at Aerotech using our Infinite Field of View function.  

Q: Can you please address encoder resolution and surface finish/form accuracy? 

A: Generally, more resolution is always better. It is best to have at least 10-50x the resolution of your part tolerance, that is, 5 um part tolerance requires at least 500 nm resolution, preferably 100 nm. 

Q: Discuss the tuning examples of non-linear load. How do you put in a different tuning setup for different loads? How do you tune a robotic arm where the loads are dynamic, depending on arm position? Would you tune for the worst case or try and tune for a middle point? 

A: Variations in the load directly affect the loop gain and therefore the stability (or robustness) of the system. These variations can be step changes (such as picking up or setting down an object) or continuous (such as winding on to or off a reel, moving a robot arm). In either case, the gains must be set to have sufficient gain and phase margin over the set of loads that are expected to occur. Often, this results in a system with the lowest bandwidth setting for all load situations, which is not usually ideal. To increase performance, gain scheduling can be employed or more sophisticated adaptive control techniques might be necessary. 

Q: What are the tuning control differences between types of motors? 

A: For brush or brushless (linear or rotary) tuning, a PID controller is identical. Other actuators, such as a piezo or servo hydraulic actuator, may require a different control law. However, the concept of measuring the loop gain and the stability criterion are all identical. The differences are the types of compensating filters that may be necessary in conjunction with the PID controller.  

Q: When should one use a full PID control versus PD or purely P? When is it appropriate to just use PI control? 

A: Generally, the proportional term acts on the present error, the integral term acts on the past error (and will eliminate the steady state error in the system) and the derivative term acts on the anticipated future error (and will add some damping to the system). Determining the best control law depends on the plant being controlled. One method is to measure the open loop frequency response of the plant and add to that a control law that shapes the loop gain as desired. The ideal is to have high, low frequency gain (to mitigate disturbances); low, high frequency gain (to suppress sensor noise); and to cross over at a slope of -1 (20 db/decade) with any changes in slope at least four times less or four times more than the crossover. This will provide a stable system assuming the gain and phase margin at any other crossover point are sufficiently large. 

Q: Hard vs. soft movements; which results in faster settling? 

A: Higher acceleration means more overshoot potential in a move. When settling is taken into account, you usually can have a shorter overall move time by using a lower acceleration rate. In addition to tuning the PID to minimize move time (including settle), it is best to use feedforward control to minimize the total move time. This combination allows higher accelerations to be used while still minimizing overshoot. 

Q: How do you control a servo motor by Arduino?  

A: With an Arduino, you can control a dc brush motor through the pulse width modulation (PWM) output pins. The Arduino does not have any built-in tools for tuning. 

Q: How do you choose between a programmable logic controller (PLC) and a motion controller in the application of constructing a 3D printer? 

A: PLC is better suited to an input/output (I/O) based system. A 3D printer will use trajectory generation with I/O. This is typically better suited to a motion controller that will run G-code based trajectories. 

Edited by Mark T. Hoske, content manager, Control Engineering, CFE Media, mhoske@cfemedia.com. 

KEYWORDS: Servo motor loop tuning, motion control  

Servo motor loop tuning can be a challenge. 

Servo motor loop tuning software can help. 

Understanding PID and controller design can help. 

CONSIDER THIS 

Tighter control over servo loops can result in better machine performance. 


Joseph Profeta
Author Bio: Joseph Profeta, Ph.D., is director, control systems group, Aerotech. Dr. Profeta has more than 30 years of experience in technology-driven companies. He is the director of the controls system group at Aerotech with P&L responsibility for the controls, drives and motors. In this role, he works with companies to design and select control system architectures that result in increased machine performance while minimizing component cost. He has earned a BS, MS, Ph.D., and Executive MBA. He has been awarded five patents and published 43 papers. Dr. Profeta is also an adjunct professor in the electrical and computer engineering department at the University of Pittsburgh where he teaches software engineering.