I don't understand Integral part of PID controller
Asked Answered
Y

6

12

I dont understand integral part of PID controller. Let's assume this pseudocode from Wikipedia:

previous_error = 0
integral = 0 
start:
  error = setpoint - measured_value
  integral = integral + error*dt
  derivative = (error - previous_error)/dt
  output = Kp*error + Ki*integral + Kd*derivative
  previous_error = error
  wait(dt)
  goto start

Integral is set to zero in the beginning. And then in the loop it's integrating the error over the time. When I make a (positive) change in measured value or setpoint, the error will become positive and integral will "eat" the values over the time (from the beginning). But what I dont understand is, when error stabilizes back to zero, the integral part will still have some value (integrated errors over time) and will still contribute to the output value of controller, but it should not.

Can somebody explain me that please?

Yoko answered 24/11, 2012 at 15:4 Comment(1)
for anyone interested, I implemented this exact algorithm to control loop speed. #38378320Appositive
T
11

Think of the output at steady state... You want the measured_value to be setpoint, the error to be zero, and the output to be whatever it takes to hold the process steady at the measured value. (Could be zero in some cases, but the output may not always need to be zero -- e.g.: you need a heater set to mark 6.5 to keep a room at 72F.)

If the error is zero, then the proportional error term doesn't contribute anything to the output.

If the process is at steady state, then the error-previous_error is zero, and the derivative term contributes nothing.

If the output is the appropriate setting that is holding the process at steady state, then the integral term has to be the sole term providing the output value. It has accumulated the proper memory of the errors, as measured in measurement units times the observation times, that can be converted into output units by the Ki term, which is in units of outputUnits/(error*measurementTime).

As a thermostat example, if the output is in the 0-11 units on the knob of an electric heater in a room, and you are measuring the degrees F in the room versus a setpoint of 72F every 1 minute, then the integral sums up the degreesFtooCold*minute that you've been recording, and the Ki term would convert the sum of the observed errors into the units on the dial.

It is perfectly fine and expected for the integral to be non-zero at steady state.

Tied answered 9/6, 2014 at 18:55 Comment(0)
S
1

Let's look it this way: it's not enough that the error itself stabilizes to zero. It's required that the integral goes to zero, which means that the average of measured value over time matches the set value.

A bad example would be trying to reach value of 100% from zero with some Ki,Kp,Kd.

x = 0,60,80,90,98,99,100,100,100.

What is the value of x? The mean value is 80.777. Not even close to 100.

Seaboard answered 24/11, 2012 at 15:37 Comment(3)
I still don't get it. Can you explain it more please?Yoko
But integral will go to zero only if measured value will overshoot the setpoint (becuase we need negative error). In your example, if (Ki is 1 and dt also 1) when the measured value will be 100 (= setpoint), the output of controller will be still non zero (i think it will oscillate). But if PI(D) controller is well tuned, there is no overshoot. I still don't get it :(Yoko
I have to disagree. Overshoot is the property of I. P/D on the other hand have the property of not reaching the destination. Also the integration is typically forgiving: I(n+1) = I(n)*alpha + (1-alpha)*error slowly forgets earlier errors giving more emphasis to present moment.Seaboard
M
1

Depending on the system you want to control and the quality of the sensor, there will always be some kind of disturbance between the controller and the system/plant. The integral portion of the controller will not go to zero when there is such a disturbance, but instead will counter-act it! This is caused by the fact that the integral will keep changing until the output of the system is equal to the reference (i.e. integral value is opposite to the disturbance).

See for example this page describing the control paramters: a steady state error is possible when the system and input have a certain character, an integral will try to oppose this which results in a much lower final error, but in some cases more overshoot.

Also, the accuracy/noise of the sensor can impose a limit on the accuracy of the value for the integral, which might oscillate around zero.

Mefford answered 24/11, 2012 at 17:3 Comment(0)
F
1

The I term is needed for the steady state error. Look at the example graph on Wikipedia.

http://en.wikipedia.org/wiki/File:Change_with_Ki.png

You can see the changes in the graph from changing the gains of the I term. Obviously Ki = 2 is way to high because of the integral windup, which is what causes that drastic overshoot. Ki = .5 looks ok, but if you want to reach a stable value as soon as possible then you need to increase Ki a little more. Look at Ki = 1, it overshoots a little bit but still reaches stability faster than Ki = .5. So you have to decide if that kind of trade off is worth it.

Feathercut answered 30/1, 2013 at 21:36 Comment(0)
D
1

I think part of the explanation here is that as the integral part overshoots, the proportional part will start to oppose it. The second overshoot will thus be smaller, the third even smaller and so on. But as mentioned above, there will normally be some process noise that causes the error to be non-zero and the controller will likely never reach a constant output but the variations of the output should be very small.

Domeniga answered 18/8, 2014 at 8:12 Comment(0)
S
0

With all due respect, you have a reason to question the PID definition, because it perpetuates a mistake in PID control, with respect to the Intergral term. The mistake can be Illustrated as follows: 1) Even though there is zero error the Intergral term will cause an output action. 2) The Intergral is based upon previous errors which are no longer relevant. Proportional control can produce 0 error if the controller is comparing the input to the output and through negative feedback and driving the Error to zero.

The correct PID term: D term: Add changes ( differentiation) to the steady-state INPUT to be combined in the summing Junction.

I term: Add changes ( differentiation) to the negative (negative feedback) of the steady-state OUTPUT to be combined in the summing Junction.

Integration is differentiation when combined across (around) negative feedback

The output is connected to the summing Junction with a very high game and negative polarity (inverting).

P term: is the desired OUTPUT divided by the desired INPUT OR the ratio of the signal fed the the summing Junction by the OUTPUT divided by the signal fed the the summing Junction by the INPUT.

D term, Differentiation speed up the output response to input so the output approaches the correct value sooner.

Integration slows down the output response as it approaches the correct/desired value.

Spiritualize answered 24/12, 2016 at 19:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.