Question re: PID Tuning


chucke

Recommended Posts

Can you explain in laymen terms the function of the 'P' 'I' &'D'. What each does individually, and how each relates to the other. I am trying to tune a PID loop which controls the speed of a pump based on a downstream flowmeter and it's close but should be better. The lag time between the pump speed and a noticible increase/decrease is approx. 1-2 mins.

Thanks

Chuck

Link to comment
Share on other sites

P = proportional, I = integral, D = derivative. A P only loop will set the output proportionally to the difference between the process variable and the set point. So if they are equal the output is 0, if they are separated by 1 unit, the output will be 1 * P, etc. The problem with P only loops is the whole half-step question: if you take steps towards an object and each step is half the distance to that object, how long will it take to get there. Answer, never. So to help push the process variable to the set point, we introduce the integral term. While the loop is running the system is constantly adding up the difference between the process variable and setpoint (also called "error") which makes up an integral. When we make I non-zero it adds the integral / I to the output. So, if the process variable is staying below the setpoint, the integral will grow and cause the output to increase and drive the process variable to the setpoint. Note that since its 1/I, smaller (non-zero) I values have more of an effect.

This is great, but most systems also have momentum which cause overshoot. In other words, the system gets driven past the setpoint and has to correct the other way. Assuming your P value isn't too big, the system usually will stabilize, but only after oscillating around the setpoint a few times. If P is big, you can get continuous, often growing, oscillation which is an unstable system.

To counteract overshoot, there is the derivative term. This term looks at the difference between the currently calculated output and the previous output (the derivative) and applies a negative force proportional to this value based on the D parameter. Larger D has more of a dampening effect, keeping the output from changing too rapidly.

What the correct values are depends on the system and how you want it to perform. In some systems, overshoot is not an option, so P is kept somewhat small, D large, and I large (remember 1/I so large = smaller effect). This results in the system taking longer to reach the setpoint, but it doesn't overshoot. In most systems a little overshoot is ok, so we use larger values and the setpoint is reached much faster. Of course if we go too far we end up with an unstable, oscillating system.

Now, how to tune? Everyone has their ways, and there is an autotune feature in DAQFactory, but it requires the system to be stable first, meaning you need to find a P value that eventually gets you to the setpoint with overshoot that dampens down to the setpoint. So, whether you autotune or not, you should start with a P only loop. Set P to something simple like 1 then change the setpoint and look at the response. If there is lots of overshoot, make P smaller. If it seems like it will never reach the setpoint, make it bigger (in your system, never is a really long time, don't correct every 5 minutes, you need to wait at least 30 minutes before adjusting values). If you want to use autotune, get it so it overshoots but settles to the setpoint then run the autotune. If not, then get it so it doesn't quite reach the setpoint then start adding integral. Again, start with 1, but this time make it smaller if it still doesn't reach. Finally you can add D if it seems like the overshoot is too large.

One final point: in general you don't want the output of the PID loop to directly feed an output channel. For PID to work right, it really needs to output negative values. The zero point of the loop (meaning the output where the process variable is stable) is usually not the zero point of the actual output channel. So, leave the output range of the PID to -100 to 100, have it set a global variable, then create another little sequence that loops at the same rate that takes that global variable number and sets the output so -100 out of the PID loop is the lowest output value (usually 0), and 100 is the largest.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.