PID Control

I am using jpearman’s PID control for EasyC. I have noticed that the integral term is limited. However, as the program goes through each loop, the integral term quickly limits out (sometime as fast as the first pass) and will stay limited out until it overshoots and can them come back down. This does not seem correct as the integral term will dominate unless the Ki term is very low and then the integral term is basically useless.

I have seen different integral upper limits. Some as low as 60 and as high as 500. I have also seen to choose 10% of the inital error. Another by Vexman, I believe, was to limit the final motor speed to around 35% of the maximum motor speed allowed. How do I choose a limit?

For a couple of years now, I have been using a limit of 60 and zeroing out the integral term once the error term passes through zero as I think it heps it recover faster.

The reason I don’t like zeroing out the integral once you reach the limit, is that the integral is many times the remaining hold strength of the arm. As soon as you cross over, you kill the integral, the hold strength of the integral wind up starts over again as a step function. I prefer smooth over sharp transitions to the system. By not killing the integral, you let it come down naturally on overshoot (even if very slight) and if it goes a wee bit below target, the integral winds up again giving more hold strength to the arm.

To figure out the max integral value, take the desired max motor value you want the integral to contribute, and divide it by the Ki value. You can pre-compute it or do it in a formula. It ends up being a static value.

One thing we do is limit the integral based upon the amount of proportional and integral that contributes to the output. Proportional always gets priority. So, if your max output power (we normally have 1.0, or 100, or you may use 127 - that’s just preference) is say 100, then calculate how much of that is contributed by the proportional, then limit the integral sum to an amount that gets your equation to the 100. Being higher than 100 doesn’t do you any good. Proportional reacts instantly while the integral is a low pass filter.
BTW, if your total output power is below 100 in our example you don’t do anything to the integral sum.