. |
PID Tuning:
|
The goal is to tune your system so that the Actual Position and Commanded Position traces overlap eachother and the Position Error is as close to zero as possible.
Before
After
Start with a Kd = 10 * Kp (Kp = 0.1 is a good conservative
place to start) if you're using a sample rate of 2000 Hz (default). If
you're using another sample rate, start with a ratio of 10 * Kp* (new
sample rate / 2000 Hz).
NOTE: All tuning examples were performed on a Trust TA9000. (www.trustautomation.com)
For example,
at 4000 Hz, use a ratio of 20 * Kp
at 2000 Hz, use a ratio of 10 * Kp
at 1000 Hz, use a ratio of 5
* Kp
To start tuning, pick a very small representative move (smallest move you would normally make—should be at least 20 counts) at a conservative velocity and acceleration rate. We will increase distance and acceleration after the servo is performing well enough to take the longer, faster move.
It is important that Kd and Kp are raised in equal proportion (i.e. Kp = 1, Kd = 10 -> Kp = 2, Kd = 20) until underdamped response (ringing) sets in. Underdamped response is shown in the figures below.
When we start with a Sample Rate = 2000 Hz, Kd = 1, Kp = 0.1, no motion is seen. See the Motion Scope plot below.
1,000 count move
|
Red - actual position Blue - commanded position Green - commanded velocity White - position error Yellow - DAC output |
Since no motion is seen, both Kp and Kd are raised 10X to Kp = 1, Kd = 10. The 10X increase in gain is a rough figurean exact increase is not necessary. Just make sure to raise Kp and Kd in proportion to each other until the general behavior changes. The resulting motion is extremely sluggish. However, the important thing is that we are now seeing motion. Now look at the actual position trace, which is highlighted in red.
1,000 count move
|
Red - actual position Blue - commanded position Green - commanded velocity White - position error Yellow - DAC output |
It is obvious that we have well damped (over damped) motion because of the lack of ringing on the actual position trace. Although the lack of ringing could possibly be a result of high friction on the stage being tested and the low gains, it is not important. We can always deal with under damped motion if we start to experience it. Since the motion is still extremely sluggish and stable, we will double the gains.
1,000 count move
|
Red - actual position Blue - commanded position Green - commanded velocity White - position error Yellow - DAC output |
After doubling the gains we are still well damped and showing slugish motion.
Double the gains again.
1,000 count move
|
Red - actual position Blue - commanded position Green - commanded velocity White - position error Yellow - DAC output |
At these gains we start to see a 38% overshoot. Notice the overshoot on the actual position trace (red), as well as the position error trace (white).
Double the gains again.
1,000 count move
|
Red - actual position Blue - commanded position Green - commanded velocity White - position error Yellow - DAC output |
Once it has reached the target position, you will notice that there is a significant ringing effect, as shown by the actual position trace (red) and the position error trace (white). We will now try to reduce this overshoot and ringing effect by increasing the Kp and Kd.
Double the gains again.
Keep in mind that doubling the gains is only an estimated figure. To make doubling easier, we will increase Kd from 8 to 15, and 80 to 150.
1,000 count move
|
Red - actual position Blue - commanded position Green - commanded velocity White - position error Yellow - DAC output |
Double the gains again.
1,000 count move
|
Red - actual position Blue - commanded position Green - commanded velocity White - position error Yellow - DAC output |
Notice that the overshoot has significantly gone down, which means that the servo is probably performing decently. Change the YScale to 200 in order to make the curves in the traces more pronounced.
We can now increase the motion trajectory parameters to the specified move. We will change the move parameters to distance = 5,000 counts, max velocity = 50,000 counts / sec, max acceleration, max deceleration = 300,000 counts / sec2.
Why do we increase the move speed and distance? We started with a small move until the system performed well enough to make a large, fast move. The large, fast move will bring out poor performance of the servo loop so we can improve it. You will want to increase the move speed until you either have performance problems or reach your target move distances and speeds. If you can't reach your target move distances and speeds without serious ringing, you may need to increase distances and speeds, refine tuning, and repeat.
5,000 count move
|
Red - actual position Blue - commanded position Green - commanded velocity White - position error Yellow - DAC output |
Notice that we get significant ringing after the motion is done. This is separate from the initial positive, then negative position error during the commanded motion. In order to combat this, we will double the Kd term (Kd = 600).
5,000 count move
|
Red - actual position Blue - commanded position Green - commanded velocity White - position error Yellow - DAC output |
There is a significant decrease in ringing, but the ringing is still there. Referring the flowchart at the top of the page, we will turn up the Kd term because the system is underdamped.
Double the Kd term (Kd = 1000).
5,000 count move
|
Red - actual position Blue - commanded position Green - commanded velocity White - position error Yellow - DAC output |
We have almost eliminated the ringing. It is almost tuned. We only need a small increase in Kd to 1500:
5,000 count move
|
Red - actual position Blue - commanded position Green - commanded velocity White - position error Yellow - DAC output |
Now we virtually have no ringing and only a little overshoot. This is a lightly underdamped system, as is often desired.
Increase the gain of Kp and Kd together to see how far we can go without reaching instability.
Increase Kp and Kd by 50%.
5,000 count move
|
Red - actual position Blue - commanded position Green - commanded velocity White - position error Yellow - DAC output |
After this 50% increase, we start to hear some audible noise. At this point you will have to make a judgment call to determine if this level of noise is acceptable or not.
Notice the noise in the DAC signal (the DAC signal is getting noisy). The noise appears to be at a fairly high frequency, so we should expect the noise to get worse if we increase Kd. (Remember that Kd primarily affects high frequency performance.)
Let's perform another 50% increase in gains (Kp = 75, Kd = 3300) to see if the increase in noise is a good trade off for the decrease in position error:
5,000 count move
|
Red - actual position Blue - commanded position Green - commanded velocity White - position error Yellow - DAC output |
You can see a slight increase in noise on the DAC signal with the increase in Kd. In this case, we will make the judgment that the increase in noise (audible) is unacceptable.
Remember that there is no single answer for everybody. Someone else could have decided that it was acceptable, and s/he would have increased Kp and Kd again. The judgement calls you make are based on your needs.
Since we don't want to increase Kd at this point (since we don't want to increase the audible noise), let's look at Kp. The main criterion we are looking for is ringing after the motion is done. Let's take a closer look at the position error. Notice we have changed the YScale to 300 to make the curves in the traces more pronounced.
5,000 count move
|
Red - actual position Blue - commanded position Green - commanded velocity White - position error Yellow - DAC output |
It is pretty clear that we get a positive error during acceleration (first half of the commanded move) and a negative error during deceleration (second half of the move). After the deceleration portion, the position error dies away quickly, and more importantly, without ringing.
Increase the Kp to make it slightly less damped.
5,000 count move
|
Red - actual position Blue - commanded position Green - commanded velocity White - position error Yellow - DAC output |
You can see the position error overshoots slightly at the start of motion and on the transition between acceleration and deceleration. However, we are mainly satisfied with the lack of position error overshoot at the end of the move. With these parameters, the position error overshoot is pretty clean at the end of the move.
Let's try increasing Kp to 125:
5,000 count move
|
Red - actual position Blue - commanded position Green - commanded velocity White - position error Yellow - DAC output |
If this position error overshoot is unacceptable, go back to Kp = 100.
If this amount of position overshoot is acceptable (considered normal in most applications), then keep increasing Kp until you get a position error overshoot that is acceptable.
"Don't forget about feedforward terms!"
Once you have found satisfactory gain parameters for Kp and Kd, you can achieve the following motion profile with properly tuned feedforward terms. Feedforward tuning is covered in a different section of the servo tuning site. (See the "Feedforward Tuning" subsection.)
5,000 count move
|
Red - actual position Blue - commanded position Green - commanded velocity White - position error Yellow - DAC output |
Will the above tuning parameters work on my system? Not unless you are using a Trust TA9000. Every type system will need its own tuning parameters. If your machines are identical, then all your machines should perform identically. If there are small differences (there always are), there will be small differences in performance.
| | Copyright © 2001-2021 Motion Engineering |