Correct PI antiwindup

Thread Starter

Krzysztof Bieda

Joined Jan 5, 2016
46
Hello Everyone!
I would like to ask about integral part in PI controller.
How should I limit integral part? - What should be value of maxIntegral?

Could someone point me if there is any mistake in my PI controller?
Regulation works fine, but in saturation point I get troubles.

My code:

signed int16 PIregulator(PIParam* REG, float32 error)
{
float32 pPart, iPart, sum_temp, upLimit, downLimit;
upLimit = REG->limit;
downLimit = 0 - upLimit;

// Input
REG->In_F = error;
sum_temp = REG->IntegralOld + error;
// Limit Integral
if( sum_temp > HardConst.maxIntegral ) sum_temp = HardConst.maxIntegral;
else if( sum_temp < -HardConst.maxIntegral ) sum_temp = -HardConst.maxIntegral;
// Proportional term
pPart = REG->Kp;
pPart *= error;
// Integral term
iPart = REG->Ki;
iPart *= sum_temp;
// Limit output
float32 out_temp = pPart + iPart;

if(out_temp > upLimit ) { out_temp = upLimit; }
else if(out_temp < downLimit ) { out_temp = downLimit; }
else REG->IntegralOld = sum_temp;

// Output
REG->Out_F = out_temp;
signed int16 out = (signed int16) out_temp;
REG->Out = out;

REG->error = (signed int16) error;
REG->integral = (signed int16) REG->IntegralOld;

return out;
}

Best regards,
Chris
 
Top