# Intergral Windup method in PID control

#### vindhyachal

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 solutions

4.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 implemenation
b) second is this: but dont know how to calculate AR band

c) Any other better method?

#### dickcaro

First, the term is INTEGRAL as in the calculus to integrate. If the integral term winds up, then this indicates that the process is NOT responding to your output of the manipulated variable. Whatever you are controlling, is NOT causing the temperature to respond. No amount of arithmetic will cure this problem. PID controllers will always wind up when their output is disconnected from the process. Anti-windup techniques are used when automatic control is resumed after being disconnected from the output, such as during an override situation, or an open cascade.

My suggestion is to fix the process and scale the controller to your output device. From your brief description, you have probably not implemented your PID correctly.

#### vindhyachal

I am using PID method to control the temperature, but issue is once setpoint is reached, integral already gets to such large value, that it takes time to fall back and in the meantime, temperature keeps on increasing. large here doesnt mean that it goes beyond output sautration limit, but large here means, large enough that it takes some time to fall back and meantime temperature goes beyonf acceptable range.

Red is integral
Setpoint is 70C
blue line is process variable
All values are to be divided by 100.

In code to prevent integral windup what I have done, is if some of p,i & d terms exceed 100%, then dont add intgegral term, otherwise add up integral term.
Looks like this is not enough.

I am using Pb, Ti & Td instread of Kp, Ti & td.

Code:
``````const float32_t c_output_max = 100.0f;
const float32_t c_output_min = 0.0f;

float32_t input_temperature;
float32_t setpoint_temperature = 70.0f;
float32_t output_duty_cycle;
float32_t unclamped_output;

float32_t previous_temperature = 0.0f;
uint32_t first_time = 1U;
float32_t dt = 1.0f;  //sec

const float32_t pb = 37.3f;
const float32_t ti = 302.0f;
const float32_t td = ti / 4.0f;

float32_t error = 0.0f;
float32_t p_term;
float32_t i_term = 0.0f;
float32_t d_term;

void compute_pid_duty_cycle(void)
{
float32_t i_term_temp;

/* get error */
error = setpoint_temperature - input_temperature;

if(first_time)
{
first_time = 0U;
previous_temperature = input_temperature;
}

/* calculate duty cycle */
if(error > pb)
{
output_duty_cycle = 100.0f;
unclamped_output = output_duty_cycle;
}
else if(error < -pb)
{
output_duty_cycle = 0.0f;
unclamped_output = output_duty_cycle;
}
else
{
/* calcukate p term */
p_term = (100.0f * error) / pb;

/* differential error */
d_term = (input_temperature - previous_temperature)/dt;     //dt = 1seconds
d_term = d_term * td * 100.0f / pb;

/* calculate i term */
i_term_temp = i_term + (100.0f / (pb * ti))*error*dt;

//clamp integral term
if((p_term + i_term_temp - d_term) > 100.0f)
{
}
else
{
i_term = i_term_temp;   //otherwise add since no saturation
}

/* Compute PID Output */
output_duty_cycle = p_term + i_term - d_term;
unclamped_output = output_duty_cycle;
if(output_duty_cycle > c_output_max)
{
output_duty_cycle = c_output_max;
}
else if(output_duty_cycle < c_output_min)
{
output_duty_cycle = c_output_min;
}
else
{
}
}

/* Remember some variables for next time */
previous_temperature = input_temperature;

}``````

#### vindhyachal

Move up, anyone has exp in this?

#### Lambert J

Is the windup occurring only during process startup? If so, defeat (temporarily eliminate) the integral and bring the process to set point by manipulating the output with Pb. Once the set point is achieved or nearly achieved, engage the integral. If windup persists, see Dickcaro's comments. - JL

#### thereisnospoon

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 solutions

4.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 implemenation
b) second is this: but dont know how to calculate AR band
View attachment 309
c) Any other better method?
Good news is, you are on the right track. In my opinion, you have a few options here:
1) Activate the integral term of the your PID controller ONLY WHEN the error value (e_min) is less than let's say 5 degree Celcius. By doing so, you will reduce the 'seriousness' of the windup, yet with integral term's advantages functioning - that is removing steady-state error.
2) Make your accumulated integral controller output (from your PID) reset to 0 WHEN error value surpass set-point - i.e. when overshoot and undershoot happen. This is a more tricky method than method 1, but you do not have the hassle to decide the a suitable e_min value.

Due to the slow temperature control process, common anti-windup didn't work well. You will need extra 'flavor' to it.

Hope it helps.

- thereisnospoon -

#### patrickduis

If you -really- want a good stable and reliable control, use RKC equipment. I used it for many ovens of all types during my Philips times, vacuum, heat treatment, tunnel, batch, ceramic, glass, you name it. And it always worked great.
So great, that I decided to even go work for the company that delivered them to me. https://cascade.net/en/controllers/
They communicate over modbus (more or less the standard in temperature control) but other protocols are also available.
You can make a scada application with them in just a few minutes time with this easy to use software: http://specview.com/
Don't re-invent the wheel, make use of existing ones and inprove those.

#### pnachtwey

Move up, anyone has exp in this?
Yes! The problem is that you are not using the right form of PID. You need to use the incremental form of PID where the P and D term are computed by multiply the gains by the differences in the process value and then integrated. The integrator will not wind up when a step change in temperature is made because the changes in the P and D terms tend to unwind the integrator.