I have edited the original pid.c to include a minoutput pin, and now it works like a charm. There is no windup and zero overshoot on the way down, just like on the way up.
To install it, open a terminal in the folder containing the modified pid.c and run:
Code:
sudo halcompile --install pid.c
Then set the minoutput pin to the minimum ADC value your setup can handle. In my case, this value is zero, since I am using a software pwmgen to generate a 0–10 V signal:
Code:
setp pid.0.minoutput 0.0
This is the piece of code I have customized:
Code:
/* apply output limits */
if (*(pid->maxoutput) != 0.0) {
if (tmp1 > *(pid->maxoutput)) {
tmp1 = *(pid->maxoutput);
pid->limit_state = 1.0;
} else if (tmp1 < *(pid->minoutput)) {
tmp1 = *(pid->minoutput);
pid->limit_state = -1.0;
} else { pid->limit_state = 0.0;
}