# Integral and Derivative terms in PID control

1. Integral Term My understanding of the integral term is: Sum of all errors since we started counting. So, even though we have reached our desired final target position, the integral of the errors should be high (no?) since we started adding all the errors from when we were in our initial position.
And if the Integral term is high at our target position, the controller would still be continually ramping up...? [I understand that the Integral term's value will be a constant at this point since the error is 0. But, would it not still be a high value?]

2. Derivative term Say, we are in time instance t1. Can I predict the rate of change for a specific time instance, say t20, and then apply this parameter to the current state? Is that how the derivative term works?

• 1) In a closed-loop system, the input to the integrator will go negative if the system output signal overshoots the system input signal, hence the integrator output will start to decrease. 2) For a real-time system you can only estimate future signals/states. Normally the 'D' in PID deals with the 'here and now' – Chu Jul 2 '15 at 7:52
• Intuitively the reason why you need the integral term to stay at a constant (potentially high) non-zero (in general) value once you reach the setpoint is because some control action may be required to remain at the setpoint. – Doug McClean Jul 2 '15 at 14:25

The constants for your PID controller as well as the error signal can be negative or positive , as your system adjusts to your PID control signal it will produce decreasing error and eventually an error of opposite sign and the integral will not continue increasing indefinitely. As the system oscillates from negative to positive error the derivative term will also change sign relative to each other. Typically the derivative and integral constant will be of opposite sign so that the control signal is rapidly reduces when the signal finally starts moving to avoid overshooting.

The integral term determines how strongly the PID controller "ramps up" its response to error. The idea is that if you are outputing a control signal and the error stays high you want to keep increasing that control signal above the proportional level.

The derivate term determines how strongly the PID controller "braces" for the error inversion and compensates for the integral term as the system responds to the PID output. The constant term here is usually of opposite sign to the Integral term, as the system starts to move to lower error, you start to increase a control signal in the opposite direction to minimize overshoot and decrease settling time.

Conceptually you are using the integral and derivative terms to set the proper damping to settle your system. For a majority of systems a slightly underdamped loop is ideal, the system settles quickly and with no overshoot. Depending on your application you will have to determine what kind of overshoot is reasonable for you.

### The Rest

I think in cases where confusion is a foe that always finds an opportunity to strike it is best to refer to the definition to center your discussion

With error signal $e(t)$ at current time $\mathbf{t}$ we produce a signal $u(t)$ with the definition $u(t) = A_Pe(t) + A_I\int_0^\mathbf{t}{e(t) dt} + A_D \frac{de(t)}{dt}$

The definition puts no bounds on the constants associated with each term. Or any assumptions on effect that u(t) has on the system being controlled. Additionally there are many variations on the core definition that can be used. You can window the input (only chose the last 30 seconds) or weight the input with a convolution (simplest case: redefine constants to also depend on t)

Consider 3 Cases

### The output signal has an immediate effect on your system

The system has no resonance or inertia and your output immediately moves your system to 0 error from the proportional term alone, you set the derivative constant to close to 0 and the integral term never has a chance to grow. This is an ideal system that probably doesn't need a PID at all to control

### The output signal has minimal effect on the system (error signal stays constant ).

Regardless of $u(t)$ the system refuses to budge, the integral term grows larger and larger and diverges to infinity. Whatever physical device you are using to generate the influence will likely burn up. Consider a PID controller driving a piston trying to move the earth, no matter how hard it tries push the earth will not budge off its course. As a theroretical concept there is nothing preventing $u(t)$ from growing arbitrarily large

### The output signal has a proportional effect on the system (properly tuned PID)

The $u(t)$ generated drives the system and reduces the error, the integral term slows its steady accumulation and the derivate term increases as the system starts moving. At some point the system will cross a threshold and the error signal $e(t)$ will change signs, this causes the integral term to start decreasing and at some point it will also change signs. .

If you pick yout constants correctly you can tune your system into a properly damped loop that has your output signal driving your system to 0 error in the shortest time allowed by the dynamic characteristics (mechanical, electrical, or otherwise) of the system you are controlling

• Can you explain: ' the derivative and integral constant will be of opposite sign' – Chu Jul 2 '15 at 7:41
• @Chu You set one to a positive number and the other to a negative number. The full terms may also change signs relative to one another as the error signal changes. – crasic Jul 2 '15 at 7:50
• Do you mean one or more of the gains: Ap; Ai; Ad, may be negative? – Chu Jul 2 '15 at 8:53