Intergral Windup method in PID control - Page 1
Forum section: electronics / beginners

author: Vindhyachal.takniki
author_rank: Frequent Contributor
timestamp: June 16, 2020, 03:33:54 pm
content: 1. Trying to write PID control for temperature maintain in oven. We are doing it Pb,Ti & Td.2. Now I see sometimes I am able to maintain temperature to setpoints.3. Problem happens when intergral grows to large values. I am reading on internet there are many ways available. I tried clamping method to try clamp to some values, but it dont work, for some cases it work and some it dont, i.e for every setpoint clamp value is different to maintain temperature. Higher the setpoint higher the clamp value required.Currently I am doing by hit and trial, but its not final solutions4.Any one have experiecne which methods work best for this type of applicaiton?5. I have seen two most common are:a) Back calculations: but found most of matlab implementations, trying to find c implemenationb) second is this: but dont know how to calculate AR bandc) Any other better method?

author: langwadt
author_rank: Super Contributor
timestamp: June 16, 2020, 03:58:34 pm
content: first thing you can try is to not let the integration grow when the output is already maxed out

author: Dave
author_rank: Super Contributor
timestamp: June 16, 2020, 08:17:36 pm
content: I implemented the back calculation method when I was working on a temperature regulator project ~2 years ago. It worked remarkably well after some tweaking of various gains.You mentioned moving the clamping value as you set different setpoints. Does that mean that the heater/cooler/heat pump you're controlling can't reach the setpoint when output is saturated (maximum power applied to plant)? The output should never be maxed out at stable conditions if you want to regulate anything.

author: Mechatrommer
author_rank: Super Contributor
timestamp: June 16, 2020, 08:31:01 pm
content: have you tried resetting I to 0 when P is saturated? (i mean causing saturated output by it alone)

author: WattsThat
author_rank: Frequent Contributor
timestamp: June 16, 2020, 08:58:30 pm
content: Quote from: Mechatrommer on June 16, 2020, 08:31:01 pmResetting the the I term is a non-starter, it will just make it oscillate. That may be acceptable with the velocity form PID but not with the position form as is used for temperature control.The first reply was the correct solution. The typical anti-windup behavior is to freeze the I value when the output reaches either limit.

author: langwadt
author_rank: Super Contributor
timestamp: June 16, 2020, 09:18:01 pm
content: Quote from: WattsThat on June 16, 2020, 08:58:30 pmI think it is better to not freeze the I but only let it increase if the output isn't max and only let it decrease if the output isn't zeroI've always thought temperature control should have some feedforward so the the PID only needto take care of disturbances and all the output isn't all I at steady state

author: thinkfat
author_rank: Unknown
timestamp: June 16, 2020, 10:26:18 pm
content: I don't know what your PID outputs, but you might find this writeup interesting:https://www.eevblog.com/forum/projects/diy-gpsdo-project-w-stm32-tdc7200/msg2877408/#msg2877408If you formulate your PID accordingly, clamping your I to the maximum/minimum of your output range comes naturally.Think of "I" as the ideal steady-state output of the controller, while P and D are compensating for externally introduced disturbance.

author: Mechatrommer
author_rank: Super Contributor
timestamp: June 17, 2020, 06:39:08 am
content: Quote from: WattsThat on June 16, 2020, 08:58:30 pmI doesnt make oscillation if implemented and Ki value correctly, its just to correct residual error in slowly manner. During large SP change, I accumulates badly that it will need slow overshoot to zero back. Large SP change can be signalled from saturated P term, during a time that I term is irrelevant or invalid.

author: voltsandjolts
author_rank: Unknown
timestamp: June 17, 2020, 07:57:33 am
content: I implemented a very basic PID oven contrtoller a few years back, it worked but needed a lot of fiddling with PID coefficients.I have attached the relevant code, maybe there are some ideas you can use.Or maybe its so full of fudge factors you should ignore it!Exported functions:void pidInit(unsigned char cycleTimeSecs);void pidSetPoint(unsigned short degc_scaled);unsigned char pidCalculate(void);Where pidCalculate is called every cycle time, maybe 2 second interval for an oven. It returns the power setting for the heater element of a passively cooled oven, 0-100%.

author: mikerj
author_rank: Super Contributor
timestamp: June 17, 2020, 10:45:29 am
content: Quote from: Mechatrommer on June 17, 2020, 06:39:08 amIt can cause bad things to happen on a positional type PID in my experience. Freezing the integrator works perfectly provided you have a suitable P term as well (i.e. not just a pure integral control), I've used this method for many years on TEC controllers. For an integral only controller the integrator needs to be selectively clamped according to which end the output is saturated at, as described by langwadt.

author: Mechatrommer
author_rank: Super Contributor
timestamp: June 17, 2020, 02:11:56 pm
content: Quote from: mikerj on June 17, 2020, 10:45:29 amyes real bad if accumulated Iterm is not taken cared of during the said immediate SP change, it will result too long overshoot or undershoot SP. i dont claim to have made a stable or robust system but i think during stable condition, Iterm reduced to zero, hence during sudden change, freezing it is similar effect as i've suggested of zeroing it (zeroing an already zero term is similar to freezing a zero term) whats not clear in your statement, is what condition that it should be freezed. i suggested freezing (zeroing) when Pterm (Kp.e(t)) is saturated, i think i've read about it somewhere but i stand to be corrected.

author: Kleinstein
author_rank: Super Contributor
timestamp: June 17, 2020, 04:37:01 pm
content: The usual good way to implement anti-windup is to engage when the control output hits the limit. In this case on calculates back the integral term to such a value that one just gets the limiting control output (or maybe a tiny bit more if the input are noisy).The simpler version is to just stop incrementing the integral term if already at the limit. One may still have to allow a change back to the liner region. In most cases the simplified version is OK, but it is not that much simpler, especially if the steps back are included.The other simple version of just limiting the integral term to a fixed value sometimes works, but often not as good.If using a variable set point it can help to use additional feed forward control, so go beyond simple PID. It is often more effective than heuristic modifications to the anti-windup. Good chosen PID parameters also avoid excessive long times in saturation.Another point for optimization is to linearize the control / system: e.g. if a resistive heater with linear control is used, us the power as the PID control output and do the square root to voltage after that.

author: max_torque
author_rank: Super Contributor
timestamp: June 17, 2020, 07:04:10 pm
content: The trick with all PIDs is to be able to let the controller do the least work possible, ie use a feedforward term to do the bulk of the steady state work. With an oven that's easy just characterise the steady state temp at a range of fixed outputs. For example, fix the heater output at 10% and leave it there until the temperature stabilises, repeat at 15, 20 % etc. That quickly forms you a lookup table to use as a feedforward value. This means you integral term is not providing the entire output, in fact, if you feed forward table was perfect, at steady state your integral would be zero, ie doing nothing!

author: mikerj
author_rank: Super Contributor
timestamp: June 17, 2020, 08:09:48 pm
content: Quote from: Mechatrommer on June 17, 2020, 02:11:56 pmZeroing != freezing. Zeroing is setting the integrated error value to zero which in a positional type PID will cause the (saturated) output to suddenly change value, often by a substantial amount, which is typically not desirable. Freezing means the integrated error and it's contribution to the output remains at it's current value. This would typically occur whilst the output is saturated as you say.Imagine a heater controller with a large error, to correct that error quickly you may want to output of the heater to be driven hard and the integral will wind up until the output is saturated. At that point you don't want anymore integral action so you freeze it. If you zeroed it then the output would suddenly drop (P term contributing only) and the integrator would then start to ramp up the output again until it saturated again. If you zeroed the integrator and also held it at zero you have just converted your PI/PID loop into a P or PD loop, so it may never converge and meet your criteria for unfreezing it.

author: Mechatrommer
author_rank: Super Contributor
timestamp: June 18, 2020, 05:02:27 am
content: it seems i forgot (missed) this is for slow reaction high thermal mass oven application

author: Kleinstein
author_rank: Super Contributor
timestamp: June 18, 2020, 08:27:08 am
content: It depends, if the feed forward can bring the integral term all the way to zero. It can do this for the fixed, predictable part, but it can not do this for uncontrolled external perturbations (e.g. weather).If one wants something like controlled ramps, the feed forward could also include a term proportional to the slope. This can help quite a bit as the integral term no longer needs to compensate for this term, and thus a faster change in slope.