PID Axis Tuning


Contents

Introduction
Ray's Experience
Tim's Experience
Jon's Experience
Fred's PID Tune
Links
Print Resources
Credits

Introduction

Axis tuning is a critical part of most emc setups. Until recently we have been able to ignore tuning by using steppers and steppermod.o. You can still do this but the newer motion files, freqmod and smdromod allow stepper users much smoother and better control of axis motion. Smdromod.o even allows stepper users to feed back actual position using a home built feedback board. (no more lost steps) But the consequence of these newer motion systems is that users must now learn some of the basics of axis tuning.

The description of PID tuning that follows is not intended to be exhaustive or rigorous but should get the beginning emc user started with these newer motion files and at least able to keep their axis from tripping out on overtravel. This page assumes that the reader is acquainted with the emc.ini file where tuning values are stored for each axis.

There are a number of excellent internet resources that will extend this description. A few links are listed at the end of this page. There are several auto tuning and computational tuning procedures but these have not been tested with EMC.

P - proportional, I - integral, and D - derivative are three common mathematical techniques that are applied to the task of getting a working process to follow a setpoint. In the case of EMC the process we want to control is actual axis position and the setpoint is the commanded axis position. PID is NIST's chosen way to connect these two things.

A mechanical system, something like a pantograph, will serve to illustrate the control problem. With a pantograph you can trace the stylus around a pattern and the pen or pencil will produce the result. The stylus is the commanded position, the pen the actual. The pattern need not be the same size as the resulting drawing. That relationship depends upon the linkage.

With a pantograph, we can consider the question, "How good is the drawing?"    The answer depends upon several factors, speed of movement, detail in the pattern, sharpness of the stylus and pencil, size of stylus and pencil, differences in size between the two,  etc.

When we get to electrical or electronic systems like EMC, instead of a hard linkage between the pattern and the product, we have signals created by reading nc program code, reading jog commands, or reading position from a digital image or drawing. These signals are sent to an amplifier and its output is sent to a motor. Most often the mechanical system driven by the motor has a feedback device that returns actual position to EMC.

EMC, or any computer controlled machine. should be thought of as a pantograph made with rubber bands in place of some of the rods and squishy bearings for some of the joints. PID tuning allows the integrator to control the stiffness of the rubber bands and the squashiness of the joints. With a mechanical pantograph the forces are all controlled by the fingers on the stylus. If the fingers are capable of 0.0001 offsets in motion then the results will be that fine. Starting, stopping, and changing the direction of the pen's inertia is also totally dependent upon the fingers of the operator. But with an electrical system, all of these things must be accounted for in the signals that produce the motion.

In any system that reproduces motion, one of the major "goodness" factors is what we call following error.  Following error is a way of quantifying how close the actual position is to the commanded position while the tool follow  the range of movement  that can be commanded.
back to contents


Ray's Experience

All three variables (6+ really) look at what is happening between commanded and actual position in the emc. My comments below may be a bit unsatisfying for those who are accustomed to very precise things but they come from a number of years of twiddling with servo controls.

P - process variable.
---------------------
This is the gain control. It is a bit like the volume on a music system. If it is set too low you can't follow the lyrics. If it's set too high the windows rattle and the neighbors fuss.

Some authors refer to P as proportional band. Think of it as a pair of lines, one ahead of the commanded position and one behind it. Actual position should be somewhere between the lines. If the actual position is farther behind then that below line the controller will run the axis flat out to reach the slower line. Conversely, if the actual position is ahead of the above line the controller will do all it can to bring actual position down to that upper bound.

As long as the actual position is between the lines, the controller will ramp gain up and down so that actual approaches commanded.

The larger the P number the narrower the space between these lines. Set P too low and your axis works like a dedicated couch potato during super bowl or world soccer finals -- even a fire may not rouse it. This condition is rather easy to spot because the axis is sluggish.

Set P too high and your axis will develop palsy. On most machines you can hear this condition by putting your ear to the motor. You may want to do this when others aren't watching -- or use a stethoscope or a long socket extension -- or perhaps the graph function.

Palsy will sound like a hum or grind when the motor is sitting still or moving very slowly. You can also feel palsy if you wrap your hand around the ball screw or grip the drive belt or pulley. (disclaimer -- This demonstration is done by a professional with only three remaining fingers, don't try this at home)

Deadband may mask too much P when a motor is sitting still so you may want to move the axis very slowly and listen to the sounds around each step. If the axis keeps up with commanded position at high speed and during acceleration and there is not a lot of ringing, grinding, jumping at very low speed, then you are real close.
 
 

I - Integral variable.
----------------------

Integral works a bit like a shock absorber. Any change in either actual or commanded position gets rounded off or averaged in so that acceleration/deceleration brought about by P is absorbed and released more slowly over time.

No integral and you get the full P effect of change in commanded position. Too much integral and the axis seems to wander off on it's own without much regard for P. A little integral may smooth out some of the frequency jumps when a stepper is running right near one of those troublesome rates.
 
 

D - Derivative variable
-----------------------

Derivative works like passing gear for acceleration or a jake-brake for stopping. Whenever commanded position changes rapidly, d will really kick the amp/motor in the *** to follow the rate-of-change of the axis command rather than the difference between commanded and actual position.

Derivative works against inertia so if you've got lots of iron to start or stop dial some in. But derivative will increase palsy so you have to balance it against gain.
 

FF1-3  Feed Forward variables
------

I know very little about the effect of these variables.  My first experience with them is while using EMC.  I need to include an idea from Jon Elson and his work with servos and his bridgeport.  He has used a value up to 8.0 for FF1 with a somewhat reduced acceleration to very successfully minimize following error.  The relevant portions of his ini file are:

DEFAULT_VELOCITY =      0.75
MAX_VELOCITY =          1.5
DEFAULT_ACCELERATION =  2.0
MAX_ACCELERATION =      2.0

MAX_VELOCITY =          1.2
P =                   100.000
I =                     0.000
D =                     0.000
FF0 =                   0.000
FF1 =                   7.500
FF2 =                   0.000

Your results will no doubt vary.
 

T - Test
--------

The final proof of tuning is in the cutting. So after your best guess with all the watching, hearing, feeling done to each axis, get out a chunk of soft aluminum, a small end or ball mill, and begin to mill circles or arcs that pass 90 degrees between each pair of axis. I like outside circles because you can hold them up to the light and see how the finish looks near the quadrants.

Digital systems will give you some steps as one axis approaches zero and the other approaches the set feedrate so don't expect a perfect mirror arc finish. Backlash and backlash compensation also affect the appearance here. Servo drives will work better than steppers. (digital vs analog) But the smoother the saw teeth the better.

Be prepared to spend some metal on this! And make a list of your settings, changes, and a better/worse judgment about the result of each change. On occasion I've spent pages of paper and made piles of swarf to get a stubborn machine to where I wanted it.

Good luck and may the electromotive force be with you.

Ray <rehenry@up.net>

back to contents


Tim's Experience
 

EMC now is handling steppers as if they were servos from what I understand (this may only be with the freqmot setup & the DRO setup?) and using freqmot I can confirm that P,I, and D definitely have an effect on steppers. If I set P too low I get constant follow errors at any speed, If I set D to anything but 0 I start having a problem with the motors stalling on acceleration (probably because this setting is trying to make the motor get up to speed faster than the stepper can accelerate). I have played with various I settings between 1 and 1000 and it does seem to help me get even higher feed rates, but I have not really figured a way to see what works best on this one.

You can easily play with these settings by going to the settings menu and selecting calibration. The values will be for the axis that is currently selected and will take effect as soon as the calibration window is closed. Make sure you remember or write down the setting you settle on as the values you put in the calibration window are not saved back to your .ini file, you have to edit them in manually.

Tim
Date: Sat, 4 Mar 2000 14:28:49 -0700
From: "Tim Goldstein" <timg@ktmarketing.com>
back to contents



Jon's Experience

--1--
I also found while working with the servo tuning (last summer)...  FF1 (I think that is the non-zero FFn parameter in my .ini file) is VERY effective in improving following error, and is, in fact,  BETTER than a PID could do, because, of course, it knows IN advance what is GOING to happen at a velocity change!  I was able to get following error down to under .001" under practically all circumstances by setting FF1 to a small value, somewhere between 4 and 7.5 or so.  You can see my graph at http://www.artsci.wustl.edu/~jmelson/servo.html showing a jog move at 90 IPM.  Oh, yes, one other thing, the acceleration parameters in the default EMC .ini file are rediculous.  I had been ignoring jerky motion when manually jogging when I started working with EMC, until I broke a brand new toothed belt on my Y axis.  This led me to realize the system was demanding much too much acceleration, and I slowed it down quite a bit.  No belts have broken since then.

Jon
Date: Wed, 14 Jun 2000 17:38:00 -0500
From: Jon Elson <jmelson@artsci.wustl.edu>
 

--2--
JohnDRoc@aol.com wrote:

> Yes, it's fast, it's definitely an industrial-strength milling center.  It's
> not a humming sound it's more like a grinding or laboring sound.  It runs in
> my mind that it ran more "freely" before, but it might just be a result of
> the compensation - maybe I didn't notice when it was slamming back and forth.

Well, I still think it is what I saw, but maybe not.  Does the sound change at different jog speeds?  What is your P parameter in the axis setup, in fact what are all your parameters in there?  If the P gain is set too high, it could cause rough operation.  Yes, it could be tuning of the servo amp, too.  I found it was best to run with a conservative P, I and D set to zero, and a small value on FF1, about 5.0  This gave me really minute following error and quite solid position holding, without any instability.

>  I think the next step is going to be working with the logging program, to
> determine the fine tuning of the amps.  Then, I think I saw in a post from
> Fred, that there is supposed to be a program that helps come up with the PID
> values.

Unless they've done some serious repair in the PID department, the I and D are programmed wrong, and do not do anything useful.  Unfortunately,  the controls theory used in EMC gave a steady-state, or at least one quadrant, definition of PID algorithms.  The problem is this is a motion control problem in all FOUR quadrants.  And, Integral history from when you were in a different quadrant is not only irrelevant, but makes your solution MORE inaccurate, instead of reducing error.  But, pedantically, because you are SUPPOSED to use the entire history of the system, EMC holds that you MUST use the entire history, even if it fails to perform the necessary goal.

The Derivative term probably works, in the general sense, but since this is a quantized system, and in slow motion there are so few encoder counts per servo cycle, the Derivative term from each encoder cycle has WAY too much quantization noise to perform well.  It needs to be smoothed a bit.  Fortunately, they put in the FF0, FF1 and FF2 terms, which are both mathematically pure, and of great use.  FF1 is actually better than some combination of I and D, because it can respond BEFORE error develops, as in a rapid acceleration of the system from rest.  The I term won't know what is going on for minutes, because it is taking the average of millions of tiny errors past, and due to the quantization, you can't set the D term very high, or the system gets unstable.  As long
as the servo amps are well behaved, just using P and FF1 has worked VERY well for me.

So, I don't know what the auto-tune program will do with those parameters.  If good, it will also find them to be unhelpful, and leave them close to zero.

Jon
Date: Wed, 12 Jul 2000 02:23:39 -0400 (EDT)
From: Jon Elson <jmelson@artsci.wustl.edu>

back to contents


Fred's PID Report

I had a guest researcher here at NIST for a few months, looking into automatic system identification and PID tuning. I have a few MS Word pictures showing what he did that I WinZip'ed up and put on the FTP site in the emc/emcsoft directory, as "pidtuning.zip". They're 8.5x11 posters that show the theory and some figures for our Bridgeport machine.

It works for systems without a tachometer. We were trying to get the performance (following error) to be equal to a machine with tachometers, to reduce cost.

The idea is to hit the axis with a step voltage, and log the resulting position v. time. The curve rises to some steady state velocity. The steady state velocity is a function of applied voltage. The time to, say, 75% of steady state is the same. For several runs, you can get an average of steady-state velocity per applied voltage, and average rise time. These can be used to deduce PID gains.

The student, Kees ("Case") Stolk, from the University of Twente in the Netherlands, wrote a Tcl/Tk script that automates much of the process, including going into machine-off, opening the log, running the DAC out command, saving the log, storing multiple runs, and popping up PID gains. It's pretty slick. I'll put this up on the FTP site once I verify that it works with the new release.

I ran this on the Bridgeport and the resulting gains outperformed my manually tuned gains for current mode (no tach), and equalled the manually tuned gains (with a FF1 feedforward term) in velocity mode (with a tach).

Date: Mon, 6 Mar 2000 18:05:59 -0500 (EST)
From: Fred Proctor <proctor@cme.nist.gov>
back to contents



Links

http://www.manufacturing.net/magazine/ce/archives/1998/ctl0301.98/03a305.htm
http://www.expertune.com/tutor.html
http://www.expertune.com/PIDspec.htm
http://www.manufacturing.net/magazine/ce/archives/1998/ctl0801.98/08abas.htm
http://members.tripod.com/aabi/index.htm
http://members.tripod.com/aabi/optimumpid/optimum_menu.htm
http://www.ctc-control.com/tutorials/pid.htm
http://www.newport.com/Motion_Control/Tutorial/Servo_Tuning_Principles/Servo_Tuning_Principles/description.php
PID tuning: Lieslehto, J., Tampere University of Technology, Tampere, Finland, (used by Kees ("Case") Stolk)
This last one is a good web reference for PID tuning, with Java applets.
back to contents


Print Resources

"Process Control Systems" by F. Greg Shinskey, available from the Foxboro Training Institute at 1-888-FOXBORO.

Controller Tuning abd Control Loop Performance: A Primer, Second Edition, Subtitled PID Without the Math, by David W. St. Clair (Retired DuPont Engineer)

Process Instrumentation Applications Manual, by Bob Connel, McGraw-Hill Book Co., 1996

References used by Kees ("Case") Stolk while developing NIST tuning software:

Modeling of DC Motors, Kuo, Benjamin C., Automatic Control Systems, Prentice-Hall, Englewood Cliffs, NJ, 1981.

Nonlinear Least Squares Model Fitting, Press, William H. et al, Numerical Recipes in C: the Art of Scientific Computing, Cambridge University Press, Port Chester, NY, 1992.

PID controllers, Åstrom, K., and Haglund, T., PID Controllers: Theory, Design and Tuning, Instrument Society of America, Research Triangle Park, NC, 1995.

"Internal Model Control", Rivera, M., Internal Model Control for PID Controller Design, 1986.

Credits

This page is based on a recent post to emc@nist.gov and is maintained by Ray Henry Your comments and criticisms are welcome. Examples with drawings or screen capture would be really nice here. As would additional experience with axis tuning.

back to contents