PID Servo Tuning /
Troubleshooting
There are generally three settings you must adjust to make a PID based controller
work correctly:
-
Proportional constant: Also called "gain". This value is multiplied
by the error between where you want the servo to be and where it is. A larger
value gets the servo to the desired position faster and makes even small
errors matter more
but it may also cause the unit to overshoot the
correct position and oscillate back and forth without ever stopping. A smaller
value will stop oscillations, but may not generate enough drive when the
error is small to actually overcome friction and move the unit all the way
to the correct position.
-
Integral constant: This value amplifies the accumulated error over
time. It makes even a small position error eventually matter enough to get
the motor to the exact right place, and increases the speed of long runs
but it really makes overshoot and oscillation a certainty. It should generally
be proportioned to the amount of friction in the system.
-
Derivative constant: This value amplifies the difference between the
prior position and the current position. It compensates for inertia and can
really help reducing oscillations, but too much will make the system "shudder"
and shake violently as it comes to a stop at a new position.
Ziegler / Nichols Starting Point: There are several ways to tune a
PID controller, these steps present the Ziegler / Nichols closed loop method
as a starting point. Further "trial and error" tuning should certainly be
used: (Commands for the BOB PID system will be shown
in parenthesis after each step... your systems commands may vary. For e.g.
Arduino or other hard coded systems, adjust the parameters in the sketch
before programming each time.)
-
No I or D, Little P Start with the I and D terms set to 0 and P set
to a very small value. (0i0d1p)
-
Power up, set desired position to 1 (1{enter}) and make sure
you have direction set correctly (216w or 286w) and enable
the driver (e), If the servo just spins and spins, it's doing a
zig when it should zag... the direction is probably wrong; disable the driver
({space}) and try the other direction before enabling again.
-
While(!Oscillating) P++; Slowly increase the P constant while moving
from one point to another and back until the unit starts to oscillate with
a consistent motion, back and forth the same amount.
(1p100{enter}1{enter}2p100{enter}1{enter}...) To save time, you
can use an exponential and then binary search. Start with 1, then 10, then
100, then 1000, etc
until you get oscillation. Then divide that number
in 2; if it still oscillates, divide by two again, otherwise, add half the
current value back. E.g. from 100, try 50, if it oscillates, try 25, if not,
try 75 = 50/2+50. And so on.
-
This setting for P is called the Ku or "ultimate gain". Record it, and count
the number of oscillations per second, which is called the frequency or Tu.
Be sure to then change Tu into units matching the sample time used in the
controller. E.g. the BOB PID uses ¼ second updates, so divide your
measurement by 4.
-
Now you can use these values to calculate good starting points for the P,
I, and D terms:
-
P/=2; In general P should be about half of Ku, so if your system started
oscillating when P was 12, try setting it to 6 to start. (6p)
-
D=Tu/(8*t); Set D to about Tu/8. For example, 0.125, with BOB PID
at 4 Hz. (.125d). We are setting D before I here to keep for getting
into out of control oscillation.
-
I=Tu/(2*t); Set I to less than Tu/2. For example, if your system
oscillated at 4 cycles per second, and you use the BOB PID with ¼ second
updates, set I to .1. (.1i)
Now try moving back and forth and see how the system reacts. Make both short
and long jumps, small and large movements. e.g.
(10{enter}1{enter}200{enter}1{enter}...) If it starts oscillating
out of control, disable the motor and continue with troubleshooting below.
({space}) Be sure to give it time to settle at each point, and ensure
it really does make it to exactly the desired point (mark the shaft if you
can).
Once you have the tuning done, save the values to non-volatile memory {321w}
PID Troubleshooting
Oscillation: If you have a very heavy shaft, meaning a lot of mass
turning on the shaft especially away from the center of rotation; this has
nothing to do with the weight of the load being moved unless that load is
spinning with the shaft, then increase D until you start to hear shuddering
or vibration as it approaches a new setpoint. If you have a lot of overshoot
when approaching a new setpoint, decrease I. Otherwise, decrease P.
Slow approach to setpoint: If you have a lot of friction in the system,
increase I. If the system "grinds" or "shudders" or vibrates as it approaches
the setpoint, decrease D. Otherwise increase P.
Overshoot (without oscillation): Decrease P.
See also:
file: /Techref/io/SERVO/PID-tuning.htm, 6KB, , updated: 2016/5/9 08:08, local time: 2024/11/16 01:47,
|
| ©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? <A HREF="http://massmind.ecomorder.com/techref/io/SERVO/PID-tuning.htm"> PID Servo Tuning</A> |
Did you find what you needed?
|
|
Welcome to ecomorder.com!
|
|
Welcome to massmind.ecomorder.com!
|
.